CrystalSpace

Public API Reference

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

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 
00096   virtual int GetStyle () { return Style; };
00097 
00098 protected:
00100   static csPixmap *sprchecked;
00102   static csPixmap *sprsubmenu;
00103 
00105   void Init ();
00106 
00108   virtual void Press ();
00109 };
00110 
00112 enum
00113 {
00120   cscmdDeactivateMenu = 0x00000200,
00125   cscmdMenuPlaceItems,
00133   cscmdMenuCaptureMouse,
00141   cscmdMenuSetItem,
00145   cscmdMenuSetLastItem,
00153   cscmdMenuQueryDropFlag,
00161   cscmdMenuSetDropFlag,
00173   cscmdMenuItemCheck,
00181   cscmdMenuItemGetStyle,
00190   cscmdMenuItemFindId
00191 };
00192 
00194 enum csMenuFrameStyle
00195 {
00197   csmfsNone,
00199   csmfsThin,
00201   csmfsBar,
00203   csmfs3D
00204 };
00205 
00209 
00210 #define CSMS_HIDEINACTIVE       0x00000001
00211 
00212 #define CSMS_DEFAULTVALUE       CSMS_HIDEINACTIVE
00213 
00223 class csMenu : public csComponent
00224 {
00225   friend class csMenuItem;
00226 
00228   int BorderWidth,BorderHeight;
00230   int FrameStyle;
00232   int MenuStyle;
00234   csComponent *first;
00236   csComponent *last;
00238   csComponent *oldparentfocus;
00240   bool SubMenuOpened;
00242   bool fPlaceItems;
00243 
00244 public:
00246   csComponent *current;
00247 
00249   csMenu (csComponent *iParent, csMenuFrameStyle iFrameStyle = csmfs3D,
00250     int iMenuStyle = CSMS_DEFAULTVALUE);
00251 
00253   virtual void Draw ();
00254 
00256   virtual bool HandleEvent (iEvent &Event);
00257 
00259   virtual bool PreHandleEvent (iEvent &Event);
00260 
00262   bool CurrentHandleEvent (iEvent &Event);
00263 
00265   virtual void PlaceItems ();
00266 
00268   bool IsMenuBar ()
00269   { return (FrameStyle == csmfsBar); }
00270 
00272   virtual void SetState (int mask, bool enable);
00273 
00275   bool SetCurrent (csComponent *newCurrent, bool DropSubmenu = false);
00276 
00278   virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00279 
00281   void Deactivate (int DismissCode);
00282 
00284   csComponent *GetItem (int iCommandCode);
00285 
00287   void SetCheck (int iCommandCode, bool iState);
00288 
00290   bool GetCheck (int iCommandCode);
00291 
00293   virtual void Insert (csComponent *comp);
00294 
00296   virtual void Delete (csComponent *comp);
00297 
00299   virtual void SuggestSize (int &w, int &h);
00300 
00301 private:
00303   void SetItemWidth (csComponent *start, int count, int width);
00304 
00306   virtual bool ExecuteKey (int key);
00307 };
00308 
00331 #endif // __CS_CSMENU_H__

Generated for Crystal Space by doxygen 1.2.14