doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PropTreeItemButton.cpp
Go to the documentation of this file.
1 // PropTreeItemButton.cpp : implementation file
2 //
3 // Copyright (C) 1998-2001 Scott Ramsay
4 // sramsay@gonavi.com
5 // http://www.gonavi.com
6 //
7 // This material is provided "as is", with absolutely no warranty expressed
8 // or implied. Any use is at your own risk.
9 //
10 // Permission to use or copy this software for any purpose is hereby granted
11 // without fee, provided the above notices are retained on all copies.
12 // Permission to modify the code and to distribute modified code is granted,
13 // provided the above notices are retained, and a notice that the code was
14 // modified is included with the above copyright notice.
15 //
16 // If you use this code, drop me an email. I'd like to know if you find the code
17 // useful.
18 
19 //#include "stdafx.h"
20 #include "../../../idlib/precompiled.h"
21 #pragma hdrstop
22 
23 #include "proptree.h"
24 #include "PropTreeItemButton.h"
25 
26 #ifdef _DEBUG
27 #define new DEBUG_NEW
28 #undef THIS_FILE
29 static char THIS_FILE[] = __FILE__;
30 #endif
31 
32 #define BUTTON_SIZE 17
33 
35 // CPropTreeItemButton
36 
38  mouseDown = false;
39 }
40 
42 }
43 
44 
46 // CPropTreeItemButton message handlers
47 
48 LONG CPropTreeItemButton::DrawItem( CDC* pDC, const RECT& rc, LONG x, LONG y )
49 {
50  CSize textSize;
51  CRect textRect;
52  LONG nTotal = 0;
53 
54  nTotal = CPropTreeItem::DrawItem( pDC, rc, x, y );
55 
56  textSize = pDC->GetOutputTextExtent( buttonText );
57 
58  buttonRect.left = m_rc.right - ( textSize.cx + 12 + 4);
59  buttonRect.top = m_rc.top + ((m_rc.bottom - m_rc.top)/2)-BUTTON_SIZE/2;
60  buttonRect.right = buttonRect.left + textSize.cx + 12;
61  buttonRect.bottom = buttonRect.top + BUTTON_SIZE;
62 
63  UINT buttonStyle;
64 
65  if ( (m_dwState & TreeItemChecked) ) {
66  buttonStyle = DFCS_BUTTONPUSH | DFCS_PUSHED;
67  } else {
68  buttonStyle = DFCS_BUTTONPUSH;
69  }
70  pDC->DrawFrameControl(&buttonRect, DFC_BUTTON, buttonStyle );
71 
72  textRect = buttonRect;
73  textRect.left += 4;
74  textRect.right -= 8;
75  pDC->DrawText( buttonText, textRect, DT_SINGLELINE|DT_VCENTER );
76 
77  //Adjust hit test rect to acount for window scrolling
79  hitTestRect.OffsetRect(0, m_pProp->GetOrigin().y);
80 
81  return nTotal;
82 }
83 
84 void CPropTreeItemButton::DrawAttribute(CDC* pDC, const RECT& rc) {
85 }
86 
87 
89  return (LPARAM)0;
90 }
91 
92 
94 }
95 
96 
98  return hitTestRect.PtInRect( pt );
99 }
100 
102  buttonText = text;
103 }
const POINT & GetOrigin()
Definition: PropTree.cpp:124
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
virtual BOOL HitButton(const POINT &pt)
virtual LONG DrawItem(CDC *pDC, const RECT &rc, LONG x, LONG y)
GLenum GLint GLint y
Definition: glext.h:2849
#define BUTTON_SIZE
virtual LPARAM GetItemValue()
GLenum GLint x
Definition: glext.h:2849
#define BOOL
Definition: mprintf.c:71
virtual void SetItemValue(LPARAM lParam)
CPropTree * m_pProp
Definition: PropTreeItem.h:147
long LONG
virtual LONG DrawItem(CDC *pDC, const RECT &rc, LONG x, LONG y)
void SetButtonText(LPCSTR text)
virtual void DrawAttribute(CDC *pDC, const RECT &rc)