Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

GToolBar.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 #ifndef __GTOOLBAR_H
00006 #define __GTOOLBAR_H
00007 
00009 
00011 #define IMGLST_SELECTED             0x0001
00012 
00013 #define IMGLST_DISABLED             0x0002
00014 
00015 #define IMGLST_GDC                  0x0004
00016 
00020 class LgiClass GImageList : public GMemDC
00021 {
00022     #if defined BEOS
00023 
00024     GSurface *Mask;
00025 
00026     #endif
00027 
00028     GSurface *pCreate;
00029     int Sx, Sy;
00030     GRect *Bounds;
00031 
00032 public:
00034     GImageList
00035     (
00037         int x,
00039         int y,
00041         GSurface *pDC = NULL
00042     );
00043     
00044     ~GImageList();
00045 
00047     int TileX() { return Sx; }
00049     int TileY() { return Sy; }
00051     int GetItems() { return X() / Sx; }
00054     GRect *GetBounds();
00055 
00057     bool Create(int x, int y, int Bits, int LineLen = 0, bool KeepData = false);
00060     void Update(int Flags);
00062     void Draw
00063     (
00065         GSurface *pDest,
00067         int x,
00069         int y,
00071         int Image,
00074         int Flags = 0
00075     );
00076 };
00077 
00084 LgiFunc GImageList *LgiLoadImageList
00085 (
00087     char *File,
00089     int x,
00091     int y
00092 );
00093 
00095 // Toolbar stuff
00096 
00097 // Tool button types
00098 
00100 #define TBT_PUSH                0
00101 
00102 #define TBT_RADIO               1
00103 
00104 #define TBT_TOGGLE              2
00105 
00106 // Tool icon types
00107 #define TOOL_ICO_NEXT           -1
00108 #define TOOL_ICO_NONE           -2
00109 
00110 // Commands
00111 #define IDM_NONE                0
00112 #define IDM_SEPARATOR           -1
00113 #define IDM_BREAK               -2
00114 
00115 // Dimensions
00116 #define BORDER_SHADE            1
00117 #define BORDER_SPACER           1
00118 #define BORDER_SEPARATOR        4
00119 #define BORDER_BUTTON           1
00120 
00122 class LgiClass GToolButton :
00123     public GView
00124 {
00125     friend class GToolBar;
00126 
00127 protected:
00128     int         Type;       // Button Type
00129     bool        Clicked;
00130     bool        Down;
00131     bool        Over;
00132     int         ImgIndex;
00133     int         TipId;
00134 
00135     virtual void SetDown(bool d);
00136 
00137 public:
00138     GToolButton(int Bx, int By);
00139     ~GToolButton();
00140 
00141     int Value() { return Down; }
00142     void Value(int i);
00144     int Image() { return ImgIndex; }
00146     void Image(int i);
00147     bool GetDown() { return Down; }
00148     int GetType() { return Type; }
00149     void SetType(int i) { Type = i; }
00150     bool Separator() { return GetId() == IDM_SEPARATOR; }
00151     void Separator(bool i) { SetId(IDM_SEPARATOR); }
00152 
00153     void OnPaint(GSurface *pDC);
00154 
00155     void OnMouseClick(GMouse &m);
00156     void OnMouseMove(GMouse &m);
00157     void OnMouseEnter(GMouse &m);
00158     void OnMouseExit(GMouse &m);
00159 
00160     virtual void OnCommand();
00161     virtual void SendNotify(int Flags);
00162     virtual bool GetDimension(int &x, int &y) { return false; }
00163 };
00164 
00188 class LgiClass GToolBar : public GLayout
00189 {
00190     friend class GToolButton;
00191 
00192 protected:
00193     class GToolBarPrivate *d;
00194 
00195     // Local
00196     void _BuildCache(GImageList *From);
00197     void _DrawFromCache(GSurface *pDC, int x, int y, int Index, bool Disabled);
00198     void FixSeparators();
00199     int GetBx();
00200     int GetBy();
00201 
00202     // Overridable
00203     virtual void ContextMenu(GMouse &m);    
00204     virtual int PostDescription(GView *Ctrl, char *Text);
00205 
00206 public:
00207     GToolBar();
00208     ~GToolBar();
00209 
00211     virtual void OnButtonClick(GToolButton *Btn);
00212 
00214     bool IsVertical();
00216     void IsVertical(bool v);
00218     bool TextLabels();
00220     void TextLabels(bool i);
00222     bool Customizable();
00224     void Customizable
00225     (
00227         ObjProperties *Store = 0,
00229         char *Option = 0
00230     );      
00232     bool SetBitmap(char *File, int Bx, int By);
00234     bool SetDC(GSurface *pDC, int Bx, int By);
00236     GImageList *GetImageList();
00238     bool SetImageList(GImageList *l, int Bx, int By, bool Own = true);
00240     GFont *GetFont();
00241 
00243     GToolButton *AppendButton
00244     (
00246         char *Tip,
00248         int Id,
00251         int Type = TBT_PUSH,
00253         int Enabled = true,
00255         int IconId = -1
00256     );
00257     
00259     bool AppendControl(GView *Ctrl);
00260     
00262     bool AppendSeparator();
00263     
00265     bool AppendBreak();
00266     
00268     void Empty();
00269 
00270     // Events
00271     int OnEvent(GMessage *Msg);
00272     void OnPaint(GSurface *pDC);
00273     void OnMouseClick(GMouse &m);
00274     void OnMouseEnter(GMouse &m);
00275     void OnMouseExit(GMouse &m);
00276     void OnMouseMove(GMouse &m);
00277     bool Pour(GRegion &r);
00278 };
00279 
00281 LgiFunc GToolBar *LgiLoadToolbar
00282 (
00284     GView *Parent,
00286     char *File,
00288     int x = 24,
00290     int y = 24
00291 );
00292 
00293 #endif

Generated on Wed Oct 26 14:46:50 2005 for Lgi by  doxygen 1.4.1