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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/7zstub/src/Windows/Control/Dialog.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,141 @@
     1.4 +// Windows/Control/Dialog.h
     1.5 +
     1.6 +#ifndef __WINDOWS_CONTROL_DIALOG_H
     1.7 +#define __WINDOWS_CONTROL_DIALOG_H
     1.8 +
     1.9 +#include "Windows/Window.h"
    1.10 +#include "Windows/Defs.h"
    1.11 +
    1.12 +namespace NWindows {
    1.13 +namespace NControl {
    1.14 +
    1.15 +class CDialog: public CWindow
    1.16 +{
    1.17 +public:
    1.18 +  CDialog(HWND wndow = NULL): CWindow(wndow){};
    1.19 +  virtual ~CDialog() {};
    1.20 +
    1.21 +  HWND GetItem(int itemID) const
    1.22 +    { return GetDlgItem(_window, itemID); }
    1.23 +
    1.24 +  bool EnableItem(int itemID, bool enable) const
    1.25 +    { return BOOLToBool(::EnableWindow(GetItem(itemID), BoolToBOOL(enable))); }
    1.26 +
    1.27 +  bool SetItemText(int itemID, LPCTSTR s)
    1.28 +    { return BOOLToBool(SetDlgItemText(_window, itemID, s)); }
    1.29 +
    1.30 +  #ifndef _UNICODE
    1.31 +  bool SetItemText(int itemID, LPCWSTR s)
    1.32 +  { 
    1.33 +    CWindow window(GetItem(itemID));
    1.34 +    return window.SetText(s); 
    1.35 +  }
    1.36 +  #endif
    1.37 +
    1.38 +  UINT GetItemText(int itemID, LPTSTR string, int maxCount)
    1.39 +    { return GetDlgItemText(_window, itemID, string, maxCount); }
    1.40 +  #ifndef _UNICODE
    1.41 +  /*
    1.42 +  bool GetItemText(int itemID, LPWSTR string, int maxCount)
    1.43 +  { 
    1.44 +    CWindow window(GetItem(itemID));
    1.45 +    return window.GetText(string, maxCount); 
    1.46 +  }
    1.47 +  */
    1.48 +  #endif
    1.49 +
    1.50 +  bool SetItemInt(int itemID, UINT value, bool isSigned)
    1.51 +    { return BOOLToBool(SetDlgItemInt(_window, itemID, value, BoolToBOOL(isSigned))); }
    1.52 +  bool GetItemInt(int itemID, bool isSigned, UINT &value)
    1.53 +    { 
    1.54 +      BOOL result;
    1.55 +      value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned));
    1.56 +      return BOOLToBool(result);
    1.57 +    }
    1.58 +
    1.59 +  HWND GetNextGroupItem(HWND control, bool previous)
    1.60 +    { return GetNextDlgGroupItem(_window, control, BoolToBOOL(previous)); }
    1.61 +  HWND GetNextTabItem(HWND control, bool previous)
    1.62 +    { return GetNextDlgTabItem(_window, control, BoolToBOOL(previous)); }
    1.63 +
    1.64 +  bool MapRect(LPRECT rect)
    1.65 +    { return BOOLToBool(MapDialogRect(_window, rect)); }
    1.66 +
    1.67 +  bool IsMessage(LPMSG message)
    1.68 +    { return BOOLToBool(IsDialogMessage(_window, message)); }
    1.69 +
    1.70 +  LRESULT SendItemMessage(int itemID, UINT message, WPARAM wParam, LPARAM lParam)
    1.71 +    { return SendDlgItemMessage(_window, itemID, message, wParam, lParam); }
    1.72 +
    1.73 +  bool CheckButton(int buttonID, UINT checkState)
    1.74 +    { return BOOLToBool(CheckDlgButton(_window, buttonID, checkState)); }
    1.75 +  bool CheckButton(int buttonID, bool checkState)
    1.76 +    { return CheckButton(buttonID, UINT(checkState ? BST_CHECKED : BST_UNCHECKED)); }
    1.77 +
    1.78 +  UINT IsButtonChecked(int buttonID) const
    1.79 +    { return IsDlgButtonChecked(_window, buttonID); }
    1.80 +  bool IsButtonCheckedBool(int buttonID) const
    1.81 +    { return (IsButtonChecked(buttonID) == BST_CHECKED); }
    1.82 +
    1.83 +  bool CheckRadioButton(int firstButtonID, int lastButtonID, int checkButtonID)
    1.84 +    { return BOOLToBool(::CheckRadioButton(_window, firstButtonID, lastButtonID, checkButtonID)); }
    1.85 +
    1.86 +  virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
    1.87 +  virtual bool OnInit() { return true; }
    1.88 +  virtual bool OnCommand(WPARAM wParam, LPARAM lParam);
    1.89 +  virtual bool OnCommand(int code, int itemID, LPARAM lParam);
    1.90 +  virtual void OnHelp(LPHELPINFO helpInfo) { OnHelp(); };
    1.91 +  virtual void OnHelp() {};
    1.92 +  virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
    1.93 +  virtual void OnOK() {};
    1.94 +  virtual void OnCancel() {};
    1.95 +  virtual bool OnNotify(UINT controlID, LPNMHDR lParam) { return false; }
    1.96 +  virtual bool OnTimer(WPARAM timerID, LPARAM callback) { return false; }
    1.97 +
    1.98 +  LONG_PTR SetMsgResult(LONG_PTR newLongPtr )
    1.99 +    { return SetLongPtr(DWLP_MSGRESULT, newLongPtr); }
   1.100 +  LONG_PTR GetMsgResult() const
   1.101 +    { return GetLongPtr(DWLP_MSGRESULT); }
   1.102 +};
   1.103 +
   1.104 +class CModelessDialog: public CDialog
   1.105 +{
   1.106 +public:
   1.107 +  bool Create(LPCTSTR templateName, HWND parentWindow);
   1.108 +  #ifndef _UNICODE
   1.109 +  bool Create(LPCWSTR templateName, HWND parentWindow);
   1.110 +  #endif
   1.111 +  virtual void OnOK() { Destroy(); }
   1.112 +  virtual void OnCancel() { Destroy(); }
   1.113 +};
   1.114 +
   1.115 +class CModalDialog: public CDialog
   1.116 +{
   1.117 +public:
   1.118 +  INT_PTR Create(LPCTSTR templateName, HWND parentWindow);
   1.119 +  INT_PTR Create(UINT resID, HWND parentWindow)
   1.120 +    {  return Create(MAKEINTRESOURCEW(resID), parentWindow); }
   1.121 +  #ifndef _UNICODE
   1.122 +  INT_PTR Create(LPCWSTR templateName, HWND parentWindow);
   1.123 +  #endif
   1.124 +
   1.125 +  bool End(INT_PTR result)
   1.126 +    { return BOOLToBool(::EndDialog(_window, result)); }
   1.127 +  virtual void OnOK() { End(IDOK); }
   1.128 +  virtual void OnCancel() { End(IDCANCEL); }
   1.129 +};
   1.130 +
   1.131 +class CDialogChildControl: public NWindows::CWindow
   1.132 +{
   1.133 +public:
   1.134 +  int m_ID;
   1.135 +  void Init(const NWindows::NControl::CDialog &parentDialog, int id)
   1.136 +  {
   1.137 +    m_ID = id;
   1.138 +    Attach(parentDialog.GetItem(id));
   1.139 +  }
   1.140 +};
   1.141 +
   1.142 +}}
   1.143 +
   1.144 +#endif
   1.145 \ No newline at end of file

mercurial