aduiButton.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // DESCRIPTION:
  12. //
  13. // Declarations for various button classes:
  14. //
  15. // CAdUiOwnerDrawButton
  16. // - A basic owner-draw button.
  17. // CAdUiBitmapButton
  18. // - A simple bitmap button.
  19. // CAdUiBitmapStatic
  20. // - A bitmap button that defaults to behaving like a static.
  21. // CAdUiDropSite
  22. // - A static bitmap that enables Drag&Drop by default.
  23. // CAdUiToolButton
  24. // - A bitmap button that enables tool button display by default.
  25. // CAdUiThemedDropDownBitmapButton
  26. // A bitmap button that have a drop down menu.
  27. //
  28. //////////////////////////////////////////////////////////////////////////////
  29. #ifndef _aduiButton_h
  30. #define _aduiButton_h
  31. #pragma pack (push, 8)
  32. #if _MSC_VER >= 1000
  33. #pragma once
  34. #endif // _MSC_VER >= 1000
  35. #include "AdUiTheme.h"
  36. #ifndef _ADESK_MAC_
  37. class CAdUiOwnerDrawButton;
  38. class CAdUiTrackButtonDraw;
  39. class CAdUiODButtonThemeModReactor : public CAdUiThemeModifiedReactor // INTERNAL USE ONLY
  40. {
  41. public:
  42. CAdUiODButtonThemeModReactor(CAdUiOwnerDrawButton* pBtn); // INTERNAL USE ONLY
  43. virtual void ThemeModified(const CAdUiTheme * pTheme, AdUiThemeElement element); // INTERNAL USE ONLY
  44. private:
  45. CAdUiOwnerDrawButton * m_pBtn;
  46. };
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CAdUiOwnerDrawButton
  49. #pragma warning(push)
  50. #pragma warning(disable : 4275)
  51. class ADUI_PORT CAdUiOwnerDrawButton : public CButton {
  52. friend class CAdUiODButtonThemeModReactor; // INTERNAL USE ONLY
  53. DECLARE_DYNAMIC(CAdUiOwnerDrawButton)
  54. public:
  55. CAdUiOwnerDrawButton ();
  56. virtual ~CAdUiOwnerDrawButton ();
  57. protected:
  58. CPoint m_lastMousePoint;
  59. CRect m_tipRect;
  60. CAdUiTheme * m_pTheme;
  61. // AdUi message handler
  62. protected:
  63. CWnd *m_aduiParent;
  64. virtual ADUI_REPLY DoAdUiMessage (
  65. ADUI_NOTIFY notifyCode, UINT controlId, LPARAM lParam
  66. );
  67. virtual void OnDrawTip (CDC& dc);
  68. virtual BOOL OnDrawTipText (CAdUiDrawTipText& dtt);
  69. virtual ADUI_REPLY OnGetTipSupport (CPoint& p);
  70. virtual BOOL OnGetTipRect (CRect& r);
  71. virtual BOOL OnGetTipText (CString& text);
  72. virtual BOOL OnHitTipRect (CPoint& p);
  73. public:
  74. CWnd *GetAdUiParent ();
  75. void SetAdUiParent (CWnd *w);
  76. virtual void SetTracking(BOOL b) { m_bIsTrackButton = b; };
  77. /// <summary>
  78. /// Sets the theme to be used by the owner draw button
  79. /// </summary>
  80. /// <param name="pTheme">
  81. /// Input pointer to the CAdUiTheme instance
  82. /// </param>
  83. /// <returns>
  84. /// The current theme used by the owner draw button
  85. /// </returns>
  86. virtual CAdUiTheme * SetTheme(CAdUiTheme *pTheme);
  87. // Owner Draw routines
  88. protected:
  89. static const UINT_PTR m_timerEvent;
  90. BOOL m_bEnableDragDrop : 1;
  91. BOOL m_bEnableFastDraw : 1;
  92. BOOL m_bEnablePointedAt : 1;
  93. BOOL m_bIsPointedAt : 1;
  94. BOOL m_bIsStatic : 1;
  95. BOOL m_bIsToolButton : 1;
  96. BOOL m_bIsTrackButton : 1;
  97. UINT_PTR m_timerId;
  98. // members added for XP look and feel
  99. int m_nPartId;
  100. int m_nStateId;
  101. UINT m_uEdge;
  102. BOOL m_bMouseHover;
  103. virtual void DrawBorder(CDC *pDC,CRect &r,COLORREF cr);
  104. virtual void DrawHotBorder();
  105. virtual void DrawButton(
  106. CDC& dc, int w, int h,
  107. BOOL isDefault,
  108. BOOL isDisabled,
  109. BOOL isSelected,
  110. BOOL isFocused
  111. );
  112. virtual void DrawPushButtonBorder (
  113. CDC& dc, CRect& rButton, BOOL isDefault, BOOL isSelected
  114. );
  115. virtual void DrawToolButtonBorder (
  116. CDC& dc, CRect& rButton, BOOL isSelected, BOOL isFocused
  117. );
  118. void DrawTransparentBitmap (
  119. CDC& dc,
  120. CBitmap& bmp,
  121. int x, int y, int w, int h,
  122. BOOL isDisabled
  123. );
  124. void DrawContentText (
  125. CDC& dc,
  126. CString sText,
  127. CRect& rcText,
  128. BOOL isDisabled
  129. );
  130. BOOL GetIsPointedAt ();
  131. void SetIsPointedAt (BOOL isPointedAt);
  132. virtual BOOL OnAutoLoad ();
  133. virtual void OnDragDrop (HDROP hDropInfo);
  134. virtual void OnPointedAt (BOOL isPointedAt);
  135. virtual BOOL OnReload (LPCTSTR strResId);
  136. void StartTimer (DWORD ms=50);
  137. void StopTimer ();
  138. /// <summary>
  139. /// Virtual method that receives the theme modification event.
  140. /// </summary>
  141. /// <param name="element">
  142. /// A index of the theme element that was modified.
  143. /// </param>
  144. /// <remarks>
  145. /// This method is also called when the theme uses the active theme colors
  146. /// and the active theme is changed. In that case, element = kUnknownElements
  147. /// </remarks>
  148. virtual void ThemeModified(AdUiThemeElement element);
  149. public:
  150. BOOL AutoLoad ();
  151. BOOL GetEnableDragDrop ();
  152. void SetEnableDragDrop (BOOL allow);
  153. BOOL GetEnableFastDraw ();
  154. void SetEnableFastDraw (BOOL allow);
  155. BOOL GetEnablePointedAt ();
  156. void SetEnablePointedAt (BOOL allow);
  157. BOOL GetIsStatic ();
  158. void SetIsStatic (BOOL isStatic);
  159. BOOL GetIsToolButton ();
  160. void SetIsToolButton (BOOL isToolButton);
  161. BOOL Reload (LPCTSTR strResId);
  162. // ClassWizard-controlled
  163. public:
  164. //{{AFX_VIRTUAL(CAdUiOwnerDrawButton)
  165. public:
  166. virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  167. virtual void PreSubclassWindow();
  168. //}}AFX_VIRTUAL
  169. protected:
  170. //{{AFX_MSG(CAdUiOwnerDrawButton)
  171. afx_msg LRESULT OnAdUiMessage (WPARAM wParam, LPARAM lParam);
  172. afx_msg void OnDropFiles(HDROP hDropInfo);
  173. afx_msg UINT OnGetDlgCode();
  174. afx_msg void OnKillFocus(CWnd* pNewWnd);
  175. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  176. afx_msg LRESULT OnMouseLeave(WPARAM, LPARAM);
  177. afx_msg void OnNcDestroy();
  178. afx_msg void OnSetFocus(CWnd* pOldWnd);
  179. afx_msg void OnTimer(UINT_PTR nIDEvent);
  180. afx_msg void OnDestroy( );
  181. afx_msg LRESULT OnThemeChanged(WPARAM wParam, LPARAM lParam);
  182. //}}AFX_MSG
  183. DECLARE_MESSAGE_MAP()
  184. protected:
  185. HANDLE GetVisualStylesTheme() {return m_hVS;}
  186. private:
  187. CAdUiODButtonThemeModReactor* m_pThemeModReactor; // INTERNAL USE ONLY
  188. HANDLE m_hVS; // INTERNAL USE ONLY
  189. };
  190. #pragma warning(pop)
  191. /////////////////////////////////////////////////////////////////////////////
  192. // CAdUiBitmapButton
  193. class ADUI_PORT CAdUiBitmapButton : public CAdUiOwnerDrawButton
  194. {
  195. DECLARE_DYNAMIC(CAdUiBitmapButton)
  196. friend class CAdUiImpBitmapButton;
  197. public:
  198. CAdUiBitmapButton ();
  199. virtual ~CAdUiBitmapButton ();
  200. enum Constants
  201. {
  202. ThemedSize = 24,
  203. };
  204. BOOL GetAutoSizeToBitmap ();
  205. void SetAutoSizeToBitmap (BOOL autoSizeToBitmap);
  206. void SizeToBitmap ();
  207. bool SetBitmapOffsets(int nBorderOffset, int nFocusRectOffset);
  208. /// <summary>
  209. /// Gets if the bitmap button has a themed look
  210. /// </summary>
  211. /// <returns>
  212. /// True if the bitmap button has a themed look or false otherwise
  213. /// </returns>
  214. virtual BOOL IsThemed() const;
  215. /// <summary>
  216. /// Sets if the bitmap button has a themed look
  217. /// </summary>
  218. /// <param name="isThemed">
  219. /// True if the bitmap button has a themed look or false otherwise
  220. /// </param>
  221. virtual void SetIsThemed(BOOL isThemed);
  222. /// <summary>
  223. /// Enables or disables the themed hover and/or click state
  224. /// </summary>
  225. /// <param name="bEnableHover">
  226. /// Specify if the themed hover state should be enabled
  227. /// </param>
  228. /// <param name="bEnableClick">
  229. /// Specify if the themed click state should be enabled
  230. /// </param>
  231. virtual void EnableThemedState(BOOL bEnableHover, BOOL bEnableClick);
  232. /// <summary>
  233. /// Sets the theme to be used by the bitmap button
  234. /// </summary>
  235. /// <param name="pTheme">
  236. /// Input pointer to the CAdUiTheme instance
  237. /// </param>
  238. /// <returns>
  239. /// The current theme used by the bitmap button
  240. /// </returns>
  241. virtual CAdUiTheme * SetTheme(CAdUiTheme *pTheme);
  242. /// <summary>
  243. /// Overrides the theme element to be used as the backgrounnd color in the
  244. /// themed draw. The default background color is the palette background color.
  245. /// </summary>
  246. /// <param name="nElement">
  247. /// Input new theme element to be used as the themed background color
  248. /// </param>
  249. virtual void SetThemeBackground(AdUiThemeElement nElement);
  250. /// <summary>
  251. /// Gets if the image in drawn at the center of the button
  252. /// </summary>
  253. /// <returns>
  254. /// True if the the image in drawn at the center of the button or false otherwise
  255. /// </returns>
  256. BOOL CenterImage() const;
  257. /// <summary>
  258. /// Sets if the image in drawn at the center of the button
  259. /// </summary>
  260. /// <param name="center">
  261. /// True if the the image in drawn at the center of the button or false otherwise
  262. /// </param>
  263. void SetCenterImage(BOOL center);
  264. BOOL LoadBitmap (LPCTSTR strResId);
  265. protected:
  266. // Owner Draw routines
  267. virtual void DrawButton(CDC& dc, int w, int h,
  268. BOOL isDefault,
  269. BOOL isDisabled,
  270. BOOL isSelected,
  271. BOOL isFocused);
  272. virtual void DrawButtonImage(CDC* pDC, const CRect& rect, BOOL isSelected, BOOL isDisabled);
  273. virtual void DrawFocusMark(CDC* pDC, CRect& rect, BOOL isDefault, BOOL isSelected, BOOL isFocused);
  274. virtual BOOL OnAutoLoad ();
  275. virtual BOOL OnReload (LPCTSTR strResId);
  276. /// <summary>
  277. /// Draws the button with a themed look. It is called from the DrawButton() method
  278. /// when IsThemed() returns true.
  279. /// </summary>
  280. /// <param name="dc">
  281. /// Input device context to draw the control
  282. /// </param>
  283. /// <param name="x">
  284. /// Input x coordinate in pixels of the upper-left corner of the rectangle for the control
  285. /// </param>
  286. /// <param name="y">
  287. /// Input y coordinate in pixels of the upper-left corner of the rectangle for the control
  288. /// </param>
  289. /// <param name="width">
  290. /// Input width in pixels of the rectangle for the control
  291. /// </param>
  292. /// <param name="height">
  293. /// Input height in pixels of the rectangle for the control
  294. /// </param>
  295. /// <param name="statusId">
  296. /// Input status ID of the control. It is a windows PUSHBUTTON state such as PBS_NORMAL
  297. /// </param>
  298. virtual void DrawThemedButton(CDC& dc, int x, int y, int width, int height, int statusId);
  299. /// <summary>
  300. /// Virtual method that receives the theme modification event.
  301. /// </summary>
  302. /// <param name="element">
  303. /// A index of the theme element that was modified.
  304. /// </param>
  305. /// <remarks>
  306. /// This method is also called when the theme uses the active theme colors
  307. /// and the active theme is changed. In that case, element = kUnknownElements
  308. /// </remarks>
  309. virtual void ThemeModified(AdUiThemeElement element);
  310. // Bitmap Button routines
  311. enum ImageType
  312. {
  313. kImageType_Undefined,
  314. kImageType_Bitmap,
  315. kImageType_Icon,
  316. kImageType_RCDATA
  317. };
  318. /// <summary>
  319. /// Loads an icon resource to be used as the button image
  320. /// </summary>
  321. /// <param name="strResId">
  322. /// Input resouce ID of the icon
  323. /// </param>
  324. /// <param name="hInst">
  325. /// Input handle of the application or DLL that will provide the resouce.
  326. /// If hInst is NULL, no resource swapping is attempted, otherwise the
  327. /// indicated module's resources will be used to provide the icon.
  328. /// </param>
  329. /// <returns>
  330. /// TRUE if strResId is not empty and the icon is successfully loaded;
  331. /// FALSE Otherwise.
  332. /// </returns>
  333. BOOL LoadIconResource(LPCTSTR strResId, HINSTANCE hInst = NULL);
  334. /// <summary>
  335. /// Loads an RCDATA resource to be used as the button image
  336. /// </summary>
  337. /// <param name="strResId">
  338. /// Input resouce ID of the RCDATA
  339. /// </param>
  340. /// <param name="hInst">
  341. /// Input handle of the application or DLL that will provide the resouce.
  342. /// If hInst is NULL, no resource swapping is attempted, otherwise the
  343. /// indicated module's resources will be used to provide the RCDATA.
  344. /// </param>
  345. /// <returns>
  346. /// TRUE if strResId is not empty and the RCDATA is successfully loaded;
  347. /// FALSE Otherwise.
  348. /// </returns>
  349. BOOL LoadRCDATAResource(LPCTSTR strResId, HINSTANCE hInst = NULL);
  350. BOOL LoadBitmapResource (LPCTSTR strResId, CBitmap& bmp, HINSTANCE hInst = NULL);
  351. virtual BOOL OnLoadBitmap (LPCTSTR strResId);
  352. /// <summary>
  353. /// Clears the image resouces and the cached resource ID if the parameter bClearResId is true.
  354. /// </summary>
  355. /// <param name="bClearResId">
  356. /// Specify if the cached resource ID should be cleared as well
  357. /// </param>
  358. void ClearImages(bool bClearResId = false);
  359. /// <summary>
  360. /// Calculates the size of the image
  361. /// </summary>
  362. void CalcBitmapSize();
  363. /// <summary>
  364. /// Saves the image resource ID and type, and caluclate the size of the image
  365. /// </summary>
  366. /// <param name="strResId">
  367. /// Input resouce ID of the image resource
  368. /// </param>
  369. /// <param name="type">
  370. /// Input type of the image resource
  371. /// </param>
  372. void SaveAndCalcSize(LPCTSTR strResId, ImageType type);
  373. BOOL m_bAutoSizeToBitmap;
  374. CBitmap m_bmp;
  375. void * m_image;
  376. CString m_bmpResId;
  377. int m_bmpHeight;
  378. int m_bmpWidth;
  379. int m_bmpX;
  380. int m_bmpY;
  381. int m_focusRectOffset;
  382. BOOL m_isThemed;
  383. BOOL m_enableThemedHoverState;
  384. BOOL m_enableThemedClickState;
  385. BOOL m_centerImage;
  386. AdUiThemeElement m_backgroundElement;
  387. ImageType m_imageType;
  388. // ClassWizard-controlled
  389. public:
  390. //{{AFX_VIRTUAL(CAdUiBitmapButton)
  391. //}}AFX_VIRTUAL
  392. protected:
  393. //{{AFX_MSG(CAdUiBitmapButton)
  394. //}}AFX_MSG
  395. DECLARE_MESSAGE_MAP()
  396. };
  397. /////////////////////////////////////////////////////////////////////////////
  398. // CAdUiBitmapStatic
  399. class ADUI_PORT CAdUiBitmapStatic : public CAdUiBitmapButton {
  400. DECLARE_DYNAMIC(CAdUiBitmapStatic)
  401. public:
  402. CAdUiBitmapStatic ();
  403. virtual ~CAdUiBitmapStatic ();
  404. // ClassWizard-controlled
  405. public:
  406. //{{AFX_VIRTUAL(CAdUiBitmapStatic)
  407. //}}AFX_VIRTUAL
  408. protected:
  409. //{{AFX_MSG(CAdUiBitmapStatic)
  410. //}}AFX_MSG
  411. DECLARE_MESSAGE_MAP()
  412. };
  413. /////////////////////////////////////////////////////////////////////////////
  414. // CAdUiDropSite
  415. class ADUI_PORT CAdUiDropSite : public CAdUiBitmapStatic {
  416. DECLARE_DYNAMIC(CAdUiDropSite)
  417. public:
  418. CAdUiDropSite ();
  419. virtual ~CAdUiDropSite ();
  420. // ClassWizard-controlled
  421. public:
  422. //{{AFX_VIRTUAL(CAdUiDropSite)
  423. //}}AFX_VIRTUAL
  424. protected:
  425. //{{AFX_MSG(CAdUiDropSite)
  426. //}}AFX_MSG
  427. DECLARE_MESSAGE_MAP()
  428. };
  429. /////////////////////////////////////////////////////////////////////////////
  430. // CAdUiToolButton
  431. class ADUI_PORT CAdUiToolButton : public CAdUiBitmapButton {
  432. DECLARE_DYNAMIC(CAdUiToolButton)
  433. public:
  434. CAdUiToolButton ();
  435. virtual ~CAdUiToolButton ();
  436. // ClassWizard-controlled
  437. public:
  438. //{{AFX_VIRTUAL(CAdUiToolButton)
  439. //}}AFX_VIRTUAL
  440. protected:
  441. //{{AFX_MSG(CAdUiToolButton)
  442. //}}AFX_MSG
  443. DECLARE_MESSAGE_MAP()
  444. };
  445. /////////////////////////////////////////////////////////////////////////////
  446. // CAdUiTrackButton
  447. class ADUI_PORT CAdUiTrackButton : public CAdUiOwnerDrawButton {
  448. DECLARE_DYNAMIC(CAdUiTrackButton)
  449. public:
  450. CAdUiTrackButton();
  451. CAdUiTrackButton(const CAdUiTrackButtonDraw & pDraw);
  452. virtual ~CAdUiTrackButton();
  453. // ClassWizard-controlled
  454. public:
  455. //{{AFX_VIRTUAL(CAdUiTrackButton)
  456. virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  457. //}}AFX_VIRTUAL
  458. /// <summary>
  459. /// Gets the theme used by the track button
  460. /// </summary>
  461. /// <returns>
  462. /// The pointer to the CAdUiTheme instance used by the track button
  463. /// </returns>
  464. virtual CAdUiTheme * GetTheme() const;
  465. /// <summary>
  466. /// Sets the theme to be used by the track button
  467. /// </summary>
  468. /// <param name="pTheme">
  469. /// Input pointer to the CAdUiTheme instance
  470. /// </param>
  471. /// <returns>
  472. /// The current theme used by the track button
  473. /// </returns>
  474. virtual CAdUiTheme * SetTheme(CAdUiTheme *pTheme);
  475. static CAdUiTrackButtonDraw * SetDefaultDraw(CAdUiTrackButtonDraw * pDraw);
  476. CAdUiTrackButtonDraw * SetDraw(CAdUiTrackButtonDraw * pDraw);
  477. virtual void SetTracking(BOOL b);
  478. protected:
  479. virtual void DrawButton(
  480. CDC& dc, int w, int h,
  481. BOOL isDefault,
  482. BOOL isDisabled,
  483. BOOL isSelected,
  484. BOOL isFocused
  485. );
  486. virtual void DrawBorder(CDC *pDC,CRect &r,COLORREF cr);
  487. virtual void DrawHotBorder();
  488. virtual void DrawPushButtonBorder (CDC& dc, CRect& rButton, BOOL isDefault, BOOL isSelected);
  489. virtual void DrawToolButtonBorder (CDC& dc, CRect& rButton, BOOL isSelected, BOOL isFocused);
  490. virtual ADUI_REPLY OnGetTipSupport (CPoint& p);
  491. //{{AFX_MSG(CAdUiTrackButton)
  492. afx_msg void OnNcPaint();
  493. afx_msg void OnPaint();
  494. //}}AFX_MSG
  495. DECLARE_MESSAGE_MAP()
  496. virtual void releaseDraw();
  497. // Implementation
  498. private:
  499. static CAdUiTrackButtonDraw * s_pDefaultDraw;
  500. CAdUiTrackButtonDraw * m_pDraw;
  501. };
  502. class ADUI_PORT CAdUiBitmapTextButton : public CAdUiBitmapButton // Internal Use!
  503. {
  504. friend class CAdUiImpBitmapButton;
  505. DECLARE_DYNAMIC(CAdUiBitmapTextButton)
  506. public:
  507. enum ButtonType
  508. {
  509. kBitmap = 0x1,
  510. kText = 0x2,
  511. };
  512. enum BitmapLocation
  513. {
  514. kLeft = 0x1,
  515. kTop = 0x2,
  516. kRight = 0x4,
  517. kBottom = 0x8,
  518. };
  519. enum ButtonStyle
  520. {
  521. kButtonStyleNone = 0,
  522. kButtonStyleFlat = 0x1,
  523. kButtonStyleCheck = 0x2,
  524. kButtonHCenter = 0x00000300,
  525. kButtonVCenter = 0x00000C00,
  526. };
  527. public:
  528. CAdUiBitmapTextButton();
  529. virtual ~CAdUiBitmapTextButton();
  530. // Owner Draw routines
  531. protected:
  532. virtual void DrawButton(
  533. CDC& dc, int w, int h,
  534. BOOL isDefault,
  535. BOOL isDisabled,
  536. BOOL isSelected,
  537. BOOL isFocused
  538. );
  539. virtual BOOL OnAutoLoad ();
  540. virtual BOOL OnReload (LPCTSTR strResId);
  541. virtual BOOL OnLoadBitmap (LPCTSTR strResId);
  542. public:
  543. BOOL GetAutoSizeToContent ();
  544. void SetAutoSizeToContent (BOOL autoSizeToContent);
  545. void SizeToContent ();
  546. void SetContentOffsets(int nBorderOffset,
  547. int nFocusRectOffset);
  548. UINT GetButtonType();
  549. UINT GetBitmapLocation();
  550. UINT SetButtonType(UINT btnType);
  551. UINT SetBitmapLocation(UINT imgPos);
  552. ButtonStyle GetBitmapTextButtonStyle() const;
  553. void SetBitmapTextButtonStyle(ButtonStyle nBtnStyle);
  554. DECLARE_MESSAGE_MAP()
  555. public:
  556. BOOL GetAutoSizeToBitmap ();
  557. void SetAutoSizeToBitmap (BOOL autoSizeToBitmap);
  558. void SizeToBitmap ();
  559. void SetBitmapOffsets(int nBorderOffset, int nFocusRectOffset);
  560. void SetBkColor(COLORREF);
  561. void SetBorderColor(COLORREF);
  562. void SetCheck(int nCheck);
  563. int GetCheck();
  564. HICON SetIcon(HICON hIcon, BOOL bRedraw = TRUE);
  565. HICON GetIcon() const;
  566. HBITMAP SetBitmap(HBITMAP hBitmap, BOOL bRedraw = TRUE);
  567. HBITMAP GetBitmap() const;
  568. private:
  569. void* mpImpObj;
  570. };
  571. /////////////////////////////////////////////////////////////////////////////
  572. // CAdUiDropDownBitmapButton
  573. /// <summary>
  574. /// CAdUiThemedDropDownBitmapButton is an owner-draw button that incorporates a
  575. /// combobox-like drop-down/pop-up button. The control's display is partitioned
  576. /// between a main button (occupying the left half) and a menu button (on the right).
  577. /// When the control detects a click, the parent will be notified as usual.
  578. /// The parent may inspect the control to determine if the main button or
  579. /// the menu button was clicked. After processing the click notification the
  580. /// parent should call ClearClick() to reset the control's state. The control
  581. /// will send a BN_CLICKED notification when it encounters a Down Arrow key
  582. /// press (similar to the standard combobox keyboard handling).
  583. ///
  584. /// The menu portion of the button can be turned off.
  585. /// </summary>
  586. class ADUI_PORT CAdUiThemedDropDownBitmapButton : public CAdUiBitmapButton
  587. {
  588. DECLARE_DYNAMIC(CAdUiThemedDropDownBitmapButton)
  589. public:
  590. enum
  591. {
  592. BitmapButtonSize = 24,
  593. MenuButtonWidth = 15,
  594. };
  595. CAdUiThemedDropDownBitmapButton();
  596. virtual ~CAdUiThemedDropDownBitmapButton();
  597. /// <summary>
  598. /// Gets if the main button is selected
  599. /// </summary>
  600. /// <returns>
  601. /// TRUE if the main button is selected or FALSE otherwise
  602. /// </returns>
  603. BOOL GetMainButtonSelected ();
  604. /// <summary>
  605. /// Sets if the main button is selected
  606. /// </summary>
  607. /// <param name="selected">
  608. /// TRUE if the main button is selected or FALSE otherwise
  609. /// </param>
  610. void SetMainButtonSelected (BOOL selected);
  611. /// <summary>
  612. /// Gets if the menu button is selected
  613. /// </summary>
  614. /// <returns>
  615. /// TRUE if the menu button is selected or FALSE otherwise
  616. /// </returns>
  617. BOOL GetMenuButtonSelected ();
  618. /// <summary>
  619. /// Sets if the menu button is selected
  620. /// </summary>
  621. /// <param name="selected">
  622. /// TRUE if the menu button is selected or FALSE otherwise
  623. /// </param>
  624. void SetMenuButtonSelected (BOOL selected);
  625. /// <summary>
  626. /// Clears the selection state of both the main button and the menu button
  627. /// </summary>
  628. void ClearClick ();
  629. /// <summary>
  630. /// Gets the width of the menu button
  631. /// </summary>
  632. /// <returns>
  633. /// The menu button width in pixels
  634. /// </returns>
  635. virtual int GetMenuButtonWidth ();
  636. /// <summary>
  637. /// Sets the width of the menu button
  638. /// </summary>
  639. /// <param name="width">
  640. /// The menu button width in pixels
  641. /// </param>
  642. /// <returns>
  643. /// True if successful or false otherwise
  644. /// </returns>
  645. virtual bool SetMenuButtonWidth(int width);
  646. protected:
  647. BOOL m_bMainButtonSelected; //flag whether button part is selected.
  648. BOOL m_bMenuButtonSelected; //flag whether button part is selected.
  649. int m_menuButtonWidth; //menu button width.
  650. protected:
  651. /// <summary>
  652. /// This routine is called from the inherited DrawItem() to handle painting of the control.
  653. /// </summary>
  654. /// <param name="dc">
  655. /// Input device context to draw the control
  656. /// </param>
  657. /// <param name="w">
  658. /// Input width in pixels of the rectangle for the control
  659. /// </param>
  660. /// <param name="h">
  661. /// Input height in pixels of the rectangle for the control
  662. /// </param>
  663. /// <param name="isDefault">
  664. /// Input Boolean indicating whether the control should appear as a default pushbutton
  665. /// </param>
  666. /// <param name="isDisabled">
  667. /// Input Boolean indicating whether the control should appear disabled
  668. /// </param>
  669. /// <param name="isSelected">
  670. /// Input Boolean indicating whether the control should appear selected (in other words, pressed)
  671. /// </param>
  672. /// <param name="isFocused">
  673. /// Input Boolean indicating whether the control should appear to have keyboard focus
  674. /// </param>
  675. virtual void DrawButton(CDC& dc, int w, int h, BOOL isDefault, BOOL isDisabled, BOOL isSelected, BOOL isFocused);
  676. //{{AFX_MSG(CAdUiDropDownBitmapButton)
  677. afx_msg void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags);
  678. afx_msg void OnKillFocus (CWnd *pNewWnd);
  679. afx_msg void OnLButtonDown (UINT nFlags, CPoint point);
  680. afx_msg void OnLButtonUp (UINT nFlags, CPoint point);
  681. afx_msg void OnSysKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags);
  682. //}}AFX_MSG
  683. DECLARE_MESSAGE_MAP()
  684. };
  685. #endif //_ADESK_MAC_
  686. /////////////////////////////////////////////////////////////////////////////
  687. //{{AFX_INSERT_LOCATION}}
  688. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  689. #pragma pack (pop)
  690. #endif
  691. //////////////////////////////////////////////////////////////////////////////