OptionTreeItemStatic.cpp
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 3k
Category:

Graph program

Development Platform:

Visual C++

  1. // COptionTree
  2. //
  3. // License
  4. // -------
  5. // This code is provided "as is" with no expressed or implied warranty.
  6. // 
  7. // You may use this code in a commercial product with or without acknowledgement.
  8. // However you may not sell this code or any modification of this code, this includes 
  9. // commercial libraries and anything else for profit.
  10. //
  11. // I would appreciate a notification of any bugs or bug fixes to help the control grow.
  12. //
  13. // History:
  14. // --------
  15. // See License.txt for full history information.
  16. //
  17. //
  18. // Copyright (c) 1999-2002 
  19. // ComputerSmarts.net 
  20. // mattrmiller@computersmarts.net
  21. #include "stdafx.h"
  22. #include "OptionTreeItemStatic.h"
  23. // Added Headers
  24. #include "OptionTree.h"
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char THIS_FILE[]=__FILE__;
  28. #define new DEBUG_NEW
  29. #endif
  30. //////////////////////////////////////////////////////////////////////
  31. // Construction/Destruction
  32. //////////////////////////////////////////////////////////////////////
  33. COptionTreeItemStatic::COptionTreeItemStatic()
  34. {
  35. // Initialize variables
  36. m_strStaticText = _T("");
  37. m_dwOptions = NULL;
  38. // Set item type
  39. SetItemType(OT_ITEM_STATIC);
  40. }
  41. COptionTreeItemStatic::~COptionTreeItemStatic()
  42. {
  43. }
  44. void COptionTreeItemStatic::DrawAttribute(CDC *pDC, const RECT &rcRect)
  45. {
  46. // Make sure option is not NULL
  47. if (m_otOption == NULL)
  48. {
  49. return;
  50. }
  51. // Declare variables
  52. HGDIOBJ hOld;
  53. COLORREF crOld;
  54. int nOldBack;
  55. CRect rcText;
  56. COLORREF crOldBack;
  57. // Select font
  58. hOld = pDC->SelectObject(m_otOption->GetNormalFont());
  59. // Set text color
  60. if (IsReadOnly() == TRUE || m_otOption->IsWindowEnabled() == FALSE)
  61. {
  62. crOld = pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
  63. }
  64. else
  65. {
  66. crOld = pDC->SetTextColor(GetTextColor());
  67. }
  68. // Set background mode
  69. nOldBack = pDC->SetBkMode(TRANSPARENT);
  70. // Set background color
  71. crOldBack = pDC->SetBkColor(GetBackgroundColor());
  72. // Get rectangle
  73. rcText = rcRect;
  74. // Draw text
  75. pDC->DrawText(m_strStaticText, rcText, DT_SINGLELINE | DT_VCENTER);
  76. // Restore GDI ojects
  77. pDC->SelectObject(hOld);
  78. pDC->SetTextColor(crOld);
  79. pDC->SetBkMode(nOldBack);
  80. pDC->SetBkColor(crOldBack);
  81. }
  82. CString COptionTreeItemStatic::GetStaticText()
  83. {
  84. // Return text
  85. return m_strStaticText;
  86. }
  87. void COptionTreeItemStatic::SetStaticText(CString strStaticText)
  88. {
  89. // Set variables
  90. m_strStaticText = strStaticText;
  91. }
  92. void COptionTreeItemStatic::CleanDestroyWindow()
  93. {
  94. // Do nothing here
  95. }
  96. void COptionTreeItemStatic::OnCommit()
  97. {
  98. // Do nothing here
  99. }
  100. void COptionTreeItemStatic::OnRefresh()
  101. {
  102. // Do nothing here
  103. }
  104. void COptionTreeItemStatic::OnMove()
  105. {
  106. // Do nothing here
  107. }
  108. void COptionTreeItemStatic::OnActivate()
  109. {
  110. // Do nothing here
  111. }
  112. void COptionTreeItemStatic::OnDeSelect()
  113. {
  114. // Do nothing here
  115. }
  116. void COptionTreeItemStatic::OnSelect()
  117. {
  118. // Do nothing here
  119. }
  120. BOOL COptionTreeItemStatic::GetOption(DWORD dwOption)
  121. {
  122. // Return option
  123. return (m_dwOptions & dwOption) ? TRUE : FALSE;
  124. }
  125. void COptionTreeItemStatic::SetOption(DWORD dwOption, BOOL bSet)
  126. {
  127. // Set option
  128. if (bSet == TRUE)
  129. {
  130. m_dwOptions |= dwOption;
  131. }
  132. else
  133. {
  134. m_dwOptions &= ~dwOption;
  135. }
  136. }
  137. BOOL COptionTreeItemStatic::CreateStaticItem(DWORD dwOptions)
  138. {
  139. // Make sure options is not NULL
  140. if (m_otOption == NULL)
  141. {
  142. return FALSE;
  143. }
  144. // Save options
  145. m_dwOptions = dwOptions;
  146. // Always return TRUE
  147. return TRUE;
  148. }