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

xap_Win32DialogHelper.h

Go to the documentation of this file.
00001 // xap_Win32DialogHelper.h
00002 
00003 /* AbiWord
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_Win32DialogHelper_H
00023 #define XAP_Win32DialogHelper_H
00024 
00025 // MSVC++ warns about using 'this' in initializer list.
00026 // and the DialogHelper uses 'this' typically for its contructor
00027 #ifdef _MSC_VER
00028 #pragma warning(disable: 4355)
00029 #endif
00030 
00031 #include <commctrl.h>
00032 
00033 /*****************************************************************/
00034 #include "xap_Frame.h"
00035 #include "xap_Win32FrameImpl.h"
00036 #include "ut_Xpm2Bmp.h"
00037 
00038 class ABI_EXPORT XAP_Win32Dialog
00039 {
00040 public:
00041     virtual BOOL                    _onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) = 0;
00042     virtual BOOL                    _onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) = 0;
00043     virtual BOOL                    _onDeltaPos(NM_UPDOWN * pnmud) = 0;
00044 };
00045 
00046 class ABI_EXPORT XAP_Win32DialogHelper
00047 {
00048 public:
00049     XAP_Win32DialogHelper(XAP_Win32Dialog* p_dialog)
00050     :   m_pDialog(p_dialog),
00051         m_hDlg(0)
00052     {
00053     }
00054 
00055     // for plugin dialogs  - they have their own runModal and s_dlgProc due to differing hInstance values
00056     // (DLL instead of Abi main executable)
00057     // Makes more sense to share this code rather than use bare WinAPI in plugins when possible
00058     XAP_Win32DialogHelper(HWND hDlg)
00059     :   m_pDialog(0),
00060         m_hDlg(hDlg)
00061     {
00062     }
00063 
00064 
00065 public:
00066 
00067     void                runModal(       XAP_Frame*              pFrame,
00068                                         XAP_Dialog_Id           dialog_id,
00069                                         UT_sint32               resource_id,
00070                                         XAP_Dialog*             p_dialog);
00071 
00072     void                 runModeless(   XAP_Frame*              pFrame,
00073                                         XAP_Dialog_Id           dialog_id,
00074                                         UT_sint32               resource_id,
00075                                         XAP_Dialog_Modeless*    p_dialog);
00076 
00077     static BOOL CALLBACK    s_dlgProc(  HWND    hWnd,
00078                                     UINT    msg,
00079                                     WPARAM  wParam,
00080                                     LPARAM  lParam);
00081 
00082     void                checkButton(UT_sint32 controlId, bool bChecked = true);
00083     void                enableControl(UT_sint32 controlId, bool bEnabled = true);
00084     void                destroyWindow();
00085     void                setDialogTitle(LPCSTR p_str);
00086     int             showWindow( int Mode );
00087     int             showControl(UT_sint32 controlId, int Mode);
00088     int             bringWindowToTop();
00089 
00090     // Combo boxes.
00091 
00092     int             addItemToCombo(UT_sint32 controlId, LPCSTR p_str);
00093     void                selectComboItem(UT_sint32 controlId, int index);
00094     int                 setComboDataItem(UT_sint32 controlId, int nIndex, DWORD dwData);
00095     int                 getComboDataItem(UT_sint32 controlId, int nIndex);
00096     int             getComboSelectedIndex(UT_sint32 controlId) const;
00097     void                resetComboContent(UT_sint32 controlId);
00098 
00099     // List boxes
00100 
00101     void                resetContent(UT_sint32 controlId);
00102     int             addItemToList(UT_sint32 controlId, LPCSTR p_str);
00103     int             getListSelectedIndex(UT_sint32 controlId) const;
00104     int                 setListDataItem(UT_sint32 controlId, int nIndex, DWORD dwData);
00105     int                 getListDataItem(UT_sint32 controlId, int nIndex);
00106     void                selectListItem(UT_sint32 controlId, int index);
00107     void                getListText(UT_sint32 controlId, int index, char *p_str) const;
00108 
00109     // Controls
00110     void                setControlText(UT_sint32 controlId, LPCSTR p_str);
00111     void                setControlInt(UT_sint32 controlId, int value);
00112     int             getControlInt(UT_sint32 controlId) const;
00113 
00114     void                selectControlText(UT_sint32 controlId,
00115                                           UT_sint32 start,
00116                                           UT_sint32 end);
00117 
00118     int             isChecked(UT_sint32 controlId) const;
00119     void                getControlText( UT_sint32   controlId,
00120                                         LPSTR       p_buffer,
00121                                         UT_sint32   Buffer_length) const;
00122 
00123     bool                isControlVisible(UT_sint32  controlId) const;
00124 
00125     bool                isParentFrame(/*const*/ XAP_Frame& frame) const;
00126     void                setParentFrame(const XAP_Frame* pFrame);
00127     XAP_Frame*          getParentFrame();
00128     void                centerDialog();
00129     static void         s_centerDialog(HWND hWnd);
00130     void                setHandle(HWND hWnd){m_hDlg=hWnd;};
00131 
00132 private:
00133     XAP_Win32Dialog *           m_pDialog;
00134     HWND                        m_hDlg;
00135 };
00136 
00137 
00138 #endif /* XAP_Win32DialogHelper_H */

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1