Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

871 lines
30 KiB

  1. //****************************************************************************
  2. //
  3. // Copyright (c) 1997-2002, Microsoft Corporation
  4. //
  5. // File: SCHEDMAT.H
  6. //
  7. // Definitions for the schedule matrix classes. These classes provide a basic
  8. // schedule matrix control. The classes defined here are:
  9. //
  10. // CMatrixCell A data structure class for the CScheduleMatrix.
  11. // CHourLegend Support window class that draws the matrix legend.
  12. // CPercentLabel Support window class that draws percentage labels.
  13. // CScheduleMatrix A class that displays daily or weekly schedule data.
  14. //
  15. // History:
  16. //
  17. // Scott Walker, SEA 3/10 Created.
  18. //
  19. //****************************************************************************
  20. #ifndef _SCHEDMAT_H_
  21. #define _SCHEDMAT_H_
  22. #if _MSC_VER >= 1000
  23. #pragma once
  24. #endif // _MSC_VER >= 1000
  25. // schedmat.h : header file
  26. //
  27. #include "AccessibleWrapper.h"
  28. #include "log_gmt.h"
  29. // SCHEDMSG_GETSELDESCRIPTION
  30. // wParam - IN size of input buffer in wide-characters, including NULL
  31. // lParam - IN address of pointer to widechar buffer
  32. // - OUT receives description of selected cells
  33. #define SCHEDMSG_GETSELDESCRIPTION WM_APP+1
  34. #define SCHEDMSG_GETPERCENTAGE WM_APP+2
  35. #ifndef UITOOLS_CLASS
  36. #define UITOOLS_CLASS
  37. #endif
  38. // Classes defined in this file
  39. class CMatrixCell;
  40. class CScheduleMatrix;
  41. // Schedule matrix types
  42. #define MT_DAILY 1 // 1x24 matrix
  43. #define MT_WEEKLY 2 // 7x24 matrix
  44. // GetMergeState return codes
  45. #define MS_UNMERGED 0
  46. #define MS_MERGED 1
  47. #define MS_MIXEDMERGE 2
  48. // Matrix notification codes
  49. #define MN_SELCHANGE (WM_USER + 175)
  50. #define ON_MN_SELCHANGE(id, memberFxn) ON_CONTROL(MN_SELCHANGE, id, memberFxn)
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CMatrixCell
  53. #define DEFBACKCOLOR RGB(255,255,255) // White
  54. #define DEFFORECOLOR RGB(0,0,128) // Dark blue
  55. #define DEFBLENDCOLOR RGB(255,255,0) // Yellow
  56. // Cell flags
  57. #define MC_MERGELEFT 0x00000001
  58. #define MC_MERGETOP 0x00000002
  59. #define MC_MERGE 0x00000004
  60. #define MC_LEFTEDGE 0x00000010
  61. #define MC_RIGHTEDGE 0x00000020
  62. #define MC_TOPEDGE 0x00000040
  63. #define MC_BOTTOMEDGE 0x00000080
  64. #define MC_BLEND 0x00000100
  65. #define MC_ALLEDGES (MC_LEFTEDGE | MC_RIGHTEDGE | MC_TOPEDGE | MC_BOTTOMEDGE)
  66. class UITOOLS_CLASS CMatrixCell : public CObject
  67. {
  68. DECLARE_DYNAMIC(CMatrixCell)
  69. friend CScheduleMatrix;
  70. // Construction
  71. public:
  72. CMatrixCell();
  73. virtual ~CMatrixCell();
  74. protected:
  75. COLORREF m_crBackColor;
  76. COLORREF m_crForeColor;
  77. UINT m_nPercentage;
  78. COLORREF m_crBlendColor;
  79. DWORD m_dwUserValue;
  80. LPVOID m_pUserDataPtr;
  81. DWORD m_dwFlags;
  82. };
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CHourLegend window
  85. class UITOOLS_CLASS CHourLegend : public CWnd
  86. {
  87. DECLARE_DYNAMIC(CHourLegend)
  88. friend CScheduleMatrix;
  89. // Construction
  90. public:
  91. CHourLegend();
  92. // Attributes
  93. public:
  94. // Operations
  95. public:
  96. // Overrides
  97. // ClassWizard generated virtual function overrides
  98. //{{AFX_VIRTUAL(CHourLegend)
  99. //}}AFX_VIRTUAL
  100. // Implementation
  101. public:
  102. virtual ~CHourLegend();
  103. protected:
  104. HICON m_hiconSun, m_hiconMoon;
  105. HFONT m_hFont;
  106. int m_nCharHeight, m_nCharWidth;
  107. int m_nCellWidth;
  108. CRect m_rLegend;
  109. // Generated message map functions
  110. protected:
  111. //{{AFX_MSG(CHourLegend)
  112. afx_msg void OnPaint();
  113. //}}AFX_MSG
  114. DECLARE_MESSAGE_MAP()
  115. };
  116. /////////////////////////////////////////////////////////////////////////////
  117. // CPercentLabel window
  118. class UITOOLS_CLASS CPercentLabel : public CWnd
  119. {
  120. DECLARE_DYNAMIC(CPercentLabel)
  121. friend CScheduleMatrix;
  122. // Construction
  123. public:
  124. CPercentLabel();
  125. // Attributes
  126. public:
  127. // Operations
  128. public:
  129. // Overrides
  130. // ClassWizard generated virtual function overrides
  131. //{{AFX_VIRTUAL(CHourLegend)
  132. //}}AFX_VIRTUAL
  133. // Implementation
  134. public:
  135. virtual ~CPercentLabel();
  136. protected:
  137. CScheduleMatrix *m_pMatrix;
  138. HFONT m_hFont;
  139. int m_nCellWidth;
  140. CRect m_rHeader;
  141. CRect m_rLabels;
  142. // Generated message map functions
  143. protected:
  144. //{{AFX_MSG(CPercentLabel)
  145. afx_msg void OnPaint();
  146. //}}AFX_MSG
  147. DECLARE_MESSAGE_MAP()
  148. };
  149. /////////////////////////////////////////////////////////////////////////////
  150. // CScheduleMatrix window
  151. // Schedule matrix command IDs
  152. #define SM_ID_DAYBASE 100
  153. #define SM_ID_ALL (SM_ID_DAYBASE + 0)
  154. #define SM_ID_MONDAY (SM_ID_DAYBASE + 1)
  155. #define SM_ID_TUESDAY (SM_ID_DAYBASE + 2)
  156. #define SM_ID_WEDNESDAY (SM_ID_DAYBASE + 3)
  157. #define SM_ID_THURSDAY (SM_ID_DAYBASE + 4)
  158. #define SM_ID_FRIDAY (SM_ID_DAYBASE + 5)
  159. #define SM_ID_SATURDAY (SM_ID_DAYBASE + 6)
  160. #define SM_ID_SUNDAY (SM_ID_DAYBASE + 7)
  161. #define SM_ID_HOURBASE 110
  162. //****************************************************************************
  163. //
  164. // CLASS: CScheduleMatrix
  165. //
  166. // CScheduleMatrix inplements a basic schedule matrix control. This control
  167. // provides the mechanics of a daily or weekly schedule UI but has no knowledge
  168. // about the data it maintains. The matrix is an array of cells representing
  169. // the hours in a day and optionally the days in a week. The cells can be
  170. // rendered in a variety of ways to represent programmer-defined meaning in
  171. // each cell. The following display properties can be set for individual cells
  172. // or for a block of cells at once:
  173. //
  174. // BackColor Background color of the cell (defaults white).
  175. // ForeColor ForeGround color of the cell (defaults dark blue).
  176. // Percentage Percentage of foreground to background color. This is
  177. // rendered as a histogram in the cell.
  178. // BlendColor 50% dither color on a cell to represent some binary state
  179. // of the cell as compared to another cell (defaults yellow).
  180. // BlendState Specifies whether blend color is showing or not.
  181. //
  182. // A block of cells can be "merged" together to form a discreet block of color
  183. // within the matrix grid. This is useful for schedule applications that want
  184. // to assign a schedule function to a time range. It is the responsibility
  185. // of the program to track these blocks and prevent or resolve any confusion
  186. // from overlapping "merged" blocks.
  187. //
  188. // Each cell can contain two kinds of programmer-defined data that are
  189. // maintained with the cell but not touched by the matrix control: a DWORD
  190. // value and a pointer value. These values can be used to hold data representing
  191. // schedule information for each hour in the matrix.
  192. //
  193. // The parent window receives a notification message (MN_SELCHANGE) whenever the
  194. // user modifies the current selection in the matrix.
  195. //
  196. //?? Later: May add Icon and Text properties per cell.
  197. //
  198. // PUBLIC MEMBERS:
  199. //
  200. // CScheduleMatrix Constructor.
  201. // ~CScheduleMatrix Destructor.
  202. // SetType Sets the matrix type to MT_DAILY or MT_WEEKLY.
  203. // Create Creates the control window.
  204. //
  205. // Selection:
  206. //
  207. // DeselectAll Deselects all cells.
  208. // SelectAll Selects all cells.
  209. // SetSel Selects a block of cells.
  210. // GetSel Gets the current selection.
  211. // GetSelDescription Gets text description of selection range
  212. // CellInSel Tests if a cell is in the current selection
  213. //
  214. // GetCellSize Gets the size of a cell in the current matrix
  215. // DrawCell Draws a sample cell in specified DC
  216. //
  217. // Block Data Functions:
  218. //
  219. // SetBackColor Sets color used to paint cell background.
  220. // SetForeColor Sets color used to paint cell percentage.
  221. // SetPercentage Sets percentage of foreground to background.
  222. // SetBlendColor Sets color blended onto cells.
  223. // SetBlendState Turns blend on or off.
  224. // SetUserValue Sets user defined DWORD value.
  225. // SetUserDataPtr Sets user defined data pointer.
  226. // MergeCells Graphically merges cells so they render as a block.
  227. // UnMergeCells Cancels merging for a block of cells.
  228. // GetMergeState Returns merge state for a block of cells
  229. //
  230. // Cell Data Functions:
  231. //
  232. // GetBackColor Gets the back color of a cell.
  233. // GetForeColor Gets the forecolor of a cell.
  234. // GetPercentage Gets the percentage of foreground to background.
  235. // GetBlendColor Gets the blend color of cell.
  236. // GetBlendState Gets the blend state of a cell.
  237. // GetUserValue Gets the user defined DWORD value of the cell.
  238. // GetUserDataPtr Gets the user defined data pointer of the cell.
  239. //
  240. //============================================================================
  241. //
  242. // CScheduleMatrix::CScheduleMatrix
  243. //
  244. // Constructor. The constructor creates the data structure associated with
  245. // the schedule matrix. As with other CWnd objects, the control itself must
  246. // be instantiated with a call to Create.
  247. //
  248. // Parameters I:
  249. //
  250. // void Default constructor. Constructs a MT_WEEKLY
  251. // schedule matrix.
  252. //
  253. // Parameters II:
  254. //
  255. // DWORD dwType Type constructor. CScheduleMatrix with initial
  256. // type: MT_DAILY or MT_WEEKLY
  257. //
  258. //----------------------------------------------------------------------------
  259. //
  260. // CScheduleMatrix::SetType
  261. //
  262. // Sets the type of the matrix to MT_WEEKLY or MT_DAILY. Call this function
  263. // after construction but before Create.
  264. //
  265. // Parameters:
  266. //
  267. // DWORD dwType Matrix Type: MT_DAILY or MT_WEEKLY
  268. //
  269. //----------------------------------------------------------------------------
  270. //
  271. // CScheduleMatrix::Create
  272. //
  273. // Create initializes the control's window and attaches it to the CScheduleMatrix.
  274. //
  275. // Parameters:
  276. //
  277. // DWORD dwStyle Specifies the window style of the control.
  278. // const RECT& rect Specifies the position and size of the control.
  279. // CWnd* pParentWnd Specifies the parent window of the control.
  280. // UINT nID Specifies the control ID.
  281. //
  282. // Returns:
  283. //
  284. // BOOL bResult TRUE if successful.
  285. //
  286. //----------------------------------------------------------------------------
  287. //
  288. // CScheduleMatrix::DeselectAll
  289. //
  290. // Deselects all cells in the matrix.
  291. //
  292. // Returns:
  293. //
  294. // BOOL bChanged TRUE if selection changes.
  295. //
  296. //----------------------------------------------------------------------------
  297. //
  298. // CScheduleMatrix::SelectAll
  299. //
  300. // Selects all cells in the matrix.
  301. //
  302. // Returns:
  303. //
  304. // BOOL bChanged TRUE if selection changes.
  305. //
  306. //----------------------------------------------------------------------------
  307. //
  308. // CScheduleMatrix::SetSel
  309. //
  310. // Sets the selection to the specified block. The selection is a continuous
  311. // block of cells defined by a starting hour/day pair and extending over a
  312. // range of hours and days.
  313. //
  314. // Parameters:
  315. //
  316. // UINT nHour Starting hour for the selection.
  317. // UINT nDay Starting day for the selection.
  318. // UINT nNumHours Range of selection along the hour axis. (Default=1).
  319. // UINT nNumDays Range of selection along the day axis. (Default=1).
  320. //
  321. // Returns:
  322. //
  323. // BOOL bChanged TRUE if selection changes.
  324. //
  325. //----------------------------------------------------------------------------
  326. //
  327. // CScheduleMatrix::GetSel
  328. //
  329. // Retrieves the current selection.
  330. //
  331. // Parameters:
  332. //
  333. // UINT &nHour Receiver for starting hour for the selection.
  334. // UINT &nDay Receiver for starting day for the selection.
  335. // UINT &nNumHours Receiver for range of selection along the hour axis.
  336. // UINT &nNumDays Receiver for range of selection along the day axis.
  337. //
  338. //----------------------------------------------------------------------------
  339. //
  340. // CScheduleMatrix::GetDescription
  341. //
  342. // Returns a textual description of the specified block of cells. This is useful
  343. // for applications that wish to provide feedback about merged or grouped blocks
  344. // in the matrix.
  345. //
  346. // Parameters:
  347. //
  348. // CString &sText Receiver for description text.
  349. // UINT nHour Starting hour for the block.
  350. // UINT nDay Starting day for the block.
  351. // UINT nNumHours Range of block along the hour axis. (Default=1).
  352. // UINT nNumDays Range of block along the day axis. (Default=1).
  353. //
  354. //
  355. //----------------------------------------------------------------------------
  356. //
  357. // CScheduleMatrix::GetSelDescription
  358. //
  359. // Returns a textual description of the current selection. This is useful for
  360. // applications that wish to provide feedback about the selection.
  361. //
  362. // Parameters:
  363. //
  364. // CString &sText Receiver for description text.
  365. //
  366. //----------------------------------------------------------------------------
  367. //
  368. // CScheduleMatrix::CellInSel
  369. //
  370. // Returns TRUE if the specified cell is selected (i.e. is in the block of
  371. // selected cells).
  372. //
  373. // Parameters:
  374. //
  375. // UINT nHour Hour position of the cell.
  376. // UINT nDay Day position of the cell.
  377. //
  378. // Returns:
  379. //
  380. // BOOL bSelected TRUE if cell is selected.
  381. //
  382. //----------------------------------------------------------------------------
  383. //
  384. // CScheduleMatrix::GetCellSize
  385. //
  386. // Returns the size of a cell in the current matrix. This function may be used
  387. // in conjunction with DrawCell (below) to render a sample cell for a legend.
  388. //
  389. // Returns:
  390. //
  391. // CSize size Size of the cell.
  392. //
  393. //----------------------------------------------------------------------------
  394. //
  395. // CScheduleMatrix::DrawCell
  396. //
  397. // Renders a cell with the specified properties. Use this function to create
  398. // a legend defining the cell states in the matrix. The cell is drawn as a
  399. // histogram with the specified background and foreground colors in a proportion
  400. // specified by the percentage. If blend state is TRUE, the blend color is
  401. // blended in with a 50% dither on top of the foreground and background.
  402. //
  403. // Parameters:
  404. //
  405. // CDC *pdc Display context to draw into.
  406. // LPCRECT pRect Cell boundaries in the specified DC.
  407. // UINT nPercent Percentage if foreground to background color.
  408. // BOOL bBlendState Draw blend dither if TRUE (Default = FALSE).
  409. // COLORREF crBackColor Background color (Default = DEFBACKCOLOR).
  410. // COLORREF crForeColor Foreground color (Default = DEFFORECOLOR).
  411. // COLORREF crBlendColor Blend color (Default = DEFBLENDCOLOR).
  412. //
  413. //----------------------------------------------------------------------------
  414. //
  415. // CScheduleMatrix::SetBackColor
  416. //
  417. // Sets the background color for the specified block of cells.
  418. //
  419. // Parameters:
  420. //
  421. // COLORREF crColor New color property for the block of cells.
  422. // UINT nHour Starting hour for the block.
  423. // UINT nDay Starting day for the block.
  424. // UINT nNumHours Range of block along the hour axis. (Default=1).
  425. // UINT nNumDays Range of block along the day axis. (Default=1).
  426. //
  427. //----------------------------------------------------------------------------
  428. //
  429. // CScheduleMatrix::SetForeColor
  430. //
  431. // Sets the foreground color for the specified block of cells.
  432. //
  433. // Parameters:
  434. //
  435. // COLORREF crColor New color property for the block of cells.
  436. // UINT nHour Starting hour for the block.
  437. // UINT nDay Starting day for the block.
  438. // UINT nNumHours Range of block along the hour axis. (Default=1).
  439. // UINT nNumDays Range of block along the day axis. (Default=1).
  440. //
  441. //----------------------------------------------------------------------------
  442. //
  443. // CScheduleMatrix::SetPercentage
  444. //
  445. // Sets the percentage of foreground to background color for the specified block
  446. // of cells. This percentage is rendered as a histogram of one color to the
  447. // other with foreground color on the bottom.
  448. //
  449. // Parameters:
  450. //
  451. // UINT nPercent Percentage of foreground to background color.
  452. // UINT nHour Starting hour for the block.
  453. // UINT nDay Starting day for the block.
  454. // UINT nNumHours Range of block along the hour axis. (Default=1).
  455. // UINT nNumDays Range of block along the day axis. (Default=1).
  456. //
  457. //----------------------------------------------------------------------------
  458. //
  459. // CScheduleMatrix::SetBlendColor
  460. //
  461. // Sets the blend color for the specified block of cells. Blend color is
  462. // overlayed in a 50% dither pattern on the foreground and background colors
  463. // of the cells.
  464. //
  465. // Parameters:
  466. //
  467. // COLORREF crColor New color property for the block of cells.
  468. // UINT nHour Starting hour for the block.
  469. // UINT nDay Starting day for the block.
  470. // UINT nNumHours Range of block along the hour axis. (Default=1).
  471. // UINT nNumDays Range of block along the day axis. (Default=1).
  472. //
  473. //----------------------------------------------------------------------------
  474. //
  475. // CScheduleMatrix::SetBlendState
  476. //
  477. // If blend state is TRUE for a block of cells, then the blend color is applied
  478. // in a 50% dither pattern.
  479. //
  480. // Parameters:
  481. //
  482. // BOOL bState Apply blend if TRUE.
  483. // UINT nHour Starting hour for the block.
  484. // UINT nDay Starting day for the block.
  485. // UINT nNumHours Range of block along the hour axis. (Default=1).
  486. // UINT nNumDays Range of block along the day axis. (Default=1).
  487. //
  488. //----------------------------------------------------------------------------
  489. //
  490. // CScheduleMatrix::SetUserValue
  491. //
  492. // Store a user-defined DWORD with each cell in the block.
  493. //
  494. // Parameters:
  495. //
  496. // DWORD dwValue User-defined value to store.
  497. // UINT nHour Starting hour for the block.
  498. // UINT nDay Starting day for the block.
  499. // UINT nNumHours Range of block along the hour axis. (Default=1).
  500. // UINT nNumDays Range of block along the day axis. (Default=1).
  501. //
  502. //----------------------------------------------------------------------------
  503. //
  504. // CScheduleMatrix::SetUserDataPtr
  505. //
  506. // Store a user-defined pointer with each cell in the block.
  507. //
  508. // Parameters:
  509. //
  510. // LPVOID lpData User-defined pointer to store.
  511. // UINT nHour Starting hour for the block.
  512. // UINT nDay Starting day for the block.
  513. // UINT nNumHours Range of block along the hour axis. (Default=1).
  514. // UINT nNumDays Range of block along the day axis. (Default=1).
  515. //
  516. //----------------------------------------------------------------------------
  517. //
  518. // CScheduleMatrix::MergeCells
  519. //
  520. // Visually merges the specified block of cells to give them the appearance
  521. // of a contiguous block. A merged block of cells does not contain the grid
  522. // lines that normally separate each cell. Use this function to create
  523. // block areas that represent an event in the schedule. Note that merged
  524. // blocks do not actually become a managed object in the matrix and that it
  525. // is therefore possible to merge a block of cells that intersects a
  526. // previously merged block. It is the application's responsibility to track
  527. // these blocks and prevent or resolve any confusion from overlapping "merged"
  528. // blocks.
  529. //
  530. // Parameters:
  531. //
  532. // UINT nHour Starting hour for the block.
  533. // UINT nDay Starting day for the block.
  534. // UINT nNumHours Range of block along the hour axis. (Default=1).
  535. // UINT nNumDays Range of block along the day axis. (Default=1).
  536. //
  537. //----------------------------------------------------------------------------
  538. //
  539. // CScheduleMatrix::UnMergeCells
  540. //
  541. // Removes the merge effect imposed by MergeCells.
  542. //
  543. // Parameters:
  544. //
  545. // UINT nHour Starting hour for the block.
  546. // UINT nDay Starting day for the block.
  547. // UINT nNumHours Range of block along the hour axis. (Default=1).
  548. // UINT nNumDays Range of block along the day axis. (Default=1).
  549. //
  550. //----------------------------------------------------------------------------
  551. //
  552. // CScheduleMatrix::GetMergeState
  553. //
  554. // Retrieves the merge state of the specified block of cells. A block can
  555. // have one of the following merge states:
  556. //
  557. // MS_UNMERGED No cell in the specified block is merged.
  558. // MS_MERGED All cells in the specified block have been merged and
  559. // in fact represent a "perfect" merge, i.e. all edges
  560. // of the merged block have been accounted for. An
  561. // incomplete part of a merged block returns MS_MIXEDMERGE.
  562. // MS_MIXEDMERGE The specified block is a mixture of merged and unmerged
  563. // cells or an incomplete portion of a merged block has
  564. // been specified.
  565. //
  566. // Parameters:
  567. //
  568. // UINT nHour Starting hour for the block.
  569. // UINT nDay Starting day for the block.
  570. // UINT nNumHours Range of block along the hour axis. (Default=1).
  571. // UINT nNumDays Range of block along the day axis. (Default=1).
  572. //
  573. // Returns:
  574. //
  575. // UINT nState MS_UNMERGED, MS_MERGED, or MS_MIXEDMERGE.
  576. //
  577. //----------------------------------------------------------------------------
  578. //
  579. // CScheduleMatrix::GetBackColor
  580. //
  581. // Retrieves the background color of the specified cell.
  582. //
  583. // Parameters:
  584. //
  585. // UINT nHour Hour position of the cell.
  586. // UINT nDay Day position of the cell.
  587. //
  588. // Returns:
  589. //
  590. // COLORREF crColor Current color property for the cell.
  591. //
  592. //----------------------------------------------------------------------------
  593. //
  594. // CScheduleMatrix::GetForeColor
  595. //
  596. // Retrieves the foreground color of the specified cell.
  597. //
  598. // Parameters:
  599. //
  600. // UINT nHour Hour position of the cell.
  601. // UINT nDay Day position of the cell.
  602. //
  603. // Returns:
  604. //
  605. // COLORREF crColor Current color property for the cell.
  606. //
  607. //----------------------------------------------------------------------------
  608. //
  609. // CScheduleMatrix::GetPercentage
  610. //
  611. // Retrieves the percentage of foreground to background color in the specified
  612. // cell.
  613. //
  614. // Parameters:
  615. //
  616. // UINT nHour Hour position of the cell.
  617. // UINT nDay Day position of the cell.
  618. //
  619. // Returns:
  620. //
  621. // UINT nPercent Current percentage of foreground to background.
  622. //
  623. //----------------------------------------------------------------------------
  624. //
  625. // CScheduleMatrix::GetBlendColor
  626. //
  627. // Retrieves the blend color of the specified cell.
  628. //
  629. // Parameters:
  630. //
  631. // UINT nHour Hour position of the cell.
  632. // UINT nDay Day position of the cell.
  633. //
  634. // Returns:
  635. //
  636. // COLORREF crColor Current color property for the cell.
  637. //
  638. //----------------------------------------------------------------------------
  639. //
  640. // CScheduleMatrix::GetBlendState
  641. //
  642. // Retrieves the blend state of the specified cell. If blend state is TRUE,
  643. // the cell is currently being rendered with a 50% blend on top of the foreground
  644. // and background colors.
  645. //
  646. // Parameters:
  647. //
  648. // UINT nHour Hour position of the cell.
  649. // UINT nDay Day position of the cell.
  650. //
  651. // Returns:
  652. //
  653. // BOOL bState TRUE if blend is turned on for this cell.
  654. //
  655. //----------------------------------------------------------------------------
  656. //
  657. // CScheduleMatrix::GetUserValue
  658. //
  659. // Returns the user-defined DWORD value associated with the specified cell.
  660. //
  661. // Parameters:
  662. //
  663. // UINT nHour Hour position of the cell.
  664. // UINT nDay Day position of the cell.
  665. //
  666. // Returns:
  667. //
  668. // DWORD dwValue User-defined DWORD value.
  669. //
  670. //----------------------------------------------------------------------------
  671. //
  672. // CScheduleMatrix::GetUserDataPtr
  673. //
  674. // Returns the user-defined data pointer associated with the specified cell.
  675. //
  676. // Parameters:
  677. //
  678. // UINT nHour Hour position of the cell.
  679. // UINT nDay Day position of the cell.
  680. //
  681. // Returns:
  682. //
  683. // LPVOID lpData User-defined pointer.
  684. //
  685. //----------------------------------------------------------------------------
  686. //
  687. // CScheduleMatrix::~CScheduleMatrix
  688. //
  689. // Destructor.
  690. //
  691. //****************************************************************************
  692. class UITOOLS_CLASS CScheduleMatrix : public CWnd
  693. {
  694. DECLARE_DYNAMIC(CScheduleMatrix)
  695. // Construction
  696. public:
  697. CScheduleMatrix();
  698. CScheduleMatrix(UINT nType);
  699. // Attributes
  700. public:
  701. // Operations
  702. public:
  703. // Overrides
  704. // ClassWizard generated virtual function overrides
  705. //{{AFX_VIRTUAL(CScheduleMatrix)
  706. public:
  707. //}}AFX_VIRTUAL
  708. virtual BOOL Create(LPCTSTR lpszWindowName, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
  709. // Implementation
  710. public:
  711. void SetType(UINT nType);
  712. BOOL DeselectAll();
  713. BOOL SelectAll();
  714. BOOL SetSel(UINT nHour, UINT nDay, UINT nNumHours, UINT nNumDays);
  715. void GetSel(UINT& nHour, UINT& nDay, UINT& nNumHours, UINT& nNumDays);
  716. void GetSelDescription(CString &sText);
  717. BOOL CellInSel(UINT nHour, UINT nDay);
  718. CSize GetCellSize();
  719. void DrawCell(CDC *pdc, LPCRECT pRect, UINT nPercent, BOOL bBlendState = FALSE,
  720. COLORREF crBackColor = DEFBACKCOLOR, COLORREF crForeColor = DEFFORECOLOR,
  721. COLORREF crBlendColor = DEFBLENDCOLOR);
  722. void SetBackColor(COLORREF crColor, UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  723. void SetForeColor(COLORREF crColor, UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  724. void SetPercentage(UINT nPercent, UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  725. void SetBlendColor(COLORREF crColor, UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  726. void SetBlendState(BOOL bState, UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  727. void SetUserValue(DWORD dwValue, UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  728. void SetUserDataPtr(LPVOID lpData, UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  729. void MergeCells(UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  730. void UnMergeCells(UINT nHour, UINT nDay, UINT nNumHours, UINT nNumDays=1);
  731. UINT GetMergeState(UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  732. COLORREF GetBackColor(UINT nHour, UINT nDay);
  733. COLORREF GetForeColor(UINT nHour, UINT nDay);
  734. UINT GetPercentage(UINT nHour, UINT nDay);
  735. COLORREF GetBlendColor(UINT nHour, UINT nDay);
  736. BOOL GetBlendState(UINT nHour, UINT nDay);
  737. DWORD GetUserValue(UINT nHour, UINT nDay);
  738. LPVOID GetUserDataPtr(UINT nHour, UINT nDay);
  739. void GetDescription(CString &sText, UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1);
  740. virtual ~CScheduleMatrix();
  741. protected:
  742. CHourLegend m_HourLegend;
  743. CPercentLabel m_PercentLabel;
  744. UINT m_nType;
  745. // Data
  746. CMatrixCell m_CellArray[24][7];
  747. // Metrics
  748. UINT m_nCellWidth;
  749. UINT m_nCellHeight;
  750. CRect m_rHourLegend;
  751. CRect m_rAllHeader;
  752. CRect m_rHourHeader;
  753. CRect m_rDayHeader;
  754. CRect m_rCellArray;
  755. CRect m_rPercentLabel;
  756. CString m_DayStrings[8];
  757. // Selection
  758. UINT m_nSelHour, m_nSelDay, m_nNumSelHours, m_nNumSelDays;
  759. UINT m_nSaveHour, m_nSaveDay, m_nNumSaveHours, m_nNumSaveDays;
  760. // Work vars
  761. CBrush m_brBlend, m_brMask;
  762. CBitmap m_bmBlend, m_bmMask;
  763. HFONT m_hFont;
  764. CPoint m_ptDown, m_ptFocus;
  765. BOOL m_bShifted;
  766. // Generated message map functions
  767. protected:
  768. CString FormatTime (UINT nHour) const;
  769. //{{AFX_MSG(CScheduleMatrix)
  770. afx_msg void OnSize(UINT nType, int cx, int cy);
  771. afx_msg void OnPaint();
  772. afx_msg void OnSetFocus(CWnd* pOldWnd);
  773. afx_msg void OnKillFocus(CWnd* pNewWnd);
  774. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  775. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  776. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  777. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  778. afx_msg UINT OnGetDlgCode();
  779. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  780. afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  781. //}}AFX_MSG
  782. afx_msg LRESULT OnSetFont( WPARAM wParam, LPARAM lParam);
  783. afx_msg LRESULT OnGetFont( WPARAM wParam, LPARAM lParam);
  784. afx_msg LRESULT OnGetObject (WPARAM wParam, LPARAM lParam);
  785. afx_msg LRESULT OnGetSelDescription (WPARAM wParam, LPARAM lParam);
  786. afx_msg LRESULT OnGetPercentage (WPARAM wParam, LPARAM lParam);
  787. BOOL SetSelValues(UINT nHour, UINT nDay, UINT nNumHours, UINT nNumDays);
  788. void InvalidateCells(UINT nHour, UINT nDay, UINT nNumHours=1, UINT nNumDays=1,
  789. BOOL bErase = TRUE);
  790. void SetMatrixMetrics(int cx, int cy);
  791. void CellToClient(LONG &nX, LONG &nY);
  792. void ClientToCell(LONG &nX, LONG &nY);
  793. void DrawCell(CDC *pdc, CMatrixCell *pCell, int x, int y, int w, int h);
  794. void DrawHeader(CDC *pdc, LPCRECT lpRect, LPCTSTR pszText, BOOL bSelected);
  795. void Press(CPoint pt, BOOL bExtend);
  796. void Extend(CPoint pt);
  797. void Release(CPoint pt);
  798. DECLARE_MESSAGE_MAP()
  799. private:
  800. CString GetLocaleDay (LCTYPE lcType) const;
  801. IAccessible * m_pWrapAcc;
  802. };
  803. /////////////////////////////////////////////////////////////////////////////
  804. /////////////////////////////////////////////////////////////////////////////
  805. //{{AFX_INSERT_LOCATION}}
  806. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  807. #endif // _SCHEDMAT_H_