Source code of Windows XP (NT5)
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.

862 lines
29 KiB

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