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

xap_Win32DialogBase.h

Go to the documentation of this file.
00001 // xap_Win32DialogBase.h
00002 
00003 /* AbiWord
00004  * Copyright (C) 2003 AbiSource, Inc.
00005  *           (C) 2003 Mike Nordell
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
00021  */
00022 
00023 #ifndef XAP_Win32DialogBase_H
00024 #define XAP_Win32DialogBase_H
00025 
00026 // MSVC++ warns about using 'this' in initializer list.
00027 // and the DialogHelper uses 'this' typically for its contructor
00028 #ifdef _MSC_VER
00029 #pragma warning(disable: 4355)
00030 #endif
00031 
00032 #include <windows.h>
00033 #include <commctrl.h>
00034 #include "ut_Win32LocaleString.h"
00035 
00036 #include "ut_types.h"
00037 /*****************************************************************/
00038 
00039 
00040 class XAP_Frame;
00041 class XAP_StringSet;
00042 
00043 class ABI_EXPORT XAP_Win32DialogBase
00044 {
00045 public:
00046     XAP_Win32DialogBase() : m_hDlg(0), m_tag(magic_tag), m_pDlg(0), m_pSS(0) {}
00047     // no need for user-defined destructor
00048     // static functions
00049     static bool setWindowText (HWND hWnd, const char* uft8_str);
00050     static bool getDlgItemText(HWND hWnd, int nIDDlgItem, UT_Win32LocaleString& str);
00051     static bool setDlgItemText(HWND hWnd, int nIDDlgItem, const char* uft8_str);
00052 
00053 protected:
00054     void createModal(XAP_Frame* pFrame, LPCWSTR dlgTemplate);
00055     void createModal(XAP_Frame* pFrame);
00056     HWND createModeless(XAP_Frame* pFrame, LPCWSTR dlgTemplate);
00057 
00058     void notifyCloseFrame(XAP_Frame *pFrame);
00059     // Subclasses: override this and use it as your DLGPROC
00060     virtual BOOL _onDlgMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
00061     virtual BOOL _onInitDialog(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/) {return FALSE;};
00062     virtual BOOL _onCommand(HWND /*hWnd*/, WPARAM /*wParam*/, LPARAM /*lParam*/) {return FALSE;};
00063     virtual BOOL _onDeltaPos(NM_UPDOWN * /*pnmud*/) {return FALSE;};
00064     virtual BOOL _callHelp();
00065 
00066 
00067     // Control Functionality
00068     void checkButton(UT_sint32 controlId, bool bChecked = true);
00069     void enableControl(UT_sint32 controlId, bool bEnabled = true);
00070     void destroyWindow();
00071     void setDialogTitle(const char* uft8_str);
00072     void localizeDialogTitle(UT_uint32 stringId);
00073     int  showWindow( int Mode );
00074     int  showControl(UT_sint32 controlId, int Mode);
00075     int  bringWindowToTop();
00076     bool setDlgItemText(int nIDDlgItem, const char* uft8_str);
00077     bool getDlgItemText(int nIDDlgItem, UT_Win32LocaleString& str);
00078 
00079     // Combo boxes.
00080 
00081     int  addItemToCombo(UT_sint32 controlId, LPCSTR p_str);
00082     void selectComboItem(UT_sint32 controlId, int index);
00083     int  setComboDataItem(UT_sint32 controlId, int nIndex, DWORD dwData);
00084     int  getComboDataItem(UT_sint32 controlId, int nIndex);
00085     int  getComboItemIndex(UT_sint32 controlId, LPCSTR p_str);
00086     int  getComboSelectedIndex(UT_sint32 controlId) const;
00087     void resetComboContent(UT_sint32 controlId);
00088     void getComboTextItem(UT_sint32 controlId, int index, UT_Win32LocaleString& str);
00089 
00090     // List boxes
00091 
00092     void resetContent(UT_sint32 controlId);
00093     int  addItemToList(UT_sint32 controlId, LPCSTR p_str);
00094     int  getListSelectedIndex(UT_sint32 controlId) const;
00095     int  setListDataItem(UT_sint32 controlId, int nIndex, DWORD dwData);
00096     int  getListDataItem(UT_sint32 controlId, int nIndex);
00097     void selectListItem(UT_sint32 controlId, int index);
00098     void getListText(UT_sint32 controlId, int index, char *p_str) const;
00099 
00100     // Controls
00101     void setControlText(UT_sint32 controlId, LPCSTR p_str);
00102     void localizeControlText(UT_sint32 controlId, UT_uint32 stringId);
00103     void setControlInt(UT_sint32 controlId, int value);
00104     int  getControlInt(UT_sint32 controlId) const;
00105 
00106     void selectControlText(UT_sint32 controlId, UT_sint32 start, UT_sint32 end);
00107 
00108     int  isChecked(UT_sint32 controlId) const;
00109     void getControlText(UT_sint32 controlId, LPSTR p_buffer, UT_sint32 Buffer_length) const;
00110 
00111     bool isControlVisible(UT_sint32 controlId) const;
00112 
00113     void centerDialog();
00114     void setHandle(HWND hWnd) { m_hDlg = hWnd; };
00115     void setDialog(XAP_Dialog * pDlg) { m_pDlg = pDlg; };
00116     bool isDialogValid() const;
00117 
00118 protected:
00119 HWND m_hDlg;
00120 
00121 protected:
00122     static BOOL CALLBACK s_dlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
00123 private:
00124 
00125     // disallow copying and assignment
00126     XAP_Win32DialogBase(const XAP_Win32DialogBase&);    // no impl.
00127     void operator=(const XAP_Win32DialogBase&);         // no impl.
00128 
00129     enum { // VC6 can't handle static int here, why an enum is the only way...
00130         magic_tag = 0x327211
00131     };
00132 
00133     int m_tag;  // all for safety
00134     XAP_Dialog* m_pDlg;
00135     const XAP_StringSet* m_pSS;
00136 };
00137 
00138 
00139 #endif /* XAP_Win32DialogBase_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1