• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

xap_Dialog.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiSource Application Framework
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 USA.
00020  */
00021 
00022 #ifndef XAP_DIALOG_H
00023 #define XAP_DIALOG_H
00024 
00025 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00026  * so even if it's commented out in-file that's still a lot of work for
00027  * the preprocessor to do...
00028  */
00029 #ifndef UT_TYPES_H
00030 #include "ut_types.h"
00031 #endif
00032 
00033 #include <glib.h>
00034 
00035 #include "ut_misc.h"
00036 #include "ut_assert.h"
00037 
00038 #include "xap_Types.h"
00039 
00040 class UT_String;
00041 
00042 class XAP_DialogFactory;
00043 class XAP_App;
00044 class XAP_Frame;
00045 class XAP_Widget;
00046 class UT_UTF8String;
00047 class XAP_Dialog;
00048 
00049 class AV_View;
00050 
00051 /*****************************************************************
00052 ******************************************************************
00053 ** This file defines the base classes for cross-platform dialogs.
00054 ******************************************************************
00055 *****************************************************************/
00056 
00057 typedef enum _XAP_Dialog_Type
00058 {
00059     XAP_DLGT_NON_PERSISTENT     = 1,
00060     XAP_DLGT_FRAME_PERSISTENT   = 2,
00061     XAP_DLGT_APP_PERSISTENT     = 3,
00062     XAP_DLGT_MODELESS       = 4
00063 
00064 } XAP_Dialog_Type;
00065 
00066 typedef int xap_widget_id;
00067 
00068 typedef XAP_Dialog *(*pt2Constructor)(XAP_DialogFactory * pFactory, XAP_Dialog_Id id );
00069 
00070 class ABI_EXPORT XAP_Dialog
00071 {
00072 public:
00073 
00074     XAP_Dialog(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id,
00075            const char * helpUrl = NULL );
00076     virtual ~XAP_Dialog(void);
00077 
00078     virtual void                runModal(XAP_Frame * pFrame) = 0;
00079 
00080     XAP_Dialog_Id               getDialogId(void) const { return m_id; }
00081     XAP_App *               getApp(void) const { return m_pApp;}
00082 
00083     const UT_String& getHelpUrl () const { return *m_helpUrl ; }
00084 
00085 
00087     bool getWidgetState(xap_widget_id wid);
00089     void setWidgetState(xap_widget_id wid, bool state);
00090 
00092     bool getWidgetVisible(xap_widget_id wid);
00094     void setWidgetVisible(xap_widget_id wid, bool visible);
00095 
00097     int getWidgetValueInt(xap_widget_id wid);
00099     void setWidgetValueInt(xap_widget_id wid, int value);
00100 
00102     void getWidgetValueString(xap_widget_id wid, UT_UTF8String &str);
00104     void setWidgetValueString(xap_widget_id wid, const UT_UTF8String &str);
00105 
00107     float getWidgetValueFloat(xap_widget_id wid);
00109     void setWidgetValueFloat(xap_widget_id wid, float value);
00110 
00112     void setWidgetLabel(xap_widget_id wid, const UT_UTF8String &val);
00113     void setWidgetLabel(xap_widget_id wid, const std::string &val);
00114 
00115     // dialog framework
00116 
00118     virtual void updateDialogData(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
00119 
00120     virtual void maybeClosePopupPreviewBubbles();
00121     virtual void maybeReallowPopupPreviewBubbles();
00122 
00123 protected:
00125     virtual void localizeDialog(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
00127     virtual void constructDialog(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
00128 
00134     virtual XAP_Widget *getWidget(xap_widget_id /*wid*/) { return NULL; };
00135 
00136     XAP_App *               m_pApp;
00137     XAP_DialogFactory *         m_pDlgFactory;
00138     XAP_Dialog_Id               m_id;
00139 
00140 private:
00141     UT_String * m_helpUrl ;
00142 };
00143 
00144 
00145 class ABI_EXPORT XAP_Dialog_NonPersistent : public XAP_Dialog
00146 {
00147 public:
00148     XAP_Dialog_NonPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00149     virtual ~XAP_Dialog_NonPersistent(void);
00150 
00151     virtual void            runModal(XAP_Frame * pFrame) = 0;
00152 
00153     static XAP_Dialog_Type      s_getPersistence(void) { return XAP_DLGT_NON_PERSISTENT; };
00154 
00155 protected:
00156 };
00157 
00158 
00159 class ABI_EXPORT XAP_TabbedDialog_NonPersistent : public XAP_Dialog_NonPersistent
00160 {
00161 public:
00162     XAP_TabbedDialog_NonPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00163     virtual ~XAP_TabbedDialog_NonPersistent(void);
00164 
00165     virtual void            setInitialPageNum   (int which) { m_pageNum = which; } // support for dialogs with pages (tabs?)
00166     virtual int             getInitialPageNum   () { return m_pageNum; }
00167 
00168 protected:
00169     int     m_pageNum;
00170 };
00171 
00172 
00173 class ABI_EXPORT XAP_Dialog_Persistent : public XAP_Dialog
00174 {
00175 public:
00176     XAP_Dialog_Persistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00177     virtual ~XAP_Dialog_Persistent(void);
00178 
00179     virtual void                useStart(void);
00180     virtual void                runModal(XAP_Frame * pFrame) = 0;
00181     virtual void                useEnd(void);
00182 
00183 protected:
00184     bool                        m_bInUse;
00185 };
00186 
00187 class ABI_EXPORT XAP_Dialog_FramePersistent : public XAP_Dialog_Persistent
00188 {
00189 public:
00190     XAP_Dialog_FramePersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00191     virtual ~XAP_Dialog_FramePersistent(void);
00192 
00193     virtual void                useStart(void);
00194     virtual void                runModal(XAP_Frame * pFrame) = 0;
00195     virtual void                useEnd(void);
00196 
00197     static XAP_Dialog_Type      s_getPersistence(void) { return XAP_DLGT_FRAME_PERSISTENT; };
00198 
00199 protected:
00200 };
00201 
00202 class ABI_EXPORT XAP_Dialog_AppPersistent : public XAP_Dialog_Persistent
00203 {
00204 public:
00205     XAP_Dialog_AppPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00206     virtual ~XAP_Dialog_AppPersistent(void);
00207 
00208     virtual void                useStart(void);
00209     virtual void                runModal(XAP_Frame * pFrame) = 0;
00210     virtual void                useEnd(void);
00211 
00212     static XAP_Dialog_Type      s_getPersistence(void) { return XAP_DLGT_APP_PERSISTENT; };
00213 
00214 protected:
00215 };
00216 
00217 
00218 class ABI_EXPORT XAP_Dialog_Modeless : public XAP_Dialog_AppPersistent
00219 {
00220 public:
00221     XAP_Dialog_Modeless(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00222     virtual ~XAP_Dialog_Modeless(void);
00223 
00224     void                        useStart(void);
00225     void                        useEnd(void);
00226 
00227 // runModal is not a virtual pure function.  It's here only to make happy the old
00228 // dialogs that have been partially transformed to non modal dialogs (is it true?)
00229     virtual void                runModal(XAP_Frame * /*pFrame*/) {}
00230 
00231     virtual void                runModeless(XAP_Frame * pFrame) = 0;
00232     virtual void                setActiveFrame(XAP_Frame *pFrame);
00233 
00234 // not pure functions.  Unix doesn't need to implement these functions
00235     virtual void                notifyActiveFrame(XAP_Frame * /*pFrame*/) {}
00236     virtual void                notifyCloseFrame(XAP_Frame * /*pFrame*/) {}
00237 
00238     virtual void                destroy(void) = 0;
00239     virtual void                activate(void) = 0;
00240     XAP_Frame *                 getActiveFrame() const;
00241     virtual void                modeless_cleanup(void);
00242     bool                        isRunning(void) const;
00243     std::string                 BuildWindowName( const char * pDialogName ) const;
00244     void                        BuildWindowName(char * pWindowName, const char * pDialogName, UT_uint32 width ) const;
00245     static XAP_Dialog_Type      s_getPersistence(void) { return XAP_DLGT_APP_PERSISTENT; };
00246 
00247     // ugly hack necessary for Win32
00248     virtual void *              pGetWindowHandle(void) { return NULL; }
00249 
00250 protected:
00251         XAP_Dialog_Modeless *                    m_pDialog;
00252 };
00253 
00254 
00258 class ABI_EXPORT XAP_NotebookDialog
00259 {
00260 public:
00261 
00262     class ABI_EXPORT Page {
00263     public:
00264         Page() {}
00265         Page(const gchar *_title, AbiNativeWidget * _widget);
00266         ~Page();
00267 
00268         gchar           * title;
00269         AbiNativeWidget * widget;
00270     };
00271 
00272     virtual ~XAP_NotebookDialog() {}
00273     virtual void addPage (const XAP_NotebookDialog::Page *page) = 0;
00274 };
00275 
00276 #endif /* XAP_DIALOG_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1