MainFrm.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:30k
源码类别:

界面编程

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "FixedSizePanels.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CDemoHtmlCtrl
  13. IMPLEMENT_DYNAMIC( CDemoHtmlCtrl, CWnd );
  14. CDemoHtmlCtrl::CDemoHtmlCtrl()
  15. : m_pBrowser( NULL )
  16. , m_bReflectParentSizing( false )
  17. {
  18. }
  19. CDemoHtmlCtrl::~CDemoHtmlCtrl()
  20. {
  21. }
  22. BEGIN_MESSAGE_MAP(CDemoHtmlCtrl, CWnd)
  23. //{{AFX_MSG_MAP(CDemoHtmlCtrl)
  24. // NOTE - the ClassWizard will add and remove mapping macros here.
  25. //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CDemoHtmlCtrl message handlers
  29. bool CDemoHtmlCtrl::Create(
  30. CWnd * pWndParent,
  31. CRect rectInit // = CRect(0,0,0,0)
  32. )
  33. {
  34. UINT nID = pWndParent->GetDlgCtrlID();
  35. CString sWindowName;
  36. pWndParent->GetWindowText( sWindowName );
  37. if( !CreateControl(
  38. CLSID_WebBrowser,
  39. LPCTSTR(sWindowName),
  40. WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
  41. rectInit,
  42. pWndParent,
  43. nID
  44. )
  45. )
  46. { // if IWebBrowser2 is not created successfully
  47. ASSERT( FALSE );
  48. DestroyWindow();
  49. return false;
  50. } // if IWebBrowser2 is not created successfully
  51. LPUNKNOWN lpUnk = GetControlUnknown();
  52. ASSERT( lpUnk != NULL );
  53. HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowser);
  54. if( FAILED(hr) )
  55. {
  56. ASSERT( FALSE );
  57. DestroyWindow();
  58. return false;
  59. }
  60. return true;
  61. }
  62. void CDemoHtmlCtrl::GoBack()
  63. {
  64. ASSERT_VALID( this );
  65. ASSERT( m_pBrowser != NULL );
  66. m_pBrowser->GoBack();
  67. }
  68. void CDemoHtmlCtrl::GoForward()
  69. {
  70. ASSERT_VALID( this );
  71. ASSERT( m_pBrowser != NULL );
  72. m_pBrowser->GoForward();
  73. }
  74. void CDemoHtmlCtrl::Refresh()
  75. {
  76. ASSERT_VALID( this );
  77. ASSERT( m_pBrowser != NULL );
  78. m_pBrowser->Refresh();
  79. }
  80. void CDemoHtmlCtrl::NavigateURL( LPCTSTR lpszURL )
  81. {
  82. ASSERT_VALID( this );
  83. ASSERT( m_pBrowser != NULL );
  84. COleSafeArray vPostData;
  85. COleVariant vURL( lpszURL, VT_BSTR );
  86. COleVariant vHeaders( LPCTSTR(NULL), VT_BSTR);
  87. COleVariant vTargetFrameName( LPCTSTR(NULL), VT_BSTR );
  88. COleVariant vFlags( 0L, VT_I4 );
  89. m_pBrowser->Navigate2(
  90. vURL,
  91. vFlags,
  92. vTargetFrameName,
  93. vPostData,
  94. vHeaders
  95. );
  96. }
  97. void CDemoHtmlCtrl::NavigateResourceID(
  98. UINT nResourceID
  99. )
  100. {
  101. ASSERT_VALID( this );
  102. ASSERT( m_pBrowser != NULL );
  103. CString sAppName;
  104. ::GetModuleFileName(
  105. NULL,
  106. sAppName.GetBuffer( _MAX_PATH + 1 ),
  107. _MAX_PATH
  108. );
  109. sAppName.ReleaseBuffer();
  110. CString sResourseID;
  111. sResourseID.Format( _T("%d"), INT(nResourceID) );
  112. CString sNavigatePath;
  113. sNavigatePath =
  114. _T("res://")
  115. + sAppName
  116. + _T("/") //+ _T(".exe/")
  117. + sResourseID
  118. ;
  119. NavigateURL( sNavigatePath );
  120. }
  121. /////////////////////////////////////////////////////////////////////////////
  122. // CPanelEmpty
  123. IMPLEMENT_DYNAMIC(CPanelEmpty, CExtPanelControlBar)
  124. CPanelEmpty::CPanelEmpty()
  125. {
  126. }
  127. CPanelEmpty::~CPanelEmpty()
  128. {
  129. }
  130. CSize CPanelEmpty::OnQueryFixedBarNewSize(
  131. CExtPanelControlBar::e_fixed_bar_size_query_t eWhichSizeNeedToKnow
  132. ) const
  133. {
  134. ASSERT_VALID( this );
  135. switch( eWhichSizeNeedToKnow )
  136. {
  137. case CExtPanelControlBar::__FSQ_DOCKED_H:
  138. return CSize(150,50);
  139. case CExtPanelControlBar::__FSQ_DOCKED_V:
  140. return CSize(50,150);
  141. default:
  142. return CSize(150,150);
  143. } // switch( eWhichSizeNeedToKnow )
  144. }
  145. BEGIN_MESSAGE_MAP(CPanelEmpty, CExtPanelControlBar)
  146. //{{AFX_MSG_MAP(CPanelEmpty)
  147. //}}AFX_MSG_MAP
  148. END_MESSAGE_MAP()
  149. /////////////////////////////////////////////////////////////////////////////
  150. // CPanelCustomDrawn
  151. IMPLEMENT_DYNAMIC(CPanelCustomDrawn, CPanelEmpty)
  152. CPanelCustomDrawn::CPanelCustomDrawn()
  153. {
  154. }
  155. CPanelCustomDrawn::~CPanelCustomDrawn()
  156. {
  157. }
  158. BEGIN_MESSAGE_MAP(CPanelCustomDrawn, CPanelEmpty)
  159. //{{AFX_MSG_MAP(CPanelCustomDrawn)
  160. ON_WM_PAINT()
  161. //}}AFX_MSG_MAP
  162. END_MESSAGE_MAP()
  163. void CPanelCustomDrawn::OnPaint()
  164. {
  165. ASSERT_VALID( this );
  166. CPaintDC dcPaint( this );
  167. CExtMemoryDC dc( &dcPaint );
  168. CRect rcClient;
  169. GetClientRect( &rcClient );
  170. ASSERT( GetWindow( GW_CHILD ) == NULL );
  171. // fill gradient & draw text
  172. dc.FillSolidRect(
  173. &rcClient,
  174. g_PaintManager->GetColor(
  175. CExtPaintManager::CLR_3DFACE_OUT,
  176. this
  177. )
  178. );
  179. rcClient.DeflateRect( 2, 2 );
  180. COLORREF clrFc = g_PaintManager->GetColor( COLOR_3DFACE, this );
  181. COLORREF clrDk = g_PaintManager->GetColor( COLOR_3DDKSHADOW, this );
  182. COLORREF clrHi = g_PaintManager->GetColor( COLOR_3DHILIGHT, this );
  183. COLORREF clrLo = g_PaintManager->GetColor( COLOR_3DSHADOW, this );
  184. dc.Draw3dRect( &rcClient, clrFc, clrDk );
  185. rcClient.DeflateRect( 1, 1 );
  186. dc.Draw3dRect( &rcClient, clrHi, clrLo );
  187. rcClient.DeflateRect( 1, 1 );
  188. dc.Draw3dRect( &rcClient, clrLo, clrHi );
  189. rcClient.DeflateRect( 1, 1 );
  190. dc.Draw3dRect( &rcClient, clrDk, clrFc );
  191. rcClient.DeflateRect( 2, 2 );
  192. UINT nDockBarID = GetSafeDockBarDlgCtrlID();
  193. CExtPaintManager::stat_PaintGradientRect(
  194. dc,
  195. rcClient,
  196. RGB( 128, 128, 255 ),
  197. RGB( 0, 0, 0 ),
  198. (nDockBarID==AFX_IDW_DOCKBAR_LEFT || nDockBarID==AFX_IDW_DOCKBAR_RIGHT)
  199. ? true : false
  200. );
  201. CRect rcDrawText( rcClient );
  202. rcDrawText.DeflateRect( 5, 5 );
  203. CRect rcDrawTextShadow( rcDrawText );
  204. CString sText;
  205. CFont * pFont = &g_PaintManager->m_FontNormal;
  206. switch( nDockBarID )
  207. {
  208. case AFX_IDW_DOCKBAR_TOP:
  209. sText = _T("Docked at top");
  210. rcDrawTextShadow.OffsetRect( 1, 1 );
  211. break;
  212. case AFX_IDW_DOCKBAR_BOTTOM:
  213. sText = _T("Docked at bottom");
  214. rcDrawTextShadow.OffsetRect( 1, 1 );
  215. break;
  216. case AFX_IDW_DOCKBAR_LEFT:
  217. sText = _T("Docked at left");
  218. pFont = &g_PaintManager->m_FontNormalVert;
  219. rcDrawText.OffsetRect( rcDrawText.Width(), 0 );
  220. rcDrawText.OffsetRect( -1, -2 );
  221. rcDrawTextShadow = rcDrawText;
  222. rcDrawTextShadow.OffsetRect( 1, 1 );
  223. break;
  224. case AFX_IDW_DOCKBAR_RIGHT:
  225. sText = _T("Docked at right");
  226. pFont = &g_PaintManager->m_FontNormalVert;
  227. rcDrawText.OffsetRect( rcDrawText.Width(), 0 );
  228. rcDrawText.OffsetRect( -1, -2 );
  229. rcDrawTextShadow = rcDrawText;
  230. rcDrawTextShadow.OffsetRect( 1, 1 );
  231. break;
  232. default:
  233. ASSERT( nDockBarID == AFX_IDW_DOCKBAR_FLOAT );
  234. sText = _T("Floating");
  235. rcDrawTextShadow.OffsetRect( 1, 1 );
  236. break;
  237. } // switch( nDockBarID )
  238. CFont * pOldFont = dc.SelectObject( pFont );
  239. int nOldBkMode = dc.SetBkMode( TRANSPARENT );
  240. COLORREF clrOldTextColor = dc.SetTextColor( RGB(128,128,128) );
  241. dc.DrawText( sText, &rcDrawTextShadow, DT_SINGLELINE|DT_NOCLIP );
  242. dc.SetTextColor( RGB(255,255,255) );
  243. dc.DrawText( sText, &rcDrawText, DT_SINGLELINE|DT_NOCLIP );
  244. dc.SetTextColor( clrOldTextColor );
  245. dc.SetBkMode( nOldBkMode );
  246. dc.SelectObject( pOldFont );
  247. }
  248. /////////////////////////////////////////////////////////////////////////////
  249. // CMainFrame::CColorStatic
  250. CMainFrame::CColorStatic::CColorStatic()
  251. : m_clrIn( RGB(0,0,0) )
  252. , m_clrOut( RGB(255,255,255) )
  253. {
  254. }
  255. LRESULT CMainFrame::CColorStatic::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  256. {
  257. if( message == WM_PAINT )
  258. {
  259. CPaintDC dc( this );
  260. CRect rcClient;
  261. GetClientRect( &rcClient );
  262. dc.FillRect( &rcClient, &g_PaintManager->m_brushLightDefault );
  263. COLORREF clrLight = g_PaintManager->GetColor( COLOR_3DHILIGHT, this );
  264. COLORREF clrDkShadow = g_PaintManager->GetColor( COLOR_3DDKSHADOW, this );
  265. COLORREF clrFace = g_PaintManager->GetColor( COLOR_3DFACE, this );
  266. COLORREF clrShadow = g_PaintManager->GetColor( COLOR_3DSHADOW, this );
  267. dc.Draw3dRect( &rcClient, clrShadow, clrLight );
  268. rcClient.DeflateRect( 1, 1 );
  269. dc.Draw3dRect( &rcClient, clrDkShadow, clrFace );
  270. rcClient.DeflateRect( 1, 1 );
  271. CRect rcButtonIn;
  272. GetWindow(GW_HWNDNEXT)->GetWindowRect( &rcButtonIn );
  273. rcButtonIn.OffsetRect( -rcButtonIn.TopLeft() );
  274. rcButtonIn.InflateRect( 1, 1 );
  275. rcButtonIn.OffsetRect( rcClient.TopLeft() );
  276. CRect rcButtonOut( rcButtonIn );
  277. rcButtonOut.OffsetRect( rcButtonOut.Width()/2, rcButtonOut.Height()/2 );
  278. CRect rcUnion( rcButtonIn.left, rcButtonIn.top, rcButtonOut.right, rcButtonOut.bottom );
  279. CPoint ptOffset(
  280. ( rcClient.Width() - rcUnion.Width() ) / 2 + 1,
  281. ( rcClient.Height() - rcUnion.Height() ) / 2 + 1
  282. );
  283. rcButtonIn.OffsetRect( ptOffset );
  284. rcButtonOut.OffsetRect( ptOffset );
  285. dc.FillSolidRect( &rcButtonOut, m_clrOut );
  286. dc.Draw3dRect( &rcButtonOut, clrFace, clrDkShadow );
  287. rcButtonOut.DeflateRect( 1, 1 );
  288. dc.Draw3dRect( &rcButtonOut, clrLight, clrShadow );
  289. rcButtonOut.DeflateRect( 1, 1 );
  290. dc.Draw3dRect( &rcButtonOut, clrFace, clrFace );
  291. dc.FillSolidRect( &rcButtonIn, m_clrIn );
  292. dc.Draw3dRect( &rcButtonIn, clrFace, clrDkShadow );
  293. rcButtonIn.DeflateRect( 1, 1 );
  294. dc.Draw3dRect( &rcButtonIn, clrLight, clrShadow );
  295. rcButtonIn.DeflateRect( 1, 1 );
  296. dc.Draw3dRect( &rcButtonIn, clrFace, clrFace );
  297. return 0;
  298. } // if( message == WM_PAINT )
  299. if( message == WM_ERASEBKGND )
  300. {
  301. return (!0);
  302. } // if( message == WM_ERASEBKGND )
  303. return CStatic::WindowProc(message,wParam,lParam);
  304. }
  305. /////////////////////////////////////////////////////////////////////////////
  306. // CMainFrame::CDynamicButton
  307. void CMainFrame::CDynamicButton::_OnClick(
  308. bool bSelectAny,
  309. bool bSeparatedDropDownClicked
  310. )
  311. {
  312. ASSERT_VALID( this );
  313. bSelectAny;
  314. bSeparatedDropDownClicked;
  315. CFrameWnd * pFrame = GetParentFrame();
  316. ASSERT_VALID( pFrame );
  317. if( pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) )
  318. {
  319. pFrame = pFrame->GetParentFrame();
  320. ASSERT_VALID( pFrame );
  321. }
  322. pFrame->SetFocus();
  323. ASSERT_KINDOF( CMainFrame, pFrame );
  324. if( ((CMainFrame*)pFrame)->m_hWndSelectedToolButton != NULL )
  325. {
  326. ::InvalidateRect(
  327. ((CMainFrame*)pFrame)->m_hWndSelectedToolButton,
  328. NULL,
  329. FALSE
  330. );
  331. }
  332. ((CMainFrame*)pFrame)->m_hWndSelectedToolButton = m_hWnd;
  333. Invalidate();
  334. pFrame->SendMessage(
  335. WM_COMMAND,
  336. (WPARAM)GetDlgCtrlID(),
  337. (LPARAM)m_hWnd
  338. );
  339. }
  340. /////////////////////////////////////////////////////////////////////////////
  341. // CMainFrame::CDynamicPaletteButton
  342. CMainFrame::CDynamicPaletteButton::CDynamicPaletteButton( COLORREF clr )
  343. : m_clr( clr )
  344. {
  345. }
  346. LRESULT CMainFrame::CDynamicPaletteButton::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  347. {
  348. if( message == WM_LBUTTONDOWN
  349. || message == WM_RBUTTONDOWN
  350. )
  351. {
  352. CFrameWnd * pFrame = GetParentFrame();
  353. ASSERT_VALID( pFrame );
  354. if( pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) )
  355. {
  356. pFrame = pFrame->GetParentFrame();
  357. ASSERT_VALID( pFrame );
  358. }
  359. pFrame->SetFocus();
  360. ASSERT_KINDOF( CMainFrame, pFrame );
  361. Invalidate();
  362. WPARAM wParam = (WPARAM)GetDlgCtrlID();
  363. if( message == WM_RBUTTONDOWN )
  364. wParam += 160;
  365. pFrame->SendMessage(
  366. WM_COMMAND,
  367. wParam,
  368. (LPARAM)m_hWnd
  369. );
  370. return 0L;
  371. }
  372. if( message == WM_LBUTTONUP
  373. || message == WM_RBUTTONUP
  374. )
  375. {
  376. return 0L;
  377. }
  378. return CDynamicButton::WindowProc(message,wParam,lParam);
  379. }
  380. void CMainFrame::CDynamicPaletteButton::_OnClick(
  381. bool bSelectAny,
  382. bool bSeparatedDropDownClicked
  383. )
  384. {
  385. ASSERT_VALID( this );
  386. bSelectAny;
  387. bSeparatedDropDownClicked;
  388. CFrameWnd * pFrame = GetParentFrame();
  389. ASSERT_VALID( pFrame );
  390. if( pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) )
  391. {
  392. pFrame = pFrame->GetParentFrame();
  393. ASSERT_VALID( pFrame );
  394. }
  395. pFrame->SetFocus();
  396. ASSERT_KINDOF( CMainFrame, pFrame );
  397. Invalidate();
  398. pFrame->SendMessage(
  399. WM_COMMAND,
  400. (WPARAM)GetDlgCtrlID(),
  401. (LPARAM)m_hWnd
  402. );
  403. }
  404. void CMainFrame::CDynamicPaletteButton::_RenderImpl( // non-buffered paint
  405. CDC & dc,
  406. bool bTransparent, // = false
  407. bool bCombinedContent // = false
  408. )
  409. {
  410. ASSERT_VALID( this );
  411. bTransparent;
  412. bCombinedContent;
  413. CRect rectClient;
  414. GetClientRect( &rectClient );
  415. bool bPushed = (m_bPushed || GetCheck()) ? true : false;
  416. bool bHover =
  417. ( m_bMouseOver
  418. && !CExtPopupMenuWnd::IsMenuTracking() )
  419. ? true : false;
  420. dc.FillSolidRect( &rectClient, m_clr );
  421. COLORREF clrLight = g_PaintManager->GetColor( COLOR_3DHILIGHT, this );
  422. COLORREF clrDkShadow = g_PaintManager->GetColor( COLOR_3DDKSHADOW, this );
  423. if( bPushed || bHover )
  424. {
  425. COLORREF clrFace = g_PaintManager->GetColor( COLOR_3DFACE, this );
  426. COLORREF clrShadow = g_PaintManager->GetColor( COLOR_3DSHADOW, this );
  427. dc.Draw3dRect(
  428. &rectClient,
  429. clrShadow,
  430. clrLight
  431. );
  432. rectClient.DeflateRect( 1, 1 );
  433. dc.Draw3dRect(
  434. &rectClient,
  435. clrDkShadow,
  436. clrFace
  437. );
  438. }
  439. else
  440. {
  441. dc.Draw3dRect(
  442. &rectClient,
  443. clrDkShadow,
  444. clrLight
  445. );
  446. }
  447. }
  448. /////////////////////////////////////////////////////////////////////////////
  449. // CMainFrame
  450. IMPLEMENT_DYNAMIC( CMainFrame, CFrameWnd )
  451. BEGIN_MESSAGE_MAP( CMainFrame, CFrameWnd )
  452. //{{AFX_MSG_MAP(CMainFrame)
  453. ON_WM_CREATE()
  454. ON_WM_SETFOCUS()
  455. //}}AFX_MSG_MAP
  456. ON_COMMAND_EX( ID_VIEW_MENUBAR, OnBarCheck )
  457. ON_UPDATE_COMMAND_UI( ID_VIEW_MENUBAR, OnUpdateControlBarMenu )
  458. ON_COMMAND_EX( ID_VIEW_UI_LOOK_BAR, OnBarCheck )
  459. ON_UPDATE_COMMAND_UI( ID_VIEW_UI_LOOK_BAR, OnUpdateControlBarMenu )
  460. ON_COMMAND_EX( ID_VIEW_PANEL_EMPTY, OnBarCheck )
  461. ON_UPDATE_COMMAND_UI( ID_VIEW_PANEL_EMPTY, OnUpdateControlBarMenu )
  462. ON_COMMAND_EX( ID_VIEW_PANEL_CUSTOM_DRAWN, OnBarCheck )
  463. ON_UPDATE_COMMAND_UI( ID_VIEW_PANEL_CUSTOM_DRAWN, OnUpdateControlBarMenu )
  464. ON_COMMAND_EX( ID_VIEW_PANEL_EDIT, OnBarCheck )
  465. ON_UPDATE_COMMAND_UI( ID_VIEW_PANEL_EDIT, OnUpdateControlBarMenu )
  466. ON_COMMAND_EX( ID_VIEW_PANEL_DIALOG, OnBarCheck )
  467. ON_UPDATE_COMMAND_UI( ID_VIEW_PANEL_DIALOG, OnUpdateControlBarMenu )
  468. ON_COMMAND_EX( ID_VIEW_PANEL_TOOLS, OnBarCheck )
  469. ON_UPDATE_COMMAND_UI( ID_VIEW_PANEL_TOOLS, OnUpdateControlBarMenu )
  470. ON_COMMAND_EX( ID_VIEW_PANEL_PALETTE, OnBarCheck )
  471. ON_UPDATE_COMMAND_UI( ID_VIEW_PANEL_PALETTE, OnUpdateControlBarMenu )
  472. ON_COMMAND_EX( ID_VIEW_PANEL_RESIZABLE1, OnBarCheck )
  473. ON_UPDATE_COMMAND_UI( ID_VIEW_PANEL_RESIZABLE1, OnUpdateControlBarMenu )
  474. ON_COMMAND_EX( ID_VIEW_PANEL_RESIZABLE2, OnBarCheck )
  475. ON_UPDATE_COMMAND_UI( ID_VIEW_PANEL_RESIZABLE2, OnUpdateControlBarMenu )
  476. ON_COMMAND_RANGE( IDC_BUTTON1, IDC_BUTTON16, OnClickedToolButton )
  477. ON_COMMAND_RANGE( IDC_BUTTON17, IDC_BUTTON176, OnClickedPaletteButtonL )
  478. ON_COMMAND_RANGE( (IDC_BUTTON17+160), (IDC_BUTTON176+160), OnClickedPaletteButtonR )
  479. END_MESSAGE_MAP()
  480. static UINT indicators[] =
  481. {
  482. ID_SEPARATOR,           // status line indicator
  483. ID_INDICATOR_CAPS,
  484. ID_INDICATOR_NUM,
  485. ID_INDICATOR_SCRL,
  486. };
  487. /////////////////////////////////////////////////////////////////////////////
  488. // CMainFrame construction/destruction
  489. CMainFrame::CMainFrame()
  490. {
  491. CWinApp * pApp = ::AfxGetApp();
  492. ASSERT( pApp != NULL );
  493. ASSERT( pApp->m_pszRegistryKey != NULL );
  494. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  495. ASSERT( pApp->m_pszProfileName != NULL );
  496. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  497. if( ! g_PaintManager.PaintManagerStateLoad(
  498. pApp->m_pszRegistryKey,
  499. pApp->m_pszProfileName,
  500. pApp->m_pszProfileName
  501. )
  502. )
  503. g_PaintManager.InstallPaintManager(
  504. RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_LunaBlue)
  505. );
  506. m_hWndSelectedToolButton = NULL;
  507. // window placement persistence
  508. ::memset( &m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT) );
  509. m_dataFrameWP.length = sizeof(WINDOWPLACEMENT);
  510. m_dataFrameWP.showCmd = SW_HIDE;
  511. }
  512. CMainFrame::~CMainFrame()
  513. {
  514. }
  515. static UINT g_statBasicCommands[] =
  516. {
  517. ID_APP_ABOUT,
  518. ID_APP_EXIT,
  519. ID_VIEW_MENUBAR,
  520. ID_VIEW_TOOLBAR,
  521. ID_VIEW_UI_LOOK_BAR,
  522. ID_VIEW_STATUS_BAR,
  523. ID_VIEW_PANEL_EMPTY,
  524. ID_VIEW_PANEL_CUSTOM_DRAWN,
  525. ID_VIEW_PANEL_EDIT,
  526. ID_VIEW_PANEL_DIALOG,
  527. ID_VIEW_PANEL_TOOLS,
  528. ID_VIEW_PANEL_PALETTE,
  529. ID_VIEW_PANEL_RESIZABLE1,
  530. ID_VIEW_PANEL_RESIZABLE2,
  531. 0, // end of list
  532. };
  533. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  534. {
  535. if( CExtNCW < CFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )
  536. return -1;
  537. // create a view to occupy the client area of the frame
  538. if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
  539. CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
  540. {
  541. TRACE0("Failed to create view windown");
  542. return -1;
  543. }
  544. CWinApp * pApp = ::AfxGetApp();
  545. ASSERT( pApp != NULL );
  546. ASSERT( pApp->m_pszRegistryKey != NULL );
  547. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  548. ASSERT( pApp->m_pszProfileName != NULL );
  549. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  550. HICON hIcon = pApp->LoadIcon( IDR_MAINFRAME );
  551. ASSERT( hIcon != NULL );
  552. SetIcon( hIcon, TRUE );
  553. SetIcon( hIcon, FALSE );
  554. ASSERT( pApp->m_pszProfileName != NULL );
  555. g_CmdManager->ProfileSetup(
  556. pApp->m_pszProfileName,
  557. GetSafeHwnd()
  558. );
  559. VERIFY(
  560. g_CmdManager->UpdateFromMenu(
  561. pApp->m_pszProfileName,
  562. IDR_MAINFRAME
  563. )
  564. );
  565. if( !m_wndMenuBar.Create(
  566. NULL,
  567. this,
  568. ID_VIEW_MENUBAR
  569. )
  570. )
  571.     {
  572.         TRACE0("Failed to create menubarn");
  573.         return -1;      // failed to create
  574.     }
  575. if( !m_wndToolBar.Create(
  576. _T("ToolBar"),
  577. this,
  578. AFX_IDW_TOOLBAR
  579. )
  580. ||
  581. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)
  582. )
  583. {
  584. TRACE0("Failed to create toolbarn");
  585. return -1;      // fail to create
  586. }
  587. if( (! m_wndToolBarUiLook.Create( NULL, this, ID_VIEW_UI_LOOK_BAR ) )
  588. || (! m_wndToolBarUiLook.ThemeSwitcherInit() )
  589. )
  590. {
  591. TRACE0("Failed to create toolbar2n");
  592. return -1;      // fail to create
  593. }
  594. if( !m_wndPanelEmpty.Create(
  595. _T("Empty Panel"),
  596. this,
  597. ID_VIEW_PANEL_EMPTY,
  598. WS_CHILD|WS_VISIBLE
  599. |CBRS_RIGHT|CBRS_GRIPPER|CBRS_TOOLTIPS
  600. |CBRS_FLYBY|CBRS_SIZE_DYNAMIC
  601. |CBRS_HIDE_INPLACE
  602. )
  603. || !m_wndPanelCustomDrawn.Create(
  604. _T("Custom-drawn Panel"),
  605. this,
  606. ID_VIEW_PANEL_CUSTOM_DRAWN,
  607. WS_CHILD|WS_VISIBLE
  608. |CBRS_RIGHT|CBRS_GRIPPER|CBRS_TOOLTIPS
  609. |CBRS_FLYBY|CBRS_SIZE_DYNAMIC
  610. |CBRS_HIDE_INPLACE
  611. )
  612. || !m_wndPanelEdit.Create(
  613. _T("Panel With Edit Control"),
  614. this,
  615. ID_VIEW_PANEL_EDIT,
  616. WS_CHILD|WS_VISIBLE
  617. |CBRS_LEFT|CBRS_GRIPPER|CBRS_TOOLTIPS
  618. |CBRS_FLYBY|CBRS_SIZE_DYNAMIC
  619. |CBRS_HIDE_INPLACE
  620. )
  621. || !m_wndEdit.Create(
  622. WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL
  623. |ES_MULTILINE|ES_WANTRETURN
  624. |ES_AUTOHSCROLL|ES_AUTOVSCROLL
  625. ,
  626. CRect(0,0,160,80),
  627. &m_wndPanelEdit,
  628. UINT(IDC_STATIC)
  629. )
  630. || !m_wndPanelDialog.Create(
  631. _T("Panel With Dialog"),
  632. this,
  633. ID_VIEW_PANEL_DIALOG,
  634. WS_CHILD|WS_VISIBLE
  635. |CBRS_LEFT|CBRS_GRIPPER|CBRS_TOOLTIPS
  636. |CBRS_FLYBY|CBRS_SIZE_DYNAMIC
  637. |CBRS_HIDE_INPLACE
  638. )
  639. || !m_dlgForPanelDialog.Create(
  640. IDD_DIALOG_FOR_PANEL,
  641. &m_wndPanelDialog
  642. )
  643. || !m_wndPanelTools.Create(
  644. _T("Tools Panel"),
  645. this,
  646. ID_VIEW_PANEL_TOOLS,
  647. WS_CHILD|WS_VISIBLE
  648. |CBRS_RIGHT|CBRS_GRIPPER|CBRS_TOOLTIPS
  649. |CBRS_FLYBY|CBRS_SIZE_DYNAMIC
  650. |CBRS_HIDE_INPLACE
  651. )
  652. || !m_dlgForPanelTools.Create(
  653. IDD_DIALOG_TOOLS,
  654. &m_wndPanelTools
  655. )
  656. || !m_wndPanelPalette.Create(
  657. _T("Palette Panel"),
  658. this,
  659. ID_VIEW_PANEL_PALETTE,
  660. WS_CHILD|WS_VISIBLE
  661. |CBRS_BOTTOM|CBRS_GRIPPER|CBRS_TOOLTIPS
  662. |CBRS_FLYBY|CBRS_SIZE_DYNAMIC
  663. |CBRS_HIDE_INPLACE
  664. )
  665. || !m_dlgForPanelPalette.Create(
  666. IDD_DIALOG_PALETTE,
  667. &m_wndPanelPalette
  668. )
  669. || !m_wndResizableBar1.Create(
  670. _T("Resizable panel 1 (in fixed mode)"),
  671. this,
  672. ID_VIEW_PANEL_RESIZABLE1
  673. )
  674. || !m_wndHtmlCtrl1.Create(
  675. &m_wndResizableBar1,
  676. CRect( 0, 0, 150, 150 )
  677. )
  678. || !m_wndResizableBar2.Create(
  679. _T("Resizable panel 2 (in fixed mode)"),
  680. this,
  681. ID_VIEW_PANEL_RESIZABLE2
  682. )
  683. || !m_wndHtmlCtrl2.Create(
  684. &m_wndResizableBar2,
  685. CRect( 0, 0, 150, 150 )
  686. )
  687. )
  688. {
  689. TRACE0("Failed to create bars/panelsn");
  690. return -1;      // fail to create
  691. }
  692. m_wndToolsPanelLabel.SubclassDlgItem( IDC_STATIC_BOTTOM_LABEL, &m_dlgForPanelTools );
  693. m_wndDialogPanelLabel.SubclassDlgItem( IDC_STATIC_TEST, &m_dlgForPanelDialog );
  694. m_wndDialogPanelCheck1.SubclassDlgItem( IDC_CHECK1, &m_dlgForPanelDialog );
  695. m_wndDialogPanelCheck2.SubclassDlgItem( IDC_CHECK2, &m_dlgForPanelDialog );
  696. m_wndHtmlCtrl1.NavigateResourceID( IDR_HTML_DEMO_PAGE1 );
  697. m_wndHtmlCtrl2.NavigateResourceID( IDR_HTML_DEMO_PAGE2 );
  698. m_wndEdit.ModifyStyleEx(0,WS_EX_CLIENTEDGE,SWP_FRAMECHANGED);
  699. m_wndEdit.SetFont(
  700. CFont::FromHandle(
  701. (HFONT)::GetStockObject(DEFAULT_GUI_FONT)
  702. )
  703. );
  704. m_wndEdit.SetWindowText( _T("Fixed size panelrnwith edit control") );
  705. m_dlgForPanelPalette.ShowSizeGrip( FALSE );
  706. m_dlgForPanelDialog.ShowSizeGrip( FALSE );
  707. m_dlgForPanelTools.ShowSizeGrip( FALSE );
  708. CImageList _ilTools;
  709. VERIFY( _ilTools.Create( IDB_BITMAP_TOOLS, 16, 1, RGB(255,0,255) ) );
  710. if( m_dlgForPanelTools.m_wndGripper.GetSafeHwnd() != NULL )
  711. m_dlgForPanelTools.m_wndGripper.SetWindowPos( &CWnd::wndBottom, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOOWNERZORDER|SWP_NOSENDCHANGING|SWP_HIDEWINDOW );
  712. HWND hWndToolBtn = ::GetWindow( m_dlgForPanelTools.m_hWnd, GW_CHILD );
  713. int iToolBtn;
  714. for( iToolBtn=0; iToolBtn < 16; iToolBtn++, hWndToolBtn = ::GetWindow(hWndToolBtn,GW_HWNDNEXT) )
  715. {
  716. ASSERT( hWndToolBtn != NULL );
  717. ASSERT( ::IsWindow(hWndToolBtn) );
  718. if( iToolBtn == 0 )
  719. {
  720. m_hWndSelectedToolButton = hWndToolBtn; 
  721. ::InvalidateRect(
  722. m_hWndSelectedToolButton,
  723. NULL,
  724. FALSE
  725. );
  726. }
  727. if( CWnd::FromHandlePermanent( hWndToolBtn ) != NULL )
  728. continue;
  729. CDynamicButton * pBtn =
  730. new CDynamicButton;
  731. pBtn->SubclassWindow( hWndToolBtn );
  732. pBtn->SetFlat( TRUE );
  733. pBtn->SetIcon( _ilTools.ExtractIcon( iToolBtn ) );
  734. CExtSafeString sToolTip;
  735. sToolTip.Format(
  736. _T("Tool button %d"),
  737. iToolBtn + 1
  738. );
  739. pBtn->SetTooltipText( sToolTip );
  740. }
  741. hWndToolBtn = ::GetWindow( m_dlgForPanelPalette.m_hWnd, GW_CHILD );
  742. ASSERT( hWndToolBtn != NULL );
  743. ASSERT( ::IsWindow(hWndToolBtn) );
  744. // skip resizing gripper
  745. hWndToolBtn = ::GetWindow(hWndToolBtn,GW_HWNDNEXT);
  746. ASSERT( hWndToolBtn != NULL );
  747. ASSERT( ::IsWindow(hWndToolBtn) );
  748. m_wndColorStatic.SubclassWindow( hWndToolBtn );
  749. hWndToolBtn = ::GetWindow(hWndToolBtn,GW_HWNDNEXT);
  750. for( iToolBtn=0; iToolBtn < 160; iToolBtn++, hWndToolBtn = ::GetWindow(hWndToolBtn,GW_HWNDNEXT) )
  751. {
  752. ASSERT( hWndToolBtn != NULL );
  753. ASSERT( ::IsWindow(hWndToolBtn) );
  754. if( CWnd::FromHandlePermanent( hWndToolBtn ) != NULL )
  755. continue;
  756. COLORREF clr;
  757. if( iToolBtn < 32 )
  758. {
  759. double fColorSrc = double(iToolBtn)/32.0;
  760. clr = 
  761. CExtBitmap::stat_HLStoRGB(
  762. 0.0,
  763. sqrt( fColorSrc ),
  764. 0.0
  765. );
  766. } // if( iToolBtn < 32 )
  767. else
  768. {
  769. int iColorSrc = iToolBtn-32;
  770. int iSat = iColorSrc/32;
  771. ASSERT( iSat >= 0 && iSat <= 3 );
  772. double fSat = 0.15;
  773. if( iSat == 1 )
  774. fSat = 0.3;
  775. else if( iSat == 2 )
  776. fSat = 0.5;
  777. else if( iSat == 3 )
  778. fSat = 1.0;
  779. iColorSrc = iColorSrc % 32;
  780. double fColorSrc = double(iColorSrc)/32.0;
  781. clr = 
  782. CExtBitmap::stat_HLStoRGB(
  783. fColorSrc,
  784. 0.5,
  785. fSat
  786. );
  787. } // else from if( iToolBtn < 32 )
  788. CDynamicPaletteButton * pBtn =
  789. new CDynamicPaletteButton( clr );
  790. pBtn->SubclassWindow( hWndToolBtn );
  791. CExtSafeString sToolTip;
  792. sToolTip.Format(
  793. _T("Palette button %d - #%02X%02X%02X"),
  794. iToolBtn + 1,
  795. int( GetRValue(clr) ),
  796. int( GetGValue(clr) ),
  797. int( GetBValue(clr) )
  798. );
  799. pBtn->SetTooltipText( sToolTip );
  800. }
  801. if( !m_wndStatusBar.Create(this)
  802. || !m_wndStatusBar.SetIndicators(
  803. indicators,
  804. sizeof(indicators) / sizeof(UINT)
  805. )
  806. )
  807. {
  808. TRACE0("Failed to create status barn");
  809. return -1;      // fail to create
  810. }
  811.     m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
  812. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  813. m_wndToolBarUiLook.EnableDocking(CBRS_ALIGN_ANY);
  814. m_wndPanelEmpty.EnableDocking(CBRS_ALIGN_ANY);
  815. m_wndPanelCustomDrawn.EnableDocking(CBRS_ALIGN_ANY);
  816. m_wndPanelEdit.EnableDocking(CBRS_ALIGN_ANY);
  817. m_wndPanelDialog.EnableDocking(CBRS_ALIGN_ANY);
  818. m_wndPanelTools.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
  819. m_wndPanelPalette.EnableDocking(CBRS_ALIGN_BOTTOM);
  820. m_wndResizableBar1.EnableDocking(CBRS_ALIGN_ANY);
  821. m_wndResizableBar2.EnableDocking(CBRS_ALIGN_ANY);
  822. if( !CExtControlBar::FrameEnableDocking(this) )
  823. {
  824. ASSERT( FALSE );
  825. return -1;
  826. }
  827. VERIFY(
  828. g_CmdManager->SetBasicCommands(
  829. pApp->m_pszProfileName,
  830. g_statBasicCommands
  831. )
  832. );
  833. if( !CExtControlBar::ProfileBarStateLoad(
  834. this,
  835. pApp->m_pszRegistryKey,
  836. pApp->m_pszProfileName,
  837. pApp->m_pszProfileName,
  838. &m_dataFrameWP
  839. )
  840. )
  841. {
  842. DockControlBar( &m_wndMenuBar );
  843. DockControlBar( &m_wndToolBar );
  844. RecalcLayout();
  845. CRect wrAlreadyDockedBar;
  846. DockControlBar( &m_wndPanelCustomDrawn );
  847. m_wndPanelCustomDrawn.GetWindowRect( &wrAlreadyDockedBar );
  848. wrAlreadyDockedBar.OffsetRect( 0, 1 );
  849. DockControlBar( &m_wndPanelEmpty, AFX_IDW_DOCKBAR_RIGHT, &wrAlreadyDockedBar );
  850. DockControlBar( &m_wndPanelEdit );
  851. m_wndPanelEdit.GetWindowRect( &wrAlreadyDockedBar );
  852. wrAlreadyDockedBar.OffsetRect( 0, 1 );
  853. DockControlBar( &m_wndPanelDialog, AFX_IDW_DOCKBAR_LEFT, &wrAlreadyDockedBar );
  854. DockControlBar( &m_wndPanelTools );
  855. DockControlBar( &m_wndPanelPalette );
  856. DockControlBar( &m_wndResizableBar1, AFX_IDW_DOCKBAR_LEFT );
  857. DockControlBar( &m_wndResizableBar2, AFX_IDW_DOCKBAR_RIGHT );
  858. DockControlBar( &m_wndToolBarUiLook, AFX_IDW_DOCKBAR_RIGHT );
  859. ShowControlBar( &m_wndPanelEmpty, FALSE, TRUE );
  860. ShowControlBar( &m_wndPanelEdit, FALSE, TRUE );
  861. ShowControlBar( &m_wndPanelDialog, FALSE, TRUE );
  862. ShowControlBar( &m_wndResizableBar2, FALSE, TRUE );
  863. RecalcLayout();
  864. }
  865. g_CmdManager->SerializeState(
  866. pApp->m_pszProfileName,
  867. pApp->m_pszRegistryKey,
  868. pApp->m_pszProfileName,
  869. false
  870. );
  871. return 0;
  872. }
  873. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  874. {
  875. if( ! CExtNCW < CFrameWnd > :: PreCreateWindow( cs ) )
  876. return FALSE;
  877. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  878. cs.lpszClass = AfxRegisterWndClass(0);
  879. return TRUE;
  880. }
  881. /////////////////////////////////////////////////////////////////////////////
  882. // CMainFrame diagnostics
  883. #ifdef _DEBUG
  884. void CMainFrame::AssertValid() const
  885. {
  886. CExtNCW < CFrameWnd > :: AssertValid();
  887. }
  888. void CMainFrame::Dump(CDumpContext& dc) const
  889. {
  890. CExtNCW < CFrameWnd > :: Dump( dc );
  891. }
  892. #endif //_DEBUG
  893. /////////////////////////////////////////////////////////////////////////////
  894. // CMainFrame message handlers
  895. void CMainFrame::OnSetFocus(CWnd* pOldWnd)
  896. {
  897. pOldWnd;
  898. // forward focus to the view window
  899. m_wndView.SetFocus();
  900. }
  901. BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  902. {
  903. // let the view have first crack at the command
  904. if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
  905. return TRUE;
  906. // otherwise, do default handling
  907. return CExtNCW < CFrameWnd > :: OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
  908. }
  909. BOOL CMainFrame::PreTranslateMessage( MSG * pMsg ) 
  910. {
  911. if( m_wndToolBarUiLook.PreTranslateMessage( pMsg ) )
  912. return TRUE;
  913. if( m_wndMenuBar.TranslateMainFrameMessage( pMsg ) )
  914. return TRUE;
  915. return CExtNCW < CFrameWnd > :: PreTranslateMessage( pMsg );
  916. }
  917. BOOL CMainFrame::DestroyWindow() 
  918. {
  919. CWinApp * pApp = ::AfxGetApp();
  920. ASSERT( pApp != NULL );
  921. ASSERT( pApp->m_pszRegistryKey != NULL );
  922. ASSERT( pApp->m_pszRegistryKey[0] != _T('') );
  923. ASSERT( pApp->m_pszProfileName != NULL );
  924. ASSERT( pApp->m_pszProfileName[0] != _T('') );
  925. VERIFY(
  926. CExtControlBar::ProfileBarStateSave(
  927. this,
  928. pApp->m_pszRegistryKey,
  929. pApp->m_pszProfileName,
  930. pApp->m_pszProfileName
  931. )
  932. );
  933. VERIFY(
  934. g_CmdManager->SerializeState(
  935. pApp->m_pszProfileName,
  936. pApp->m_pszRegistryKey,
  937. pApp->m_pszProfileName,
  938. true
  939. )
  940. );
  941. VERIFY(
  942. g_PaintManager.PaintManagerStateSave(
  943. pApp->m_pszRegistryKey,
  944. pApp->m_pszProfileName,
  945. pApp->m_pszProfileName
  946. )
  947. );
  948. g_CmdManager->ProfileWndRemove( GetSafeHwnd() );
  949. return CExtNCW < CFrameWnd > :: DestroyWindow();
  950. }
  951. void CMainFrame::ActivateFrame(int nCmdShow) 
  952. {
  953. // window placement persistence
  954. if( m_dataFrameWP.showCmd != SW_HIDE )
  955. {
  956. SetWindowPlacement( &m_dataFrameWP );
  957. CExtNCW < CFrameWnd > :: ActivateFrame( m_dataFrameWP.showCmd );
  958. m_dataFrameWP.showCmd = SW_HIDE;
  959. return;
  960. }
  961. CExtNCW < CFrameWnd > :: ActivateFrame( nCmdShow );
  962. }
  963. void CMainFrame::OnClickedToolButton( UINT nID )
  964. {
  965. ASSERT( IDC_BUTTON1 <= nID && nID <= IDC_BUTTON16 );
  966. CString sMsg;
  967. sMsg.Format(
  968. _T("Tool button %d clicked"),
  969. nID - IDC_BUTTON1 + 1
  970. );
  971. ::AfxMessageBox( sMsg );
  972. }
  973. void CMainFrame::OnClickedPaletteButtonL( UINT nID )
  974. {
  975. ASSERT( IDC_BUTTON17 <= nID && nID <= IDC_BUTTON176 );
  976. CDynamicPaletteButton * pBtn = (CDynamicPaletteButton *)
  977. CWnd::FromHandlePermanent(
  978. ::GetDlgItem( m_dlgForPanelPalette.m_hWnd, nID ) 
  979. );
  980. ASSERT_VALID( pBtn );
  981. m_wndColorStatic.m_clrIn = pBtn->m_clr;
  982. m_wndColorStatic.Invalidate();
  983. CString sMsg;
  984. sMsg.Format(
  985. _T("Palette button %d clicked (left mouse button)nColor is #%02X%02X%02X"),
  986. nID - IDC_BUTTON17 + 1,
  987. int( GetRValue(pBtn->m_clr) ),
  988. int( GetGValue(pBtn->m_clr) ),
  989. int( GetBValue(pBtn->m_clr) )
  990. );
  991. ::AfxMessageBox( sMsg );
  992. }
  993. void CMainFrame::OnClickedPaletteButtonR( UINT nID )
  994. {
  995. nID -= 160;
  996. ASSERT( IDC_BUTTON17 <= nID && nID <= IDC_BUTTON176 );
  997. CDynamicPaletteButton * pBtn = (CDynamicPaletteButton *)
  998. CWnd::FromHandlePermanent(
  999. ::GetDlgItem( m_dlgForPanelPalette.m_hWnd, nID ) 
  1000. );
  1001. ASSERT_VALID( pBtn );
  1002. m_wndColorStatic.m_clrOut = pBtn->m_clr;
  1003. m_wndColorStatic.Invalidate();
  1004. CString sMsg;
  1005. sMsg.Format(
  1006. _T("Palette button %d clicked (right mouse button)nColor is #%02X%02X%02X"),
  1007. nID - IDC_BUTTON17 + 1,
  1008. int( GetRValue(pBtn->m_clr) ),
  1009. int( GetGValue(pBtn->m_clr) ),
  1010. int( GetBValue(pBtn->m_clr) )
  1011. );
  1012. ::AfxMessageBox( sMsg );
  1013. }