other-licenses/7zstub/src/Windows/Control/Dialog.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Windows/Control/Dialog.h
michael@0 2
michael@0 3 #ifndef __WINDOWS_CONTROL_DIALOG_H
michael@0 4 #define __WINDOWS_CONTROL_DIALOG_H
michael@0 5
michael@0 6 #include "Windows/Window.h"
michael@0 7 #include "Windows/Defs.h"
michael@0 8
michael@0 9 namespace NWindows {
michael@0 10 namespace NControl {
michael@0 11
michael@0 12 class CDialog: public CWindow
michael@0 13 {
michael@0 14 public:
michael@0 15 CDialog(HWND wndow = NULL): CWindow(wndow){};
michael@0 16 virtual ~CDialog() {};
michael@0 17
michael@0 18 HWND GetItem(int itemID) const
michael@0 19 { return GetDlgItem(_window, itemID); }
michael@0 20
michael@0 21 bool EnableItem(int itemID, bool enable) const
michael@0 22 { return BOOLToBool(::EnableWindow(GetItem(itemID), BoolToBOOL(enable))); }
michael@0 23
michael@0 24 bool SetItemText(int itemID, LPCTSTR s)
michael@0 25 { return BOOLToBool(SetDlgItemText(_window, itemID, s)); }
michael@0 26
michael@0 27 #ifndef _UNICODE
michael@0 28 bool SetItemText(int itemID, LPCWSTR s)
michael@0 29 {
michael@0 30 CWindow window(GetItem(itemID));
michael@0 31 return window.SetText(s);
michael@0 32 }
michael@0 33 #endif
michael@0 34
michael@0 35 UINT GetItemText(int itemID, LPTSTR string, int maxCount)
michael@0 36 { return GetDlgItemText(_window, itemID, string, maxCount); }
michael@0 37 #ifndef _UNICODE
michael@0 38 /*
michael@0 39 bool GetItemText(int itemID, LPWSTR string, int maxCount)
michael@0 40 {
michael@0 41 CWindow window(GetItem(itemID));
michael@0 42 return window.GetText(string, maxCount);
michael@0 43 }
michael@0 44 */
michael@0 45 #endif
michael@0 46
michael@0 47 bool SetItemInt(int itemID, UINT value, bool isSigned)
michael@0 48 { return BOOLToBool(SetDlgItemInt(_window, itemID, value, BoolToBOOL(isSigned))); }
michael@0 49 bool GetItemInt(int itemID, bool isSigned, UINT &value)
michael@0 50 {
michael@0 51 BOOL result;
michael@0 52 value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
michael@0 53 return BOOLToBool(result);
michael@0 54 }
michael@0 55
michael@0 56 HWND GetNextGroupItem(HWND control, bool previous)
michael@0 57 { return GetNextDlgGroupItem(_window, control, BoolToBOOL(previous)); }
michael@0 58 HWND GetNextTabItem(HWND control, bool previous)
michael@0 59 { return GetNextDlgTabItem(_window, control, BoolToBOOL(previous)); }
michael@0 60
michael@0 61 bool MapRect(LPRECT rect)
michael@0 62 { return BOOLToBool(MapDialogRect(_window, rect)); }
michael@0 63
michael@0 64 bool IsMessage(LPMSG message)
michael@0 65 { return BOOLToBool(IsDialogMessage(_window, message)); }
michael@0 66
michael@0 67 LRESULT SendItemMessage(int itemID, UINT message, WPARAM wParam, LPARAM lParam)
michael@0 68 { return SendDlgItemMessage(_window, itemID, message, wParam, lParam); }
michael@0 69
michael@0 70 bool CheckButton(int buttonID, UINT checkState)
michael@0 71 { return BOOLToBool(CheckDlgButton(_window, buttonID, checkState)); }
michael@0 72 bool CheckButton(int buttonID, bool checkState)
michael@0 73 { return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED)); }
michael@0 74
michael@0 75 UINT IsButtonChecked(int buttonID) const
michael@0 76 { return IsDlgButtonChecked(_window, buttonID); }
michael@0 77 bool IsButtonCheckedBool(int buttonID) const
michael@0 78 { return (IsButtonChecked(buttonID) == BST_CHECKED); }
michael@0 79
michael@0 80 bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID)
michael@0 81 { return BOOLToBool(::CheckRadioButton(_window, firstButtonID, lastButtonID, checkButtonID)); }
michael@0 82
michael@0 83 virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
michael@0 84 virtual bool OnInit() { return true; }
michael@0 85 virtual bool OnCommand(WPARAM wParam, LPARAM lParam);
michael@0 86 virtual bool OnCommand(int code, int itemID, LPARAM lParam);
michael@0 87 virtual void OnHelp(LPHELPINFO helpInfo) { OnHelp(); };
michael@0 88 virtual void OnHelp() {};
michael@0 89 virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
michael@0 90 virtual void OnOK() {};
michael@0 91 virtual void OnCancel() {};
michael@0 92 virtual bool OnNotify(UINT controlID, LPNMHDR lParam) { return false; }
michael@0 93 virtual bool OnTimer(WPARAM timerID, LPARAM callback) { return false; }
michael@0 94
michael@0 95 LONG_PTR SetMsgResult(LONG_PTR newLongPtr )
michael@0 96 { return SetLongPtr(DWLP_MSGRESULT, newLongPtr); }
michael@0 97 LONG_PTR GetMsgResult() const
michael@0 98 { return GetLongPtr(DWLP_MSGRESULT); }
michael@0 99 };
michael@0 100
michael@0 101 class CModelessDialog: public CDialog
michael@0 102 {
michael@0 103 public:
michael@0 104 bool Create(LPCTSTR templateName, HWND parentWindow);
michael@0 105 #ifndef _UNICODE
michael@0 106 bool Create(LPCWSTR templateName, HWND parentWindow);
michael@0 107 #endif
michael@0 108 virtual void OnOK() { Destroy(); }
michael@0 109 virtual void OnCancel() { Destroy(); }
michael@0 110 };
michael@0 111
michael@0 112 class CModalDialog: public CDialog
michael@0 113 {
michael@0 114 public:
michael@0 115 INT_PTR Create(LPCTSTR templateName, HWND parentWindow);
michael@0 116 INT_PTR Create(UINT resID, HWND parentWindow)
michael@0 117 { return Create(MAKEINTRESOURCEW(resID), parentWindow); }
michael@0 118 #ifndef _UNICODE
michael@0 119 INT_PTR Create(LPCWSTR templateName, HWND parentWindow);
michael@0 120 #endif
michael@0 121
michael@0 122 bool End(INT_PTR result)
michael@0 123 { return BOOLToBool(::EndDialog(_window, result)); }
michael@0 124 virtual void OnOK() { End(IDOK); }
michael@0 125 virtual void OnCancel() { End(IDCANCEL); }
michael@0 126 };
michael@0 127
michael@0 128 class CDialogChildControl: public NWindows::CWindow
michael@0 129 {
michael@0 130 public:
michael@0 131 int m_ID;
michael@0 132 void Init(const NWindows::NControl::CDialog &parentDialog, int id)
michael@0 133 {
michael@0 134 m_ID = id;
michael@0 135 Attach(parentDialog.GetItem(id));
michael@0 136 }
michael@0 137 };
michael@0 138
michael@0 139 }}
michael@0 140
michael@0 141 #endif

mercurial