00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CS_CSNOTEBK_H__
00021 #define __CS_CSNOTEBK_H__
00022
00031 #include "cscomp.h"
00032 #include "csbutton.h"
00033 #include "csutil/parray.h"
00034
00043
00044 #define CSNBS_TABPOS_MASK 0x00000003
00045
00046 #define CSNBS_TABPOS_TOP 0x00000000
00047
00048 #define CSNBS_TABPOS_BOTTOM 0x00000001
00049
00050 #define CSNBS_TABPOS_LEFT 0x00000002
00051
00052 #define CSNBS_TABPOS_RIGHT 0x00000003
00053
00054 #define CSNBS_PAGEFRAME 0x00000010
00055
00056 #define CSNBS_PAGEINFO 0x00000020
00057
00058 #define CSNBS_THINTABS 0x00000040
00059
00060 #define CSNBS_DEFAULTVALUE \
00061 CSNBS_TABPOS_TOP | CSNBS_PAGEFRAME | CSNBS_PAGEINFO
00062
00067 enum
00068 {
00078 cscmdNotebookLeavePage = 0x00000c00,
00089 cscmdNotebookSelectPage,
00097 cscmdNotebookNextPage,
00105 cscmdNotebookPrevPage,
00113 cscmdNotebookScrollTabsForward,
00121 cscmdNotebookScrollTabsBackward
00122 };
00123
00124 class cspNotebookButton;
00125
00134 class csNotebook : public csComponent
00135 {
00136
00137 struct cspPageData
00138 {
00139
00140 csComponent *page;
00141
00142 csRect bound;
00143
00144 int zorder;
00145
00146 unsigned char flags;
00147
00148
00149 csPixmap *image;
00150
00151 char *text;
00152
00153 int underline_pos;
00154
00155
00156 cspPageData (csComponent *ipage, unsigned char iflags);
00157
00158 ~cspPageData ();
00159
00160 bool IsHotKey (int iKey);
00161 };
00162
00164 int style;
00166 csButton *nextpage, *prevpage;
00168 cspNotebookButton *tabfor, *taback;
00170 static csPixmap *sprites [12];
00172 bool fReposition;
00174 int firsttab, activetab;
00176 csPDelArray<cspPageData> pages;
00177
00178 public:
00180 csNotebook (csComponent *iParent, int iStyle = CSNBS_DEFAULTVALUE);
00182 virtual ~csNotebook ();
00184 virtual void Draw ();
00186 virtual bool HandleEvent (iEvent &Event);
00187
00189 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax);
00190
00192 int GetStyle () { return style; }
00194 void SetStyle (int iStyle);
00195
00197 bool AddPrimaryTab (csComponent *iComponent, const char *iText,
00198 const char *iInfo = 0, csComponent *iBefore = 0);
00200 bool AddSecondaryTab (csComponent *iComponent, const char *iInfo,
00201 csComponent *iBefore = 0);
00203 bool AddPrimaryTab (csComponent *iComponent, csPixmap *iPixmap,
00204 bool iDeletePixmap = true, const char *iInfo = 0,
00205 csComponent *iBefore = 0);
00206
00208 bool DeleteTab (int iIndex);
00210 bool DeleteTab (csComponent *iComponent);
00211
00213 bool SelectTab (int iIndex);
00215 bool SelectTab (csComponent *iComponent);
00216
00217 protected:
00219 int tabx, taby, tabw, tabh, lasttab, lastpos, primary;
00220
00222 void PlaceGadgets ();
00224 bool AddTab (cspPageData *iPageData, const char *iInfo,
00225 csComponent *iBefore);
00227 void GetClientRect (csRect &oRect);
00229 int InfoHeight ();
00231 bool GetTabSize (int iTab, int &oW, int &oH);
00233 bool InsideTab (int iIndex, int x, int y);
00235 int FindPage (csComponent *iComponent);
00236 };
00237
00240 #endif // __CS_CSNOTEBK_H__