Mercurial > flash_v2
comparison host/tools/configtool/common/win32/DescView.cpp @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 75:41bf073c0c32 | 76:435cced73e2f |
|---|---|
| 1 //####COPYRIGHTBEGIN#### | |
| 2 // | |
| 3 // ---------------------------------------------------------------------------- | |
| 4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 5 // | |
| 6 // This program is part of the eCos host tools. | |
| 7 // | |
| 8 // This program is free software; you can redistribute it and/or modify it | |
| 9 // under the terms of the GNU General Public License as published by the Free | |
| 10 // Software Foundation; either version 2 of the License, or (at your option) | |
| 11 // any later version. | |
| 12 // | |
| 13 // This program is distributed in the hope that it will be useful, but WITHOUT | |
| 14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
| 16 // more details. | |
| 17 // | |
| 18 // You should have received a copy of the GNU General Public License along with | |
| 19 // this program; if not, write to the Free Software Foundation, Inc., | |
| 20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 // | |
| 22 // ---------------------------------------------------------------------------- | |
| 23 // | |
| 24 //####COPYRIGHTEND#### | |
| 25 // DescView.cpp : implementation file | |
| 26 // | |
| 27 | |
| 28 #include "stdafx.h" | |
| 29 #include "DescView.h" | |
| 30 #include "ConfigItem.h" | |
| 31 #include "ConfigTool.h" | |
| 32 #include "ControlView.h" | |
| 33 #include "ConfigToolDoc.h" | |
| 34 #include "CTUtils.h" | |
| 35 #include "resource.h" | |
| 36 | |
| 37 #ifndef PLUGIN | |
| 38 #include "MainFrm.h" | |
| 39 #endif | |
| 40 | |
| 41 #ifdef _DEBUG | |
| 42 #define new DEBUG_NEW | |
| 43 #undef THIS_FILE | |
| 44 static char THIS_FILE[] = __FILE__; | |
| 45 #endif | |
| 46 | |
| 47 ///////////////////////////////////////////////////////////////////////////// | |
| 48 // CDescView | |
| 49 | |
| 50 IMPLEMENT_DYNCREATE(CDescView, CScrollView) | |
| 51 | |
| 52 CDescView::CDescView(): | |
| 53 m_pti(NULL) | |
| 54 { | |
| 55 CConfigTool::SetDescView(this); | |
| 56 } | |
| 57 | |
| 58 CDescView::~CDescView() | |
| 59 { | |
| 60 CConfigTool::SetDescView(0); | |
| 61 } | |
| 62 | |
| 63 | |
| 64 BEGIN_MESSAGE_MAP(CDescView, CScrollView) | |
| 65 //{{AFX_MSG_MAP(CDescView) | |
| 66 ON_WM_ERASEBKGND() | |
| 67 ON_WM_SIZE() | |
| 68 ON_WM_CREATE() | |
| 69 ON_WM_HELPINFO() | |
| 70 //}}AFX_MSG_MAP | |
| 71 END_MESSAGE_MAP() | |
| 72 | |
| 73 ///////////////////////////////////////////////////////////////////////////// | |
| 74 // CDescView drawing | |
| 75 | |
| 76 void CDescView::OnInitialUpdate() | |
| 77 { | |
| 78 CScrollView::OnInitialUpdate(); | |
| 79 CControlView *pControlView=CConfigTool::GetControlView(); | |
| 80 if(pControlView){ | |
| 81 HTREEITEM hItem = pControlView->GetSelectedItem(); | |
| 82 if(NULL!=hItem){ | |
| 83 OnUpdate(this,(LPARAM)CConfigToolDoc::SelChanged,(CObject *)&(pControlView->TI(hItem))); | |
| 84 } | |
| 85 } | |
| 86 // TODO: calculate the total size of this view | |
| 87 SIZE sizeTotal; | |
| 88 sizeTotal.cx = sizeTotal.cy = 100; | |
| 89 SetScrollSizes(MM_TEXT, sizeTotal); | |
| 90 } | |
| 91 | |
| 92 void CDescView::OnDraw(CDC* pDC) | |
| 93 { | |
| 94 if(m_pti){ | |
| 95 CRect rcClient; | |
| 96 GetClientRect(rcClient); | |
| 97 rcClient.bottom=m_nTotalHeight; | |
| 98 #ifdef PLUGIN | |
| 99 CFont *pOldFont=pDC->SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT))); | |
| 100 #else | |
| 101 CMainFrame *pMain=(CMainFrame *)AfxGetMainWnd(); | |
| 102 CFont *pOldFont=pDC->SelectObject(&pMain->GetPaneFont(CMainFrame::ShortDesc)); | |
| 103 #endif | |
| 104 pDC->SetBkColor(GetSysColor(COLOR_INFOBK)); | |
| 105 pDC->SetBkMode(TRANSPARENT); | |
| 106 pDC->DrawText(m_pti->Desc(),rcClient,DT_NOPREFIX|DT_WORDBREAK); | |
| 107 pDC->SelectObject(pOldFont); | |
| 108 } | |
| 109 } | |
| 110 ///////////////////////////////////////////////////////////////////////////// | |
| 111 // CDescView diagnostics | |
| 112 | |
| 113 #ifdef _DEBUG | |
| 114 void CDescView::AssertValid() const | |
| 115 { | |
| 116 CScrollView::AssertValid(); | |
| 117 } | |
| 118 | |
| 119 void CDescView::Dump(CDumpContext& dc) const | |
| 120 { | |
| 121 CScrollView::Dump(dc); | |
| 122 } | |
| 123 #endif //_DEBUG | |
| 124 | |
| 125 ///////////////////////////////////////////////////////////////////////////// | |
| 126 // CDescView message handlers | |
| 127 | |
| 128 void CDescView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) | |
| 129 { | |
| 130 CConfigToolDoc* pDoc = CConfigTool::GetConfigToolDoc(); | |
| 131 // For all known hints we redraw everything | |
| 132 // The Selchanged hint tells us what to redraw | |
| 133 switch(lHint){ | |
| 134 case CConfigToolDoc::SelChanged: | |
| 135 if(pDoc->ItemCount()>0){ | |
| 136 m_pti=(CConfigItem *)pHint; | |
| 137 } else { | |
| 138 // In process of destroying configitems - no nothing | |
| 139 m_pti=NULL; | |
| 140 } | |
| 141 break; | |
| 142 case CConfigToolDoc::Clear: | |
| 143 m_pti=NULL; | |
| 144 break; | |
| 145 default: | |
| 146 return; | |
| 147 } | |
| 148 SetScrollInfo(); | |
| 149 Invalidate(); | |
| 150 | |
| 151 UNUSED_ALWAYS(pSender); | |
| 152 } | |
| 153 | |
| 154 BOOL CDescView::OnEraseBkgnd(CDC* pDC) | |
| 155 { | |
| 156 CRect rcClient; | |
| 157 pDC->GetClipBox(rcClient); | |
| 158 pDC->FillSolidRect(rcClient,GetSysColor(COLOR_INFOBK)); | |
| 159 | |
| 160 return TRUE;//return CScrollView::OnEraseBkgnd(pDC); | |
| 161 } | |
| 162 | |
| 163 | |
| 164 void CDescView::SetScrollInfo() | |
| 165 { | |
| 166 CSize sizePage,sizeLine,sizeTotal; | |
| 167 if(m_pti){ | |
| 168 CDC *pDC=GetDC(); | |
| 169 CRect rcClient; | |
| 170 GetClientRect(rcClient); | |
| 171 #ifdef PLUGIN | |
| 172 CFont *pOldFont=pDC->SelectObject(CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT))); | |
| 173 #else | |
| 174 CMainFrame *pMain=(CMainFrame *)AfxGetMainWnd(); | |
| 175 CFont *pOldFont=pDC->SelectObject(&pMain->GetPaneFont(CMainFrame::ShortDesc)); | |
| 176 #endif | |
| 177 //pDC->DrawText(m_pti->Desc(),rcClient,DT_NOPREFIX|DT_WORDBREAK); | |
| 178 sizeTotal.cx=0; | |
| 179 m_nTotalHeight=sizeTotal.cy=pDC->DrawText(m_pti->Desc(),rcClient,DT_NOPREFIX|DT_CALCRECT|DT_WORDBREAK); | |
| 180 TEXTMETRIC tm; | |
| 181 pDC->GetTextMetrics(&tm); | |
| 182 sizeLine.cx=0; | |
| 183 sizeLine.cy=tm.tmHeight; | |
| 184 sizePage.cx=0; | |
| 185 sizePage.cy=sizeTotal.cy-sizeLine.cy; | |
| 186 pDC->SelectObject(pOldFont); | |
| 187 ReleaseDC(pDC); | |
| 188 } else { | |
| 189 sizeTotal=CSize(0,0); | |
| 190 sizePage=sizeDefault; | |
| 191 sizeLine=sizeDefault; | |
| 192 } | |
| 193 SetScrollSizes(MM_TEXT,sizeTotal,sizePage,sizeLine); | |
| 194 | |
| 195 } | |
| 196 | |
| 197 void CDescView::OnSize(UINT nType, int cx, int cy) | |
| 198 { | |
| 199 CScrollView::OnSize(nType, cx, cy); | |
| 200 | |
| 201 SetScrollInfo(); | |
| 202 } | |
| 203 | |
| 204 int CDescView::OnCreate(LPCREATESTRUCT lpCreateStruct) | |
| 205 { | |
| 206 if (CScrollView::OnCreate(lpCreateStruct) == -1) | |
| 207 return -1; | |
| 208 | |
| 209 | |
| 210 SendMessage(WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); | |
| 211 return 0; | |
| 212 } | |
| 213 | |
| 214 | |
| 215 | |
| 216 BOOL CDescView::OnHelpInfo(HELPINFO*) | |
| 217 { | |
| 218 return CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_DESC_VIEW_HELP)); | |
| 219 } |
