OSDN Git Service

Add Show Whole Project Button at commitDialog
[tortoisegit/TortoiseGitJp.git] / ext / ResizableLib / ResizableSheetState.cpp
1 /////////////////////////////////////////////////////////////////////////////\r
2 //\r
3 // This file is part of ResizableLib\r
4 // http://sourceforge.net/projects/resizablelib\r
5 //\r
6 // Copyright (C) 2000-2004 by Paolo Messina\r
7 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com\r
8 //\r
9 // The contents of this file are subject to the Artistic License (the "License").\r
10 // You may not use this file except in compliance with the License. \r
11 // You may obtain a copy of the License at:\r
12 // http://www.opensource.org/licenses/artistic-license.html\r
13 //\r
14 // If you find this code useful, credits would be nice!\r
15 //\r
16 /////////////////////////////////////////////////////////////////////////////\r
17 \r
18 /*!\r
19  *  @file\r
20  *  @brief Implementation of the CResizableSheetState class.\r
21  */\r
22 \r
23 #include "stdafx.h"\r
24 #include "ResizableSheetState.h"\r
25 \r
26 //////////////////////////////////////////////////////////////////////\r
27 // Construction/Destruction\r
28 //////////////////////////////////////////////////////////////////////\r
29 \r
30 CResizableSheetState::CResizableSheetState()\r
31 {\r
32 \r
33 }\r
34 \r
35 CResizableSheetState::~CResizableSheetState()\r
36 {\r
37 \r
38 }\r
39 \r
40 // used to save/restore active page\r
41 // either in the registry or a private .INI file\r
42 // depending on your application settings\r
43 \r
44 #define ACTIVEPAGE_ENT  _T("ActivePage")\r
45 \r
46 /*!\r
47  *  This function saves the current property sheet active page using the base\r
48  *  class persist method.\r
49  *  @sa CResizableState::WriteState\r
50  *  \r
51  *  @param pszName String that identifies stored settings\r
52  *  \r
53  *  @return Returns @a TRUE if successful, @a FALSE otherwise\r
54  */\r
55 BOOL CResizableSheetState::SavePage(LPCTSTR pszName)\r
56 {\r
57         // saves active page index, or the initial page if problems\r
58         // cannot use GetActivePage, because it always fails\r
59 \r
60         CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, GetResizableWnd());\r
61         if (pSheet == NULL)\r
62                 return FALSE;\r
63 \r
64         int page = pSheet->m_psh.nStartPage;\r
65         CTabCtrl *pTab = pSheet->GetTabControl();\r
66         if (pTab != NULL) \r
67                 page = pTab->GetCurSel();\r
68         if (page < 0)\r
69                 page = pSheet->m_psh.nStartPage;\r
70 \r
71         CString data, id;\r
72         _itot(page, data.GetBuffer(10), 10);\r
73         id = CString(pszName) + ACTIVEPAGE_ENT;\r
74         return WriteState(id, data);\r
75 }\r
76 \r
77 /*!\r
78  *  This function loads the active page using the base class persist method.\r
79  *  @sa CResizableState::ReadState\r
80  *  \r
81  *  @param pszName String that identifies stored settings\r
82  *  \r
83  *  @return Returns @a TRUE if successful, @a FALSE otherwise\r
84  */\r
85 BOOL CResizableSheetState::LoadPage(LPCTSTR pszName)\r
86 {\r
87         // restore active page, zero (the first) if not found\r
88 \r
89         CString data, id;\r
90         id = CString(pszName) + ACTIVEPAGE_ENT;\r
91         if (!ReadState(id, data))\r
92                 return FALSE;\r
93         \r
94         int page = _ttoi(data);\r
95         CPropertySheet* pSheet = DYNAMIC_DOWNCAST(CPropertySheet, GetResizableWnd());\r
96         if (pSheet != NULL)\r
97                 return pSheet->SetActivePage(page);\r
98         return FALSE;\r
99 }\r