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
00096
00097
00098
00100 #define TBT_PUSH 0
00101
00102 #define TBT_RADIO 1
00103
00104 #define TBT_TOGGLE 2
00105
00106
00107 #define TOOL_ICO_NEXT -1
00108 #define TOOL_ICO_NONE -2
00109
00110
00111 #define IDM_NONE 0
00112 #define IDM_SEPARATOR -1
00113 #define IDM_BREAK -2
00114
00115
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;
00129 bool Clicked;
00130 bool Down;
00131 bool Over;
00132 int ImgIndex;
00133 int TipId;
00134 bool NeedsRightClick;
00135
00136 virtual void SetDown(bool d);
00137
00138 public:
00139 GToolButton(int Bx, int By);
00140 ~GToolButton();
00141
00142 int Value() { return Down; }
00143 void Value(int i);
00144
00146 int Image() { return ImgIndex; }
00148 void Image(int i);
00149
00150 bool GetDown() { return Down; }
00151 int GetType() { return Type; }
00152 void SetType(int i) { Type = i; }
00153 bool Separator() { return GetId() == IDM_SEPARATOR; }
00154 void Separator(bool i) { SetId(IDM_SEPARATOR); }
00155 bool GetNeedsRightClick() { return NeedsRightClick; }
00156 void SetNeedsRightClick(bool b) { NeedsRightClick = b; }
00157
00158 void OnPaint(GSurface *pDC);
00159
00160 void OnMouseClick(GMouse &m);
00161 void OnMouseMove(GMouse &m);
00162 void OnMouseEnter(GMouse &m);
00163 void OnMouseExit(GMouse &m);
00164
00165 virtual void OnCommand();
00166 virtual void SendNotify(int Flags);
00167 virtual bool GetDimension(int &x, int &y) { return false; }
00168 };
00169
00193 class LgiClass GToolBar : public GLayout
00194 {
00195 friend class GToolButton;
00196
00197 protected:
00198 class GToolBarPrivate *d;
00199
00200
00201 void _BuildCache(GImageList *From);
00202 void _DrawFromCache(GSurface *pDC, int x, int y, int Index, bool Disabled);
00203 int GetBx();
00204 int GetBy();
00205
00206
00207 virtual void ContextMenu(GMouse &m);
00208 virtual int PostDescription(GView *Ctrl, char *Text);
00209
00210 public:
00211 GToolBar();
00212 ~GToolBar();
00213
00215 virtual void OnButtonClick(GToolButton *Btn);
00216
00218 bool IsVertical();
00220 void IsVertical(bool v);
00222 bool TextLabels();
00224 void TextLabels(bool i);
00226 bool IsCustomizable();
00228 void Customizable
00229 (
00231 ObjProperties *Store = 0,
00233 char *Option = 0
00234 );
00236 void Customizable
00237 (
00239 GXmlTag *Store = 0,
00241 char *Option = 0
00242 );
00244 bool SetBitmap(char *File, int Bx, int By);
00246 bool SetDC(GSurface *pDC, int Bx, int By);
00248 GImageList *GetImageList();
00250 bool SetImageList(GImageList *l, int Bx, int By, bool Own = true);
00252 GFont *GetFont();
00253
00255 GToolButton *AppendButton
00256 (
00258 char *Tip,
00260 int Id,
00263 int Type = TBT_PUSH,
00265 int Enabled = true,
00267 int IconId = -1
00268 );
00269
00271 bool AppendControl(GView *Ctrl);
00272
00274 bool AppendSeparator();
00275
00277 bool AppendBreak();
00278
00280 void Empty();
00281
00282
00283 int OnEvent(GMessage *Msg);
00284 void OnPaint(GSurface *pDC);
00285 void OnMouseClick(GMouse &m);
00286 void OnMouseEnter(GMouse &m);
00287 void OnMouseExit(GMouse &m);
00288 void OnMouseMove(GMouse &m);
00289 bool Pour(GRegion &r);
00290 };
00291
00293 LgiFunc GToolBar *LgiLoadToolbar
00294 (
00296 GViewI *Parent,
00298 char *File,
00300 int x = 24,
00302 int y = 24
00303 );
00304
00305 #endif