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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [mltwin.cpp] - Blame information for rev 790

Go to most recent revision | 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
// mltwin.cpp :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians
28
// Contact(s):  julians
29
// Date:        2000/09/27
30
// Version:     $Id: mltwin.cpp,v 1.2 2001/03/22 11:27:28 julians Exp $
31
// Purpose:
32
// Description: Implementation file for ecMemoryLayoutWindow
33
// Requires:
34
// Provides:
35
// See also:
36
// Known bugs:
37
// Usage:
38
//
39
//####DESCRIPTIONEND####
40
//
41
//===========================================================================
42
 
43
// ============================================================================
44
// declarations
45
// ============================================================================
46
 
47
// ----------------------------------------------------------------------------
48
// headers
49
// ----------------------------------------------------------------------------
50
#ifdef __GNUG__
51
    #pragma implementation "mltwin.h"
52
#endif
53
 
54
// Includes other headers for precompiled compilation
55
#include "ecpch.h"
56
 
57
#ifdef __BORLANDC__
58
    #pragma hdrstop
59
#endif
60
 
61
#include "mltwin.h"
62
#include "sectiondlg.h"
63
 
64
#define VERT_BORDER 30 /* the vertical border at the top/bottom of the client area */
65
#define HORIZ_BORDER 30 /* the horizontal border at the left/right of the client area */
66
#define BAR_HEIGHT 18 /* the height of the memory section caption bar */
67
#define MAP_HEIGHT 66 /* the height of each memory section rectangle (including caption bar) */
68
#define REGION_SPACING 115 /* the vertical offset between successive memory regions */
69
#define ADDRESS_TEXT_SPACE 0.9 /* use 90% of the section width to draw the address */
70
#define EXTERNAL_TEXT_BORDER 5 /* spacing between external text and border of region */
71
#define ADDRESS_FORMAT _T("%08X") /* draw memory addresses in hex format */
72
#define UNITS_PER_SECTION 3 /* memory section width in units, unused sections are 1 unit wide */
73
#define UNIT_WIDTH_MIN 27 /* minimum width of memory section unit before horizontal scrolling enabled */
74
#define TICK_HEIGHT 4 /* the height of the tick marks on the memory sections and regions */
75
 
76
#define DISPLAY_MODE 1 /* 1 == const unit width for all regions */
77
/* 2 == const region width for all regions */
78
 
79
 
80
/*
81
 * ecMemoryLayoutWindow
82
 */
83
 
84
IMPLEMENT_CLASS(ecMemoryLayoutWindow, wxScrolledWindow)
85
 
86
BEGIN_EVENT_TABLE(ecMemoryLayoutWindow, wxScrolledWindow)
87
//    EVT_PAINT(ecMemoryLayoutWindow::OnPaint)
88
    EVT_MOUSE_EVENTS(ecMemoryLayoutWindow::OnMouseEvent)
89
    EVT_PAINT(ecMemoryLayoutWindow::OnPaint)
90
    EVT_SIZE(ecMemoryLayoutWindow::OnSize)
91
    EVT_MENU(ecID_TREE_PROPERTIES, ecMemoryLayoutWindow::OnProperties)
92
END_EVENT_TABLE()
93
 
94
ecMemoryLayoutWindow::ecMemoryLayoutWindow(wxWindow* parent, wxWindowID id, const wxPoint& pt,
95
        const wxSize& sz, long style):
96
        wxScrolledWindow(parent, id, pt, sz, style)
97
{
98
    m_uViewWidth = 0;
99
    m_uClientWidth = 0;
100
    m_uUnitCountMax = 0;
101
 
102
    SetBackgroundColour(* wxWHITE);
103
 
104
    m_propertiesMenu = new wxMenu;
105
 
106
    m_propertiesMenu->Append(ecID_WHATS_THIS, _("&What's This?"));
107
    m_propertiesMenu->AppendSeparator();
108
    m_propertiesMenu->Append(ecID_TREE_PROPERTIES, _("P&roperties"));
109
}
110
 
111
ecMemoryLayoutWindow::~ecMemoryLayoutWindow()
112
{
113
    delete m_propertiesMenu;
114
}
115
 
116
void ecMemoryLayoutWindow::OnPaint(wxPaintEvent& event)
117
{
118
    wxPaintDC dc(this);
119
 
120
    PrepareDC(dc);
121
 
122
    ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();
123
    if (pDoc == NULL) // no document so nothing to draw
124
        return;
125
 
126
#if 0    
127
    // clear the lists of region and section rectangles used for hit testing
128
 
129
    listRegionRect.RemoveAll ();
130
    listSectionRect.RemoveAll ();
131
 
132
    // setup background mode
133
 
134
    int nOldBkMode = pDC->SetBkMode (TRANSPARENT);
135
 
136
    // setup font
137
 
138
    CFont fntName;
139
    if (!fntName.CreatePointFont (80, _T("MS Sans Serif"), pDC))
140
        return;
141
    CFont * pOldFont = pDC->SelectObject (&fntName);
142
 
143
    // determine max unit count for any region
144
 
145
    mem_map * pMemoryMap = &CConfigTool::GetConfigToolDoc()->MemoryMap;
146
 
147
    // calculate the unit scaling for DISPLAY_MODE 1
148
 
149
    UINT uPixelsPerUnit = UNIT_WIDTH_MIN;
150
    RECT rectClientRect;
151
    if (m_uUnitCountMax != 0) // if there is something to draw
152
    {
153
 
154
        GetClientRect (&rectClientRect);
155
        uPixelsPerUnit = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN);
156
        m_uViewWidth = uPixelsPerUnit * m_uUnitCountMax + HORIZ_BORDER * 2;
157
    }
158
 
159
    // draw the regions
160
 
161
    UINT uRegion = 0;
162
    UINT uUnitCount;
163
    list <mem_region>::iterator region;
164
    for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region)
165
    {
166
        uUnitCount = 0;
167
        for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
168
            uUnitCount += (section_view->section == NULL ? 1 : UNITS_PER_SECTION);
169
 
170
        if (DISPLAY_MODE == 1)
171
            DrawRegion (pDC, uRegion++, uUnitCount, uPixelsPerUnit, region);
172
        else // DISPLAY_MODE == 2
173
            DrawRegion (pDC, uRegion++, uUnitCount, (rectClientRect.right - HORIZ_BORDER * 2) / uUnitCount, region);
174
    }
175
 
176
    pDC->SelectObject (pOldFont);
177
    pDC->SetBkMode (nOldBkMode);
178
#endif
179
}
180
 
181
void ecMemoryLayoutWindow::OnMouseEvent(wxMouseEvent& event)
182
{
183
    if (event.RightDown())
184
    {
185
        PopupMenu(GetPropertiesMenu(), event.GetX(), event.GetY());
186
    }
187
}
188
 
189
void ecMemoryLayoutWindow::OnProperties(wxCommandEvent& event)
190
{
191
    ecSectionDialog dialog(wxTheApp->GetTopWindow());
192
    dialog.ShowModal();
193
}
194
 
195
void ecMemoryLayoutWindow::RefreshMLT()
196
{
197
#if 0
198
    // From OnUpdate in the MFC tool
199
 
200
    if ((lHint != 0) && (pHint != NULL) && (lHint != CConfigToolDoc::MemLayoutChanged))
201
        return; // no need to invalidate the view
202
    m_arstrTooltipRects.RemoveAll();
203
 
204
    CalcUnitCountMax (); // recalculate the total view width since the section count may have changed
205
    if (m_uUnitCountMax == 0 || (m_uClientWidth < HORIZ_BORDER * 2)) // there is nothing to draw
206
        m_uViewWidth = 0;
207
    else // allow horizontal scrolling when the unit width reduces to UNIT_WIDTH_MIN
208
        m_uViewWidth = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN) * m_uUnitCountMax + HORIZ_BORDER * 2;
209
 
210
    SIZE sizeTotal;
211
    sizeTotal.cx = __max (m_uViewWidth, m_uClientWidth);
212
    sizeTotal.cy = CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size () * REGION_SPACING + EXTERNAL_TEXT_BORDER * 2;
213
    SetScrollSizes (MM_TEXT, sizeTotal);
214
#endif
215
}
216
 
217
#if ecUSE_MLT
218
void ecMemoryLayoutWindow::DrawRegion (wxDC& dc, int uRegion, int uUnitCount, int uPixelsPerUnit, std::list <mem_region>::iterator region)
219
{
220
#if 0
221
    BOOL bDrawFocusRect = FALSE;
222
    CRect rectAddress;
223
    CString strAddress;
224
 
225
    // setup the drawing objects
226
 
227
    CBrush brshUnusedSection;
228
    if (!brshUnusedSection.CreateHatchBrush (HS_BDIAGONAL, RGB (128, 128, 128)))
229
        return;
230
 
231
    CBrush brshUsedSection;
232
    if (!brshUsedSection.CreateSolidBrush (GetSysColor (COLOR_WINDOW)))
233
        return;
234
 
235
    CBrush brshInitialSectionBar;
236
    if (!brshInitialSectionBar.CreateSolidBrush (GetSysColor (COLOR_INACTIVECAPTION)))
237
        return;
238
 
239
    CBrush brshFixedSectionBar;
240
    if (!brshFixedSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
241
        return;
242
 
243
    CBrush brshFinalSectionBar;
244
    if (!brshFinalSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
245
        return;
246
 
247
    CPen penBorder;
248
    if (!penBorder.CreatePen (PS_SOLID, 1, GetSysColor (COLOR_WINDOWTEXT)))
249
        return;
250
 
251
    CPen penSelected;
252
    if (!penSelected.CreatePen (PS_SOLID, 2, GetSysColor (COLOR_WINDOWTEXT)))
253
        return;
254
 
255
    // select the border pen object
256
 
257
    CPen * pOldPen = pDC->SelectObject (&penBorder);
258
 
259
    // calculate the region rectangle
260
 
261
    REGIONRECT srRegion;
262
    srRegion.Rect.SetRect (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + uUnitCount * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + 1);
263
    srRegion.Region = region;
264
    listRegionRect.AddTail (srRegion);
265
 
266
    // draw the region
267
 
268
    CPoint pointOrigin (srRegion.Rect.left, srRegion.Rect.top);
269
    pDC->LPtoDP (&pointOrigin);
270
    pointOrigin.x %= 8;
271
    pointOrigin.y %= 8;
272
    pDC->SetBrushOrg (pointOrigin);
273
    CBrush * pOldBrush = pDC->SelectObject (&brshUnusedSection);
274
    pDC->Rectangle (srRegion.Rect);
275
    /*
276
    pDC->MoveTo (srRegion.Rect.left, srRegion.Rect.bottom - 1); // draw tick
277
    pDC->LineTo (srRegion.Rect.left, srRegion.Rect.bottom + TICK_HEIGHT); // draw tick
278
    */
279
    if (region == m_riSelectedRegion)
280
    {
281
        bDrawFocusRect = TRUE;
282
        m_rectSelectedItem = srRegion.Rect;
283
    }
284
 
285
    // draw the region label
286
 
287
    CRect rectRegionLabel (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion - EXTERNAL_TEXT_BORDER - 20, m_uViewWidth - HORIZ_BORDER /*HORIZ_BORDER + uUnitCount * uPixelsPerUnit + 1*/, VERT_BORDER + REGION_SPACING * uRegion - EXTERNAL_TEXT_BORDER);
288
    CString strRegionLabel;
289
    strRegionLabel.Format (_T("%s (%08X-%08X)%s"), CString(region->name.c_str ()), region->address, region->address + region->size - 1, ((region->type == read_only) ? _T(" read only") : _T("")));
290
    pDC->DrawText (strRegionLabel, -1, rectRegionLabel, DT_BOTTOM | DT_SINGLELINE);
291
 
292
    // draw the start address of the region
293
    /*
294
    rectAddress.SetRect (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + ADDRESS_TEXT_SPACE * UNITS_PER_SECTION * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
295
    strAddress.Format (ADDRESS_FORMAT, region->address);
296
    pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
297
    */
298
    // draw the end address of the region
299
    /*
300
    rectAddress.SetRect (HORIZ_BORDER + (uUnitCount - ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + (uUnitCount + ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
301
    strAddress.Format (ADDRESS_FORMAT, region->address + region->size);
302
    pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
303
    */
304
    // draw the sections within the region
305
 
306
    UINT uSectionUnitCount = 0;
307
    CRect rectBar;
308
    SECTIONRECT srSection;
309
    for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
310
    {
311
        if (section_view->section != NULL) // the section is used
312
        {
313
            // draw the section
314
 
315
            pDC->SelectObject (brshUsedSection);
316
            srSection.Rect.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION) * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + 1);
317
            srSection.SectionView = section_view;
318
            listSectionRect.AddTail (srSection);
319
            pDC->Rectangle (srSection.Rect);
320
            if (section_view == m_sviSelectedSectionView)
321
            {
322
                bDrawFocusRect = TRUE;
323
                m_rectSelectedItem = srSection.Rect;
324
            }
325
 
326
            // draw text within the section
327
 
328
            CString strSection, strSectionLine;
329
 
330
            if ((section_view->section_location != initial_location) && (section_view->section->alignment > 1))
331
            {
332
                strSectionLine.Format (_T("align %lX\n"), section_view->section->alignment);
333
                strSection += strSectionLine;
334
            }
335
 
336
            if (section_view->section->size > 0)
337
            {
338
                strSectionLine.Format (_T("size %lX\n"), section_view->section->size);
339
                strSection += strSectionLine;
340
            }
341
 
342
            if (section_view->section_location == final_location)
343
            {
344
                strSectionLine.Format (_T("relocated\n"));
345
                strSection += strSectionLine;
346
            }
347
 
348
            pDC->DrawText (strSection, -1, srSection.Rect - (LPCRECT) CRect (EXTERNAL_TEXT_BORDER, EXTERNAL_TEXT_BORDER + BAR_HEIGHT, EXTERNAL_TEXT_BORDER, EXTERNAL_TEXT_BORDER), DT_LEFT);
349
 
350
            // select caption bar colour according to type of section
351
 
352
            if (section_view->section_location == initial_location)
353
            {
354
                pDC->SetTextColor (GetSysColor (COLOR_INACTIVECAPTIONTEXT));
355
                pDC->SelectObject (&brshInitialSectionBar);
356
            }
357
            else
358
            {
359
                pDC->SetTextColor (GetSysColor (COLOR_CAPTIONTEXT));
360
                pDC->SelectObject (&brshFinalSectionBar);
361
            }
362
 
363
            // draw the caption bar
364
 
365
            rectBar.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION) * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + BAR_HEIGHT + 1);
366
            pDC->Rectangle (rectBar);
367
 
368
            // draw the section name within the caption bar
369
 
370
            CString strName(section_view->section->name.c_str ());
371
            CRect *pRect=NULL;
372
            m_arstrTooltipRects.Lookup(strName,(void *&)pRect);
373
            UINT format;
374
            if(pDC->GetTextExtent(strName).cx>rectBar.Width()-2*EXTERNAL_TEXT_BORDER){
375
                format=DT_LEFT;
376
                if(pRect){
377
                    pRect->CopyRect(rectBar);
378
                } else {
379
                    pRect=new CRect;
380
                    m_arstrTooltipRects.SetAt(strName,pRect);
381
                }
382
                // Replace final three characters of name with an elipsis
383
                int nLength=1+max(1,strName.GetLength()-3);
384
                do {
385
                    --nLength;
386
                    strName=strName.Left(nLength)+_T("...");
387
                } while(nLength>1 && pDC->GetTextExtent(strName).cx>rectBar.Width()-2*EXTERNAL_TEXT_BORDER);
388
 
389
                rectBar.left+=EXTERNAL_TEXT_BORDER;
390
                rectBar.right-=EXTERNAL_TEXT_BORDER;
391
            } else {
392
                format=DT_CENTER;
393
                if (pRect) {
394
                    m_arstrTooltipRects.RemoveKey(strName);
395
                }
396
            }
397
 
398
            pDC->DrawText (strName, -1, rectBar, format | DT_VCENTER | DT_SINGLELINE);
399
            pDC->SetTextColor (GetSysColor (COLOR_WINDOWTEXT));
400
 
401
            // find the mem_section item describing the current section_view item
402
 
403
            list <mem_section>::iterator MemorySection = section_view->section;
404
 
405
            // draw the section address if appropriate
406
 
407
            if ((section_view->section_location == initial_location))
408
            {
409
                if (MemorySection->initial_location->anchor == absolute)
410
                {
411
                    pDC->MoveTo (srSection.Rect.left, srSection.Rect.bottom - 1); // draw tick
412
                    pDC->LineTo (srSection.Rect.left, srSection.Rect.bottom + TICK_HEIGHT); // draw tick
413
                    rectAddress.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, (int) (HORIZ_BORDER + (uSectionUnitCount + ADDRESS_TEXT_SPACE * UNITS_PER_SECTION) * uPixelsPerUnit), VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
414
                    strAddress.Format (ADDRESS_FORMAT, MemorySection->initial_location->address);
415
                    pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
416
 
417
                    /*
418
                    if (MemorySection->size > 0) // the end address can be calculated
419
                    {
420
                    rectAddress.SetRect (HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION - ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION + ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
421
                    strAddress.Format (ADDRESS_FORMAT, MemorySection->initial_location->address + MemorySection->size);
422
                    pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
423
                    }
424
                    */
425
                }
426
            }
427
 
428
            else if ((section_view->section_location == final_location) || (section_view->section_location == fixed_location))
429
            {
430
                if (MemorySection->final_location->anchor == absolute)
431
                {
432
                    pDC->MoveTo (srSection.Rect.left, srSection.Rect.bottom - 1); // draw tick
433
                    pDC->LineTo (srSection.Rect.left, srSection.Rect.bottom + TICK_HEIGHT); // draw tick
434
                    rectAddress.SetRect (HORIZ_BORDER + uSectionUnitCount * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, (int) (HORIZ_BORDER + (uSectionUnitCount + ADDRESS_TEXT_SPACE * UNITS_PER_SECTION) * uPixelsPerUnit), VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
435
                    strAddress.Format (ADDRESS_FORMAT, MemorySection->final_location->address);
436
                    pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
437
 
438
                    /*
439
                    if (MemorySection->size > 0) // the end address can be calculated
440
                    {
441
                    rectAddress.SetRect (HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION - ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER, HORIZ_BORDER + (uSectionUnitCount + UNITS_PER_SECTION + ADDRESS_TEXT_SPACE) * uPixelsPerUnit, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + EXTERNAL_TEXT_BORDER + 30);
442
                    strAddress.Format (ADDRESS_FORMAT, MemorySection->final_location->address + MemorySection->size);
443
                    pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
444
                    }
445
                    */
446
                }
447
            }
448
 
449
            uSectionUnitCount += UNITS_PER_SECTION;
450
    }
451
    else
452
    {
453
        uSectionUnitCount++; // unused sections occupy a single unit
454
    }
455
  }
456
 
457
  // draw the focus rectangle around the selected object (if any)
458
 
459
  if (bDrawFocusRect)
460
      pDC->DrawFocusRect (m_rectSelectedItem + CRect (1, 1, 1, 1));
461
 
462
  // restore previous drawing objects
463
 
464
  pDC->SelectObject (pOldBrush);
465
  pDC->SelectObject (pOldPen);
466
#endif
467
}
468
 
469
SECTIONRECT * ecMemoryLayoutWindow::SectionHitTest (wxPoint pntTest)
470
{
471
#if 0
472
    for (POSITION posSection = listSectionRect.GetHeadPosition (); posSection != NULL; listSectionRect.GetNext (posSection))
473
    {
474
        if (listSectionRect.GetAt (posSection).Rect.PtInRect (pntTest))
475
            return & listSectionRect.GetAt (posSection);
476
    }
477
#endif
478
 
479
    return NULL;
480
}
481
 
482
REGIONRECT * ecMemoryLayoutWindow::RegionHitTest (wxPoint pntTest)
483
{
484
#if 0
485
    for (POSITION posRegion = listRegionRect.GetHeadPosition (); posRegion != NULL; listRegionRect.GetNext (posRegion))
486
    {
487
        CRect rectRegion = listRegionRect.GetAt (posRegion).Rect +
488
            CRect (EXTERNAL_TEXT_BORDER + 20, EXTERNAL_TEXT_BORDER + 20, EXTERNAL_TEXT_BORDER + 20, EXTERNAL_TEXT_BORDER + 20); // extended rectangle to allow clicking on region label
489
        if (rectRegion.PtInRect (pntTest))
490
            return & listRegionRect.GetAt (posRegion);
491
    }
492
#endif
493
 
494
    return NULL;
495
}
496
#endif
497
 
498
void ecMemoryLayoutWindow::OnSize(wxSizeEvent& event)
499
{
500
#if 0
501
    CScrollView::OnSize(nType, cx, cy);
502
 
503
    m_uClientWidth = cx;
504
    if (m_uUnitCountMax == 0) // there is nothing to draw
505
        m_uViewWidth = 0;
506
    else // allow horizontal scrolling when the unit width reduces to UNIT_WIDTH_MIN
507
        m_uViewWidth = __max ((cx - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN) * m_uUnitCountMax + HORIZ_BORDER * 2;
508
 
509
    SIZE sizeTotal;
510
    sizeTotal.cx = __max (m_uViewWidth, m_uClientWidth);
511
    if (CConfigTool::GetConfigToolDoc() == NULL)
512
        sizeTotal.cy = 0;
513
    else
514
        sizeTotal.cy = CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size () * REGION_SPACING + EXTERNAL_TEXT_BORDER * 2;
515
    SetScrollSizes (MM_TEXT, sizeTotal);
516
#endif
517
}
518
 
519
void ecMemoryLayoutWindow::CalcUnitCountMax ()
520
{
521
#if 0
522
    UINT uUnitCountMax = 0;
523
    UINT uUnitCount;
524
    list <mem_region>::iterator region;
525
    mem_map * pMemoryMap = & (CConfigTool::GetConfigToolDoc()->MemoryMap);
526
    for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region)
527
    {
528
        uUnitCount = 0;
529
        for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
530
            uUnitCount += (section_view->section == NULL ? 1 : UNITS_PER_SECTION);
531
 
532
        if (uUnitCount > uUnitCountMax)
533
            uUnitCountMax = uUnitCount;
534
    }
535
    m_uUnitCountMax = uUnitCountMax;
536
 #endif
537
}

powered by: WebSVN 2.1.0

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