• 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., 59 Temple Place - Suite 330, Boston, MA
00019  * 02111-1307, 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 
00114     // dialog framework
00115 
00117     virtual void updateDialogData(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
00118 
00119     virtual void maybeClosePopupPreviewBubbles();
00120     virtual void maybeReallowPopupPreviewBubbles();
00121 
00122 protected:
00124     virtual void localizeDialog(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
00126     virtual void constructDialog(void) {UT_ASSERT(UT_NOT_IMPLEMENTED);} //FIXME = 0
00127 
00133     virtual XAP_Widget *getWidget(xap_widget_id /*wid*/) { return NULL; };
00134 
00135     XAP_App *               m_pApp;
00136     XAP_DialogFactory *         m_pDlgFactory;
00137     XAP_Dialog_Id               m_id;
00138 
00139 private:
00140     UT_String * m_helpUrl ;
00141 };
00142 
00143 
00144 class ABI_EXPORT XAP_Dialog_NonPersistent : public XAP_Dialog
00145 {
00146 public:
00147     XAP_Dialog_NonPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00148     virtual ~XAP_Dialog_NonPersistent(void);
00149 
00150     virtual void            runModal(XAP_Frame * pFrame) = 0;
00151 
00152     static XAP_Dialog_Type      s_getPersistence(void) { return XAP_DLGT_NON_PERSISTENT; };
00153 
00154 protected:
00155 };
00156 
00157 
00158 class ABI_EXPORT XAP_TabbedDialog_NonPersistent : public XAP_Dialog_NonPersistent
00159 {
00160 public:
00161     XAP_TabbedDialog_NonPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00162     virtual ~XAP_TabbedDialog_NonPersistent(void);
00163 
00164     virtual void            setInitialPageNum   (int which) { m_pageNum = which; } // support for dialogs with pages (tabs?)
00165     virtual int             getInitialPageNum   () { return m_pageNum; }
00166 
00167 protected:
00168     int     m_pageNum;
00169 };
00170 
00171 
00172 class ABI_EXPORT XAP_Dialog_Persistent : public XAP_Dialog
00173 {
00174 public:
00175     XAP_Dialog_Persistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00176     virtual ~XAP_Dialog_Persistent(void);
00177 
00178     virtual void                useStart(void);
00179     virtual void                runModal(XAP_Frame * pFrame) = 0;
00180     virtual void                useEnd(void);
00181 
00182 protected:
00183     bool                        m_bInUse;
00184 };
00185 
00186 class ABI_EXPORT XAP_Dialog_FramePersistent : public XAP_Dialog_Persistent
00187 {
00188 public:
00189     XAP_Dialog_FramePersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00190     virtual ~XAP_Dialog_FramePersistent(void);
00191 
00192     virtual void                useStart(void);
00193     virtual void                runModal(XAP_Frame * pFrame) = 0;
00194     virtual void                useEnd(void);
00195 
00196     static XAP_Dialog_Type      s_getPersistence(void) { return XAP_DLGT_FRAME_PERSISTENT; };
00197 
00198 protected:
00199 };
00200 
00201 class ABI_EXPORT XAP_Dialog_AppPersistent : public XAP_Dialog_Persistent
00202 {
00203 public:
00204     XAP_Dialog_AppPersistent(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00205     virtual ~XAP_Dialog_AppPersistent(void);
00206 
00207     virtual void                useStart(void);
00208     virtual void                runModal(XAP_Frame * pFrame) = 0;
00209     virtual void                useEnd(void);
00210 
00211     static XAP_Dialog_Type      s_getPersistence(void) { return XAP_DLGT_APP_PERSISTENT; };
00212 
00213 protected:
00214 };
00215 
00216 
00217 class ABI_EXPORT XAP_Dialog_Modeless : public XAP_Dialog_AppPersistent
00218 {
00219 public:
00220     XAP_Dialog_Modeless(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id, const char * helpUrl = NULL );
00221     virtual ~XAP_Dialog_Modeless(void);
00222 
00223     void                        useStart(void);
00224     void                        useEnd(void);
00225 
00226 // runModal is not a virtual pure function.  It's here only to make happy the old
00227 // dialogs that have been partially transformed to non modal dialogs (is it true?)
00228     virtual void                runModal(XAP_Frame * /*pFrame*/) {}
00229 
00230     virtual void                runModeless(XAP_Frame * pFrame) = 0;
00231     virtual void                setActiveFrame(XAP_Frame *pFrame);
00232 
00233 // not pure functions.  Unix doesn't need to implement these functions
00234     virtual void                notifyActiveFrame(XAP_Frame * /*pFrame*/) {}
00235     virtual void                notifyCloseFrame(XAP_Frame * /*pFrame*/) {}
00236 
00237     virtual void                destroy(void) = 0;
00238     virtual void                activate(void) = 0;
00239     XAP_Frame *                 getActiveFrame() const;
00240     virtual void                modeless_cleanup(void);
00241     bool                        isRunning(void) const;
00242     std::string                 BuildWindowName( const char * pDialogName ) const;
00243     void                        BuildWindowName(char * pWindowName, const char * pDialogName, UT_uint32 width ) const;
00244     static XAP_Dialog_Type      s_getPersistence(void) { return XAP_DLGT_APP_PERSISTENT; };
00245 
00246     // ugly hack necessary for Win32
00247     virtual void *              pGetWindowHandle(void) { return NULL; }
00248 
00249 protected:
00250         XAP_Dialog_Modeless *                    m_pDialog;
00251 };
00252 
00253 
00257 class ABI_EXPORT XAP_NotebookDialog
00258 {
00259 public:
00260 
00261     class ABI_EXPORT Page {
00262     public:
00263         Page() {}
00264         Page(const gchar *_title, AbiNativeWidget * _widget);
00265         ~Page();
00266 
00267         gchar           * title;
00268         AbiNativeWidget * widget;
00269     };
00270 
00271     virtual ~XAP_NotebookDialog() {}
00272     virtual void addPage (const XAP_NotebookDialog::Page *page) = 0;
00273 };
00274 
00275 #endif /* XAP_DIALOG_H */

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1