1 /*
2 
3     eboard - chess client
4     http://www.bergo.eng.br/eboard
5     https://github.com/fbergo/eboard
6     Copyright (C) 2000-2016 Felipe Bergo
7     fbergo/at/gmail/dot/com
8 
9     This program is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13 
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18 
19     You should have received a copy of the GNU General Public License
20     along with this program; if not, write to the Free Software
21     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22 
23 */
24 
25 #ifndef NOTEBOOK_H
26 #define NOTEBOOK_H 1
27 
28 #include "stl.h"
29 #include "eboard.h"
30 #include "widgetproxy.h"
31 
32 class Page {
33  public:
34   Page();
35   Page(int _number,GtkWidget *_content, char *_title, bool _removable=false);
36   void setTitle(char *_title);
37   char *getTitle();
38   int operator==(int n);
39   int under(Importance imp);
40   int above(Importance imp);
41   void setLevel(Importance imp);
42 
43   int number;
44   bool naughty;
45   bool removable;
46   GtkWidget *content,*label,*labelframe;
47 
48   void dump();
49   void renumber(int newid);
50 
51  private:
52   Importance level;
53   char title[256];
54 };
55 
56 class Notebook : public WidgetProxy {
57  public:
58   Notebook();
~Notebook()59   virtual ~Notebook() {}
60   void addPage(GtkWidget *what,char *title,int id,bool removable=false);
61   void removePage(int id);
62   unsigned int getCurrentPage();
63   int getCurrentPageId();
64   void setTabColor(int pageid,int color,Importance imp=IM_TOP);
65   void setTabPosition(GtkPositionType pos);
66   void goToPageId(int id);
67 
68   void goToLastVisited();
69   void goToNext();
70   void goToPrevious();
71 
72   void setNaughty(int pageid, bool val);
73   void getNaughty(vector<int> &evil_ids);
74   bool isNaughty(int pageid);
75   bool hasNaughty();
76 
77   void dump();
78 
79   void renumberPage(int oldid,int newid);
80   void setListener(PaneChangeListener *listener);
81   void pretendPaneChanged();
82 
83   static void ensurePixmaps();
84   static GdkPixmap *trashface;
85   static GdkBitmap *trashmask;
86   static GtkWidget *swidget;
87 
88  private:
89   vector<Page *> pages;
90   PaneChangeListener *pcl;
91 
92   void setTabColor(int page_num,int color,int poly,Importance imp=IM_TOP);
93   void addBombToTab(Page *pg);
94 
95   friend void notebook_switch_page(GtkNotebook *notebook,
96 				   GtkNotebookPage *page,
97 				   gint page_num,
98 				   gpointer data);
99 
100   friend gboolean gtkDgtnixEvent(GIOChannel* channel, GIOCondition cond, gpointer data);
101 
102 
103 };
104 
105 void notebook_switch_page(GtkNotebook *notebook,
106 			  GtkNotebookPage *page,
107 			  gint page_num,
108 			  gpointer data);
109 
110 class NotebookInsider {
111  public:
112   NotebookInsider();
113   void setNotebook(Notebook *nb,int pageid);
114   void contentUpdated();
115   void pop();
116   int  getPageId();
117  protected:
118   void pushLevel(Importance imp);
119  private:
120   Notebook *mynotebook;
121   int pgid;
122   stack<Importance> impstack;
123 };
124 
125 #endif
126