|
csnotebk.h00001 /* 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 __CSNOTEBK_H__ 00021 #define __CSNOTEBK_H__ 00022 00023 #include "cscomp.h" 00024 #include "csbutton.h" 00025 00034 00035 #define CSNBS_TABPOS_MASK 0x00000003 00036 00037 #define CSNBS_TABPOS_TOP 0x00000000 00038 00039 #define CSNBS_TABPOS_BOTTOM 0x00000001 00040 00041 #define CSNBS_TABPOS_LEFT 0x00000002 00042 00043 #define CSNBS_TABPOS_RIGHT 0x00000003 00044 00045 #define CSNBS_PAGEFRAME 0x00000010 00046 00047 #define CSNBS_PAGEINFO 0x00000020 00048 00049 #define CSNBS_THINTABS 0x00000040 00050 00051 #define CSNBS_DEFAULTVALUE CSNBS_TABPOS_TOP | \ 00052 CSNBS_PAGEFRAME | \ 00053 CSNBS_PAGEINFO 00054 00058 enum 00059 { 00069 cscmdNotebookLeavePage = 0x00000c00, 00080 cscmdNotebookSelectPage, 00088 cscmdNotebookNextPage, 00096 cscmdNotebookPrevPage, 00104 cscmdNotebookScrollTabsForward, 00112 cscmdNotebookScrollTabsBackward 00113 }; 00114 00115 class cspNotebookButton; 00116 00125 class csNotebook : public csComponent 00126 { 00127 // Structure used to keep per-page private information 00128 struct cspPageData 00129 { 00130 // The page component 00131 csComponent *page; 00132 // Tab bounds (empty if not visible) 00133 csRect bound; 00134 // The Z-order of this tab (-1 if not visible) 00135 int zorder; 00136 // Notebook page flags (see NOTEBOOK_PAGE_XXX) 00137 unsigned char flags; 00138 00139 // The image on this tab (only primary pages) 00140 csPixmap *image; 00141 // The text on this tab 00142 char *text; 00143 // The underline position 00144 int underline_pos; 00145 00146 // Constructor 00147 cspPageData (csComponent *ipage, unsigned char iflags); 00148 // Destructor 00149 ~cspPageData (); 00150 // Check if this character is the hotkey for this tab 00151 bool IsHotKey (int iKey); 00152 }; 00153 00155 int style; 00157 csButton *nextpage, *prevpage; 00159 cspNotebookButton *tabfor, *taback; 00161 static csPixmap *sprites [12]; 00163 bool fReposition; 00165 int firsttab, activetab; 00167 CS_DECLARE_TYPED_VECTOR (cspPageDataVector, cspPageData) pages; 00168 00169 public: 00171 csNotebook (csComponent *iParent, int iStyle = CSNBS_DEFAULTVALUE); 00173 virtual ~csNotebook (); 00175 virtual void Draw (); 00177 virtual bool HandleEvent (iEvent &Event); 00178 00180 virtual bool SetRect (int xmin, int ymin, int xmax, int ymax); 00181 00183 int GetStyle () { return style; } 00185 void SetStyle (int iStyle); 00186 00188 bool AddPrimaryTab (csComponent *iComponent, const char *iText, 00189 const char *iInfo = NULL, csComponent *iBefore = NULL); 00191 bool AddSecondaryTab (csComponent *iComponent, const char *iInfo, 00192 csComponent *iBefore = NULL); 00194 bool AddPrimaryTab (csComponent *iComponent, csPixmap *iPixmap, 00195 bool iDeletePixmap = true, const char *iInfo = NULL, 00196 csComponent *iBefore = NULL); 00197 00199 bool DeleteTab (int iIndex); 00201 bool DeleteTab (csComponent *iComponent); 00202 00204 bool SelectTab (int iIndex); 00206 bool SelectTab (csComponent *iComponent); 00207 00208 protected: 00210 int tabx, taby, tabw, tabh, lasttab, lastpos, primary; 00211 00213 void PlaceGadgets (); 00215 bool AddTab (cspPageData *iPageData, const char *iInfo, 00216 csComponent *iBefore); 00218 void GetClientRect (csRect &oRect); 00220 int InfoHeight (); 00222 bool GetTabSize (int iTab, int &oW, int &oH); 00224 bool InsideTab (int iIndex, int x, int y); 00226 int FindPage (csComponent *iComponent); 00227 }; 00228 00229 #endif // __CSNOTEBK_H__ Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |