~ubuntu-branches/ubuntu/precise/p7zip/precise-updates

« back to all changes in this revision

Viewing changes to CPP/Windows/Control/Dialog.h

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2009-02-14 20:12:27 UTC
  • mfrom: (1.1.11 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090214201227-go63qxm9ozfdma60
Tags: 4.65~dfsg.1-1
* New upstream release.
* Remove wx2.8 Build-Depends added by mistakes (7zG is not yet
  intended to be built).
* Use dh_clean without -k.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Windows/Control/Dialog.h
 
2
 
 
3
#ifndef __WINDOWS_CONTROL_DIALOG_H
 
4
#define __WINDOWS_CONTROL_DIALOG_H
 
5
 
 
6
#include "Windows/Window.h"
 
7
 
 
8
#ifndef _WIN32
 
9
#define SW_HIDE             0
 
10
#define SW_SHOW             5
 
11
 
 
12
#define WM_SETTEXT (6000) // wxID_HIGHEST + 1
 
13
#define WM_USER    (6999) // wxID_HIGHEST + 1000
 
14
 
 
15
#endif
 
16
 
 
17
#ifndef _WIN32
 
18
#define CBN_SELCHANGE       1
 
19
#endif
 
20
 
 
21
// FIXME
 
22
#define IDOK      (5100) // wxID_OK
 
23
#define IDCANCEL  (5101) // wxID_CANCEL
 
24
#define IDABORT   (5115) // wxID_ABORT
 
25
#define IDYES     (5103) // wxID_YES
 
26
#define IDNO      (5104) // wxID_NO
 
27
#define IDHELP    (5009) // wxID_HELP
 
28
 
 
29
#define BST_CHECKED 1
 
30
#define BST_UNCHECKED 0
 
31
// #define BST_INDETERMINATE  0x0002
 
32
 
 
33
#define wsprintf(a,b,c,d,e) swprintf(a,9999,b,c,d,e)  // FIXME
 
34
 
 
35
namespace NWindows {
 
36
        namespace NControl {
 
37
 
 
38
                class CModalDialogImpl;
 
39
 
 
40
                class CDialog
 
41
                {
 
42
                protected:
 
43
                        CModalDialogImpl * _window;
 
44
                public:
 
45
                        operator HWND() const { return HWND(_window); }
 
46
 
 
47
                        bool OnInit(CModalDialogImpl * window) { 
 
48
                                _window = window;
 
49
                                return OnInit();
 
50
                        }
 
51
                        virtual bool OnInit() { return false; }
 
52
                        virtual void OnOK() {}
 
53
                        virtual void OnCancel() {}
 
54
                        virtual void OnHelp() {}
 
55
                        virtual bool OnButtonClicked(int buttonID, wxWindow * buttonHWND) { return false; }
 
56
                        virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { return false; }
 
57
                        virtual bool OnCommand(int code, int itemID, LPARAM lParam) { return false; }
 
58
                        virtual bool OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { return false; }
 
59
                };
 
60
 
 
61
                class CModalDialog : public CDialog
 
62
                {
 
63
                public:
 
64
 
 
65
 
 
66
                        ////////////////// COMPATIBILITY
 
67
 
 
68
                        bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID)
 
69
                        {
 
70
/*
 
71
                                for(int id = firstButtonID; id <= lastButtonID; id++)
 
72
                                {
 
73
                                        CheckButton(id,id == checkButtonID);
 
74
                                }
 
75
*/
 
76
                                this->CheckButton(checkButtonID,true);
 
77
 
 
78
                                return true;
 
79
                        }
 
80
 
 
81
 
 
82
                        bool CheckButton(int buttonID, UINT checkState);
 
83
                        bool CheckButton(int buttonID, bool checkState)
 
84
                        {
 
85
                                return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED));
 
86
                        }
 
87
 
 
88
 
 
89
                        UINT IsButtonChecked(int buttonID) const;
 
90
 
 
91
                        bool IsButtonCheckedBool(long buttonID) const
 
92
                                { return (IsButtonChecked(buttonID) == BST_CHECKED); }
 
93
 
 
94
                        void EnableItem(int id, bool state);
 
95
 
 
96
                        void SetItemText(int id, const TCHAR *txt);
 
97
 
 
98
                        wxWindow * GetItem(long id) const ;
 
99
 
 
100
                        void ShowItem(int itemID, int cmdShow) const;
 
101
 
 
102
                        void End(int result);
 
103
 
 
104
                        void SetText(const TCHAR *_title); // {  _dialog->SetTitle(_title); }
 
105
 
 
106
                        bool GetText(CSysString &s);
 
107
 
 
108
                        INT_PTR Create(int id , HWND parentWindow);
 
109
 
 
110
                        void PostMessage(UINT message);
 
111
 
 
112
                        virtual void OnHelp() {}
 
113
 
 
114
                        UINT_PTR SetTimer(UINT_PTR idEvent , unsigned milliseconds);
 
115
 
 
116
                        void KillTimer(UINT_PTR idEvent);
 
117
 
 
118
                        virtual void OnOK() { End(IDOK); }
 
119
                        virtual void OnCancel() { End(IDCANCEL); }
 
120
                };
 
121
 
 
122
class CDialogChildControl : public NWindows::CWindow
 
123
{
 
124
public:
 
125
  CDialogChildControl() {}
 
126
 
 
127
  int m_ID;
 
128
  void Init(const NWindows::NControl::CModalDialog &parentDialog, int id)
 
129
  {
 
130
    m_ID = id;
 
131
    this->Attach(parentDialog.GetItem(id));
 
132
  }
 
133
  virtual void SetText(LPCWSTR s);
 
134
  virtual bool GetText(CSysString &s);
 
135
};
 
136
 
 
137
}
 
138
}
 
139
 
 
140
struct CStringTable
 
141
{
 
142
        int id;
 
143
        const wchar_t *str;
 
144
};
 
145
 
 
146
struct CDialogInfo
 
147
{
 
148
        int id;
 
149
        NWindows::NControl::CModalDialogImpl * (*createDialog)(NWindows::NControl::CModalDialog * dialog, HWND parentWindow);
 
150
        CStringTable * stringTable;
 
151
};
 
152
 
 
153
void RegisterDialog(const CDialogInfo *dialogInfo);
 
154
 
 
155
#define REGISTER_DIALOG_NAME(x) CRegister ## x
 
156
 
 
157
#define REGISTER_DIALOG(id,x,stringTable) \
 
158
        static NWindows::NControl::CModalDialogImpl * myCreate##x(NWindows::NControl::CModalDialog * dialog,HWND parentWindow) \
 
159
        { return new x##Impl(dialog,parentWindow,id); } \
 
160
        static struct CDialogInfo g_DialogInfo = { id , myCreate##x, stringTable }; \
 
161
        struct REGISTER_DIALOG_NAME(x) { \
 
162
                REGISTER_DIALOG_NAME(x)() { RegisterDialog(&g_DialogInfo); }}; \
 
163
        static REGISTER_DIALOG_NAME(x) g_RegisterDialog;
 
164
 
 
165
#define REGISTER_STRINGTABLE(stringTable) \
 
166
        static struct CDialogInfo g_DialogInfo = { -1 , 0 , stringTable }; \
 
167
        struct REGISTER_DIALOG_NAME(x) { \
 
168
                REGISTER_DIALOG_NAME(x)() { RegisterDialog(&g_DialogInfo); }}; \
 
169
        static REGISTER_DIALOG_NAME(x) g_RegisterDialog;
 
170
 
 
171
#endif
 
172