custcont.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. /**********************************************************************
  2. *<
  3. FILE: custcont.h
  4. DESCRIPTION: Custom Controls for Jaguar
  5. CREATED BY: Rolf Berteig
  6. HISTORY: created 17 November, 1994
  7. *> Copyright (c) 1994, All Rights Reserved.
  8. **********************************************************************/
  9. #ifndef __CUSTCONT__
  10. #define __CUSTCONT__
  11. #include "winutil.h"
  12. void CoreExport InitCustomControls( HINSTANCE hInst );
  13. class ICustomControl {
  14. public:
  15. virtual HWND GetHwnd()=0;
  16. virtual void Enable()=0;
  17. virtual void Disable()=0;
  18. virtual BOOL IsEnabled()=0;
  19. };
  20. // This is a bitmap brush where the bitmap is a gray and white checker board.
  21. HBRUSH CoreExport GetLTGrayBrush();
  22. HBRUSH CoreExport GetDKGrayBrush();
  23. // The standard font...
  24. HFONT CoreExport GetFixedFont();
  25. // The hand cursor used for panning.
  26. HCURSOR CoreExport GetPanCursor();
  27. //---------------------------------------------------------------------------//
  28. // Spinner control
  29. #define SPINNERWINDOWCLASS _T("SpinnerControl")
  30. // LOWORD(wParam) = ctrlID,
  31. // HIWORD(wParam) = TRUE if user is dragging the spinner interactively.
  32. // lParam = pointer to ISpinnerControl
  33. #define CC_SPINNER_CHANGE WM_USER + 600
  34. // LOWORD(wParam) = ctrlID,
  35. // lParam = pointer to ISpinnerControl
  36. #define CC_SPINNER_BUTTONDOWN WM_USER + 601
  37. // LOWORD(wParam) = ctrlID,
  38. // HIWORD(wParam) = FALSE if user cancelled - TRUE otherwise
  39. // lParam = pointer to ISpinnerControl
  40. #define CC_SPINNER_BUTTONUP WM_USER + 602
  41. enum EditSpinnerType {
  42. EDITTYPE_INT,
  43. EDITTYPE_FLOAT,
  44. EDITTYPE_UNIVERSE,
  45. EDITTYPE_POS_INT,
  46. EDITTYPE_POS_FLOAT,
  47. EDITTYPE_POS_UNIVERSE,
  48. EDITTYPE_TIME
  49. };
  50. class ISpinnerControl : public ICustomControl {
  51. public:
  52. virtual float GetFVal()=0;
  53. virtual int GetIVal()=0;
  54. virtual void SetAutoScale(BOOL on=TRUE)=0;
  55. virtual void SetScale( float s )=0;
  56. virtual void SetValue( float v, int notify )=0;
  57. virtual void SetValue( int v, int notify )=0;
  58. virtual void SetLimits( int min, int max, int limitCurValue = TRUE )=0;
  59. virtual void SetLimits( float min, float max, int limitCurValue = TRUE )=0;
  60. virtual void LinkToEdit( HWND hEdit, EditSpinnerType type )=0;
  61. virtual void SetIndeterminate(BOOL i=TRUE)=0;
  62. virtual BOOL IsIndeterminate()=0;
  63. virtual void SetResetValue(float v)=0;
  64. virtual void SetResetValue(int v)=0;
  65. };
  66. ISpinnerControl CoreExport *GetISpinner( HWND hCtrl );
  67. void CoreExport ReleaseISpinner( ISpinnerControl *isc );
  68. CoreExport void SetSnapSpinner(BOOL b);
  69. CoreExport BOOL GetSnapSpinner();
  70. CoreExport void SetSnapSpinValue(float f);
  71. CoreExport float GetSnapSpinValue();
  72. CoreExport void SetSpinnerPrecision(int p);
  73. CoreExport int GetSpinnerPrecision();
  74. //---------------------------------------------------------------------------//
  75. // Rollup window control
  76. #define ROLLUPWINDOWCLASS _T("RollupWindow")
  77. typedef void *RollupState;
  78. // Flags passed to AppendRollup
  79. #define APPENDROLL_CLOSED (1<<0) // Starts the page out rolled up.
  80. class IRollupWindow : public ICustomControl {
  81. public:
  82. // Shows or hides all
  83. virtual void Show()=0;
  84. virtual void Hide()=0;
  85. // Shows or hides by index
  86. virtual void Show(int index)=0;
  87. virtual void Hide(int index)=0;
  88. virtual HWND GetPanelDlg(int index)=0;
  89. virtual int GetPanelIndex(HWND hWnd)=0;
  90. virtual void SetPanelTitle(int index,TCHAR *title)=0;
  91. // returns index of new panel
  92. virtual int AppendRollup( HINSTANCE hInst, TCHAR *dlgTemplate,
  93. DLGPROC dlgProc, TCHAR *title, LPARAM param=0,DWORD flags=0 )=0;
  94. virtual int ReplaceRollup( int index, HINSTANCE hInst, TCHAR *dlgTemplate,
  95. DLGPROC dlgProc, TCHAR *title, LPARAM param=0,DWORD flags=0 )=0;
  96. virtual void DeleteRollup( int index, int count )=0;
  97. virtual void SetPageDlgHeight(int index,int height)=0;
  98. virtual void SaveState( RollupState *hState )=0;
  99. virtual void RestoreState( RollupState *hState )=0;
  100. // Passing WM_LBUTTONDOWN, WM_MOUSEMOVE, and WM_LBUTTONUP to
  101. // this function allows scrolling with unused areas in the dialog.
  102. virtual void DlgMouseMessage( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )=0;
  103. virtual int GetNumPanels()=0;
  104. virtual BOOL IsPanelOpen(int index) = 0;
  105. virtual void SetPanelOpen(int index, BOOL isOpen) =0;
  106. virtual int GetScrollPos()=0;
  107. virtual void SetScrollPos(int spos)=0;
  108. };
  109. // This function returns TRUE if a particular rollup panel is open given
  110. // a handle to the dialog window in the panel.
  111. CoreExport BOOL IsRollupPanelOpen(HWND hDlg);
  112. IRollupWindow CoreExport *GetIRollup( HWND hCtrl );
  113. void CoreExport ReleaseIRollup( IRollupWindow *irw );
  114. //----------------------------------------------------------------------------//
  115. // CustEdit control
  116. #define CUSTEDITWINDOWCLASS _T("CustEdit")
  117. // Sent when the user hits the enter key in an edit control.
  118. // wParam = cust edit ID
  119. // lParam = HWND of cust edit control.
  120. #define WM_CUSTEDIT_ENTER (WM_USER+685)
  121. class ICustEdit : public ICustomControl {
  122. public:
  123. virtual void GetText( TCHAR *text, int ct )=0;
  124. virtual void SetText( TCHAR *text )=0;
  125. virtual void SetText( int i )=0;
  126. virtual void SetText( float f, int precision=3 )=0;
  127. virtual int GetInt(BOOL *valid=NULL)=0;
  128. virtual float GetFloat(BOOL *valid=NULL)=0;
  129. virtual void SetLeading(int lead)=0;
  130. };
  131. ICustEdit CoreExport *GetICustEdit( HWND hCtrl );
  132. void CoreExport ReleaseICustEdit( ICustEdit *ice );
  133. //----------------------------------------------------------------------------//
  134. // CustButton control
  135. #define CUSTBUTTONWINDOWCLASS _T("CustButton")
  136. #define CC_COMMAND WM_USER + 700
  137. // send these with CC_COMMAND: wParam = CC_???
  138. #define CC_CMD_SET_TYPE 23 // lParam = CBT_PUSH, CBT_CHECK
  139. #define CC_CMD_SET_STATE 24 // lParam = 0/1 for popped/pushed
  140. #define CC_CMD_HILITE_COLOR 25 // lParam = RGB packed int
  141. #define RED_WASH RGB(255,192,192)
  142. #define GREEN_WASH RGB(192,255,192)
  143. #define BLUE_WASH RGB(192,192,255)
  144. enum CustButType { CBT_PUSH, CBT_CHECK };
  145. // If the button is set to notify on button down, it will send a WM_COMMAND
  146. // with this notify code when the user touches the button.
  147. #define BN_BUTTONDOWN 8173
  148. // It will also send this message when the mouse is released regardless
  149. // if the mouse is released inside the toolbutton rectangle
  150. #define BN_BUTTONUP 8174
  151. // If a button is set to notify on right clicks, it will send a WM_COMMAND
  152. // with this notify code when the user right clicks on the button.
  153. #define BN_RIGHTCLICK 8183
  154. // When the user chooses a new fly-off item, this notify code will be sent.
  155. #define BN_FLYOFF 8187
  156. // When the user presses a button a WM_MENUSELECT message is sent so that
  157. // the client can display a status prompt describing the function of
  158. // the tool. The fuFlags parameter is set to this value:
  159. #define CMF_TOOLBUTTON 9274
  160. class FlyOffData {
  161. public:
  162. int iOutEn;
  163. int iInEn;
  164. int iOutDis;
  165. int iInDis;
  166. };
  167. // Directions the fly off will go.
  168. #define FLY_VARIABLE 1
  169. #define FLY_UP 2
  170. #define FLY_DOWN 3
  171. #define FLY_HVARIABLE 4 // horizontal variable
  172. #define FLY_LEFT 5
  173. #define FLY_RIGHT 6
  174. class ICustButton : public ICustomControl {
  175. public:
  176. virtual void GetText( TCHAR *text, int ct )=0;
  177. virtual void SetText( TCHAR *text )=0;
  178. virtual void SetImage( HIMAGELIST hImage,
  179. int iOutEn, int iInEn, int iOutDis, int iInDis, int w, int h )=0;
  180. virtual void SetType( CustButType type )=0;
  181. virtual void SetFlyOff(int count,FlyOffData *data,int timeOut,int init,int dir=FLY_VARIABLE)=0;
  182. virtual void SetCurFlyOff(int f,BOOL notify=FALSE)=0;
  183. virtual int GetCurFlyOff()=0;
  184. virtual BOOL IsChecked()=0;
  185. virtual void SetCheck( BOOL checked )=0;
  186. virtual void SetCheckHighlight( BOOL highlight )=0;
  187. virtual void SetButtonDownNotify(BOOL notify)=0;
  188. virtual void SetRightClickNotify(BOOL notify)=0;
  189. virtual void SetHighlightColor(COLORREF clr)=0;
  190. virtual void SetTooltip(BOOL onOff, LPSTR text)=0;
  191. };
  192. ICustButton CoreExport *GetICustButton( HWND hCtrl );
  193. void CoreExport ReleaseICustButton( ICustButton *icb );
  194. //---------------------------------------------------------------------------//
  195. // CustStatus
  196. #define CUSTSTATUSWINDOWCLASS _T("CustStatus")
  197. enum StatusTextFormat {
  198. STATUSTEXT_LEFT,
  199. STATUSTEXT_CENTERED,
  200. STATUSTEXT_RIGHT };
  201. class ICustStatus : public ICustomControl {
  202. public:
  203. virtual void SetText(TCHAR *text)=0;
  204. virtual void SetTextFormat(StatusTextFormat f)=0;
  205. };
  206. ICustStatus CoreExport *GetICustStatus( HWND hCtrl );
  207. void CoreExport ReleaseICustStatus( ICustStatus *ics );
  208. //----------------------------------------------------------------------------//
  209. // CustToolbar control
  210. #define CUSTTOOLBARWINDOWCLASS _T("CustToolbar")
  211. // Sent in a WM_COMMAND when the user right clicks in open space
  212. // on a toolbar.
  213. #define TB_RIGHTCLICK 0x2861
  214. enum ToolItemType {
  215. CTB_PUSHBUTTON,
  216. CTB_CHECKBUTTON,
  217. CTB_SEPARATOR,
  218. CTB_STATUS,
  219. CTB_OTHER
  220. };
  221. class ToolItem {
  222. public:
  223. ToolItemType type;
  224. int id;
  225. DWORD helpID;
  226. int w, h;
  227. virtual ~ToolItem() {}
  228. };
  229. class ToolButtonItem : public ToolItem {
  230. public:
  231. int iOutEn, iInEn;
  232. int iOutDis, iInDis;
  233. int iw;
  234. int ih;
  235. ToolButtonItem(ToolItemType t,
  236. int iOE, int iIE, int iOD, int iID,
  237. int iW, int iH, int wd,int ht, int ID, DWORD hID=0)
  238. {
  239. type = t;
  240. iOutEn = iOE; iInEn = iIE; iOutDis = iOD; iInDis = iID;
  241. iw = iW; ih = iH; w = wd; h = ht; id = ID; helpID = hID;
  242. }
  243. };
  244. class ToolSeparatorItem : public ToolItem {
  245. public:
  246. ToolSeparatorItem(int w) {
  247. type = CTB_SEPARATOR;
  248. id = 0;
  249. helpID = 0;
  250. this->w = w;
  251. h = 0;
  252. }
  253. };
  254. class ToolStatusItem : public ToolItem {
  255. public:
  256. BOOL fixed;
  257. ToolStatusItem(int w, int h,BOOL f,int id, DWORD hID=0) {
  258. type = CTB_STATUS;
  259. this->w = w;
  260. this->h = h;
  261. this->id = id;
  262. this->helpID = hID;
  263. fixed = f;
  264. }
  265. };
  266. #define CENTER_TOOL_VERTICALLY 0xffffffff
  267. class ToolOtherItem : public ToolItem {
  268. public:
  269. int y;
  270. DWORD style;
  271. TCHAR *className;
  272. TCHAR *windowText;
  273. ToolOtherItem(TCHAR *cls,int w,int h,int id,DWORD style=WS_CHILD|WS_VISIBLE,
  274. int y=CENTER_TOOL_VERTICALLY,TCHAR *wt=NULL,DWORD hID=0) {
  275. type = CTB_OTHER;
  276. this->y = y;
  277. this->w = w;
  278. this->h = h;
  279. this->id = id;
  280. this->helpID = hID;
  281. this->style = style;
  282. className = cls;
  283. windowText = wt;
  284. }
  285. };
  286. class ICustToolbar : public ICustomControl {
  287. public:
  288. virtual void SetImage( HIMAGELIST hImage )=0;
  289. virtual void AddTool( const ToolItem& entry, int pos=-1 )=0;
  290. virtual void DeleteTools( int start, int num=-1 )=0; // num = -1 deletes 'start' through count-1 tools
  291. virtual void SetBottomBorder(BOOL on)=0;
  292. virtual void SetTopBorder(BOOL on)=0;
  293. virtual ICustButton *GetICustButton( int id )=0;
  294. virtual ICustStatus *GetICustStatus( int id )=0;
  295. virtual HWND GetItemHwnd(int id)=0;
  296. };
  297. ICustToolbar CoreExport *GetICustToolbar( HWND hCtrl );
  298. void CoreExport ReleaseICustToolbar( ICustToolbar *ict );
  299. //---------------------------------------------------------------------------//
  300. // CustImage
  301. #define CUSTIMAGEWINDOWCLASS _T("CustImage")
  302. class ICustImage : public ICustomControl {
  303. public:
  304. virtual void SetImage( HIMAGELIST hImage,int index, int w, int h )=0;
  305. };
  306. ICustImage CoreExport *GetICustImage( HWND hCtrl );
  307. void CoreExport ReleaseICustImage( ICustImage *ici );
  308. //------------------------------------------------------------------------
  309. // Off Screen Buffer
  310. class IOffScreenBuf {
  311. public:
  312. virtual HDC GetDC()=0;
  313. virtual void Erase(Rect *rct=NULL)=0;
  314. virtual void Blit(Rect *rct=NULL)=0;
  315. virtual void Resize()=0;
  316. virtual void SetBkColor(COLORREF color)=0;
  317. virtual COLORREF GetBkColor()=0;
  318. };
  319. CoreExport IOffScreenBuf *CreateIOffScreenBuf(HWND hWnd);
  320. CoreExport void DestroyIOffScreenBuf(IOffScreenBuf *iBuf);
  321. //------------------------------------------------------------------------
  322. // Color swatch control
  323. // Puts up the ColorPicker when user right clicks on it.
  324. //
  325. // This message is sent as the color is being adjusted in the
  326. // ColorPicker.
  327. // LOWORD(wParam) = ctrlID,
  328. // HIWORD(wParam) = 1 if button UP
  329. // = 0 if mouse drag.
  330. // lParam = pointer to ColorSwatchControl
  331. #define CC_COLOR_CHANGE WM_USER + 603
  332. // LOWORD(wParam) = ctrlID,
  333. // lParam = pointer to ColorSwatchControl
  334. #define CC_COLOR_BUTTONDOWN WM_USER + 606
  335. // LOWORD(wParam) = ctrlID,
  336. // HIWORD(wParam) = FALSE if user cancelled - TRUE otherwise
  337. // lParam = pointer to ColorSwatchControl
  338. #define CC_COLOR_BUTTONUP WM_USER + 607
  339. // This message is sent if the color has been clicked on, before
  340. // bringing up the color picker.
  341. // LOWORD(wParam) = ctrlID,
  342. // HIWORD(wParam) = 0
  343. // lParam = pointer to ColorSwatchControl
  344. #define CC_COLOR_SEL WM_USER + 604
  345. // This message is sent if another color swatch has been dragged and dropped
  346. // on this swatch.
  347. // LOWORD(wParam) = toCtrlID,
  348. // HIWORD(wParam) = 0
  349. // lParam = pointer to ColorSwatchControl
  350. #define CC_COLOR_DROP WM_USER + 605
  351. #define COLORSWATCHWINDOWCLASS _T("ColorSwatch")
  352. class IColorSwatch: public ICustomControl {
  353. public:
  354. // sets only the varying color of the color picker if showing
  355. virtual COLORREF SetColor(COLORREF c, int notify=FALSE)=0; // returns old color
  356. // sets both the varying color and the "reset"color of the color picker
  357. virtual COLORREF InitColor(COLORREF c, int notify=FALSE)=0; // returns old color
  358. virtual COLORREF GetColor()=0;
  359. virtual void ForceDitherMode(BOOL onOff)=0;
  360. virtual void SetModal()=0;
  361. virtual void Activate(int onOff)=0;
  362. virtual void EditThis(BOOL startNew=TRUE)=0;
  363. };
  364. IColorSwatch CoreExport *GetIColorSwatch( HWND hCtrl, COLORREF col, TCHAR *name);
  365. void CoreExport ReleaseIColorSwatch( IColorSwatch *ics );
  366. //------------------------------------------------------------------------
  367. // Window thumb tack
  368. // This function installs a thumb tack in the title bar of a window
  369. // which allows the user to make it an always on top window.
  370. // NOTE: The window class for the window should have 4 extra bytes in
  371. // the window structure for SetWindowLong().
  372. CoreExport void InstallThumbTack(HWND hwnd);
  373. CoreExport void RemoveThumbTack(HWND hwnd);
  374. // Handy routines for setting up Spinners.
  375. CoreExport ISpinnerControl *SetupIntSpinner(HWND hwnd, int idSpin, int idEdit, int min, int max, int val);
  376. CoreExport ISpinnerControl *SetupFloatSpinner(HWND hwnd, int idSpin, int idEdit, float min, float max, float val, float scale = 0.1f);
  377. //---------------------------------------------------------------------------
  378. //
  379. CoreExport void DisableAccelerators();
  380. CoreExport void EnableAccelerators();
  381. CoreExport BOOL AcceleratorsEnabled();
  382. CoreExport void SetSaveRequired(int b=TRUE);
  383. CoreExport BOOL GetSaveRequired();
  384. #endif // __CUSTCONT__