CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

csmenu.h

Go to the documentation of this file.
00001 /*
00002     Crystal Space Windowing System: menu class
00003     Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSMENU_H__
00021 #define __CS_CSMENU_H__
00022 
00031 #include "cscomp.h"
00032 
00036 
00037 #define CSMIS_CHECKED           0x00000001
00038 
00039 #define CSMIS_SEPARATOR         0x00000010
00040 
00041 #define CSMIS_NEWCOLUMN         0x00000020
00042 
00043 #define CSMIS_NOCLOSE           0x00000040
00044 
00045 #define CSMIS_DEFAULTVALUE      0
00046 
00048 // Forward declaration (for usage in csMenuItem)
00049 class csMenu;
00050 
00052 class csMenuItem : public csComponent
00053 {
00055   char *info;
00057   int underline_pos;
00059   int Style;
00061   int CommandCode;
00063   csMenu *SubMenu;
00064 
00065 public:
00067   csMenuItem (csComponent *iParent, const char *iText,
00068     int iCommandCode = 0, int iStyle = CSMIS_DEFAULTVALUE);
00069 
00071   csMenuItem (csComponent *iParent, int iStyle = CSMIS_DEFAULTVALUE);
00072 
00074   csMenuItem (csComponent *iParent, const char *iText, csMenu *iSubMenu,
00075     int iStyle = CSMIS_DEFAULTVALUE);
00076 
00078   virtual ~csMenuItem ();
00079 
00081   virtual void SuggestSize (int &w, int &h);
00082 
00084   virtual void SetText (const char *iText);
00085 
00087   virtual bool HandleEvent (iEvent &Event);
00088 
00090   virtual void Draw ();
00091 
00093   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00094 
00095 protected:
00097   static csPixmap *sprchecked;
00099   static csPixmap *sprsubmenu;
00100 
00102   void Init ();
00103 
00105   virtual void Press ();
00106 };
00107 
00109 enum
00110 {
00117   cscmdDeactivateMenu = 0x00000200,
00122   cscmdMenuPlaceItems,
00130   cscmdMenuCaptureMouse,
00138   cscmdMenuSetItem,
00142   cscmdMenuSetLastItem,
00150   cscmdMenuQueryDropFlag,
00158   cscmdMenuSetDropFlag,
00170   cscmdMenuItemCheck,
00178   cscmdMenuItemGetStyle,
00187   cscmdMenuItemFindId
00188 };
00189 
00191 enum csMenuFrameStyle
00192 {
00194   csmfsNone,
00196   csmfsThin,
00198   csmfsBar,
00200   csmfs3D
00201 };
00202 
00206 
00207 #define CSMS_HIDEINACTIVE       0x00000001
00208 
00209 #define CSMS_DEFAULTVALUE       CSMS_HIDEINACTIVE
00210 
00220 class csMenu : public csComponent
00221 {
00222   friend class csMenuItem;
00223 
00225   int BorderWidth,BorderHeight;
00227   int FrameStyle;
00229   int MenuStyle;
00231   csComponent *first;
00233   csComponent *last;
00235   csComponent *oldparentfocus;
00237   bool SubMenuOpened;
00239   bool fPlaceItems;
00240 
00241 public:
00243   csComponent *current;
00244 
00246   csMenu (csComponent *iParent, csMenuFrameStyle iFrameStyle = csmfs3D,
00247     int iMenuStyle = CSMS_DEFAULTVALUE);
00248 
00250   virtual void Draw ();
00251 
00253   virtual bool HandleEvent (iEvent &Event);
00254 
00256   virtual bool PreHandleEvent (iEvent &Event);
00257 
00259   bool CurrentHandleEvent (iEvent &Event);
00260 
00262   virtual void PlaceItems ();
00263 
00265   bool IsMenuBar ()
00266   { return (FrameStyle == csmfsBar); }
00267 
00269   virtual void SetState (int mask, bool enable);
00270 
00272   bool SetCurrent (csComponent *newCurrent, bool DropSubmenu = false);
00273 
00275   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00276 
00278   void Deactivate (int DismissCode);
00279 
00281   csComponent *GetItem (int iCommandCode);
00282 
00284   void SetCheck (int iCommandCode, bool iState);
00285 
00287   virtual void Insert (csComponent *comp);
00288 
00290   virtual void Delete (csComponent *comp);
00291 
00293   virtual void SuggestSize (int &w, int &h);
00294 
00295 private:
00297   void SetItemWidth (csComponent *start, int count, int width);
00298 
00300   virtual bool ExecuteKey (int key);
00301 };
00302 
00325 #endif // __CS_CSMENU_H__

Generated for Crystal Space by doxygen 1.2.14