Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

CSHTMLPanel Class Reference

#include <CSHTMLPanel.h>

Inheritance diagram for CSHTMLPanel:

CSGrafikElement CSMessageDispatchable CSMessageListener

Public Member Functions

 CSHTMLPanel (int height, int width, const std::string &filename)
virtual ~CSHTMLPanel ()
virtual std::string getType ()
virtual void setPage (const std::string &filename)
void reactOnMessageHTMLPanel (CSMessage *message)
virtual void reactOnMessage (CSMessage *message)
 to be overloaded

virtual void paint (SDL_Surface *destination, SDL_Rect *parentViewport)
virtual void layoutSetup ()

Static Public Attributes

const char * CLASS = "CSHTMLPanel"
 static element, name of this class (introsepection)


Protected Member Functions

virtual void layoutSetupHTMLPanel ()
virtual void rebuildElement ()

Constructor & Destructor Documentation

CSHTMLPanel::CSHTMLPanel int  height,
int  width,
const std::string &  filename
 

Definition at line 39 of file CSHTMLPanel.cpp.

References LOG_ENTER, LOG_EXIT, and setPage().

00040 : CSGrafikElement(height, width)
00041 {
00042     static char *functionName="CSHTMLPanel";
00043     LOG_ENTER 
00044     initHTMLPanel();
00045     setPage(filename);
00046     LOG_EXIT
00047 }

Here is the call graph for this function:

CSHTMLPanel::~CSHTMLPanel  )  [virtual]
 

Definition at line 49 of file CSHTMLPanel.cpp.

00050 {
00051     if (mMessageBox)
00052     {
00053         delete mMessageBox;
00054         mMessageBox = 0;
00055     }
00056     deleteOldPage();
00057 }


Member Function Documentation

void CSHTMLPanel::layoutSetupHTMLPanel  )  [protected, virtual]
 

Definition at line 470 of file CSHTMLPanel.cpp.

References HTMLElement::buildDisplay(), CSGrafikElement::getBackgroundColor(), CSLAF::getCurrentLAF(), CSGrafikElement::getFont(), CSFont::getHeight(), CSGrafikElement::getParentWindow(), CSGrafikElement::getViewportWidth(), LOG_ENTER, HTMLCursor::mBackgroundColor, HTMLCursor::mFont, HTMLCursor::mXPos, HTMLCursor::mXPosMax, HTMLCursor::mYPos, HTMLCursor::nextAdd, CSGrafikElement::setBackgroundColor(), and CSWindow::setTitle().

Referenced by layoutSetup().

00471 {
00472     static char *functionName="layoutSetupHTMLPanel";
00473     LOG_ENTER 
00474     CSLAF *laf = CSLAF::getCurrentLAF();
00475 
00476     // clear all compiled or collected information - 
00477     // we have to start anew
00478     getHTMLSize(mMinWidth, mMinHeight);
00479     clearElements();
00480     
00481     if (mCleared)
00482     {
00483         // set up the starting cursor!
00484         HTMLCursor htmlCursor;
00485         htmlCursor.mBackgroundColor = getBackgroundColor();
00486         htmlCursor.mXPos = 0;
00487         htmlCursor.mYPos = 0;
00488         htmlCursor.mXPosMax = 0;
00489 
00490         htmlCursor.mFont = getFont();
00491         htmlCursor.nextAdd = htmlCursor.mFont->getHeight(); 
00492 
00493         // and paint all elements recursivly
00494         // Insets not respected -> doesn't matter if Insets stay at 0
00495         HTMLElements::iterator iter;
00496         for (iter = mHTMLElements.begin(); iter != mHTMLElements.end(); iter++)
00497         {
00498             std::string title = "";
00499             HTMLElement *element = *iter;
00500             htmlCursor = element->buildDisplay(htmlCursor, this, getViewportWidth(), title);
00501             if (title.size() >0)
00502             {
00503                 CSWindow *window = getParentWindow();
00504                 if (window)
00505                 {
00506                     window->setTitle(title);
00507                 }
00508             }
00509         }
00510         mCleared = false;
00511     }
00512         
00513     setBackgroundColor(getBackgroundColorHTML());
00514 }

Here is the call graph for this function:

void CSHTMLPanel::rebuildElement  )  [protected, virtual]
 

Reimplemented from CSGrafikElement.

Definition at line 443 of file CSHTMLPanel.cpp.

00444 {
00445     // befor we calculate the new viewport size
00446     // we have to remove the scrollbars
00447     // otherwise the viewport width might calculated wrongly
00448     // (when setHeight/setWidth of parent ist called, the scrollbar sizes are
00449     //  added (when removed) to the new size - but the new size never knew
00450     //  of the scrollbars in first place)
00451 
00452     // the size of the viewport changes if a scrollbar is added -> every size might change...
00453     // looks like ping pong - but is a must :-(
00454 }

virtual std::string CSHTMLPanel::getType  )  [inline, virtual]
 

Reimplemented from CSGrafikElement.

Definition at line 61 of file CSHTMLPanel.h.

References CLASS.

00061 {return (std::string) CLASS;}

void CSHTMLPanel::setPage const std::string &  filename  )  [virtual]
 

Definition at line 154 of file CSHTMLPanel.cpp.

References CSGrafikElement::addFrontElementCenter(), CSHTML_OK, ERROR_ICON, CSHTMLHelper::getError(), CSGrafikElement::getParentWindow(), CSHTMLHelper::getRootNode(), CSGrafikElement::layoutChanged(), CSGrafikElement::removeFrontElement(), CSWindow::setHorizontalDisplayStart(), CSWindow::setVerticalDisplayStart(), and CSGrafikElement::setVisible().

Referenced by CSHTMLPanel(), and reactOnMessageHTMLPanel().

00155 {
00156     static char *functionName="setPage";
00157 
00158     // filename handling
00159     // Anker and Bases...
00160     CSHTMLHelper *helper;
00161     std::string newFilename = filename;
00162     std::string anker = extractAnker(newFilename);
00163     helper = new CSHTMLHelper(newFilename);
00164     if (helper->getError() != CSHTML_OK)
00165     {
00166         delete helper;
00167         helper = 0;
00168         
00169         newFilename = mBaseDirectory + filename;
00170         anker = extractAnker(newFilename);
00171         helper = new CSHTMLHelper(newFilename);
00172         if (helper->getError() != CSHTML_OK)
00173         {
00174             delete helper;
00175             helper = 0;
00176             if (mMessageBox)
00177             {
00178                 removeFrontElement(mMessageBox);
00179                 delete mMessageBox;
00180                 mMessageBox = 0;
00181             }
00182             mMessageBox = new CSMessageBox("Error loading Page:\n"+filename, "Error loading html page!", ERROR_ICON);
00183             if (mMessageBox)
00184             {
00185                 addFrontElementCenter(mMessageBox);
00186                 mMessageBox->setVisible(true);
00187             }
00188 
00189             return;
00190         }
00191     }
00192     mBaseDirectory = getBaseDirectory(newFilename);
00193     deleteOldPage();
00194     mHelper = helper;
00195     mFilename = filename;
00196     CSHTMLNode node = mHelper->getRootNode();
00197 
00198     // from the root node
00199     // all other nodes are recursivly created!
00200     HTMLElement *element = new HTMLElement(node);
00201     mHTMLElements.push_back(element);
00202     mHTMLHeightInPixel = 0;
00203     mHTMLWidthInPixel = 0;
00204     CSWindow *window = getParentWindow();
00205 
00206     // if we have an anker we start there
00207     // by setting the scroll offsets likewise
00208 //  if (anker.size()>0)
00209 //  {
00210 //      startAtAnker(anker);
00211 //  }
00212 //  else
00213     {
00214         if (window)
00215         {
00216             window->setVerticalDisplayStart(0);
00217             window->setHorizontalDisplayStart(0);
00218 //          setViewportOffset(0,0);
00219 //          getParent()->setViewportOffset(0,0);
00220         }
00221     }
00222     layoutChanged(true);
00223 }

Here is the call graph for this function:

void CSHTMLPanel::reactOnMessageHTMLPanel CSMessage message  ) 
 

Definition at line 238 of file CSHTMLPanel.cpp.

References HTMLElement::getAncestorType(), HTMLElement::getAttributValue(), CSMessage::getSubtype(), CSMessage::getType(), CSGrafikElement::getViewportX(), CSGrafikElement::getViewportY(), GUI_MESSAGE, HTML_A, CSMessage::mIsHandled, MOUSE_BUTTON_PRESSED_MESSAGE, CSGrafikElement::reactOnMessageGrafikElement(), GuiMessage::receiver, GuiMessage::receiverX, GuiMessage::receiverY, and setPage().

Referenced by reactOnMessage().

00239 {
00240     static char *functionName="reactOnMessage";
00241     if (message->mIsHandled)
00242     {
00243         reactOnMessageGrafikElement(message);
00244         return;
00245     }
00246     switch (message->getType())
00247     {
00248         case GUI_MESSAGE:
00249         {
00250             GuiMessage *gm = (GuiMessage *) message;
00251             if (gm->receiver != this)
00252             {
00253             }
00254             else // receiver == this
00255             {
00256                 switch (message->getSubtype())
00257                 {
00258                     // some link to set?
00259                     case MOUSE_BUTTON_PRESSED_MESSAGE:
00260                     {
00261                         int x,y;
00262                         x = gm->receiverX;
00263                         y = gm->receiverY;
00264                         
00265                         HTMLElements::iterator iter;
00266                         for (iter = mHTMLElements.begin(); iter != mHTMLElements.end(); iter++)
00267                         {
00268                             HTMLElement *checked = (*iter)->checkPostion(x - getViewportX() ,y - getViewportY());
00269                             if (checked != 0)
00270                             {
00271                                 // clicked on a link?
00272                                 HTMLElement *linkNode = checked->getAncestorType(HTML_A);
00273                                 if (linkNode)
00274                                 {
00275                                     // yop - try trying to get it!
00276                                     // open new page
00277                                     std::string linkValue = linkNode->getAttributValue("HREF");
00278                                     if (linkValue.size() != 0)
00279                                     {
00280                                         setPage(linkValue);
00281                                         break;
00282                                     }
00283                                 }
00284                             }
00285                         }
00286                         gm->mIsHandled = true;
00287                         break;
00288                     }
00289                 }
00290             }                       
00291         }
00292     }
00293     reactOnMessageGrafikElement(message);
00294 }

Here is the call graph for this function:

void CSHTMLPanel::reactOnMessage CSMessage message  )  [virtual]
 

to be overloaded

Reimplemented from CSGrafikElement.

Definition at line 233 of file CSHTMLPanel.cpp.

References reactOnMessageHTMLPanel().

00234 {
00235     reactOnMessageHTMLPanel(message);
00236 }

Here is the call graph for this function:

void CSHTMLPanel::paint SDL_Surface *  destination,
SDL_Rect *  parentViewport
[virtual]
 

Todo:
html area only painting in the specified region, not everything and clippin!

Reimplemented from CSGrafikElement.

Definition at line 227 of file CSHTMLPanel.cpp.

References CSGrafikElement::paintChildren().

00228 {
00229     static char *functionName="paint";
00230     paintChildren(destination, parentViewport);
00231 }

Here is the call graph for this function:

virtual void CSHTMLPanel::layoutSetup  )  [inline, virtual]
 

Reimplemented from CSGrafikElement.

Definition at line 69 of file CSHTMLPanel.h.

References layoutSetupHTMLPanel().

Here is the call graph for this function:


Field Documentation

const char * CSHTMLPanel::CLASS = "CSHTMLPanel" [static]
 

static element, name of this class (introsepection)

Reimplemented from CSGrafikElement.

Definition at line 17 of file CSHTMLPanel.cpp.

Referenced by CSLAF::getBorderInternal(), and getType().


Generated on Wed Jul 14 00:44:31 2004 for CSLib by doxygen 1.3.6