4 #include "PropertiesWnd.h"
\r
5 #include "Resource.h"
\r
7 #include "TortoiseGitBlame.h"
\r
11 static char THIS_FILE[]=__FILE__;
\r
12 #define new DEBUG_NEW
\r
15 /////////////////////////////////////////////////////////////////////////////
\r
18 CPropertiesWnd::CPropertiesWnd()
\r
22 CPropertiesWnd::~CPropertiesWnd()
\r
26 BEGIN_MESSAGE_MAP(CPropertiesWnd, CDockablePane)
\r
29 ON_COMMAND(ID_EXPAND_ALL, OnExpandAllProperties)
\r
30 ON_UPDATE_COMMAND_UI(ID_EXPAND_ALL, OnUpdateExpandAllProperties)
\r
31 ON_COMMAND(ID_SORTPROPERTIES, OnSortProperties)
\r
32 ON_UPDATE_COMMAND_UI(ID_SORTPROPERTIES, OnUpdateSortProperties)
\r
33 ON_COMMAND(ID_PROPERTIES1, OnProperties1)
\r
34 ON_UPDATE_COMMAND_UI(ID_PROPERTIES1, OnUpdateProperties1)
\r
35 ON_COMMAND(ID_PROPERTIES2, OnProperties2)
\r
36 ON_UPDATE_COMMAND_UI(ID_PROPERTIES2, OnUpdateProperties2)
\r
38 ON_WM_SETTINGCHANGE()
\r
41 /////////////////////////////////////////////////////////////////////////////
\r
42 // CResourceViewBar message handlers
\r
44 void CPropertiesWnd::AdjustLayout()
\r
46 if (GetSafeHwnd() == NULL)
\r
51 CRect rectClient,rectCombo;
\r
52 GetClientRect(rectClient);
\r
54 m_wndObjectCombo.GetWindowRect(&rectCombo);
\r
56 int cyCmb = rectCombo.Size().cy;
\r
57 int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy;
\r
59 m_wndObjectCombo.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), 200, SWP_NOACTIVATE | SWP_NOZORDER);
\r
60 m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER);
\r
61 m_wndPropList.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb + cyTlb, rectClient.Width(), rectClient.Height() -(cyCmb+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER);
\r
64 int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
\r
66 if (CDockablePane::OnCreate(lpCreateStruct) == -1)
\r
70 rectDummy.SetRectEmpty();
\r
73 const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
\r
75 if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1))
\r
77 TRACE0("Failed to create Properties Combo \n");
\r
78 return -1; // fail to create
\r
81 m_wndObjectCombo.AddString(_T("Application"));
\r
82 m_wndObjectCombo.AddString(_T("Properties Window"));
\r
83 m_wndObjectCombo.SetFont(CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)));
\r
84 m_wndObjectCombo.SetCurSel(0);
\r
86 if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2))
\r
88 TRACE0("Failed to create Properties Grid \n");
\r
89 return -1; // fail to create
\r
94 m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES);
\r
95 m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* Is locked */);
\r
96 m_wndToolBar.CleanUpLockedImages();
\r
97 m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROPERTIES_HC : IDR_PROPERTIES, 0, 0, TRUE /* Locked */);
\r
99 m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
\r
100 m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
\r
101 m_wndToolBar.SetOwner(this);
\r
103 // All commands will be routed via this control , not via the parent frame:
\r
104 m_wndToolBar.SetRouteCommandsViaFrame(FALSE);
\r
110 void CPropertiesWnd::OnSize(UINT nType, int cx, int cy)
\r
112 CDockablePane::OnSize(nType, cx, cy);
\r
116 void CPropertiesWnd::OnExpandAllProperties()
\r
118 m_wndPropList.ExpandAll();
\r
121 void CPropertiesWnd::OnUpdateExpandAllProperties(CCmdUI* pCmdUI)
\r
125 void CPropertiesWnd::OnSortProperties()
\r
127 m_wndPropList.SetAlphabeticMode(!m_wndPropList.IsAlphabeticMode());
\r
130 void CPropertiesWnd::OnUpdateSortProperties(CCmdUI* pCmdUI)
\r
132 pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode());
\r
135 void CPropertiesWnd::OnProperties1()
\r
137 // TODO: Add your command handler code here
\r
140 void CPropertiesWnd::OnUpdateProperties1(CCmdUI* /*pCmdUI*/)
\r
142 // TODO: Add your command update UI handler code here
\r
145 void CPropertiesWnd::OnProperties2()
\r
147 // TODO: Add your command handler code here
\r
150 void CPropertiesWnd::OnUpdateProperties2(CCmdUI* /*pCmdUI*/)
\r
152 // TODO: Add your command update UI handler code here
\r
155 void CPropertiesWnd::InitPropList()
\r
159 m_wndPropList.EnableHeaderCtrl(FALSE);
\r
160 m_wndPropList.EnableDescriptionArea();
\r
161 m_wndPropList.SetVSDotNetLook();
\r
162 m_wndPropList.MarkModifiedProperties();
\r
164 CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("Appearance"));
\r
166 pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("3D Look"), (_variant_t) false, _T("Specifies the window's font will be non-bold and controls will have a 3D border")));
\r
168 CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Border"), _T("Dialog Frame"), _T("One of: None, Thin, Resizable, or Dialog Frame"));
\r
169 pProp->AddOption(_T("None"));
\r
170 pProp->AddOption(_T("Thin"));
\r
171 pProp->AddOption(_T("Resizable"));
\r
172 pProp->AddOption(_T("Dialog Frame"));
\r
173 pProp->AllowEdit(FALSE);
\r
175 pGroup1->AddSubItem(pProp);
\r
176 pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Caption"), (_variant_t) _T("About"), _T("Specifies the text that will be displayed in the window's title bar")));
\r
178 m_wndPropList.AddProperty(pGroup1);
\r
180 CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("Window Size"), 0, TRUE);
\r
182 pProp = new CMFCPropertyGridProperty(_T("Height"), (_variant_t) 250l, _T("Specifies the window's height"));
\r
183 pProp->EnableSpinControl(TRUE, 0, 1000);
\r
184 pSize->AddSubItem(pProp);
\r
186 pProp = new CMFCPropertyGridProperty( _T("Width"), (_variant_t) 150l, _T("Specifies the window's width"));
\r
187 pProp->EnableSpinControl();
\r
188 pSize->AddSubItem(pProp);
\r
190 m_wndPropList.AddProperty(pSize);
\r
192 CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("Font"));
\r
195 CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
\r
196 font->GetLogFont(&lf);
\r
198 lstrcpy(lf.lfFaceName, _T("Arial"));
\r
200 pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the window")));
\r
201 pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("Use System Font"), (_variant_t) true, _T("Specifies that the window uses MS Shell Dlg font")));
\r
203 m_wndPropList.AddProperty(pGroup2);
\r
205 CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("Misc"));
\r
206 pProp = new CMFCPropertyGridProperty(_T("(Name)"), _T("Application"));
\r
207 pProp->Enable(FALSE);
\r
208 pGroup3->AddSubItem(pProp);
\r
210 CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default window color"));
\r
211 pColorProp->EnableOtherButton(_T("Other..."));
\r
212 pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE));
\r
213 pGroup3->AddSubItem(pColorProp);
\r
215 static TCHAR BASED_CODE szFilter[] = _T("Icon Files(*.ico)|*.ico|All Files(*.*)|*.*||");
\r
216 pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the window icon")));
\r
218 pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Folder"), _T("c:\\")));
\r
220 m_wndPropList.AddProperty(pGroup3);
\r
222 CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("Hierarchy"));
\r
224 CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("First sub-level"));
\r
225 pGroup4->AddSubItem(pGroup41);
\r
227 CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("Second sub-level"));
\r
228 pGroup41->AddSubItem(pGroup411);
\r
230 pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 1"), (_variant_t) _T("Value 1"), _T("This is a description")));
\r
231 pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 2"), (_variant_t) _T("Value 2"), _T("This is a description")));
\r
232 pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 3"), (_variant_t) _T("Value 3"), _T("This is a description")));
\r
234 pGroup4->Expand(FALSE);
\r
235 m_wndPropList.AddProperty(pGroup4);
\r
238 void CPropertiesWnd::OnSetFocus(CWnd* pOldWnd)
\r
240 CDockablePane::OnSetFocus(pOldWnd);
\r
241 m_wndPropList.SetFocus();
\r
244 void CPropertiesWnd::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
\r
246 CDockablePane::OnSettingChange(uFlags, lpszSection);
\r
250 void CPropertiesWnd::SetPropListFont()
\r
252 ::DeleteObject(m_fntPropList.Detach());
\r
255 afxGlobalData.fontRegular.GetLogFont(&lf);
\r
257 NONCLIENTMETRICS info;
\r
258 info.cbSize = sizeof(info);
\r
260 afxGlobalData.GetNonClientMetrics(info);
\r
262 lf.lfHeight = info.lfMenuFont.lfHeight;
\r
263 lf.lfWeight = info.lfMenuFont.lfWeight;
\r
264 lf.lfItalic = info.lfMenuFont.lfItalic;
\r
266 m_fntPropList.CreateFontIndirect(&lf);
\r
268 m_wndPropList.SetFont(&m_fntPropList);
\r