csws/csnotebk.h
Go to the documentation of this file.00001 /* 00002 Crystal Space Windowing System: notebook class 00003 Copyright (C) 2000 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 __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 // Structure used to keep per-page private information 00137 struct cspPageData 00138 { 00139 // The page component 00140 csComponent *page; 00141 // Tab bounds (empty if not visible) 00142 csRect bound; 00143 // The Z-order of this tab (-1 if not visible) 00144 int zorder; 00145 // Notebook page flags (see NOTEBOOK_PAGE_XXX) 00146 unsigned char flags; 00147 00148 // The image on this tab (only primary pages) 00149 csPixmap *image; 00150 // The text on this tab 00151 char *text; 00152 // The underline position 00153 int underline_pos; 00154 00155 // Constructor 00156 cspPageData (csComponent *ipage, unsigned char iflags); 00157 // Destructor 00158 ~cspPageData (); 00159 // Check if this character is the hotkey for this tab 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__
Generated for Crystal Space by doxygen 1.2.18