| 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_DIALOGFACTORY_H |
| 23 |
#define XAP_DIALOGFACTORY_H |
| 24 |
|
| 25 |
/***************************************************************** |
| 26 |
****************************************************************** |
| 27 |
** This file defines the base class for the cross-platform |
| 28 |
** application dialog factory. This is used as a container |
| 29 |
** and constructor for all dialogs. |
| 30 |
****************************************************************** |
| 31 |
*****************************************************************/ |
| 32 |
|
| 33 |
/* pre-emptive dismissal; ut_types.h is needed by just about everything, |
| 34 |
* so even if it's commented out in-file that's still a lot of work for |
| 35 |
* the preprocessor to do... |
| 36 |
*/ |
| 37 |
|
| 38 |
#if defined(__MINGW32__) |
| 39 |
# undef snprintf |
| 40 |
# if __GNUC__ <= 3 |
| 41 |
# define _GLIBCXX_USE_C99_DYNAMIC 1 |
| 42 |
# endif |
| 43 |
#endif |
| 44 |
|
| 45 |
#include <map> |
| 46 |
|
| 47 |
#ifndef UT_TYPES_H |
| 48 |
#include "ut_types.h" |
| 49 |
#endif |
| 50 |
#include "ut_misc.h" |
| 51 |
#include "ut_vector.h" |
| 52 |
|
| 53 |
#include "xap_Dialog.h" |
| 54 |
#include "xap_Types.h" |
| 55 |
|
| 56 |
class XAP_Dialog; |
| 57 |
class XAP_App; |
| 58 |
class XAP_Frame; |
| 59 |
|
| 60 |
/*****************************************************************/ |
| 61 |
|
| 62 |
class ABI_EXPORT XAP_DialogFactory |
| 63 |
{ |
| 64 |
public: |
| 65 |
struct _dlg_table |
| 66 |
{ |
| 67 |
XAP_Dialog_Id m_id; |
| 68 |
XAP_Dialog_Type m_type; |
| 69 |
XAP_Dialog * (*m_pfnStaticConstructor)(XAP_DialogFactory *, XAP_Dialog_Id id); |
| 70 |
bool m_tabbed; |
| 71 |
}; |
| 72 |
|
| 73 |
XAP_DialogFactory(XAP_App * pApp, int nrElem, const struct _dlg_table * pDlgTable, XAP_Frame * pFrame = NULL); |
| 74 |
virtual ~XAP_DialogFactory(void); |
| 75 |
|
| 76 |
inline XAP_App * getApp(void) const { return m_pApp; }; |
| 77 |
|
| 78 |
XAP_Dialog * requestDialog(XAP_Dialog_Id id); |
| 79 |
XAP_Dialog * justMakeTheDialog(XAP_Dialog_Id id); |
| 80 |
void releaseDialog(XAP_Dialog * pDialog); |
| 81 |
XAP_Dialog_Id getNextId(void); |
| 82 |
XAP_Dialog_Id registerDialog(XAP_Dialog *(*pStaticConstructor)(XAP_DialogFactory *, XAP_Dialog_Id id),XAP_Dialog_Type iDialogType); |
| 83 |
void unregisterDialog(XAP_Dialog_Id id); |
| 84 |
|
| 85 |
bool registerNotebookPage(XAP_Dialog_Id dialog, const XAP_NotebookDialog::Page * page); |
| 86 |
bool unregisterNotebookPage(XAP_Dialog_Id dialog, const XAP_NotebookDialog::Page * page); |
| 87 |
|
| 88 |
protected: |
| 89 |
bool _findDialogInTable(XAP_Dialog_Id id, UT_sint32 * pIndex) const; |
| 90 |
|
| 91 |
XAP_App * m_pApp; |
| 92 |
XAP_Frame * m_pFrame; |
| 93 |
XAP_Dialog_Type m_dialogType; |
| 94 |
UT_Vector m_vecDialogs; |
| 95 |
UT_NumberVector m_vecDialogIds; |
| 96 |
|
| 97 |
UT_uint32 m_nrElementsDlgTable; |
| 98 |
UT_GenericVector<const _dlg_table *> m_vec_dlg_table; /* a Vector of elements */ |
| 99 |
UT_GenericVector<_dlg_table *> m_vecDynamicTable; /* a Vector of elements */ |
| 100 |
|
| 101 |
private: |
| 102 |
void addPages(XAP_NotebookDialog * pDialog, XAP_Dialog_Id id); |
| 103 |
}; |
| 104 |
|
| 105 |
#endif /* XAP_DIALOGFACTORY_H */ |