Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

WndSettingsPage.cpp

Go to the documentation of this file.
00001 //
00002 // WndSettingsPage.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "WndSettingsSheet.h"
00025 #include "WndSettingsPage.h"
00026 
00027 #include <afxpriv.h>
00028 #include <..\src\mfc\afximpl.h>
00029 //#include "C:\Development\VisualStudio2003\Vc7\atlmfc\src\mfc\afximpl.h"
00030 
00031 #include "Skin.h"
00032 
00033 #ifdef _DEBUG
00034 #define new DEBUG_NEW
00035 #undef THIS_FILE
00036 static char THIS_FILE[] = __FILE__;
00037 #endif
00038 
00039 IMPLEMENT_DYNAMIC(CSettingsPage, CDialog)
00040 
00041 BEGIN_MESSAGE_MAP(CSettingsPage, CDialog)
00042         //{{AFX_MSG_MAP(CSettingsPage)
00043         //}}AFX_MSG_MAP
00044         ON_WM_ERASEBKGND()
00045         ON_WM_CTLCOLOR()
00046 END_MESSAGE_MAP()
00047 
00048 
00050 // CSettingsPage construction
00051 
00052 CSettingsPage::CSettingsPage(UINT nIDTemplate, LPCTSTR pszCaption) : CDialog( nIDTemplate )
00053 {
00054         //{{AFX_DATA_INIT(CSettingsPage)
00055         //}}AFX_DATA_INIT
00056 
00057         if ( pszCaption != NULL ) m_sCaption = pszCaption;
00058         else if ( m_lpszTemplateName != NULL ) LoadDefaultCaption();
00059 }
00060 
00061 CSettingsPage::~CSettingsPage()
00062 {
00063 }
00064 
00066 // CSettingsPage operations
00067 
00068 BOOL CSettingsPage::LoadDefaultCaption()
00069 {
00070         CDialogTemplate pTemplate;
00071         DLGTEMPLATE* pData;
00072         LPWORD pWord;
00073 
00074         if ( ! pTemplate.Load( m_lpszTemplateName ) ) return FALSE;
00075 
00076         pData = (DLGTEMPLATE*)GlobalLock( pTemplate.m_hTemplate );
00077 
00078         if ( ((DLGTEMPLATEEX*)pData)->signature == 0xFFFF )
00079         {
00080                 pWord = (WORD*)( (DLGTEMPLATEEX*)pData + 1 );
00081         }
00082         else
00083         {
00084                 pWord = (WORD*)( pData + 1 );
00085         }
00086 
00087         if ( *pWord == 0xFFFF )
00088         {
00089                 pWord += 2;
00090         }
00091         else
00092         {
00093                 while ( *pWord++ );
00094         }
00095 
00096         if ( *pWord == 0xFFFF )
00097         {
00098                 pWord += 2;
00099         }
00100         else
00101         {
00102                 while ( *pWord++ );
00103         }
00104 
00105         m_sCaption = (wchar_t*)pWord;
00106 
00107         GlobalUnlock( pTemplate.m_hTemplate );
00108 
00109         return m_sCaption.GetLength() > 0;
00110 }
00111 
00112 BOOL CSettingsPage::Create(CRect& rcPage, CWnd* pSheetWnd)
00113 {
00114         ASSERT_VALID(this);
00115         ASSERT( m_lpszTemplateName != NULL );
00116 
00117         CDialogTemplate pTemplate;
00118         LPDLGTEMPLATE pData;
00119 
00120         if ( ! pTemplate.Load( m_lpszTemplateName ) ) return FALSE;
00121         pData = (LPDLGTEMPLATE)GlobalLock( pTemplate.m_hTemplate );
00122 
00123         DWORD dwExStyle = theApp.m_bRTL ? WS_EX_RTLREADING|WS_EX_RIGHT|WS_EX_LEFTSCROLLBAR|WS_EX_LAYOUTRTL : 
00124                 WS_EX_LTRREADING|WS_EX_LEFT|WS_EX_RIGHTSCROLLBAR;
00125 
00126         if ( ((DLGTEMPLATEEX*)pData)->signature == 0xFFFF )
00127         {
00128                 DLGTEMPLATEEX* pEx = (DLGTEMPLATEEX*)pData;
00129                 pEx->style              = WS_CHILDWINDOW|WS_OVERLAPPED|DS_3DLOOK|DS_SETFONT|DS_CONTROL;
00130                 pEx->exStyle    = dwExStyle|WS_EX_WINDOWEDGE|WS_EX_CONTROLPARENT;
00131         }
00132         else
00133         {
00134                 pData->style                    = WS_CHILDWINDOW|WS_OVERLAPPED|DS_3DLOOK|DS_SETFONT|DS_CONTROL;
00135                 pData->dwExtendedStyle  = dwExStyle|WS_EX_WINDOWEDGE|WS_EX_CONTROLPARENT;
00136         }
00137 
00138         GlobalUnlock( pTemplate.m_hTemplate );
00139         CreateIndirect( pTemplate.m_hTemplate, pSheetWnd );
00140         SetFont( &theApp.m_gdiFont );
00141 
00142         MoveWindow( rcPage );
00143 
00144         return ( m_hWnd != NULL );
00145 }
00146 
00147 CSettingsPage* CSettingsPage::GetPage(CRuntimeClass* pClass) const
00148 {
00149         return GetSheet()->GetPage( pClass );
00150 }
00151 
00153 // CSettingsPage message handlers
00154 
00155 BOOL CSettingsPage::OnInitDialog()
00156 {
00157         CDialog::OnInitDialog();
00158 
00159         Skin.Apply( NULL, this );
00160 
00161         return TRUE;
00162 }
00163 
00164 void CSettingsPage::DoDataExchange(CDataExchange* pDX)
00165 {
00166         CDialog::DoDataExchange( pDX );
00167         //{{AFX_DATA_MAP(CSettingsPage)
00168         //}}AFX_DATA_MAP
00169 }
00170 
00171 void CSettingsPage::SetModified(BOOL bChanged)
00172 {
00173         ASSERT_VALID(this);
00174         GetSheet()->SetModified( bChanged );
00175 }
00176 
00177 BOOL CSettingsPage::OnApply()
00178 {
00179         ASSERT_VALID(this);
00180         OnOK();
00181         return TRUE;
00182 }
00183 
00184 void CSettingsPage::OnReset()
00185 {
00186         ASSERT_VALID(this);
00187         OnCancel();
00188 }
00189 
00190 void CSettingsPage::OnOK()
00191 {
00192         ASSERT_VALID(this);
00193 }
00194 
00195 void CSettingsPage::OnCancel()
00196 {
00197         ASSERT_VALID(this);
00198 }
00199 
00200 BOOL CSettingsPage::OnSetActive()
00201 {
00202         ASSERT_VALID(this);
00203         return TRUE;
00204 }
00205 
00206 BOOL CSettingsPage::OnKillActive()
00207 {
00208         ASSERT_VALID(this);
00209         if ( ! UpdateData() ) return FALSE;
00210         return TRUE;
00211 }
00212 
00213 BOOL CSettingsPage::OnEraseBkgnd(CDC* pDC)
00214 {
00215         CRect rc;
00216         GetClientRect( &rc );
00217         pDC->FillSolidRect( &rc, Skin.m_crDialog );
00218         return TRUE;
00219 }
00220 
00221 HBRUSH CSettingsPage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00222 {
00223         HBRUSH hbr = CDialog::OnCtlColor( pDC, pWnd, nCtlColor );
00224 
00225         if ( nCtlColor == CTLCOLOR_DLG || nCtlColor == CTLCOLOR_STATIC )
00226         {
00227                 pDC->SetBkColor( Skin.m_crDialog );
00228                 hbr = Skin.m_brDialog;
00229         }
00230 
00231         return hbr;
00232 }

Generated on Thu Dec 15 10:39:53 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2