⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mltwin.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//####COPYRIGHTBEGIN####//// ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// This program is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it// under the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 of the License, or (at your option)// any later version.//// This program is distributed in the hope that it will be useful, but WITHOUT// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for// more details.//// You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.//// ----------------------------------------------------------------------------////####COPYRIGHTEND####// mltwin.cpp :////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   julians// Contact(s):  julians// Date:        2000/09/27// Version:     $Id: mltwin.cpp,v 1.2 2001/03/22 11:27:28 julians Exp $// Purpose:// Description: Implementation file for ecMemoryLayoutWindow// Requires:// Provides:// See also:// Known bugs:// Usage:////####DESCRIPTIONEND####////===========================================================================// ============================================================================// declarations// ============================================================================// ----------------------------------------------------------------------------// headers// ----------------------------------------------------------------------------#ifdef __GNUG__    #pragma implementation "mltwin.h"#endif// Includes other headers for precompiled compilation#include "ecpch.h"#ifdef __BORLANDC__    #pragma hdrstop#endif#include "mltwin.h"#include "sectiondlg.h"#define VERT_BORDER 30 /* the vertical border at the top/bottom of the client area */#define HORIZ_BORDER 30 /* the horizontal border at the left/right of the client area */#define BAR_HEIGHT 18 /* the height of the memory section caption bar */#define MAP_HEIGHT 66 /* the height of each memory section rectangle (including caption bar) */#define REGION_SPACING 115 /* the vertical offset between successive memory regions */#define ADDRESS_TEXT_SPACE 0.9 /* use 90% of the section width to draw the address */#define EXTERNAL_TEXT_BORDER 5 /* spacing between external text and border of region */#define ADDRESS_FORMAT _T("%08X") /* draw memory addresses in hex format */#define UNITS_PER_SECTION 3 /* memory section width in units, unused sections are 1 unit wide */#define UNIT_WIDTH_MIN 27 /* minimum width of memory section unit before horizontal scrolling enabled */#define TICK_HEIGHT 4 /* the height of the tick marks on the memory sections and regions */#define DISPLAY_MODE 1 /* 1 == const unit width for all regions *//* 2 == const region width for all regions *//* * ecMemoryLayoutWindow */IMPLEMENT_CLASS(ecMemoryLayoutWindow, wxScrolledWindow)BEGIN_EVENT_TABLE(ecMemoryLayoutWindow, wxScrolledWindow)//    EVT_PAINT(ecMemoryLayoutWindow::OnPaint)    EVT_MOUSE_EVENTS(ecMemoryLayoutWindow::OnMouseEvent)    EVT_PAINT(ecMemoryLayoutWindow::OnPaint)    EVT_SIZE(ecMemoryLayoutWindow::OnSize)    EVT_MENU(ecID_TREE_PROPERTIES, ecMemoryLayoutWindow::OnProperties)END_EVENT_TABLE()ecMemoryLayoutWindow::ecMemoryLayoutWindow(wxWindow* parent, wxWindowID id, const wxPoint& pt,        const wxSize& sz, long style):        wxScrolledWindow(parent, id, pt, sz, style){    m_uViewWidth = 0;    m_uClientWidth = 0;    m_uUnitCountMax = 0;    SetBackgroundColour(* wxWHITE);    m_propertiesMenu = new wxMenu;    m_propertiesMenu->Append(ecID_WHATS_THIS, _("&What's This?"));    m_propertiesMenu->AppendSeparator();    m_propertiesMenu->Append(ecID_TREE_PROPERTIES, _("P&roperties"));        }ecMemoryLayoutWindow::~ecMemoryLayoutWindow(){    delete m_propertiesMenu;}void ecMemoryLayoutWindow::OnPaint(wxPaintEvent& event){    wxPaintDC dc(this);    PrepareDC(dc);    ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();    if (pDoc == NULL) // no document so nothing to draw        return;#if 0        // clear the lists of region and section rectangles used for hit testing        listRegionRect.RemoveAll ();    listSectionRect.RemoveAll ();        // setup background mode        int nOldBkMode = pDC->SetBkMode (TRANSPARENT);        // setup font        CFont fntName;    if (!fntName.CreatePointFont (80, _T("MS Sans Serif"), pDC))        return;    CFont * pOldFont = pDC->SelectObject (&fntName);        // determine max unit count for any region        mem_map * pMemoryMap = &CConfigTool::GetConfigToolDoc()->MemoryMap;        // calculate the unit scaling for DISPLAY_MODE 1        UINT uPixelsPerUnit = UNIT_WIDTH_MIN;    RECT rectClientRect;    if (m_uUnitCountMax != 0) // if there is something to draw    {                GetClientRect (&rectClientRect);        uPixelsPerUnit = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN);        m_uViewWidth = uPixelsPerUnit * m_uUnitCountMax + HORIZ_BORDER * 2;    }        // draw the regions        UINT uRegion = 0;    UINT uUnitCount;    list <mem_region>::iterator region;    for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region)    {        uUnitCount = 0;        for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)            uUnitCount += (section_view->section == NULL ? 1 : UNITS_PER_SECTION);                if (DISPLAY_MODE == 1)            DrawRegion (pDC, uRegion++, uUnitCount, uPixelsPerUnit, region);        else // DISPLAY_MODE == 2            DrawRegion (pDC, uRegion++, uUnitCount, (rectClientRect.right - HORIZ_BORDER * 2) / uUnitCount, region);    }            pDC->SelectObject (pOldFont);    pDC->SetBkMode (nOldBkMode);#endif}void ecMemoryLayoutWindow::OnMouseEvent(wxMouseEvent& event){    if (event.RightDown())    {        PopupMenu(GetPropertiesMenu(), event.GetX(), event.GetY());    }}void ecMemoryLayoutWindow::OnProperties(wxCommandEvent& event){    ecSectionDialog dialog(wxTheApp->GetTopWindow());    dialog.ShowModal();}void ecMemoryLayoutWindow::RefreshMLT(){#if 0    // From OnUpdate in the MFC tool    if ((lHint != 0) && (pHint != NULL) && (lHint != CConfigToolDoc::MemLayoutChanged))        return; // no need to invalidate the view    m_arstrTooltipRects.RemoveAll();        CalcUnitCountMax (); // recalculate the total view width since the section count may have changed    if (m_uUnitCountMax == 0 || (m_uClientWidth < HORIZ_BORDER * 2)) // there is nothing to draw        m_uViewWidth = 0;    else // allow horizontal scrolling when the unit width reduces to UNIT_WIDTH_MIN        m_uViewWidth = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN) * m_uUnitCountMax + HORIZ_BORDER * 2;        SIZE sizeTotal;    sizeTotal.cx = __max (m_uViewWidth, m_uClientWidth);    sizeTotal.cy = CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size () * REGION_SPACING + EXTERNAL_TEXT_BORDER * 2;    SetScrollSizes (MM_TEXT, sizeTotal);#endif}#if ecUSE_MLTvoid ecMemoryLayoutWindow::DrawRegion (wxDC& dc, int uRegion, int uUnitCount, int uPixelsPerUnit, std::list <mem_region>::iterator region){#if 0    BOOL bDrawFocusRect = FALSE;    CRect rectAddress;    CString strAddress;        // setup the drawing objects        CBrush brshUnusedSection;    if (!brshUnusedSection.CreateHatchBrush (HS_BDIAGONAL, RGB (128, 128, 128)))        return;        CBrush brshUsedSection;    if (!brshUsedSection.CreateSolidBrush (GetSysColor (COLOR_WINDOW)))        return;        CBrush brshInitialSectionBar;    if (!brshInitialSectionBar.CreateSolidBrush (GetSysColor (COLOR_INACTIVECAPTION)))        return;        CBrush brshFixedSectionBar;    if (!brshFixedSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))        return;        CBrush brshFinalSectionBar;    if (!brshFinalSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))        return;        CPen penBorder;    if (!penBorder.CreatePen (PS_SOLID, 1, GetSysColor (COLOR_WINDOWTEXT)))        return;        CPen penSelected;    if (!penSelected.CreatePen (PS_SOLID, 2, GetSysColor (COLOR_WINDOWTEXT)))        return;        // select the border pen object        CPen * pOldPen = pDC->SelectObject (&penBorder);        // calculate the region rectangle        REGIONRECT srRegion;    srRegion.Rect.SetRect (HORIZ_BORDER, VERT_BORDER + REGION_SPACING * uRegion, HORIZ_BORDER + uUnitCount * uPixelsPerUnit + 1, VERT_BORDER + REGION_SPACING * uRegion + MAP_HEIGHT + 1);    srRegion.Region = region;    listRegionRect.AddTail (srRegion);        // draw the region        CPoint pointOrigin (srRegion.Rect.left, srRegion.Rect.top);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -