vdk 2.4.0
notebook.h
1 /*
2  * ===========================
3  * VDK Visual Development Kit
4  * Version 0.4
5  * October 1998
6  * ===========================
7  *
8  * Copyright (C) 1998, Mario Motta
9  * Developed by Mario Motta <mmotta@guest.net>
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  * 02111-1307, USA.
25  */
26 
27 #ifndef NOTEBOOK_H
28 #define NOTEBOOK_H
29 #include <vdk/widcontain.h>
30 #include <vdk/dlist.h>
31 #include <vdk/vdkprops.h>
32 extern char *book_open_xpm[];
33 extern char *book_closed_xpm[];
34 
35 class VDKPixmap;
36 class VDKLabel;
37 class VDKBox;
38 class VDKForm;
39 class VDKNotebook;
40 class PageList;
41 class VDKTabPage;
44 #define PageListIterator PListIterator
45 /*
46 */
47 typedef VDKReadWriteValueProp<VDKNotebook,int> NoteBookIntProp;
48 
49 class ActivePageProperty: public NoteBookIntProp
50 {
51 
52 public:
53  ActivePageProperty();
54  ActivePageProperty(
55  char* name,
56  VDKNotebook* object,
57  void (VDKNotebook::*write)(int) = NULL,
58  int (VDKNotebook::*read)(void) = NULL
59  );
60  virtual ~ActivePageProperty();
61  operator int();
62  void operator=(int page);
63  void operator++();
64  void operator--();
65  void operator++(int);
66  void operator--(int);
67 };
68 
69 /*
70  */
71 class NotebookTabPosProperty: public NoteBookIntProp
72 {
73 
74 public:
75  NotebookTabPosProperty();
76  NotebookTabPosProperty(
77  char* name,
78  VDKNotebook* object,
79  void (VDKNotebook::*write)(int) = NULL,
80  int (VDKNotebook::*read)(void) = NULL
81  );
82  virtual ~NotebookTabPosProperty();
83  void operator = (int pos);
84 };
89 class VDKTabPage
90 {
91 
92  GtkWidget *tab;
93  GdkPixmap *open;
94  GdkPixmap *closed;
95  GdkBitmap *open_mask;
96  GdkBitmap *closed_mask;
97  friend class PageList;
98  friend class VDKNotebook;
99  VDKObject* child;
100  VDKObject* book;
101 
102  public:
103 
104  // properties
108  VDKLabel* TabLabel; // the tab label
112  VDKObject* Child() { return child; }
116  VDKTabPage(VDKObject* owner,
117  VDKObject* child,
118  const char *label,
119  char **pixmap_closed,
120  char **pixmap_open);
121  virtual ~VDKTabPage() {}
122 };
127 class PageList: public PList
128 {
129  friend class VDKNotebook;
130  VDKNotebook *book;
131  public:
135  PageList(VDKNotebook* book = NULL): PList(), book(book) {}
136  ~PageList();
140  void AddPage(VDKObject* child,
141  const char *label,
142  char **pixmap_closed,
143  char **pixmap_open);
148  VDKTabPage* operator[](int n);
152  int size() { return PList::size() ; }
153 };
166 {
167  static void PageSwitch(GtkWidget *widget,
168  GtkNotebookPage *page,
169  int pagenum,
170  gpointer gp);
171  protected:
172 
173 public:
174  // properties
184  PageList Pages; // run-time read only
194  ActivePageProperty ActivePage;
198  NotebookTabPosProperty TabPosition;
202  VDKReadWriteValueProp<VDKNotebook,bool> Scrollable;
206  VDKReadWriteValueProp<VDKNotebook,bool> PopUp;
210  VDKReadOnlyValueProp<VDKNotebook,int> PreviousActivePage;
211  //
216  VDKNotebook(VDKForm* owner = NULL);
220  virtual ~VDKNotebook();
226  void Add(VDKObject* obj, int , int , int , int )
227  { AddPage(obj,""); }
239  void AddPage(VDKObject* obj,
240  const char *label,
241  char **pixmap_closed = NULL,
242  char **pixmap_open = NULL);
252  void RemovePage(int page, bool removechild = true);
253  bool GetScrollable()
254  { return Scrollable; }
255  void SetScrollable(bool flag)
256  {
257  gtk_notebook_set_show_tabs (GTK_NOTEBOOK(widget), flag);
258  gtk_notebook_set_scrollable (GTK_NOTEBOOK(widget), flag);
259  }
260  bool GetPopUp()
261  { return PopUp; }
262  void SetPopUp(bool flag)
263  {
264  if (flag)
265  gtk_notebook_popup_enable (GTK_NOTEBOOK(widget));
266  else
267  gtk_notebook_popup_disable (GTK_NOTEBOOK(widget));
268  }
269  int GetPreviousActivePage()
270  { return gtk_notebook_current_page(GTK_NOTEBOOK(widget)); }
271 #ifdef USE_SIGCPLUSPLUS
272  VDKSignal1<void,int> OnPageSwitch;
273 #endif // USE_SIGCPLUSPLUS
274 };
275 #endif
276 
277 
278