Debian Codegraph @

src/af/xap/xp/xap_Dialog.h

raw
1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2
3 /* AbiSource Application Framework
4 * Copyright (C) 1998 AbiSource, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA.
20 */
21
22 #ifndef XAP_DIALOG_H
23 #define XAP_DIALOG_H
24
25 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
26 * so even if it's commented out in-file that's still a lot of work for
27 * the preprocessor to do...
28 */
29 #ifndef UT_TYPES_H
30 #include "ut_types.h"
31 #endif
32
33 #include <glib.h>
34
35 #include "ut_misc.h"
36 #include "ut_assert.h"
37
38 #include "xap_Types.h"
39
40 class UT_String;
41
42 class XAP_DialogFactory;
43 class XAP_App;
44 class XAP_Frame;
45 class XAP_Widget;
46 class UT_UTF8String;
47 class XAP_Dialog;
48
49 class AV_View;
50
51 /*****************************************************************
52 ******************************************************************
53 ** This file defines the base classes for cross-platform dialogs.
54 ******************************************************************
55 *****************************************************************/
56
57 typedef enum _XAP_Dialog_Type
58 {
59 XAP_DLGT_NON_PERSISTENT = 1,
60 XAP_DLGT_FRAME_PERSISTENT = 2,
61 XAP_DLGT_APP_PERSISTENT = 3,
62 XAP_DLGT_MODELESS = 4
63
64 } XAP_Dialog_Type;
65
66 typedef int xap_widget_id;
67
68 typedef XAP_Dialog *(*pt2Constructor)(XAP_DialogFactory * pFactory, XAP_Dialog_Id id );
69
70 class ABI_EXPORT XAP_Dialog
71 {
72 public:
73
74 XAP_Dialog(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id,
75 const char * helpUrl = NULL );
76 virtual ~XAP_Dialog(void);
77
78 virtual void runModal(XAP_Frame * pFrame) = 0;
79
80 XAP_Dialog_Id getDialogId(void) const { return m_id; }
81 XAP_App * getApp(void) const { return m_pApp;}
82
83 const UT_String& getHelpUrl () const { return *m_helpUrl ; }
84
85
86 /** get a widget state (enabled/disabled) */
87 bool getWidgetState(xap_widget_id wid);
88 /** set a widget state (enable/disabled) */
89 void setWidgetState(xap_widget_id wid, bool state);
90
91 /** get a widget visible state */
92 bool getWidgetVisible(xap_widget_id wid);
93 /** set a widget visible state */
94 void setWidgetVisible(xap_widget_id wid, bool visible);
95
96 /** get a widget value int */
97 int getWidgetValueInt(xap_widget_id wid);
98 /** set a widget value int */
99 void setWidgetValueInt(xap_widget_id wid, int value);
100
101 /** get a widget value UTF-8 string */
102 void getWidgetValueString(xap_widget_id wid, UT_UTF8String &str);
103 /** set a widget value UTF-8 string */
104 void setWidgetValueString(xap_widget_id wid, const UT_UTF8String &str);
105
106 /** get a widget value float*/
107 float getWidgetValueFloat(xap_widget_id wid);
108 /** set a widget value float */
109 void setWidgetValueFloat(xap_widget_id wid, float value);
110
111 /** set the widget label */
112 void setWidgetLabel(xap_widget_id wid, const UT_UTF8String &val);
113 void setWidgetLabel(xap_widget_id wid, const std::string &val);
114
115 // dialog framework
116
117 /** set the data to the widgets in the dialog. Dialog specific, XP*/
118 virtual void updateDialogData(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
119
120 virtual void maybeClosePopupPreviewBubbles();
121 virtual void maybeReallowPopupPreviewBubbles();
122
123 protected:
124 /** localize the widgets in the dialog. Dialog specific, XP */
125 virtual void localizeDialog(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
126 /** construct the dialog. Dialog and platfom specific */
127 virtual void constructDialog(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
128
129 /** convert widget ID to XAP_Widget. Must be implemented by each dialogs
130 on each platforms
131 \return a newly allocated XAP_Widget. Caller is responsible from
132 freeing it.
133 */
134 virtual XAP_Widget *getWidget(xap_widget_id /*wid*/) { return NULL; };
135
136 XAP_App * m_pApp;
137 XAP_DialogFactory * m_pDlgFactory;
138 XAP_Dialog_Id m_id;
139
140 private:
141 UT_String * m_helpUrl ;
142 };
143
144
145 class ABI_EXPORT XAP_Dialog_NonPersistent : public XAP_Dialog
146 {
147 public:
148 XAP_Dialog_NonPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
149 virtual ~XAP_Dialog_NonPersistent(void);
150
151 virtual void runModal(XAP_Frame * pFrame) = 0;
152
153 static XAP_Dialog_Type s_getPersistence(void) { return XAP_DLGT_NON_PERSISTENT; };
154
155 protected:
156 };
157
158
159 class ABI_EXPORT XAP_TabbedDialog_NonPersistent : public XAP_Dialog_NonPersistent
160 {
161 public:
162 XAP_TabbedDialog_NonPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
163 virtual ~XAP_TabbedDialog_NonPersistent(void);
164
165 virtual void setInitialPageNum (int which) { m_pageNum = which; } // support for dialogs with pages (tabs?)
166 virtual int getInitialPageNum () { return m_pageNum; }
167
168 protected:
169 int m_pageNum;
170 };
171
172
173 class ABI_EXPORT XAP_Dialog_Persistent : public XAP_Dialog
174 {
175 public:
176 XAP_Dialog_Persistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
177 virtual ~XAP_Dialog_Persistent(void);
178
179 virtual void useStart(void);
180 virtual void runModal(XAP_Frame * pFrame) = 0;
181 virtual void useEnd(void);
182
183 protected:
184 bool m_bInUse;
185 };
186
187 class ABI_EXPORT XAP_Dialog_FramePersistent : public XAP_Dialog_Persistent
188 {
189 public:
190 XAP_Dialog_FramePersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
191 virtual ~XAP_Dialog_FramePersistent(void);
192
193 virtual void useStart(void);
194 virtual void runModal(XAP_Frame * pFrame) = 0;
195 virtual void useEnd(void);
196
197 static XAP_Dialog_Type s_getPersistence(void) { return XAP_DLGT_FRAME_PERSISTENT; };
198
199 protected:
200 };
201
202 class ABI_EXPORT XAP_Dialog_AppPersistent : public XAP_Dialog_Persistent
203 {
204 public:
205 XAP_Dialog_AppPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
206 virtual ~XAP_Dialog_AppPersistent(void);
207
208 virtual void useStart(void);
209 virtual void runModal(XAP_Frame * pFrame) = 0;
210 virtual void useEnd(void);
211
212 static XAP_Dialog_Type s_getPersistence(void) { return XAP_DLGT_APP_PERSISTENT; };
213
214 protected:
215 };
216
217
218 class ABI_EXPORT XAP_Dialog_Modeless : public XAP_Dialog_AppPersistent
219 {
220 public:
221 XAP_Dialog_Modeless(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
222 virtual ~XAP_Dialog_Modeless(void);
223
224 void useStart(void);
225 void useEnd(void);
226
227 // runModal is not a virtual pure function. It's here only to make happy the old
228 // dialogs that have been partially transformed to non modal dialogs (is it true?)
229 virtual void runModal(XAP_Frame * /*pFrame*/) {}
230
231 virtual void runModeless(XAP_Frame * pFrame) = 0;
232 virtual void setActiveFrame(XAP_Frame *pFrame);
233
234 // not pure functions. Unix doesn't need to implement these functions
235 virtual void notifyActiveFrame(XAP_Frame * /*pFrame*/) {}
236 virtual void notifyCloseFrame(XAP_Frame * /*pFrame*/) {}
237
238 virtual void destroy(void) = 0;
239 virtual void activate(void) = 0;
240 XAP_Frame * getActiveFrame() const;
241 virtual void modeless_cleanup(void);
242 bool isRunning(void) const;
243 std::string BuildWindowName( const char * pDialogName ) const;
244 void BuildWindowName(char * pWindowName, const char * pDialogName, UT_uint32 width ) const;
245 static XAP_Dialog_Type s_getPersistence(void) { return XAP_DLGT_APP_PERSISTENT; };
246
247 // ugly hack necessary for Win32
248 virtual void * pGetWindowHandle(void) { return NULL; }
249
250 protected:
251 XAP_Dialog_Modeless * m_pDialog;
252 };
253
254
255 /*!
256 * Interface for a tabbed dialog to be extensible by plugins.
257 */
258 class ABI_EXPORT XAP_NotebookDialog
259 {
260 public:
261
262 class ABI_EXPORT Page {
263 public:
264 Page() {}
265 Page(const gchar *_title, AbiNativeWidget * _widget);
266 ~Page();
267
268 gchar * title;
269 AbiNativeWidget * widget;
270 };
271
272 virtual ~XAP_NotebookDialog() {}
273 virtual void addPage (const XAP_NotebookDialog::Page *page) = 0;
274 };
275
276 #endif /* XAP_DIALOG_H */