home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / h / vd2 / VDLib / Dialog.h next >
Encoding:
C/C++ Source or Header  |  2009-09-14  |  3.9 KB  |  168 lines

  1. #ifndef f_VD2_VDLIB_DIALOG_H
  2. #define f_VD2_VDLIB_DIALOG_H
  3.  
  4. #ifdef _MSC_VER
  5. #pragma once
  6. #endif
  7.  
  8. #include <vd2/system/vdstl.h>
  9. #include <vd2/system/win32/miniwindows.h>
  10. #include <vd2/VDLib/UIProxies.h>
  11.  
  12. class IVDUIDropFileList {
  13. public:
  14.     virtual bool GetFileName(int index, VDStringW& fileName) = 0;
  15. };
  16.  
  17. class VDDialogFrameW32 {
  18. public:
  19.     VDZHWND GetWindowHandle() const { return mhdlg; }
  20.  
  21.     bool    Create(VDGUIHandle hwndParent);
  22.     void    Destroy();
  23.  
  24.     void    Show();
  25.     void    Hide();
  26.  
  27.     sintptr ShowDialog(VDGUIHandle hwndParent);
  28.  
  29. protected:
  30.     VDDialogFrameW32(uint32 dlgid);
  31.  
  32.     void End(sintptr result);
  33.  
  34.     void AddProxy(VDUIProxyControl *proxy, uint32 id);
  35.  
  36.     VDZHWND GetControl(uint32 id);
  37.  
  38.     void SetFocusToControl(uint32 id);
  39.     void EnableControl(uint32 id, bool enabled);
  40.  
  41.     void SetCaption(uint32 id, const wchar_t *format);
  42.  
  43.     void SetControlText(uint32 id, const wchar_t *s);
  44.     void SetControlTextF(uint32 id, const wchar_t *format, ...);
  45.  
  46.     uint32 GetControlValueUint32(uint32 id);
  47.     double GetControlValueDouble(uint32 id);
  48.     VDStringW GetControlValueString(uint32 id);
  49.  
  50.     void ExchangeControlValueBoolCheckbox(bool write, uint32 id, bool& val);
  51.     void ExchangeControlValueDouble(bool write, uint32 id, const wchar_t *format, double& val, double minVal, double maxVal);
  52.     void ExchangeControlValueString(bool write, uint32 id, VDStringW& s);
  53.  
  54.     void CheckButton(uint32 id, bool checked);
  55.     bool IsButtonChecked(uint32 id);
  56.  
  57.     void BeginValidation();
  58.     bool EndValidation();
  59.  
  60.     void FailValidation(uint32 id);
  61.     void SignalFailedValidation(uint32 id);
  62.  
  63.     // listbox
  64.     void LBClear(uint32 id);
  65.     sint32 LBGetSelectedIndex(uint32 id);
  66.     void LBSetSelectedIndex(uint32 id, sint32 idx);
  67.     void LBAddString(uint32 id, const wchar_t *s);
  68.     void LBAddStringF(uint32 id, const wchar_t *format, ...);
  69.  
  70.     // trackbar
  71.     sint32 TBGetValue(uint32 id);
  72.     void TBSetValue(uint32 id, sint32 value);
  73.     void TBSetRange(uint32 id, sint32 minval, sint32 maxval);
  74.  
  75. protected:
  76.     virtual VDZINT_PTR DlgProc(VDZUINT msg, VDZWPARAM wParam, VDZLPARAM lParam);
  77.     virtual void OnDataExchange(bool write);
  78.     virtual bool OnLoaded();
  79.     virtual bool OnOK();
  80.     virtual bool OnCancel();
  81.     virtual void OnSize();
  82.     virtual void OnDestroy();
  83.     virtual bool OnTimer(uint32 id);
  84.     virtual bool OnCommand(uint32 id, uint32 extcode);
  85.     virtual void OnDropFiles(VDZHDROP hDrop);
  86.     virtual void OnDropFiles(IVDUIDropFileList *dropFileList);
  87.     virtual void OnHScroll(uint32 id, int code);
  88.     virtual void OnVScroll(uint32 id, int code);
  89.     virtual bool PreNCDestroy();
  90.  
  91.     bool    mbValidationFailed;
  92.     bool    mbIsModal;
  93.     VDZHWND    mhdlg;
  94.  
  95. private:
  96.     static VDZINT_PTR VDZCALLBACK StaticDlgProc(VDZHWND hwnd, VDZUINT msg, VDZWPARAM wParam, VDZLPARAM lParam);
  97.  
  98.     const char *mpDialogResourceName;
  99.     uint32    mFailedId;
  100.  
  101. protected:
  102.     VDUIProxyMessageDispatcherW32 mMsgDispatcher;
  103. };
  104.  
  105. class VDDialogResizerW32 {
  106. public:
  107.     VDDialogResizerW32();
  108.     ~VDDialogResizerW32();
  109.  
  110.     enum {
  111.         kAnchorX1_C    = 0x01,
  112.         kAnchorX1_R    = 0x02,
  113.         kAnchorX2_C    = 0x04,
  114.         kAnchorX2_R    = 0x08,
  115.         kAnchorY1_M    = 0x10,
  116.         kAnchorY1_B    = 0x20,
  117.         kAnchorY2_M    = 0x40,
  118.         kAnchorY2_B    = 0x80,
  119.  
  120.         kL        = 0,
  121.         kC        = kAnchorX2_R,
  122.         kR        = kAnchorX2_R | kAnchorX1_R,
  123.         kHMask    = 0x0F,
  124.  
  125.         kT        = 0,
  126.         kM        = kAnchorY2_B,
  127.         kB        = kAnchorY2_B | kAnchorY1_B,
  128.         kVMask    = 0xF0,
  129.  
  130.         kX1Y1Mask = 0x33,
  131.         kX2Y2Mask = 0xCC,
  132.  
  133.         kTL        = kT | kL,
  134.         kTR        = kT | kR,
  135.         kTC        = kT | kC,
  136.         kML        = kM | kL,
  137.         kMR        = kM | kR,
  138.         kMC        = kM | kC,
  139.         kBL        = kB | kL,
  140.         kBR        = kB | kR,
  141.         kBC        = kB | kC,
  142.     };
  143.  
  144.     void Init(VDZHWND hwnd);
  145.     void Relayout();
  146.     void Relayout(int width, int height);
  147.     void Add(uint32 id, int alignment);
  148.  
  149. protected:
  150.     struct ControlEntry {
  151.         VDZHWND    mhwnd;
  152.         int        mAlignment;
  153.         sint32    mX1;
  154.         sint32    mY1;
  155.         sint32    mX2;
  156.         sint32    mY2;
  157.     };
  158.  
  159.     VDZHWND    mhwndBase;
  160.     int        mWidth;
  161.     int        mHeight;
  162.  
  163.     typedef vdfastvector<ControlEntry> Controls;
  164.     Controls mControls;
  165. };
  166.  
  167. #endif
  168.