00001
00002
00003
00004
00005 #ifndef __GTOOLBAR_H
00006 #define __GTOOLBAR_H
00007
00009
00011 #define IMGLST_SELECTED 0x0001
00013 #define IMGLST_DISABLED 0x0002
00015 #define IMGLST_GDC 0x0004
00016
00020 class LgiClass GImageList : public GMemDC
00021 {
00022 class GImageListPriv *d;
00023
00024 public:
00026 GImageList
00027 (
00029 int TileX,
00031 int TileY,
00033 GSurface *pDC = NULL
00034 );
00035
00036 ~GImageList();
00037
00039 int TileX();
00041 int TileY();
00043 int GetItems();
00046 GRect *GetBounds();
00047
00050 void Update(int Flags);
00052 void Draw
00053 (
00055 GSurface *pDest,
00057 int x,
00059 int y,
00061 int Image,
00064 int Flags = 0
00065 );
00066 };
00067
00074 LgiFunc GImageList *LgiLoadImageList
00075 (
00077 const char *File,
00079 int x,
00081 int y
00082 );
00083
00085
00086
00087
00088
00090 #define TBT_PUSH 0
00092 #define TBT_RADIO 1
00094 #define TBT_TOGGLE 2
00095
00096
00097 #define TOOL_ICO_NEXT -1
00098 #define TOOL_ICO_NONE -2
00099
00100
00101 #define IDM_NONE 0
00102 #define IDM_SEPARATOR -1
00103 #define IDM_BREAK -2
00104
00105
00106 #define BORDER_SHADE 1
00107 #define BORDER_SPACER 1
00108 #define BORDER_SEPARATOR 4
00109 #define BORDER_BUTTON 1
00110
00112 class LgiClass GToolButton :
00113 public GView
00114 {
00115 friend class GToolBar;
00116
00117 protected:
00118 int Type;
00119 bool Clicked;
00120 bool Down;
00121 bool Over;
00122 int ImgIndex;
00123 int TipId;
00124 bool NeedsRightClick;
00125
00126 #ifdef MAC
00127 HIToolbarItemRef ItemRef;
00128 #endif
00129
00130 GArray<GDisplayString*> Text;
00131 void Layout();
00132
00133 virtual void SetDown(bool d);
00134
00135 public:
00136 GToolButton(int Bx, int By);
00137 ~GToolButton();
00138
00139 const char *GetClass() { return "GToolButton"; }
00140
00141 int64 Value() { return Down; }
00142 void Value(int64 i);
00143
00144 char *Name() { return GView::Name(); }
00145 bool Name(const char *n);
00146
00148 int Image() { return ImgIndex; }
00150 void Image(int i);
00151
00152 bool GetDown() { return Down; }
00153 int GetType() { return Type; }
00154 void SetType(int i) { Type = i; }
00155 bool Separator() { return GetId() == IDM_SEPARATOR; }
00156 void Separator(bool i) { SetId(IDM_SEPARATOR); }
00157 bool GetNeedsRightClick() { return NeedsRightClick; }
00158 void SetNeedsRightClick(bool b) { NeedsRightClick = b; }
00159
00160 void OnPaint(GSurface *pDC);
00161
00162 void OnMouseClick(GMouse &m);
00163 void OnMouseMove(GMouse &m);
00164 void OnMouseEnter(GMouse &m);
00165 void OnMouseExit(GMouse &m);
00166
00167 virtual void OnCommand();
00168 virtual void SendNotify(int Flags);
00169 virtual bool GetDimension(int &x, int &y) { return false; }
00170 };
00171
00195 class LgiClass GToolBar : public GLayout
00196 {
00197 friend class GToolButton;
00198
00199 protected:
00200 class GToolBarPrivate *d;
00201
00202
00203 void _BuildCache(GImageList *From);
00204 void _DrawFromCache(GSurface *pDC, int x, int y, int Index, bool Disabled);
00205 int GetBx();
00206 int GetBy();
00207
00208
00209 virtual void ContextMenu(GMouse &m);
00210 virtual int PostDescription(GView *Ctrl, const char *Text);
00211
00212 #ifdef MAC
00213 HIToolbarRef ToolbarRef;
00214 #endif
00215
00216 public:
00217 GToolBar();
00218 ~GToolBar();
00219
00220 const char *GetClass() { return "GToolBar"; }
00221
00223 virtual void OnButtonClick(GToolButton *Btn);
00224
00226 bool IsVertical();
00228 void IsVertical(bool v);
00230 bool TextLabels();
00232 void TextLabels(bool i);
00234 bool IsCustomizable();
00235
00237
00238
00240
00242
00243
00244
00246 void Customizable
00247 (
00249 GDom *Store = 0,
00251 const char *Option = 0
00252 );
00254 bool SetBitmap(char *File, int Bx, int By);
00256 bool SetDC(GSurface *pDC, int Bx, int By);
00258 GImageList *GetImageList();
00260 bool SetImageList(GImageList *l, int Bx, int By, bool Own = true);
00262 GFont *GetFont();
00263
00265 GToolButton *AppendButton
00266 (
00268 const char *Tip,
00270 int Id,
00273 int Type = TBT_PUSH,
00275 int Enabled = true,
00277 int IconId = -1
00278 );
00279
00281 bool AppendControl(GView *Ctrl);
00282
00284 bool AppendSeparator();
00285
00287 bool AppendBreak();
00288
00290 void Empty();
00291
00293 int Length() { return Children.Length(); }
00294
00295
00296 int OnEvent(GMessage *Msg);
00297 void OnPaint(GSurface *pDC);
00298 void OnMouseClick(GMouse &m);
00299 void OnMouseEnter(GMouse &m);
00300 void OnMouseExit(GMouse &m);
00301 void OnMouseMove(GMouse &m);
00302 bool Pour(GRegion &r);
00303 void OnCreate();
00304
00305 #ifdef MAC
00306 bool Attach(GViewI *parent);
00307
00308 class Custom : public GView
00309 {
00310 public:
00311 Custom();
00312 ~Custom();
00313 };
00314 #endif
00315 };
00316
00318 LgiFunc GToolBar *LgiLoadToolbar
00319 (
00321 GViewI *Parent,
00323 const char *File,
00325 int x = 24,
00327 int y = 24
00328 );
00329
00330 #endif