• 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., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301 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 // Compat stuff
00034 
00035 // newer MINGW32 seems to have that. Just prevent the redefine.
00036 #if defined(__MINGW32__) && !defined(ListView_GetSelectionMark)
00037 #define LVM_GETSELECTIONMARK    (LVM_FIRST+66)
00038 #define ListView_GetSelectionMark(w) (INT)SNDMSG((w),LVM_GETSELECTIONMARK,0,0)
00039 #endif
00040 
00041 /*****************************************************************/
00042 #include "xap_Frame.h"
00043 #include "xap_Win32FrameImpl.h"
00044 #include "ut_Xpm2Bmp.h"
00045 
00046 class ABI_EXPORT XAP_Win32Dialog
00047 {
00048 public:
00049     virtual BOOL                    _onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) = 0;
00050     virtual BOOL                    _onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) = 0;
00051     virtual BOOL                    _onDeltaPos(NM_UPDOWN * pnmud) = 0;
00052 };
00053 
00054 class ABI_EXPORT XAP_Win32DialogHelper
00055 {
00056 public:
00057     XAP_Win32DialogHelper(XAP_Win32Dialog* p_dialog)
00058     :   m_pDialog(p_dialog),
00059         m_hDlg(0)
00060     {
00061     }
00062 
00063     // for plugin dialogs  - they have their own runModal and s_dlgProc due to differing hInstance values
00064     // (DLL instead of Abi main executable)
00065     // Makes more sense to share this code rather than use bare WinAPI in plugins when possible
00066     XAP_Win32DialogHelper(HWND hDlg)
00067     :   m_pDialog(0),
00068         m_hDlg(hDlg)
00069     {
00070     }
00071 
00072 
00073 public:
00074 
00075     void                runModal(       XAP_Frame*              pFrame,
00076                                         XAP_Dialog_Id           dialog_id,
00077                                         UT_sint32               resource_id,
00078                                         XAP_Dialog*             p_dialog);
00079 
00080     void                 runModeless(   XAP_Frame*              pFrame,
00081                                         XAP_Dialog_Id           dialog_id,
00082                                         UT_sint32               resource_id,
00083                                         XAP_Dialog_Modeless*    p_dialog);
00084 
00085     static BOOL CALLBACK    s_dlgProc(  HWND    hWnd,
00086                                     UINT    msg,
00087                                     WPARAM  wParam,
00088                                     LPARAM  lParam);
00089 
00090     void                checkButton(UT_sint32 controlId, bool bChecked = true);
00091     void                enableControl(UT_sint32 controlId, bool bEnabled = true);
00092     void                destroyWindow();
00093     void                setDialogTitle(LPCSTR p_str);
00094     int             showWindow( int Mode );
00095     int             showControl(UT_sint32 controlId, int Mode);
00096     int             bringWindowToTop();
00097 
00098     // Combo boxes.
00099 
00100     int             addItemToCombo(UT_sint32 controlId, LPCSTR p_str);
00101     void                selectComboItem(UT_sint32 controlId, int index);
00102     int                 setComboDataItem(UT_sint32 controlId, int nIndex, DWORD dwData);
00103     int                 getComboDataItem(UT_sint32 controlId, int nIndex);
00104     int             getComboSelectedIndex(UT_sint32 controlId) const;
00105     void                resetComboContent(UT_sint32 controlId);
00106 
00107     // List boxes
00108 
00109     void                resetContent(UT_sint32 controlId);
00110     int             addItemToList(UT_sint32 controlId, LPCSTR p_str);
00111     int             getListSelectedIndex(UT_sint32 controlId) const;
00112     int                 setListDataItem(UT_sint32 controlId, int nIndex, DWORD dwData);
00113     int                 getListDataItem(UT_sint32 controlId, int nIndex);
00114     void                selectListItem(UT_sint32 controlId, int index);
00115     void                getListText(UT_sint32 controlId, int index, char *p_str) const;
00116 
00117     // Controls
00118     void                setControlText(UT_sint32 controlId, LPCSTR p_str);
00119     void                setControlInt(UT_sint32 controlId, int value);
00120     int             getControlInt(UT_sint32 controlId) const;
00121 
00122     void                selectControlText(UT_sint32 controlId,
00123                                           UT_sint32 start,
00124                                           UT_sint32 end);
00125 
00126     int             isChecked(UT_sint32 controlId) const;
00127     void                getControlText( UT_sint32   controlId,
00128                                         LPSTR       p_buffer,
00129                                         UT_sint32   Buffer_length) const;
00130 
00131     bool                isControlVisible(UT_sint32  controlId) const;
00132 
00133     bool                isParentFrame(/*const*/ XAP_Frame& frame) const;
00134     void                setParentFrame(const XAP_Frame* pFrame);
00135     XAP_Frame*          getParentFrame();
00136     void                centerDialog();
00137     static void         s_centerDialog(HWND hWnd);
00138     static HBITMAP          s_loadBitmap(HWND hWnd, UINT nId,
00139                              const char* pName,
00140                              int width, int height,
00141                              const UT_RGBColor & Color);
00142 
00143     void                setHandle(HWND hWnd){m_hDlg=hWnd;}
00144 
00145 private:
00146     XAP_Win32Dialog *           m_pDialog;
00147     HWND                        m_hDlg;
00148 };
00149 
00150 
00151 #endif /* XAP_Win32DialogHelper_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1