CrystalSpace

Public API Reference

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

csws/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 "csextern.h"
00032  
00033 #include "cscomp.h"
00034 
00038 
00039 #define CSMIS_CHECKED           0x00000001
00040 
00041 #define CSMIS_SEPARATOR         0x00000010
00042 
00043 #define CSMIS_NEWCOLUMN         0x00000020
00044 
00045 #define CSMIS_NOCLOSE           0x00000040
00046 
00047 #define CSMIS_DEFAULTVALUE      0
00048 
00050 // Forward declaration (for usage in csMenuItem)
00051 class csMenu;
00052 
00054 class CS_CSWS_EXPORT csMenuItem : public csComponent
00055 {
00057   char *info;
00059   int underline_pos;
00061   int Style;
00063   int CommandCode;
00065   csMenu *SubMenu;
00066 
00067 public:
00069   csMenuItem (csComponent *iParent, const char *iText,
00070     int iCommandCode = 0, int iStyle = CSMIS_DEFAULTVALUE);
00071 
00073   csMenuItem (csComponent *iParent, int iStyle = CSMIS_DEFAULTVALUE);
00074 
00076   csMenuItem (csComponent *iParent, const char *iText, csMenu *iSubMenu,
00077     int iStyle = CSMIS_DEFAULTVALUE);
00078 
00080   virtual ~csMenuItem ();
00081 
00083   virtual void SuggestSize (int &w, int &h);
00084 
00086   virtual void SetText (const char *iText);
00087 
00089   virtual bool HandleEvent (iEvent &Event);
00090 
00092   virtual void Draw ();
00093 
00095   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00096 
00098   virtual int GetStyle () { return Style; };
00099 
00100 protected:
00102   static csPixmap *sprchecked;
00104   static csPixmap *sprsubmenu;
00105 
00107   void Init ();
00108 
00110   virtual void Press ();
00111 };
00112 
00114 enum
00115 {
00122   cscmdDeactivateMenu = 0x00000200,
00127   cscmdMenuPlaceItems,
00135   cscmdMenuCaptureMouse,
00143   cscmdMenuSetItem,
00147   cscmdMenuSetLastItem,
00155   cscmdMenuQueryDropFlag,
00163   cscmdMenuSetDropFlag,
00175   cscmdMenuItemCheck,
00183   cscmdMenuItemGetStyle,
00192   cscmdMenuItemFindId
00193 };
00194 
00196 enum csMenuFrameStyle
00197 {
00199   csmfsNone,
00201   csmfsThin,
00203   csmfsBar,
00205   csmfs3D
00206 };
00207 
00211 
00212 #define CSMS_HIDEINACTIVE       0x00000001
00213 
00214 #define CSMS_DEFAULTVALUE       CSMS_HIDEINACTIVE
00215 
00225 class CS_CSWS_EXPORT csMenu : public csComponent
00226 {
00227   friend class csMenuItem;
00228 
00230   int BorderWidth,BorderHeight;
00232   int FrameStyle;
00234   int MenuStyle;
00236   csComponent *first;
00238   csComponent *last;
00240   csComponent *oldparentfocus;
00242   bool SubMenuOpened;
00244   bool fPlaceItems;
00245 
00246 public:
00248   csComponent *current;
00249 
00251   csMenu (csComponent *iParent, csMenuFrameStyle iFrameStyle = csmfs3D,
00252     int iMenuStyle = CSMS_DEFAULTVALUE);
00253 
00255   virtual void Draw ();
00256 
00258   virtual bool HandleEvent (iEvent &Event);
00259 
00261   virtual bool PreHandleEvent (iEvent &Event);
00262 
00264   bool CurrentHandleEvent (iEvent &Event);
00265 
00267   virtual void PlaceItems ();
00268 
00270   bool IsMenuBar ()
00271   { return (FrameStyle == csmfsBar); }
00272 
00274   virtual void SetState (int mask, bool enable);
00275 
00277   bool SetCurrent (csComponent *newCurrent, bool DropSubmenu = false);
00278 
00280   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00281 
00283   void Deactivate (int DismissCode);
00284 
00286   csComponent *GetItem (int iCommandCode);
00287 
00289   void SetCheck (int iCommandCode, bool iState);
00290 
00292   bool GetCheck (int iCommandCode);
00293 
00295   virtual void Insert (csComponent *comp);
00296 
00298   virtual void Delete (csComponent *comp);
00299 
00301   virtual void SuggestSize (int &w, int &h);
00302 
00303 private:
00305   void SetItemWidth (csComponent *start, int count, int width);
00306 
00308   virtual bool ExecuteKey (int key);
00309 };
00310 
00333 #endif // __CS_CSMENU_H__

Generated for Crystal Space by doxygen 1.2.18