|
csmenu.h00001 /* 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 __CSMENU_H__ 00021 #define __CSMENU_H__ 00022 00023 #include "cscomp.h" 00024 00034 00035 #define CSMIS_CHECKED 0x00000001 00036 00037 #define CSMIS_SEPARATOR 0x00000010 00038 00039 #define CSMIS_NEWCOLUMN 0x00000020 00040 00041 #define CSMIS_NOCLOSE 0x00000040 00042 00043 #define CSMIS_DEFAULTVALUE 0 00044 00045 // Forward declaration (for usage in csMenuItem) 00046 class csMenu; 00047 00049 class csMenuItem : public csComponent 00050 { 00052 char *info; 00054 int underline_pos; 00056 int Style; 00058 int CommandCode; 00060 csMenu *SubMenu; 00061 00062 public: 00064 csMenuItem (csComponent *iParent, const char *iText, 00065 int iCommandCode = 0, int iStyle = CSMIS_DEFAULTVALUE); 00066 00068 csMenuItem (csComponent *iParent, int iStyle = CSMIS_DEFAULTVALUE); 00069 00071 csMenuItem (csComponent *iParent, const char *iText, csMenu *iSubMenu, 00072 int iStyle = CSMIS_DEFAULTVALUE); 00073 00075 virtual ~csMenuItem (); 00076 00078 virtual void SuggestSize (int &w, int &h); 00079 00081 virtual void SetText (const char *iText); 00082 00084 virtual bool HandleEvent (iEvent &Event); 00085 00087 virtual void Draw (); 00088 00090 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax); 00091 00092 protected: 00094 static csPixmap *sprchecked; 00096 static csPixmap *sprsubmenu; 00097 00099 void Init (); 00100 00102 virtual void Press (); 00103 }; 00104 00106 enum 00107 { 00114 cscmdDeactivateMenu = 0x00000200, 00119 cscmdMenuPlaceItems, 00127 cscmdMenuCaptureMouse, 00135 cscmdMenuSetItem, 00139 cscmdMenuSetLastItem, 00147 cscmdMenuQueryDropFlag, 00155 cscmdMenuSetDropFlag, 00167 cscmdMenuItemCheck, 00175 cscmdMenuItemGetStyle, 00184 cscmdMenuItemFindId 00185 }; 00186 00188 enum csMenuFrameStyle 00189 { 00191 csmfsNone, 00193 csmfsThin, 00195 csmfsBar, 00197 csmfs3D 00198 }; 00199 00201 #define CSMS_HIDEINACTIVE 0x00000001 00202 00203 #define CSMS_DEFAULTVALUE CSMS_HIDEINACTIVE 00204 00209 class csMenu : public csComponent 00210 { 00211 friend class csMenuItem; 00212 00214 int BorderWidth,BorderHeight; 00216 int FrameStyle; 00218 int MenuStyle; 00220 csComponent *first; 00222 csComponent *last; 00224 csComponent *oldparentfocus; 00226 bool SubMenuOpened; 00228 bool fPlaceItems; 00229 00230 public: 00232 csComponent *current; 00233 00235 csMenu (csComponent *iParent, csMenuFrameStyle iFrameStyle = csmfs3D, 00236 int iMenuStyle = CSMS_DEFAULTVALUE); 00237 00239 virtual void Draw (); 00240 00242 virtual bool HandleEvent (iEvent &Event); 00243 00245 virtual bool PreHandleEvent (iEvent &Event); 00246 00248 bool CurrentHandleEvent (iEvent &Event); 00249 00251 virtual void PlaceItems (); 00252 00254 bool IsMenuBar () 00255 { return (FrameStyle == csmfsBar); } 00256 00258 virtual void SetState (int mask, bool enable); 00259 00261 bool SetCurrent (csComponent *newCurrent, bool DropSubmenu = false); 00262 00264 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax); 00265 00267 void Deactivate (int DismissCode); 00268 00270 csComponent *GetItem (int iCommandCode); 00271 00273 void SetCheck (int iCommandCode, bool iState); 00274 00276 virtual void Insert (csComponent *comp); 00277 00279 virtual void Delete (csComponent *comp); 00280 00282 virtual void SuggestSize (int &w, int &h); 00283 00284 private: 00286 void SetItemWidth (csComponent *start, int count, int width); 00287 00289 virtual bool ExecuteKey (int key); 00290 }; 00291 00311 #endif // __CSMENU_H__ Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |