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.

187 lines
6.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1992 **/
  4. /**********************************************************************/
  5. /*
  6. bltlhour.hxx
  7. The logon hours custom control
  8. FILE HISTORY:
  9. beng 12-May-1992 Created
  10. */
  11. #ifndef _BLTLHOUR_HXX_
  12. #define _BLTLHOUR_HXX_
  13. #include "lhourset.hxx"
  14. #include "string.hxx"
  15. /**********************************************************************
  16. NAME: LOGON_HOURS_CONTROL
  17. SYNOPSIS:
  18. INTERFACE:
  19. LOGON_HOURS_CONTROL() - Ctor
  20. QueryHours() - Query and set the state of the control,
  21. SetHours() using the LOGON_HOURS_SETTING auxclass.
  22. DoPermitButton() - Hook for the dialog.
  23. DoBanButton() - Another hook for the dialog
  24. PARENT: CUSTOM_CONTROL, CONTROL_WINDOW
  25. USES: LOGON_HOURS_SETTING, RESOURCE_STR, XYDIMENSION, XYPOINT
  26. CAVEATS:
  27. NOTES:
  28. HISTORY:
  29. beng 12-May-1992 Created
  30. beng 18-May-1992 Enabled mouse and keyboard handling
  31. **********************************************************************/
  32. DLL_CLASS LOGON_HOURS_CONTROL: public CONTROL_WINDOW, public CUSTOM_CONTROL
  33. {
  34. private:
  35. static const TCHAR * _pszClassName;
  36. HCURSOR _hcurCross; // Used within the grid.
  37. UINT _dyRow; // Size metrics, calc'd in CalcSizes,
  38. UINT _dxFirstColumn; // used all over the place
  39. UINT _dxColumn;
  40. INT _dxLabelFudge;
  41. RESOURCE_STR * _apnlsDayOfWeek[7]; // For button titles
  42. UINT _iButtonDown; // Index (1-based) of which button is depressed.
  43. // 0 = None; 1-7 = Day; 8-31 = Hour; 32 = Corner.
  44. // (Only one can be down at a time, so this works.)
  45. UINT _iWithFocus; // Index, similar to above, but followed by every call,
  46. // of which element within the control has the focus.
  47. // 0 denotes none; 1-32 = buttons; 33-200 = cells,
  48. // moving left to right, top to bottom in the control.
  49. UINT _iFocusSave; // Saves the above while control doesn't have focus
  50. BOOL _fSpaceIsDown; // In the middle of a spacebar sequence
  51. BOOL _fFocusVisible; // Focus rectangle displayed (i.e. needs erase
  52. // in some situations)
  53. BYTE _abSetting[24*7]; // The currently set logon hours. Representation
  54. // is an efficiency compromise between an array of
  55. // 168 full BOOLs and a packed bitfield.
  56. BOOL _fCellsSelected; // Set if some cells are selected
  57. UINT _iCellSelUpper; // Index of selected cell
  58. UINT _iCellSelLower; // If not same as previous, other corner of rect
  59. BOOL _fMouseTrap; // In mid-click-sequence.
  60. BOOL DrawBackground( PAINT_DISPLAY_CONTEXT &dc ) const;
  61. BOOL DrawGridWires( PAINT_DISPLAY_CONTEXT &dc ) const;
  62. BOOL DrawAllButtons( PAINT_DISPLAY_CONTEXT &dc ) const;
  63. VOID DrawOneCornerButton( PAINT_DISPLAY_CONTEXT &dc, const XYRECT &r,
  64. BOOL fDown,
  65. HBRUSH hbrFace,
  66. HPEN hpenShadow, HPEN hpenHlight ) const;
  67. VOID DrawOneFlatButton( PAINT_DISPLAY_CONTEXT &dc, const XYRECT &r,
  68. BOOL fDown,
  69. HBRUSH hbrFace,
  70. HPEN hpenShadow, HPEN hpenHlight ) const;
  71. BOOL DrawGridSetting( PAINT_DISPLAY_CONTEXT &dc ) const;
  72. BOOL DrawOneDayBar( PAINT_DISPLAY_CONTEXT &dc,
  73. INT iRow, INT iColHead, INT iColTail,
  74. HBRUSH hbrBar ) const;
  75. VOID DrawFocusOnCell( const DISPLAY_CONTEXT &dc, INT iCell ) const;
  76. VOID DrawFocusOnDayButton( const DISPLAY_CONTEXT &dc, INT iDay ) const;
  77. VOID DrawFocusOnHourButton( const DISPLAY_CONTEXT &dc, INT iHour ) const;
  78. VOID DrawFocusOnCornerButton( const DISPLAY_CONTEXT &dc ) const;
  79. VOID DrawFocusSomewhere( const DISPLAY_CONTEXT &dc, INT iFocus ) const;
  80. VOID DrawCurrentSelection( const DISPLAY_CONTEXT &dc ) const;
  81. VOID DrawSelectionOnCell( const DISPLAY_CONTEXT &dc, INT iCell ) const;
  82. VOID DrawSelectionOnCells( const DISPLAY_CONTEXT &dc,
  83. INT iFrom, INT iTo ) const;
  84. VOID EraseSelection( const DISPLAY_CONTEXT &dc );
  85. VOID SetSelection( INT iCell );
  86. VOID SetSelection( INT iFrom, INT iTo );
  87. VOID MoveFocusTo( INT iNewFocus );
  88. VOID MoveFocusUp();
  89. VOID MoveFocusDown();
  90. VOID MoveFocusLeft();
  91. VOID MoveFocusRight();
  92. VOID CalcGridRect( XYRECT * pr ) const;
  93. APIERR CalcSizes( XYDIMENSION dxy );
  94. VOID CalcRectForCell( XYRECT * pr, INT iCell ) const;
  95. VOID CalcRectForHour( XYRECT * pr, INT iHour ) const;
  96. VOID CalcRectForDay( XYRECT * pr, INT iDay ) const;
  97. VOID CalcRectForCorner( XYRECT * pr ) const;
  98. INT CalcButtonFromPoint( XYPOINT xy ) const;
  99. APIERR LoadLabels( MSGID idDay0 );
  100. VOID UnloadLabels();
  101. VOID DoButtonDownVisuals();
  102. VOID DoButtonUpVisuals( BOOL fTrigger = TRUE );
  103. VOID DoButtonClick( INT iButton );
  104. VOID SetSelectedCells( BOOL fPermit );
  105. VOID InvalidateButton( INT iButtonOrCell );
  106. VOID Beep() const;
  107. BOOL IsButtonACell( INT iButton ) const;
  108. protected:
  109. virtual BOOL OnPaintReq();
  110. virtual BOOL OnFocus( const FOCUS_EVENT & );
  111. virtual BOOL OnDefocus( const FOCUS_EVENT & );
  112. virtual BOOL OnKeyDown( const VKEY_EVENT & );
  113. virtual BOOL OnKeyUp( const VKEY_EVENT & );
  114. virtual BOOL OnLMouseButtonDown( const MOUSE_EVENT & );
  115. virtual BOOL OnLMouseButtonUp( const MOUSE_EVENT & );
  116. virtual BOOL OnMouseMove( const MOUSE_EVENT & );
  117. virtual BOOL OnQMouseCursor( const QMOUSEACT_EVENT & );
  118. virtual ULONG OnQDlgCode();
  119. virtual ULONG OnQHitTest( const XYPOINT & xy );
  120. virtual ULONG OnQMouseActivate( const QMOUSEACT_EVENT & );
  121. public:
  122. LOGON_HOURS_CONTROL( OWNER_WINDOW *powin, CID cid );
  123. LOGON_HOURS_CONTROL( OWNER_WINDOW *powin, CID cid,
  124. XYPOINT xy, XYDIMENSION dxy );
  125. ~LOGON_HOURS_CONTROL();
  126. APIERR QueryHours( LOGON_HOURS_SETTING * plhours ) const;
  127. APIERR SetHours( const LOGON_HOURS_SETTING * plhours );
  128. // External hooks with which a dialog coordinates this control
  129. // with its Permit and Ban buttons.
  130. VOID DoPermitButton();
  131. VOID DoBanButton();
  132. // subclasses and others can use this to determine the X-position
  133. // in pixels for a particular row separator, 1 <= iRow <= 25
  134. // 1 for left midnight, 13 for noon, 25 for right midnight
  135. UINT QueryXForRow( INT nRow );
  136. };
  137. #endif // _BLTLHOUR_HXX_ - end of file