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

CSMenu Class Reference

#include <CSMenu.h>

Inheritance diagram for CSMenu:

CSButton CSGrafikElement CSMessageDispatchable CSMessageListener CSMenuItem

Public Member Functions

virtual std::string getType ()
 CSMenu (const std::string &menuTitle)
virtual ~CSMenu ()
std::string getTitle ()
void reactOnMessageMenu (CSMessage *message)
virtual void reactOnMessage (CSMessage *message)
 to be overloaded

virtual void layoutSetup ()
virtual void addMenuItem (CSMenuItem *item)
virtual void removeMenuItem (CSMenuItem *item)
virtual void openMenu ()
virtual void closeMenu ()
virtual CSMenuBargetMenuBar ()
void setMenuBar (CSMenuBar *bar)
virtual int getButtonState ()

Static Public Attributes

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


Protected Member Functions

void layoutSetupMenu ()

Protected Attributes

CSMenuBarmMenuBar

Constructor & Destructor Documentation

CSMenu::CSMenu const std::string &  menuTitle  ) 
 

Definition at line 18 of file CSMenu.cpp.

References CSGrafikElement::getLayoutData(), CSGrafikElement::getLayoutDataInternal(), LOG_ENTER, LOG_EXIT, mMenuBar, POSITION_WEST, CSGrafikElement::setFocusable(), CSGrafikElement::setGUIType(), CSGrafikElement::setLayoutData(), CSGrafikElement::setLayoutManager(), CSLayoutData::setPackedHorizontal(), CSLayoutData::setPackedVertical(), CSLayoutData::setPosition(), and CSGrafikElement::setVisible().

00018                                          : CSButton(CSTextIcon::buildIcon(menuTitle))
00019 {
00020     static char *functionName="CSMenu";
00021     LOG_ENTER 
00022     mTitle = menuTitle;
00023     mMenuBar = 0;
00024     mMenuIsOpen = false;
00025     getLayoutDataInternal()->setPosition(POSITION_WEST);
00026     
00027     mMenuPanel = new CSPanel(0, 0);
00028     mMenuPanel->setVisible(true);
00029     mMenuPanel->setLayoutManager(new CSLayoutManagerStackVertical());
00030     CSLayoutData layout = mMenuPanel->getLayoutData();
00031     layout.setPackedHorizontal(true);
00032     layout.setPackedVertical(true);
00033     mMenuPanel->setLayoutData(layout);
00034     mMenuPanel->setGUIType("MenuWindow");
00035     this->setFocusable(false);
00036     mBorderState = 0;
00037     LOG_EXIT
00038 }

Here is the call graph for this function:

CSMenu::~CSMenu  )  [virtual]
 

Definition at line 40 of file CSMenu.cpp.

00041 {
00042     static char *functionName="~CSMenu";
00043     if (mMenuPanel != 0)
00044     {
00045         delete (mMenuPanel);
00046         mMenuPanel = 0;
00047     }
00048 }


Member Function Documentation

void CSMenu::layoutSetupMenu  )  [protected]
 

Definition at line 252 of file CSMenu.cpp.

References CSButton::layoutSetupButton(), LOG_ENTER, and LOG_EXIT.

Referenced by layoutSetup(), and CSMenuItem::layoutSetupMenuItem().

00253 {
00254     static char *functionName="layoutSetupMenu";
00255     LOG_ENTER 
00256     layoutSetupButton();
00257     LOG_EXIT
00258 }

Here is the call graph for this function:

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

Reimplemented from CSButton.

Reimplemented in CSMenuItem.

Definition at line 39 of file CSMenu.h.

References CLASS.

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

std::string CSMenu::getTitle  )  [inline]
 

Definition at line 43 of file CSMenu.h.

00043 {return mTitle;}

void CSMenu::reactOnMessageMenu CSMessage message  ) 
 

Definition at line 55 of file CSMenu.cpp.

References BUTTON_HOVERING, BUTTON_PRESSED, BUTTON_VISIBLE, CSMenuBar::closeLastMenu(), closeMenu(), FOCUS_LOST_MESSAGE, CSMenuBar::getActiveMenu(), CSMenuBar::getLastActiveMenu(), getMenuBar(), CSMenuBar::getMenuState(), CSMessage::getSubtype(), CSMessage::getType(), GUI_MESSAGE, CSGrafikElement::isChild(), CSMessage::mIsHandled, mMenuPanel, MOUSE_BUTTON_PRESSED_MESSAGE, MOUSE_MOTION_LOST_MESSAGE, MOUSE_MOTION_MESSAGE, openMenu(), CSButton::reactOnMessageButton(), GuiMessage::receiver, CSMenuBar::resetMenu(), CSMenuBar::setActiveMenu(), and CSMenuBar::setMenuState().

Referenced by reactOnMessage(), and CSMenuItem::reactOnMessageMenuItem().

00056 {
00057     static char *functionName="reactOnMessage";
00058     if (message->mIsHandled)
00059     {
00060         reactOnMessageButton(message);
00061         return;
00062     }
00063     if (message->getType() == GUI_MESSAGE)
00064     {
00065         GuiMessage *gm = (GuiMessage *) message;
00066         if (isChild(gm->receiver))
00067         {
00068             switch (message->getSubtype())
00069             {
00070                 case MOUSE_MOTION_LOST_MESSAGE:
00071                 {
00072                     mBorderState = mBorderState & (~BUTTON_VISIBLE);
00073                     gm->mIsHandled = true;
00074                     break;
00075                 }
00076                 case MOUSE_MOTION_MESSAGE:
00077                 {
00078                     mBorderState = mBorderState | BUTTON_VISIBLE;
00079                     mBorderState = mBorderState | BUTTON_HOVERING;
00080                     if (getMenuBar() != 0)
00081                     {
00082                         if ((getMenuBar()->getMenuState(this) & BUTTON_PRESSED) == BUTTON_PRESSED)
00083                         {
00084                             if (getMenuBar()->getActiveMenu() != this)
00085                             {
00086                                 mBorderState = mBorderState | BUTTON_PRESSED;
00087                                 getMenuBar()->setActiveMenu(this);
00088                                 getMenuBar()->closeLastMenu();
00089                                 openMenu();
00090                             }
00091                         }
00092                     }
00093                     gm->mIsHandled = true;
00094                     break;
00095                 }
00096                 case MOUSE_BUTTON_PRESSED_MESSAGE:
00097                 {
00098                     mBorderState = mBorderState | BUTTON_PRESSED;
00099                     if (getMenuBar() != 0)
00100                     {
00101                         getMenuBar()->setMenuState(mBorderState);
00102                         getMenuBar()->setActiveMenu(this);
00103                         openMenu();
00104                     }
00105                     gm->mIsHandled = true;
00106                     break;
00107                 }
00108             }
00109         }
00110         else // receiver is not a child
00111         {
00112             switch (message->getSubtype())
00113             {
00114                 case FOCUS_LOST_MESSAGE:
00115                 {
00116                     if (getMenuBar() != 0)
00117                     {
00118                         CSGrafikElement *lastActiveMenu = 0;
00119                         // check whether we just switched menus in the same menuBar
00120                         // if the lastActiveMenu was ourselfs AND the component that lost
00121                         // the focus was we ourself too -> than there was just a switch
00122                         // in menus (if another outsider component had received the focus
00123                         // we would still be the active menu!)
00124                         if (getMenuBar()->getLastActiveMenu())
00125                         {
00126                             lastActiveMenu = getMenuBar()->getLastActiveMenu()->mMenuPanel;
00127                         }
00128                         CSGrafikElement *lastFocusedComponent =  gm->receiver;
00129                         if (lastActiveMenu != lastFocusedComponent)
00130                         {
00131                             getMenuBar()->resetMenu();
00132                             mBorderState = mBorderState & (~BUTTON_VISIBLE);
00133                             mBorderState = mBorderState & (~(BUTTON_PRESSED | BUTTON_HOVERING));
00134                         }
00135 
00136                         getMenuBar()->setMenuState(mBorderState);
00137                         getMenuBar()->setActiveMenu(0);
00138                     }
00139                     closeMenu();
00140 
00141                     gm->mIsHandled = true;
00142                 }
00143             }
00144         }
00145     }
00146 }

Here is the call graph for this function:

void CSMenu::reactOnMessage CSMessage message  )  [virtual]
 

to be overloaded

Reimplemented from CSButton.

Reimplemented in CSMenuItem.

Definition at line 50 of file CSMenu.cpp.

References reactOnMessageMenu().

00051 {
00052     reactOnMessageMenu(message);
00053 }

Here is the call graph for this function:

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

Reimplemented from CSButton.

Reimplemented in CSMenuItem.

Definition at line 48 of file CSMenu.h.

References layoutSetupMenu().

00048 {layoutSetupMenu();}

Here is the call graph for this function:

void CSMenu::addMenuItem CSMenuItem item  )  [virtual]
 

Definition at line 158 of file CSMenu.cpp.

References CSGrafikElement::addElement(), POSITION_ORDER_TOP, CSGrafikElement::setGUIType(), CSGrafikElement::setLayoutData(), CSLayoutData::setStretchedHorizontal(), and CSLayoutData::setStretchedVertical().

00159 {
00160     item->setGUIType("Menu");
00161     CSLayoutData layoutData(POSITION_ORDER_TOP);
00162     layoutData.setStretchedHorizontal(true);
00163     layoutData.setStretchedVertical(true);
00164     item->setLayoutData(layoutData);
00165     mMenuPanel->addElement(item);
00166 }

Here is the call graph for this function:

void CSMenu::removeMenuItem CSMenuItem item  )  [virtual]
 

Definition at line 168 of file CSMenu.cpp.

References CSGrafikElement::removeElement().

00169 {
00170     mMenuPanel->removeElement(item);
00171 }

Here is the call graph for this function:

void CSMenu::openMenu  )  [virtual]
 

Definition at line 185 of file CSMenu.cpp.

References CSGrafikElement::addFrontElement(), CSMessageDispatchable::addMessageListener(), CSMenuBar::closeLastMenu(), CSLAF::getCurrentLAF(), CSGrafikElement::getDesktop(), CSGrafikElement::getHeight(), CSGrafikElement::getLayoutManager(), getMenuBar(), CSLAF::getMenuOpenXOffset(), CSLAF::getMenuOpenYOffset(), CSBar::getPosition(), CSGrafikElement::getY(), GUI_MESSAGE, CSLayoutManager::pack(), POSITION_SOUTH, CSDesktop::setFocusedComponent(), and CSGrafikElement::translateToDesktop().

Referenced by reactOnMessageMenu().

00186 {
00187     if (mMenuIsOpen)
00188     {
00189         return;
00190     }
00191     if (getMenuBar() != 0)
00192     {
00193         getMenuBar()->closeLastMenu();
00194     }
00195     CSDesktop *desktop = getDesktop();
00196     if (desktop)
00197     {
00198         CSLAF *laf = CSLAF::getCurrentLAF();
00199 
00200         if ((getMenuBar() != 0) && (getMenuBar()->getPosition() == POSITION_SOUTH))
00201         {
00202             int x = laf->getMenuOpenXOffset();
00203             int y = getY() - laf->getMenuOpenYOffset() - mMenuPanel->getHeight();
00204             translateToDesktop(x, y);
00205             desktop->addFrontElement(mMenuPanel, x, y);
00206 
00207         }
00208         else
00209         {
00210             int x = laf->getMenuOpenXOffset();
00211             int y = laf->getMenuOpenYOffset() + getHeight();
00212             translateToDesktop(x, y);
00213             desktop->addFrontElement(mMenuPanel, x, y);
00214         }
00215         mMenuPanel->getLayoutManager()->pack(mMenuPanel);
00216         desktop->setFocusedComponent(mMenuPanel);
00217         mMenuPanel->addMessageListener(this, GUI_MESSAGE);
00218         mMenuIsOpen = true;
00219     }
00220 }

Here is the call graph for this function:

void CSMenu::closeMenu  )  [virtual]
 

Definition at line 173 of file CSMenu.cpp.

References CSGrafikElement::getDesktop(), and CSGrafikElement::removeFrontElement().

Referenced by CSMenuBar::closeLastMenu(), reactOnMessageMenu(), and CSMenuBar::resetMenu().

00174 {
00175     CSDesktop *desktop = getDesktop();
00176     if (desktop == 0)
00177     {
00178         return;
00179     }
00180     // desktop->removeElement(mMenuPanel);
00181     desktop->removeFrontElement(mMenuPanel);
00182     mMenuIsOpen = false;
00183 }

Here is the call graph for this function:

CSMenuBar * CSMenu::getMenuBar  )  [virtual]
 

Definition at line 227 of file CSMenu.cpp.

References CSMenuBar::CLASS, CSGrafikElement::getParent(), CSGrafikElement::getType(), LOG_ENTER, LOG_EXIT, mMenuBar, and CSMenuBar::setMenuState().

Referenced by getButtonState(), openMenu(), and reactOnMessageMenu().

00228 {
00229     static char *functionName="setParent";
00230     LOG_ENTER 
00231     if (mMenuBar != 0)
00232     {
00233         return mMenuBar;
00234     }
00235 
00236     CSGrafikElement *parent = getParent();
00237     while (parent != 0)
00238     {
00239         std::string type = parent->getType();
00240         if (type.compare(CSMenuBar::CLASS) == 0)
00241         {
00242             mMenuBar = (CSMenuBar *) parent;
00243             mMenuBar->setMenuState(mBorderState);
00244             break;
00245         }
00246         parent = parent->getParent();
00247     }
00248     LOG_EXIT
00249     return mMenuBar;
00250 }

Here is the call graph for this function:

void CSMenu::setMenuBar CSMenuBar bar  ) 
 

Definition at line 222 of file CSMenu.cpp.

References mMenuBar.

00223 {
00224     mMenuBar=bar;
00225 }   

int CSMenu::getButtonState  )  [virtual]
 

Reimplemented from CSButton.

Definition at line 148 of file CSMenu.cpp.

References getMenuBar(), and CSMenuBar::getMenuState().

00149 {
00150     if (getMenuBar() != 0)
00151     {
00152         return getMenuBar()->getMenuState(this);
00153     }
00154     return mBorderState;
00155 }

Here is the call graph for this function:


Field Documentation

CSMenuBar* CSMenu::mMenuBar [protected]
 

Definition at line 34 of file CSMenu.h.

Referenced by CSMenu(), getMenuBar(), and setMenuBar().

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

static element, name of this class (introsepection)

Reimplemented from CSButton.

Reimplemented in CSMenuItem.

Definition at line 16 of file CSMenu.cpp.

Referenced by CSLAF::getBackgroundColorEnabledInternal(), CSLAF::getBorderInternal(), CSLAF::getHorizontalElementSpacingInternal(), CSLAF::getTextColorDisabledInternal(), CSLAF::getTextColorEnabledInternal(), getType(), and CSLAF::getVerticalElementSpacingInternal().


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