00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef _WX_SMARTMSGDLG_H_
00013 #define _WX_SMARTMSGDLG_H_
00014
00015
00016 #include "wx/msgdlg.h"
00017 #include "wx/config.h"
00018
00019
00020 #include "wxp/wxputils.h"
00021
00022
00023
00024
00025
00026
00027
00028 class wxSmartMessageDialog : public wxDialog, public wxMessageDialogBase
00029 {
00030 friend class wxSmartMessageDialogModule;
00031
00032 DECLARE_DYNAMIC_CLASS( wxSmartMessageDialog )
00033 DECLARE_EVENT_TABLE()
00034
00035 public:
00036
00037 wxSmartMessageDialog(const wxString &keyname);
00038
00039 bool Create( wxWindow *parent,
00040 const wxString& message,
00041 const wxString& caption = wxMessageBoxCaptionStr,
00042 long style = wxOK | wxCENTRE,
00043 const wxPoint& pos = wxDefaultPosition);
00044
00045 ~wxSmartMessageDialog()
00046 {
00047 Save();
00048 }
00049
00050 public:
00051
00052 void OnYes(wxCommandEvent& WXUNUSED(event));
00053 void OnNo(wxCommandEvent& WXUNUSED(event));
00054 void OnCancel(wxCommandEvent& WXUNUSED(event));
00055
00056 public:
00057
00058 bool ShowAgain() const
00059 {
00060 if (m_pDoNotShowAgain)
00061 return !m_pDoNotShowAgain->GetValue();
00062 return m_bShowAgain;
00063 }
00064
00065 void Save()
00066 {
00067 m_bShowAgain = ShowAgain();
00068 SetValueFor(m_strKeyName, m_bShowAgain);
00069 }
00070
00071 void Load()
00072 { m_bShowAgain = GetValueFor(m_strKeyName); }
00073
00074 public:
00075
00076 static wxStringHashMap s_hashDesc;
00077
00078
00079 static wxString GetDescriptionFor(const wxString &keyname)
00080 { return s_hashDesc[keyname]; }
00081
00082 static bool GetValueFor(const wxString &keyname)
00083 {
00084 bool value = true;
00085 if (m_pCfg)
00086 m_pCfg->Read(m_strPath + wxT("/") + keyname, &value);
00087 return value;
00088 }
00089
00090 static void SetValueFor(const wxString &keyname, bool value)
00091 {
00092 if (m_pCfg)
00093 m_pCfg->Write(m_strPath + wxT("/") + keyname, value);
00094 }
00095
00096 static void SetConfig(wxConfigBase *cfg, const wxString &path)
00097 { m_pCfg=cfg; m_strPath=path; }
00098
00099 static wxConfigBase *GetConfig()
00100 { return m_pCfg; }
00101
00102 static wxString GetConfigPath()
00103 { return m_strPath; }
00104
00105 protected:
00106 wxCheckBox *m_pDoNotShowAgain;
00107 wxString m_strKeyName;
00108 bool m_bShowAgain;
00109
00110 protected:
00111 static wxConfigBase *m_pCfg;
00112 static wxString m_strPath;
00113 };
00114
00115
00116
00117
00118
00119
00120 int WXDLLEXPORT wxSmartMessageBox(const wxString &keyname,
00121 const wxString& message,
00122 const wxString& caption = wxMessageBoxCaptionStr,
00123 long style = wxOK | wxCENTRE,
00124 wxWindow *parent = NULL);
00125
00126
00127
00128
00129
00130
00131
00132
00133 #define DECLARE_SMARTLOG_FUNCTION(level) \
00134 extern int WXDLLIMPEXP_BASE wxSmartVLog##level(const wxChar *keyname, \
00135 const wxChar *szFormat, \
00136 va_list argptr); \
00137 extern int WXDLLIMPEXP_BASE wxSmartLog##level(const wxChar *keyname, \
00138 const wxChar *szFormat, \
00139 ...);
00140
00141 DECLARE_SMARTLOG_FUNCTION(Message)
00142 DECLARE_SMARTLOG_FUNCTION(Warning)
00143 DECLARE_SMARTLOG_FUNCTION(Error)
00144 DECLARE_SMARTLOG_FUNCTION(YesNoQuestion)
00145
00146 #endif
00147
00148