OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [win32/] [DescView.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.