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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [wxwin/] [mltwin.cpp] - Blame information for rev 174

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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