//####COPYRIGHTBEGIN####
|
//####COPYRIGHTBEGIN####
|
//
|
//
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
|
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
|
//
|
//
|
// This program is part of the eCos host tools.
|
// This program is part of the eCos host tools.
|
//
|
//
|
// This program is free software; you can redistribute it and/or modify it
|
// 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
|
// 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)
|
// Software Foundation; either version 2 of the License, or (at your option)
|
// any later version.
|
// any later version.
|
//
|
//
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
// more details.
|
// more details.
|
//
|
//
|
// You should have received a copy of the GNU General Public License along with
|
// 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.,
|
// this program; if not, write to the Free Software Foundation, Inc.,
|
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
//
|
//
|
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
//
|
//
|
//####COPYRIGHTEND####
|
//####COPYRIGHTEND####
|
// MLTView.cpp: implementation of the CMLTView class.
|
// MLTView.cpp: implementation of the CMLTView class.
|
//
|
//
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
|
#include "stdafx.h"
|
#include "stdafx.h"
|
#ifndef PLUGIN
|
#ifndef PLUGIN
|
#include "BCMenu.h"
|
#include "BCMenu.h"
|
#endif
|
#endif
|
#include "ConfigtoolDoc.h"
|
#include "ConfigtoolDoc.h"
|
#include "MLTView.h"
|
#include "MLTView.h"
|
#include "ConfigTool.h"
|
#include "ConfigTool.h"
|
#include "CTUtils.h"
|
#include "CTUtils.h"
|
#include "resource.h"
|
#include "resource.h"
|
|
|
#ifdef _DEBUG
|
#ifdef _DEBUG
|
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
#undef THIS_FILE
|
#undef THIS_FILE
|
static char THIS_FILE[] = __FILE__;
|
static char THIS_FILE[] = __FILE__;
|
#endif
|
#endif
|
|
|
using namespace std;
|
using namespace std;
|
|
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
// Construction/Destruction
|
// Construction/Destruction
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
|
IMPLEMENT_DYNCREATE(CMLTView, CScrollView)
|
IMPLEMENT_DYNCREATE(CMLTView, CScrollView)
|
|
|
BEGIN_MESSAGE_MAP(CMLTView, CScrollView)
|
BEGIN_MESSAGE_MAP(CMLTView, CScrollView)
|
//{{AFX_MSG_MAP(CMLTView)
|
//{{AFX_MSG_MAP(CMLTView)
|
ON_WM_LBUTTONDOWN()
|
ON_WM_LBUTTONDOWN()
|
ON_WM_LBUTTONDBLCLK()
|
ON_WM_LBUTTONDBLCLK()
|
ON_WM_SIZE()
|
ON_WM_SIZE()
|
ON_WM_ERASEBKGND()
|
ON_WM_ERASEBKGND()
|
ON_WM_MOUSEMOVE()
|
ON_WM_MOUSEMOVE()
|
ON_COMMAND(ID_EDIT_NEW_REGION, OnMLTNewRegion)
|
ON_COMMAND(ID_EDIT_NEW_REGION, OnMLTNewRegion)
|
ON_COMMAND(ID_EDIT_NEW_SECTION, OnMLTNewSection)
|
ON_COMMAND(ID_EDIT_NEW_SECTION, OnMLTNewSection)
|
ON_COMMAND(ID_EDIT_DELETE_SECTION, OnMLTDelete)
|
ON_COMMAND(ID_EDIT_DELETE_SECTION, OnMLTDelete)
|
ON_COMMAND(ID_EDIT_PROPERTIES, OnMLTProperties)
|
ON_COMMAND(ID_EDIT_PROPERTIES, OnMLTProperties)
|
ON_UPDATE_COMMAND_UI(ID_EDIT_NEW_SECTION, OnUpdateMLTNewSection)
|
ON_UPDATE_COMMAND_UI(ID_EDIT_NEW_SECTION, OnUpdateMLTNewSection)
|
ON_UPDATE_COMMAND_UI(ID_EDIT_DELETE_SECTION, OnUpdateMLTDelete)
|
ON_UPDATE_COMMAND_UI(ID_EDIT_DELETE_SECTION, OnUpdateMLTDelete)
|
ON_UPDATE_COMMAND_UI(ID_EDIT_PROPERTIES, OnUpdateMLTProperties)
|
ON_UPDATE_COMMAND_UI(ID_EDIT_PROPERTIES, OnUpdateMLTProperties)
|
ON_WM_CONTEXTMENU()
|
ON_WM_CONTEXTMENU()
|
ON_COMMAND(ID_POPUP_PROPERTIES, OnPopupProperties)
|
ON_COMMAND(ID_POPUP_PROPERTIES, OnPopupProperties)
|
ON_WM_RBUTTONDOWN()
|
ON_WM_RBUTTONDOWN()
|
ON_WM_KEYDOWN()
|
ON_WM_KEYDOWN()
|
ON_WM_HELPINFO()
|
ON_WM_HELPINFO()
|
ON_WM_MENUCHAR()
|
ON_WM_MENUCHAR()
|
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
|
// Standard printing commands
|
// Standard printing commands
|
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
|
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
|
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
|
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
|
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
|
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
|
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
|
|
CMLTView::CMLTView()
|
CMLTView::CMLTView()
|
{
|
{
|
m_uViewWidth = 0;
|
m_uViewWidth = 0;
|
m_uUnitCountMax = 0;
|
m_uUnitCountMax = 0;
|
CConfigTool::SetMLTView(this);
|
CConfigTool::SetMLTView(this);
|
}
|
}
|
|
|
CMLTView::~CMLTView()
|
CMLTView::~CMLTView()
|
{
|
{
|
CConfigTool::SetMLTView(0);
|
CConfigTool::SetMLTView(0);
|
for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){
|
for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){
|
CRect *pRect;
|
CRect *pRect;
|
CString strName;
|
CString strName;
|
m_arstrTooltipRects.GetNextAssoc( pos, strName, (void *&)pRect );
|
m_arstrTooltipRects.GetNextAssoc( pos, strName, (void *&)pRect );
|
delete pRect;
|
delete pRect;
|
}
|
}
|
}
|
}
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
// CMLTView drawing
|
// CMLTView drawing
|
|
|
#define VERT_BORDER 30 /* the vertical border at the top/bottom of the client area */
|
#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 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 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 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 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 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 EXTERNAL_TEXT_BORDER 5 /* spacing between external text and border of region */
|
#define ADDRESS_FORMAT _T("%08X") /* draw memory addresses in hex format */
|
#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 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 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 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 */
|
#define DISPLAY_MODE 1 /* 1 == const unit width for all regions */
|
/* 2 == const region width for all regions */
|
/* 2 == const region width for all regions */
|
|
|
void CMLTView::OnDraw(CDC* pDC)
|
void CMLTView::OnDraw(CDC* pDC)
|
{
|
{
|
CConfigToolDoc* pDoc = CConfigTool::GetConfigToolDoc();
|
CConfigToolDoc* pDoc = CConfigTool::GetConfigToolDoc();
|
if (pDoc == NULL) // no document so nothing to draw
|
if (pDoc == NULL) // no document so nothing to draw
|
return;
|
return;
|
|
|
// clear the lists of region and section rectangles used for hit testing
|
// clear the lists of region and section rectangles used for hit testing
|
|
|
listRegionRect.RemoveAll ();
|
listRegionRect.RemoveAll ();
|
listSectionRect.RemoveAll ();
|
listSectionRect.RemoveAll ();
|
|
|
// setup background mode
|
// setup background mode
|
|
|
int nOldBkMode = pDC->SetBkMode (TRANSPARENT);
|
int nOldBkMode = pDC->SetBkMode (TRANSPARENT);
|
|
|
// setup font
|
// setup font
|
|
|
CFont fntName;
|
CFont fntName;
|
if (!fntName.CreatePointFont (80, _T("MS Sans Serif"), pDC))
|
if (!fntName.CreatePointFont (80, _T("MS Sans Serif"), pDC))
|
return;
|
return;
|
CFont * pOldFont = pDC->SelectObject (&fntName);
|
CFont * pOldFont = pDC->SelectObject (&fntName);
|
|
|
// determine max unit count for any region
|
// determine max unit count for any region
|
|
|
mem_map * pMemoryMap = &CConfigTool::GetConfigToolDoc()->MemoryMap;
|
mem_map * pMemoryMap = &CConfigTool::GetConfigToolDoc()->MemoryMap;
|
|
|
// calculate the unit scaling for DISPLAY_MODE 1
|
// calculate the unit scaling for DISPLAY_MODE 1
|
|
|
UINT uPixelsPerUnit = UNIT_WIDTH_MIN;
|
UINT uPixelsPerUnit = UNIT_WIDTH_MIN;
|
RECT rectClientRect;
|
RECT rectClientRect;
|
if (m_uUnitCountMax != 0) // if there is something to draw
|
if (m_uUnitCountMax != 0) // if there is something to draw
|
{
|
{
|
|
|
GetClientRect (&rectClientRect);
|
GetClientRect (&rectClientRect);
|
uPixelsPerUnit = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN);
|
uPixelsPerUnit = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN);
|
m_uViewWidth = uPixelsPerUnit * m_uUnitCountMax + HORIZ_BORDER * 2;
|
m_uViewWidth = uPixelsPerUnit * m_uUnitCountMax + HORIZ_BORDER * 2;
|
}
|
}
|
|
|
// draw the regions
|
// draw the regions
|
|
|
UINT uRegion = 0;
|
UINT uRegion = 0;
|
UINT uUnitCount;
|
UINT uUnitCount;
|
list <mem_region>::iterator region;
|
list <mem_region>::iterator region;
|
for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region)
|
for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region)
|
{
|
{
|
uUnitCount = 0;
|
uUnitCount = 0;
|
for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
|
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);
|
uUnitCount += (section_view->section == NULL ? 1 : UNITS_PER_SECTION);
|
|
|
if (DISPLAY_MODE == 1)
|
if (DISPLAY_MODE == 1)
|
DrawRegion (pDC, uRegion++, uUnitCount, uPixelsPerUnit, region);
|
DrawRegion (pDC, uRegion++, uUnitCount, uPixelsPerUnit, region);
|
else // DISPLAY_MODE == 2
|
else // DISPLAY_MODE == 2
|
DrawRegion (pDC, uRegion++, uUnitCount, (rectClientRect.right - HORIZ_BORDER * 2) / uUnitCount, region);
|
DrawRegion (pDC, uRegion++, uUnitCount, (rectClientRect.right - HORIZ_BORDER * 2) / uUnitCount, region);
|
}
|
}
|
|
|
pDC->SelectObject (pOldFont);
|
pDC->SelectObject (pOldFont);
|
pDC->SetBkMode (nOldBkMode);
|
pDC->SetBkMode (nOldBkMode);
|
}
|
}
|
|
|
|
|
void CMLTView::DrawRegion (CDC* pDC, UINT uRegion, UINT uUnitCount, UINT uPixelsPerUnit, list <mem_region>::iterator region)
|
void CMLTView::DrawRegion (CDC* pDC, UINT uRegion, UINT uUnitCount, UINT uPixelsPerUnit, list <mem_region>::iterator region)
|
{
|
{
|
BOOL bDrawFocusRect = FALSE;
|
BOOL bDrawFocusRect = FALSE;
|
CRect rectAddress;
|
CRect rectAddress;
|
CString strAddress;
|
CString strAddress;
|
|
|
// setup the drawing objects
|
// setup the drawing objects
|
|
|
CBrush brshUnusedSection;
|
CBrush brshUnusedSection;
|
if (!brshUnusedSection.CreateHatchBrush (HS_BDIAGONAL, RGB (128, 128, 128)))
|
if (!brshUnusedSection.CreateHatchBrush (HS_BDIAGONAL, RGB (128, 128, 128)))
|
return;
|
return;
|
|
|
CBrush brshUsedSection;
|
CBrush brshUsedSection;
|
if (!brshUsedSection.CreateSolidBrush (GetSysColor (COLOR_WINDOW)))
|
if (!brshUsedSection.CreateSolidBrush (GetSysColor (COLOR_WINDOW)))
|
return;
|
return;
|
|
|
CBrush brshInitialSectionBar;
|
CBrush brshInitialSectionBar;
|
if (!brshInitialSectionBar.CreateSolidBrush (GetSysColor (COLOR_INACTIVECAPTION)))
|
if (!brshInitialSectionBar.CreateSolidBrush (GetSysColor (COLOR_INACTIVECAPTION)))
|
return;
|
return;
|
|
|
CBrush brshFixedSectionBar;
|
CBrush brshFixedSectionBar;
|
if (!brshFixedSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
|
if (!brshFixedSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
|
return;
|
return;
|
|
|
CBrush brshFinalSectionBar;
|
CBrush brshFinalSectionBar;
|
if (!brshFinalSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
|
if (!brshFinalSectionBar.CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)))
|
return;
|
return;
|
|
|
CPen penBorder;
|
CPen penBorder;
|
if (!penBorder.CreatePen (PS_SOLID, 1, GetSysColor (COLOR_WINDOWTEXT)))
|
if (!penBorder.CreatePen (PS_SOLID, 1, GetSysColor (COLOR_WINDOWTEXT)))
|
return;
|
return;
|
|
|
CPen penSelected;
|
CPen penSelected;
|
if (!penSelected.CreatePen (PS_SOLID, 2, GetSysColor (COLOR_WINDOWTEXT)))
|
if (!penSelected.CreatePen (PS_SOLID, 2, GetSysColor (COLOR_WINDOWTEXT)))
|
return;
|
return;
|
|
|
// select the border pen object
|
// select the border pen object
|
|
|
CPen * pOldPen = pDC->SelectObject (&penBorder);
|
CPen * pOldPen = pDC->SelectObject (&penBorder);
|
|
|
// calculate the region rectangle
|
// calculate the region rectangle
|
|
|
REGIONRECT srRegion;
|
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.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;
|
srRegion.Region = region;
|
listRegionRect.AddTail (srRegion);
|
listRegionRect.AddTail (srRegion);
|
|
|
// draw the region
|
// draw the region
|
|
|
CPoint pointOrigin (srRegion.Rect.left, srRegion.Rect.top);
|
CPoint pointOrigin (srRegion.Rect.left, srRegion.Rect.top);
|
pDC->LPtoDP (&pointOrigin);
|
pDC->LPtoDP (&pointOrigin);
|
pointOrigin.x %= 8;
|
pointOrigin.x %= 8;
|
pointOrigin.y %= 8;
|
pointOrigin.y %= 8;
|
pDC->SetBrushOrg (pointOrigin);
|
pDC->SetBrushOrg (pointOrigin);
|
CBrush * pOldBrush = pDC->SelectObject (&brshUnusedSection);
|
CBrush * pOldBrush = pDC->SelectObject (&brshUnusedSection);
|
pDC->Rectangle (srRegion.Rect);
|
pDC->Rectangle (srRegion.Rect);
|
/*
|
/*
|
pDC->MoveTo (srRegion.Rect.left, srRegion.Rect.bottom - 1); // draw tick
|
pDC->MoveTo (srRegion.Rect.left, srRegion.Rect.bottom - 1); // draw tick
|
pDC->LineTo (srRegion.Rect.left, srRegion.Rect.bottom + TICK_HEIGHT); // draw tick
|
pDC->LineTo (srRegion.Rect.left, srRegion.Rect.bottom + TICK_HEIGHT); // draw tick
|
*/
|
*/
|
if (region == m_riSelectedRegion)
|
if (region == m_riSelectedRegion)
|
{
|
{
|
bDrawFocusRect = TRUE;
|
bDrawFocusRect = TRUE;
|
m_rectSelectedItem = srRegion.Rect;
|
m_rectSelectedItem = srRegion.Rect;
|
}
|
}
|
|
|
// draw the region label
|
// draw the region label
|
|
|
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);
|
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);
|
CString strRegionLabel;
|
CString strRegionLabel;
|
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("")));
|
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("")));
|
pDC->DrawText (strRegionLabel, -1, rectRegionLabel, DT_BOTTOM | DT_SINGLELINE);
|
pDC->DrawText (strRegionLabel, -1, rectRegionLabel, DT_BOTTOM | DT_SINGLELINE);
|
|
|
// draw the start address of the region
|
// draw the start address of the region
|
/*
|
/*
|
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);
|
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);
|
strAddress.Format (ADDRESS_FORMAT, region->address);
|
strAddress.Format (ADDRESS_FORMAT, region->address);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
|
*/
|
*/
|
// draw the end address of the region
|
// draw the end address of the region
|
/*
|
/*
|
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);
|
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);
|
strAddress.Format (ADDRESS_FORMAT, region->address + region->size);
|
strAddress.Format (ADDRESS_FORMAT, region->address + region->size);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
|
*/
|
*/
|
// draw the sections within the region
|
// draw the sections within the region
|
|
|
UINT uSectionUnitCount = 0;
|
UINT uSectionUnitCount = 0;
|
CRect rectBar;
|
CRect rectBar;
|
SECTIONRECT srSection;
|
SECTIONRECT srSection;
|
for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
|
for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
|
{
|
{
|
if (section_view->section != NULL) // the section is used
|
if (section_view->section != NULL) // the section is used
|
{
|
{
|
// draw the section
|
// draw the section
|
|
|
pDC->SelectObject (brshUsedSection);
|
pDC->SelectObject (brshUsedSection);
|
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);
|
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);
|
srSection.SectionView = section_view;
|
srSection.SectionView = section_view;
|
listSectionRect.AddTail (srSection);
|
listSectionRect.AddTail (srSection);
|
pDC->Rectangle (srSection.Rect);
|
pDC->Rectangle (srSection.Rect);
|
if (section_view == m_sviSelectedSectionView)
|
if (section_view == m_sviSelectedSectionView)
|
{
|
{
|
bDrawFocusRect = TRUE;
|
bDrawFocusRect = TRUE;
|
m_rectSelectedItem = srSection.Rect;
|
m_rectSelectedItem = srSection.Rect;
|
}
|
}
|
|
|
// draw text within the section
|
// draw text within the section
|
|
|
CString strSection, strSectionLine;
|
CString strSection, strSectionLine;
|
|
|
if ((section_view->section_location != initial_location) && (section_view->section->alignment > 1))
|
if ((section_view->section_location != initial_location) && (section_view->section->alignment > 1))
|
{
|
{
|
strSectionLine.Format (_T("align %lX\n"), section_view->section->alignment);
|
strSectionLine.Format (_T("align %lX\n"), section_view->section->alignment);
|
strSection += strSectionLine;
|
strSection += strSectionLine;
|
}
|
}
|
|
|
if (section_view->section->size > 0)
|
if (section_view->section->size > 0)
|
{
|
{
|
strSectionLine.Format (_T("size %lX\n"), section_view->section->size);
|
strSectionLine.Format (_T("size %lX\n"), section_view->section->size);
|
strSection += strSectionLine;
|
strSection += strSectionLine;
|
}
|
}
|
|
|
if (section_view->section_location == final_location)
|
if (section_view->section_location == final_location)
|
{
|
{
|
strSectionLine.Format (_T("relocated\n"));
|
strSectionLine.Format (_T("relocated\n"));
|
strSection += strSectionLine;
|
strSection += strSectionLine;
|
}
|
}
|
|
|
pDC->DrawText (strSection, -1, srSection.Rect - (LPCRECT) CRect (EXTERNAL_TEXT_BORDER, EXTERNAL_TEXT_BORDER + BAR_HEIGHT, EXTERNAL_TEXT_BORDER, EXTERNAL_TEXT_BORDER), DT_LEFT);
|
pDC->DrawText (strSection, -1, srSection.Rect - (LPCRECT) CRect (EXTERNAL_TEXT_BORDER, EXTERNAL_TEXT_BORDER + BAR_HEIGHT, EXTERNAL_TEXT_BORDER, EXTERNAL_TEXT_BORDER), DT_LEFT);
|
|
|
// select caption bar colour according to type of section
|
// select caption bar colour according to type of section
|
|
|
if (section_view->section_location == initial_location)
|
if (section_view->section_location == initial_location)
|
{
|
{
|
pDC->SetTextColor (GetSysColor (COLOR_INACTIVECAPTIONTEXT));
|
pDC->SetTextColor (GetSysColor (COLOR_INACTIVECAPTIONTEXT));
|
pDC->SelectObject (&brshInitialSectionBar);
|
pDC->SelectObject (&brshInitialSectionBar);
|
}
|
}
|
else
|
else
|
{
|
{
|
pDC->SetTextColor (GetSysColor (COLOR_CAPTIONTEXT));
|
pDC->SetTextColor (GetSysColor (COLOR_CAPTIONTEXT));
|
pDC->SelectObject (&brshFinalSectionBar);
|
pDC->SelectObject (&brshFinalSectionBar);
|
}
|
}
|
|
|
// draw the caption bar
|
// draw the caption bar
|
|
|
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);
|
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);
|
pDC->Rectangle (rectBar);
|
pDC->Rectangle (rectBar);
|
|
|
// draw the section name within the caption bar
|
// draw the section name within the caption bar
|
|
|
CString strName(section_view->section->name.c_str ());
|
CString strName(section_view->section->name.c_str ());
|
CRect *pRect=NULL;
|
CRect *pRect=NULL;
|
m_arstrTooltipRects.Lookup(strName,(void *&)pRect);
|
m_arstrTooltipRects.Lookup(strName,(void *&)pRect);
|
UINT format;
|
UINT format;
|
if(pDC->GetTextExtent(strName).cx>rectBar.Width()-2*EXTERNAL_TEXT_BORDER){
|
if(pDC->GetTextExtent(strName).cx>rectBar.Width()-2*EXTERNAL_TEXT_BORDER){
|
format=DT_LEFT;
|
format=DT_LEFT;
|
if(pRect){
|
if(pRect){
|
pRect->CopyRect(rectBar);
|
pRect->CopyRect(rectBar);
|
} else {
|
} else {
|
pRect=new CRect;
|
pRect=new CRect;
|
m_arstrTooltipRects.SetAt(strName,pRect);
|
m_arstrTooltipRects.SetAt(strName,pRect);
|
}
|
}
|
// Replace final three characters of name with an elipsis
|
// Replace final three characters of name with an elipsis
|
int nLength=1+max(1,strName.GetLength()-3);
|
int nLength=1+max(1,strName.GetLength()-3);
|
do {
|
do {
|
--nLength;
|
--nLength;
|
strName=strName.Left(nLength)+_T("...");
|
strName=strName.Left(nLength)+_T("...");
|
} while(nLength>1 && pDC->GetTextExtent(strName).cx>rectBar.Width()-2*EXTERNAL_TEXT_BORDER);
|
} while(nLength>1 && pDC->GetTextExtent(strName).cx>rectBar.Width()-2*EXTERNAL_TEXT_BORDER);
|
|
|
rectBar.left+=EXTERNAL_TEXT_BORDER;
|
rectBar.left+=EXTERNAL_TEXT_BORDER;
|
rectBar.right-=EXTERNAL_TEXT_BORDER;
|
rectBar.right-=EXTERNAL_TEXT_BORDER;
|
} else {
|
} else {
|
format=DT_CENTER;
|
format=DT_CENTER;
|
if (pRect) {
|
if (pRect) {
|
m_arstrTooltipRects.RemoveKey(strName);
|
m_arstrTooltipRects.RemoveKey(strName);
|
}
|
}
|
}
|
}
|
|
|
pDC->DrawText (strName, -1, rectBar, format | DT_VCENTER | DT_SINGLELINE);
|
pDC->DrawText (strName, -1, rectBar, format | DT_VCENTER | DT_SINGLELINE);
|
pDC->SetTextColor (GetSysColor (COLOR_WINDOWTEXT));
|
pDC->SetTextColor (GetSysColor (COLOR_WINDOWTEXT));
|
|
|
// find the mem_section item describing the current section_view item
|
// find the mem_section item describing the current section_view item
|
|
|
list <mem_section>::iterator MemorySection = section_view->section;
|
list <mem_section>::iterator MemorySection = section_view->section;
|
|
|
// draw the section address if appropriate
|
// draw the section address if appropriate
|
|
|
if ((section_view->section_location == initial_location))
|
if ((section_view->section_location == initial_location))
|
{
|
{
|
if (MemorySection->initial_location->anchor == absolute)
|
if (MemorySection->initial_location->anchor == absolute)
|
{
|
{
|
pDC->MoveTo (srSection.Rect.left, srSection.Rect.bottom - 1); // draw tick
|
pDC->MoveTo (srSection.Rect.left, srSection.Rect.bottom - 1); // draw tick
|
pDC->LineTo (srSection.Rect.left, srSection.Rect.bottom + TICK_HEIGHT); // draw tick
|
pDC->LineTo (srSection.Rect.left, srSection.Rect.bottom + TICK_HEIGHT); // draw tick
|
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);
|
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);
|
strAddress.Format (ADDRESS_FORMAT, MemorySection->initial_location->address);
|
strAddress.Format (ADDRESS_FORMAT, MemorySection->initial_location->address);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
|
|
|
/*
|
/*
|
if (MemorySection->size > 0) // the end address can be calculated
|
if (MemorySection->size > 0) // the end address can be calculated
|
{
|
{
|
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);
|
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);
|
strAddress.Format (ADDRESS_FORMAT, MemorySection->initial_location->address + MemorySection->size);
|
strAddress.Format (ADDRESS_FORMAT, MemorySection->initial_location->address + MemorySection->size);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
|
}
|
}
|
*/
|
*/
|
}
|
}
|
}
|
}
|
|
|
else if ((section_view->section_location == final_location) || (section_view->section_location == fixed_location))
|
else if ((section_view->section_location == final_location) || (section_view->section_location == fixed_location))
|
{
|
{
|
if (MemorySection->final_location->anchor == absolute)
|
if (MemorySection->final_location->anchor == absolute)
|
{
|
{
|
pDC->MoveTo (srSection.Rect.left, srSection.Rect.bottom - 1); // draw tick
|
pDC->MoveTo (srSection.Rect.left, srSection.Rect.bottom - 1); // draw tick
|
pDC->LineTo (srSection.Rect.left, srSection.Rect.bottom + TICK_HEIGHT); // draw tick
|
pDC->LineTo (srSection.Rect.left, srSection.Rect.bottom + TICK_HEIGHT); // draw tick
|
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);
|
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);
|
strAddress.Format (ADDRESS_FORMAT, MemorySection->final_location->address);
|
strAddress.Format (ADDRESS_FORMAT, MemorySection->final_location->address);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_LEFT | DT_SINGLELINE);
|
|
|
/*
|
/*
|
if (MemorySection->size > 0) // the end address can be calculated
|
if (MemorySection->size > 0) // the end address can be calculated
|
{
|
{
|
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);
|
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);
|
strAddress.Format (ADDRESS_FORMAT, MemorySection->final_location->address + MemorySection->size);
|
strAddress.Format (ADDRESS_FORMAT, MemorySection->final_location->address + MemorySection->size);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
|
pDC->DrawText (strAddress, -1, rectAddress, DT_CENTER | DT_SINGLELINE);
|
}
|
}
|
*/
|
*/
|
}
|
}
|
}
|
}
|
|
|
uSectionUnitCount += UNITS_PER_SECTION;
|
uSectionUnitCount += UNITS_PER_SECTION;
|
}
|
}
|
else
|
else
|
{
|
{
|
uSectionUnitCount++; // unused sections occupy a single unit
|
uSectionUnitCount++; // unused sections occupy a single unit
|
}
|
}
|
}
|
}
|
|
|
// draw the focus rectangle around the selected object (if any)
|
// draw the focus rectangle around the selected object (if any)
|
|
|
if (bDrawFocusRect)
|
if (bDrawFocusRect)
|
pDC->DrawFocusRect (m_rectSelectedItem + CRect (1, 1, 1, 1));
|
pDC->DrawFocusRect (m_rectSelectedItem + CRect (1, 1, 1, 1));
|
|
|
// restore previous drawing objects
|
// restore previous drawing objects
|
|
|
pDC->SelectObject (pOldBrush);
|
pDC->SelectObject (pOldBrush);
|
pDC->SelectObject (pOldPen);
|
pDC->SelectObject (pOldPen);
|
}
|
}
|
|
|
|
|
SECTIONRECT * CMLTView::SectionHitTest (CPoint pntTest)
|
SECTIONRECT * CMLTView::SectionHitTest (CPoint pntTest)
|
{
|
{
|
for (POSITION posSection = listSectionRect.GetHeadPosition (); posSection != NULL; listSectionRect.GetNext (posSection))
|
for (POSITION posSection = listSectionRect.GetHeadPosition (); posSection != NULL; listSectionRect.GetNext (posSection))
|
{
|
{
|
if (listSectionRect.GetAt (posSection).Rect.PtInRect (pntTest))
|
if (listSectionRect.GetAt (posSection).Rect.PtInRect (pntTest))
|
return & listSectionRect.GetAt (posSection);
|
return & listSectionRect.GetAt (posSection);
|
}
|
}
|
|
|
return NULL;
|
return NULL;
|
}
|
}
|
|
|
|
|
REGIONRECT * CMLTView::RegionHitTest (CPoint pntTest)
|
REGIONRECT * CMLTView::RegionHitTest (CPoint pntTest)
|
{
|
{
|
for (POSITION posRegion = listRegionRect.GetHeadPosition (); posRegion != NULL; listRegionRect.GetNext (posRegion))
|
for (POSITION posRegion = listRegionRect.GetHeadPosition (); posRegion != NULL; listRegionRect.GetNext (posRegion))
|
{
|
{
|
CRect rectRegion = listRegionRect.GetAt (posRegion).Rect +
|
CRect rectRegion = listRegionRect.GetAt (posRegion).Rect +
|
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
|
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
|
if (rectRegion.PtInRect (pntTest))
|
if (rectRegion.PtInRect (pntTest))
|
return & listRegionRect.GetAt (posRegion);
|
return & listRegionRect.GetAt (posRegion);
|
}
|
}
|
|
|
return NULL;
|
return NULL;
|
}
|
}
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
// CMLTView printing
|
// CMLTView printing
|
|
|
BOOL CMLTView::OnPreparePrinting(CPrintInfo* pInfo)
|
BOOL CMLTView::OnPreparePrinting(CPrintInfo* pInfo)
|
{
|
{
|
// default preparation
|
// default preparation
|
return DoPreparePrinting(pInfo);
|
return DoPreparePrinting(pInfo);
|
}
|
}
|
|
|
void CMLTView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
void CMLTView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
{
|
{
|
// TODO: add extra initialization before printing
|
// TODO: add extra initialization before printing
|
}
|
}
|
|
|
void CMLTView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
void CMLTView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
{
|
{
|
// TODO: add cleanup after printing
|
// TODO: add cleanup after printing
|
}
|
}
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
// CMLTView diagnostics
|
// CMLTView diagnostics
|
|
|
#ifdef _DEBUG
|
#ifdef _DEBUG
|
void CMLTView::AssertValid() const
|
void CMLTView::AssertValid() const
|
{
|
{
|
CView::AssertValid();
|
CView::AssertValid();
|
}
|
}
|
|
|
void CMLTView::Dump(CDumpContext& dc) const
|
void CMLTView::Dump(CDumpContext& dc) const
|
{
|
{
|
CView::Dump(dc);
|
CView::Dump(dc);
|
}
|
}
|
|
|
#endif //_DEBUG
|
#endif //_DEBUG
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
// CMLTView message handlers
|
// CMLTView message handlers
|
|
|
|
|
void CMLTView::OnLButtonDown(UINT nFlags, CPoint point)
|
void CMLTView::OnLButtonDown(UINT nFlags, CPoint point)
|
{
|
{
|
if (CConfigTool::GetConfigToolDoc() == NULL) // nothing to do
|
if (CConfigTool::GetConfigToolDoc() == NULL) // nothing to do
|
return;
|
return;
|
|
|
list <mem_section_view>::iterator sviOldSelectedSectionView = m_sviSelectedSectionView;
|
list <mem_section_view>::iterator sviOldSelectedSectionView = m_sviSelectedSectionView;
|
list <mem_region>::iterator riOldSelectedRegion = m_riSelectedRegion;
|
list <mem_region>::iterator riOldSelectedRegion = m_riSelectedRegion;
|
CRect rectOldSelectedItem = m_rectSelectedItem;
|
CRect rectOldSelectedItem = m_rectSelectedItem;
|
|
|
CConfigTool::GetConfigToolDoc()->strSelectedRegion = _T("");
|
CConfigTool::GetConfigToolDoc()->strSelectedRegion = _T("");
|
CConfigTool::GetConfigToolDoc()->strSelectedSection = _T("");
|
CConfigTool::GetConfigToolDoc()->strSelectedSection = _T("");
|
|
|
SECTIONRECT * psrSection = SectionHitTest (point + GetScrollPosition ());
|
SECTIONRECT * psrSection = SectionHitTest (point + GetScrollPosition ());
|
if (psrSection != NULL) // a section was clicked
|
if (psrSection != NULL) // a section was clicked
|
{
|
{
|
m_sviSelectedSectionView = psrSection->SectionView;
|
m_sviSelectedSectionView = psrSection->SectionView;
|
m_rectSelectedItem = psrSection->Rect;
|
m_rectSelectedItem = psrSection->Rect;
|
m_riSelectedRegion = NULL;
|
m_riSelectedRegion = NULL;
|
CConfigTool::GetConfigToolDoc()->strSelectedSection = m_sviSelectedSectionView->section->name.c_str ();
|
CConfigTool::GetConfigToolDoc()->strSelectedSection = m_sviSelectedSectionView->section->name.c_str ();
|
}
|
}
|
|
|
else // no section was clicked, test for regions
|
else // no section was clicked, test for regions
|
{
|
{
|
REGIONRECT * prrRegion = RegionHitTest (point + GetScrollPosition ());
|
REGIONRECT * prrRegion = RegionHitTest (point + GetScrollPosition ());
|
if (prrRegion != NULL) // a region was clicked, but not a section
|
if (prrRegion != NULL) // a region was clicked, but not a section
|
{
|
{
|
m_riSelectedRegion = prrRegion->Region;
|
m_riSelectedRegion = prrRegion->Region;
|
m_rectSelectedItem = prrRegion->Rect;
|
m_rectSelectedItem = prrRegion->Rect;
|
m_sviSelectedSectionView = NULL;
|
m_sviSelectedSectionView = NULL;
|
CConfigTool::GetConfigToolDoc()->strSelectedRegion = m_riSelectedRegion->name.c_str ();
|
CConfigTool::GetConfigToolDoc()->strSelectedRegion = m_riSelectedRegion->name.c_str ();
|
}
|
}
|
}
|
}
|
|
|
// redraw the focus rectangle if the selection has changed
|
// redraw the focus rectangle if the selection has changed
|
|
|
if ((m_sviSelectedSectionView != sviOldSelectedSectionView) || (m_riSelectedRegion != riOldSelectedRegion))
|
if ((m_sviSelectedSectionView != sviOldSelectedSectionView) || (m_riSelectedRegion != riOldSelectedRegion))
|
{
|
{
|
// CDC * pDC = GetDC ();
|
// CDC * pDC = GetDC ();
|
if ((sviOldSelectedSectionView != NULL) || (riOldSelectedRegion != NULL))
|
if ((sviOldSelectedSectionView != NULL) || (riOldSelectedRegion != NULL))
|
// pDC->DrawFocusRect (rectOldSelectedItem + CRect (1, 1, 1, 1) - GetScrollPosition ());
|
// pDC->DrawFocusRect (rectOldSelectedItem + CRect (1, 1, 1, 1) - GetScrollPosition ());
|
InvalidateRect (rectOldSelectedItem + CRect (1, 1, 1, 1) - GetScrollPosition ()); // paint over the old focus rectangle
|
InvalidateRect (rectOldSelectedItem + CRect (1, 1, 1, 1) - GetScrollPosition ()); // paint over the old focus rectangle
|
if ((m_sviSelectedSectionView != NULL) || (m_riSelectedRegion != NULL))
|
if ((m_sviSelectedSectionView != NULL) || (m_riSelectedRegion != NULL))
|
// pDC->DrawFocusRect (m_rectSelectedItem + CRect (1, 1, 1, 1) - GetScrollPosition ());
|
// pDC->DrawFocusRect (m_rectSelectedItem + CRect (1, 1, 1, 1) - GetScrollPosition ());
|
InvalidateRect (m_rectSelectedItem + CRect (1, 1, 1, 1) - GetScrollPosition ()); // paint the new focus rectangle
|
InvalidateRect (m_rectSelectedItem + CRect (1, 1, 1, 1) - GetScrollPosition ()); // paint the new focus rectangle
|
}
|
}
|
|
|
// perform default processing
|
// perform default processing
|
|
|
CView::OnLButtonDown(nFlags, point);
|
CView::OnLButtonDown(nFlags, point);
|
}
|
}
|
|
|
void CMLTView::OnLButtonDblClk(UINT nFlags, CPoint point)
|
void CMLTView::OnLButtonDblClk(UINT nFlags, CPoint point)
|
{
|
{
|
if (CConfigTool::GetConfigToolDoc() != NULL)
|
if (CConfigTool::GetConfigToolDoc() != NULL)
|
CConfigTool::GetConfigToolDoc()->OnMLTProperties ();
|
CConfigTool::GetConfigToolDoc()->OnMLTProperties ();
|
|
|
CView::OnLButtonDblClk(nFlags, point);
|
CView::OnLButtonDblClk(nFlags, point);
|
}
|
}
|
|
|
void CMLTView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
|
void CMLTView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
|
{
|
{
|
if ((lHint != 0) && (pHint != NULL) && (lHint != CConfigToolDoc::MemLayoutChanged))
|
if ((lHint != 0) && (pHint != NULL) && (lHint != CConfigToolDoc::MemLayoutChanged))
|
return; // no need to invalidate the view
|
return; // no need to invalidate the view
|
m_arstrTooltipRects.RemoveAll();
|
m_arstrTooltipRects.RemoveAll();
|
|
|
CalcUnitCountMax (); // recalculate the total view width since the section count may have changed
|
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
|
if (m_uUnitCountMax == 0 || (m_uClientWidth < HORIZ_BORDER * 2)) // there is nothing to draw
|
m_uViewWidth = 0;
|
m_uViewWidth = 0;
|
else // allow horizontal scrolling when the unit width reduces to UNIT_WIDTH_MIN
|
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;
|
m_uViewWidth = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN) * m_uUnitCountMax + HORIZ_BORDER * 2;
|
|
|
SIZE sizeTotal;
|
SIZE sizeTotal;
|
sizeTotal.cx = __max (m_uViewWidth, m_uClientWidth);
|
sizeTotal.cx = __max (m_uViewWidth, m_uClientWidth);
|
sizeTotal.cy = CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size () * REGION_SPACING + EXTERNAL_TEXT_BORDER * 2;
|
sizeTotal.cy = CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size () * REGION_SPACING + EXTERNAL_TEXT_BORDER * 2;
|
SetScrollSizes (MM_TEXT, sizeTotal);
|
SetScrollSizes (MM_TEXT, sizeTotal);
|
|
|
CScrollView::OnUpdate (pSender, lHint, pHint);
|
CScrollView::OnUpdate (pSender, lHint, pHint);
|
}
|
}
|
|
|
void CMLTView::OnSize(UINT nType, int cx, int cy)
|
void CMLTView::OnSize(UINT nType, int cx, int cy)
|
{
|
{
|
CScrollView::OnSize(nType, cx, cy);
|
CScrollView::OnSize(nType, cx, cy);
|
|
|
m_uClientWidth = cx;
|
m_uClientWidth = cx;
|
if (m_uUnitCountMax == 0) // there is nothing to draw
|
if (m_uUnitCountMax == 0) // there is nothing to draw
|
m_uViewWidth = 0;
|
m_uViewWidth = 0;
|
else // allow horizontal scrolling when the unit width reduces to UNIT_WIDTH_MIN
|
else // allow horizontal scrolling when the unit width reduces to UNIT_WIDTH_MIN
|
m_uViewWidth = __max ((cx - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN) * m_uUnitCountMax + HORIZ_BORDER * 2;
|
m_uViewWidth = __max ((cx - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN) * m_uUnitCountMax + HORIZ_BORDER * 2;
|
|
|
SIZE sizeTotal;
|
SIZE sizeTotal;
|
sizeTotal.cx = __max (m_uViewWidth, m_uClientWidth);
|
sizeTotal.cx = __max (m_uViewWidth, m_uClientWidth);
|
if (CConfigTool::GetConfigToolDoc() == NULL)
|
if (CConfigTool::GetConfigToolDoc() == NULL)
|
sizeTotal.cy = 0;
|
sizeTotal.cy = 0;
|
else
|
else
|
sizeTotal.cy = CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size () * REGION_SPACING + EXTERNAL_TEXT_BORDER * 2;
|
sizeTotal.cy = CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size () * REGION_SPACING + EXTERNAL_TEXT_BORDER * 2;
|
SetScrollSizes (MM_TEXT, sizeTotal);
|
SetScrollSizes (MM_TEXT, sizeTotal);
|
}
|
}
|
|
|
void CMLTView::CalcUnitCountMax ()
|
void CMLTView::CalcUnitCountMax ()
|
{
|
{
|
UINT uUnitCountMax = 0;
|
UINT uUnitCountMax = 0;
|
UINT uUnitCount;
|
UINT uUnitCount;
|
list <mem_region>::iterator region;
|
list <mem_region>::iterator region;
|
mem_map * pMemoryMap = & (CConfigTool::GetConfigToolDoc()->MemoryMap);
|
mem_map * pMemoryMap = & (CConfigTool::GetConfigToolDoc()->MemoryMap);
|
for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region)
|
for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region)
|
{
|
{
|
uUnitCount = 0;
|
uUnitCount = 0;
|
for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
|
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);
|
uUnitCount += (section_view->section == NULL ? 1 : UNITS_PER_SECTION);
|
|
|
if (uUnitCount > uUnitCountMax)
|
if (uUnitCount > uUnitCountMax)
|
uUnitCountMax = uUnitCount;
|
uUnitCountMax = uUnitCount;
|
}
|
}
|
m_uUnitCountMax = uUnitCountMax;
|
m_uUnitCountMax = uUnitCountMax;
|
}
|
}
|
|
|
BOOL CMLTView::OnEraseBkgnd(CDC* pDC)
|
BOOL CMLTView::OnEraseBkgnd(CDC* pDC)
|
{
|
{
|
// Work around bug apparently caused by SlickEdit
|
// Work around bug apparently caused by SlickEdit
|
CRect rcClient;
|
CRect rcClient;
|
pDC->GetClipBox(rcClient);
|
pDC->GetClipBox(rcClient);
|
pDC->FillSolidRect(rcClient,GetSysColor(COLOR_WINDOW));
|
pDC->FillSolidRect(rcClient,GetSysColor(COLOR_WINDOW));
|
|
|
return TRUE;//return CScrollView::OnEraseBkgnd(pDC);
|
return TRUE;//return CScrollView::OnEraseBkgnd(pDC);
|
}
|
}
|
|
|
BOOL CMLTView::OnToolTipText(UINT id, NMHDR* pNMHDR, LRESULT*pResult)
|
BOOL CMLTView::OnToolTipText(UINT id, NMHDR* pNMHDR, LRESULT*pResult)
|
{
|
{
|
// need to handle both ANSI and UNICODE versions of the message
|
// need to handle both ANSI and UNICODE versions of the message
|
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
|
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
|
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
|
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
|
id=pNMHDR->idFrom;
|
id=pNMHDR->idFrom;
|
|
|
if(id){
|
if(id){
|
for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){
|
for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){
|
CRect *pRect;
|
CRect *pRect;
|
CString strTipText;
|
CString strTipText;
|
m_arstrTooltipRects.GetNextAssoc( pos, strTipText, (void *&)pRect );
|
m_arstrTooltipRects.GetNextAssoc( pos, strTipText, (void *&)pRect );
|
if((UINT)pRect==id){
|
if((UINT)pRect==id){
|
#ifndef _UNICODE
|
#ifndef _UNICODE
|
if (pNMHDR->code == TTN_NEEDTEXTA)
|
if (pNMHDR->code == TTN_NEEDTEXTA)
|
lstrcpyn(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
|
lstrcpyn(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
|
else
|
else
|
_mbstowcsz(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
|
_mbstowcsz(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
|
#else
|
#else
|
if (pNMHDR->code == TTN_NEEDTEXTA)
|
if (pNMHDR->code == TTN_NEEDTEXTA)
|
_wcstombsz(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
|
_wcstombsz(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
|
else
|
else
|
lstrcpyn(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
|
lstrcpyn(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
|
#endif
|
#endif
|
*pResult = 0;
|
*pResult = 0;
|
return TRUE; // message was handled
|
return TRUE; // message was handled
|
}
|
}
|
}
|
}
|
}
|
}
|
return FALSE;
|
return FALSE;
|
}
|
}
|
|
|
int CMLTView::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const
|
int CMLTView::OnToolHitTest( CPoint point, TOOLINFO* pTI ) const
|
{
|
{
|
for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){
|
for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){
|
CRect *pRect;
|
CRect *pRect;
|
CString strName;
|
CString strName;
|
m_arstrTooltipRects.GetNextAssoc( pos, strName, (void *&)pRect );
|
m_arstrTooltipRects.GetNextAssoc( pos, strName, (void *&)pRect );
|
|
|
if(pRect->PtInRect(point)){
|
if(pRect->PtInRect(point)){
|
pTI->hwnd = m_hWnd;
|
pTI->hwnd = m_hWnd;
|
pTI->uId = (UINT)pRect;
|
pTI->uId = (UINT)pRect;
|
pTI->uFlags = 0 ;
|
pTI->uFlags = 0 ;
|
GetClientRect(&pTI->rect);
|
GetClientRect(&pTI->rect);
|
pTI->lpszText=LPSTR_TEXTCALLBACK;
|
pTI->lpszText=LPSTR_TEXTCALLBACK;
|
return pTI->uId;
|
return pTI->uId;
|
}
|
}
|
}
|
}
|
return -1;
|
return -1;
|
}
|
}
|
|
|
void CMLTView::OnInitialUpdate()
|
void CMLTView::OnInitialUpdate()
|
{
|
{
|
CScrollView::OnInitialUpdate();
|
CScrollView::OnInitialUpdate();
|
EnableToolTips(true);
|
EnableToolTips(true);
|
}
|
}
|
|
|
void CMLTView::OnMouseMove(UINT nFlags, CPoint point)
|
void CMLTView::OnMouseMove(UINT nFlags, CPoint point)
|
{
|
{
|
/*
|
/*
|
CString strToolTipText;
|
CString strToolTipText;
|
for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){
|
for(POSITION pos = m_arstrTooltipRects.GetStartPosition(); pos != NULL; ){
|
CRect *pRect;
|
CRect *pRect;
|
CString strName;
|
CString strName;
|
m_arstrTooltipRects.GetNextAssoc( pos, strName, (void *&)pRect );
|
m_arstrTooltipRects.GetNextAssoc( pos, strName, (void *&)pRect );
|
|
|
if(pRect->PtInRect(point)){
|
if(pRect->PtInRect(point)){
|
strToolTipText=strName;
|
strToolTipText=strName;
|
break;
|
break;
|
}
|
}
|
}
|
}
|
if(strToolTipText!=m_strTipText){
|
if(strToolTipText!=m_strTipText){
|
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
|
_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
|
CToolTipCtrl* pToolTip = pThreadState->m_pToolTip;
|
CToolTipCtrl* pToolTip = pThreadState->m_pToolTip;
|
if(!m_strTipText.IsEmpty()){
|
if(!m_strTipText.IsEmpty()){
|
pToolTip->Activate(false);
|
pToolTip->Activate(false);
|
}
|
}
|
pToolTip->Activate(!strToolTipText.IsEmpty());
|
pToolTip->Activate(!strToolTipText.IsEmpty());
|
m_strTipText=strToolTipText;
|
m_strTipText=strToolTipText;
|
}
|
}
|
*/
|
*/
|
CScrollView::OnMouseMove(nFlags, point);
|
CScrollView::OnMouseMove(nFlags, point);
|
}
|
}
|
|
|
void CMLTView::OnMLTNewRegion ()
|
void CMLTView::OnMLTNewRegion ()
|
{
|
{
|
CConfigTool::GetConfigToolDoc ()->OnMLTNewRegion ();
|
CConfigTool::GetConfigToolDoc ()->OnMLTNewRegion ();
|
}
|
}
|
|
|
void CMLTView::OnMLTNewSection ()
|
void CMLTView::OnMLTNewSection ()
|
{
|
{
|
CConfigTool::GetConfigToolDoc ()->OnMLTNewSection ();
|
CConfigTool::GetConfigToolDoc ()->OnMLTNewSection ();
|
}
|
}
|
|
|
void CMLTView::OnMLTDelete ()
|
void CMLTView::OnMLTDelete ()
|
{
|
{
|
CConfigTool::GetConfigToolDoc ()->OnMLTDelete ();
|
CConfigTool::GetConfigToolDoc ()->OnMLTDelete ();
|
}
|
}
|
|
|
void CMLTView::OnMLTProperties ()
|
void CMLTView::OnMLTProperties ()
|
{
|
{
|
CConfigTool::GetConfigToolDoc ()->OnMLTProperties ();
|
CConfigTool::GetConfigToolDoc ()->OnMLTProperties ();
|
}
|
}
|
|
|
void CMLTView::OnUpdateMLTNewRegion (CCmdUI* pCmdUI)
|
void CMLTView::OnUpdateMLTNewRegion (CCmdUI* pCmdUI)
|
{
|
{
|
pCmdUI->Enable (true);
|
pCmdUI->Enable (true);
|
}
|
}
|
|
|
void CMLTView::OnUpdateMLTNewSection (CCmdUI* pCmdUI)
|
void CMLTView::OnUpdateMLTNewSection (CCmdUI* pCmdUI)
|
{
|
{
|
pCmdUI->Enable (CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size() > 0);
|
pCmdUI->Enable (CConfigTool::GetConfigToolDoc()->MemoryMap.region_list.size() > 0);
|
}
|
}
|
|
|
void CMLTView::OnUpdateMLTDelete (CCmdUI* pCmdUI)
|
void CMLTView::OnUpdateMLTDelete (CCmdUI* pCmdUI)
|
{
|
{
|
pCmdUI->Enable(
|
pCmdUI->Enable(
|
(!CConfigTool::GetConfigToolDoc ()->strSelectedRegion.IsEmpty() || !CConfigTool::GetConfigToolDoc ()->strSelectedSection.IsEmpty()));
|
(!CConfigTool::GetConfigToolDoc ()->strSelectedRegion.IsEmpty() || !CConfigTool::GetConfigToolDoc ()->strSelectedSection.IsEmpty()));
|
}
|
}
|
|
|
void CMLTView::OnUpdateMLTProperties (CCmdUI* pCmdUI)
|
void CMLTView::OnUpdateMLTProperties (CCmdUI* pCmdUI)
|
{
|
{
|
pCmdUI->Enable(
|
pCmdUI->Enable(
|
(!CConfigTool::GetConfigToolDoc ()->strSelectedRegion.IsEmpty() || !CConfigTool::GetConfigToolDoc ()->strSelectedSection.IsEmpty()));
|
(!CConfigTool::GetConfigToolDoc ()->strSelectedRegion.IsEmpty() || !CConfigTool::GetConfigToolDoc ()->strSelectedSection.IsEmpty()));
|
}
|
}
|
|
|
|
|
void CMLTView::OnContextMenu(CWnd*, CPoint point)
|
void CMLTView::OnContextMenu(CWnd*, CPoint point)
|
{
|
{
|
CConfigToolDoc* pDoc = CConfigTool::GetConfigToolDoc();
|
CConfigToolDoc* pDoc = CConfigTool::GetConfigToolDoc();
|
if (!pDoc->strSelectedRegion.IsEmpty() || !pDoc->strSelectedSection.IsEmpty()){
|
if (!pDoc->strSelectedRegion.IsEmpty() || !pDoc->strSelectedSection.IsEmpty()){
|
if(point.x<0){
|
if(point.x<0){
|
// Keyboard
|
// Keyboard
|
point=!pDoc->strSelectedRegion.IsEmpty()?m_rectSelectedItem.TopLeft():m_rectSelectedItem.CenterPoint();
|
point=!pDoc->strSelectedRegion.IsEmpty()?m_rectSelectedItem.TopLeft():m_rectSelectedItem.CenterPoint();
|
ClientToScreen(&point);
|
ClientToScreen(&point);
|
}
|
}
|
Menu menu;
|
Menu menu;
|
menu.LoadMenu(IDR_MLTVIEW_POPUP);
|
menu.LoadMenu(IDR_MLTVIEW_POPUP);
|
|
|
#ifndef PLUGIN
|
#ifndef PLUGIN
|
menu.LoadToolbar(IDR_MISCBAR);
|
menu.LoadToolbar(IDR_MISCBAR);
|
#endif
|
#endif
|
|
|
Menu *pPopup=(Menu *)menu.GetSubMenu(0);
|
Menu *pPopup=(Menu *)menu.GetSubMenu(0);
|
pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x,point.y,this);
|
pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x,point.y,this);
|
}
|
}
|
}
|
}
|
|
|
void CMLTView::OnPopupProperties()
|
void CMLTView::OnPopupProperties()
|
{
|
{
|
CConfigTool::GetConfigToolDoc()->OnMLTProperties ();
|
CConfigTool::GetConfigToolDoc()->OnMLTProperties ();
|
}
|
}
|
|
|
void CMLTView::OnRButtonDown(UINT nFlags, CPoint point)
|
void CMLTView::OnRButtonDown(UINT nFlags, CPoint point)
|
{
|
{
|
OnLButtonDown(nFlags, point);
|
OnLButtonDown(nFlags, point);
|
ClientToScreen(&point);
|
ClientToScreen(&point);
|
OnContextMenu(this, point) ;
|
OnContextMenu(this, point) ;
|
}
|
}
|
|
|
void CMLTView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
void CMLTView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
{
|
{
|
POSITION pos;
|
POSITION pos;
|
switch(nChar){
|
switch(nChar){
|
case VK_RIGHT:
|
case VK_RIGHT:
|
pos = listSectionRect.GetHeadPosition ();
|
pos = listSectionRect.GetHeadPosition ();
|
if(!CConfigTool::GetConfigToolDoc()->strSelectedSection.IsEmpty()){
|
if(!CConfigTool::GetConfigToolDoc()->strSelectedSection.IsEmpty()){
|
while(NULL!=pos){
|
while(NULL!=pos){
|
if (listSectionRect.GetNext (pos).SectionView==m_sviSelectedSectionView){
|
if (listSectionRect.GetNext (pos).SectionView==m_sviSelectedSectionView){
|
if(NULL==pos){
|
if(NULL==pos){
|
pos=listSectionRect.GetHeadPosition();
|
pos=listSectionRect.GetHeadPosition();
|
}
|
}
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
OnLButtonDown(0, listSectionRect.GetNext(pos).Rect.CenterPoint()-GetScrollPosition());
|
OnLButtonDown(0, listSectionRect.GetNext(pos).Rect.CenterPoint()-GetScrollPosition());
|
break;
|
break;
|
case VK_LEFT:
|
case VK_LEFT:
|
pos = listSectionRect.GetTailPosition ();
|
pos = listSectionRect.GetTailPosition ();
|
if(!CConfigTool::GetConfigToolDoc()->strSelectedSection.IsEmpty()){
|
if(!CConfigTool::GetConfigToolDoc()->strSelectedSection.IsEmpty()){
|
while(NULL!=pos){
|
while(NULL!=pos){
|
if (listSectionRect.GetPrev (pos).SectionView==m_sviSelectedSectionView){
|
if (listSectionRect.GetPrev (pos).SectionView==m_sviSelectedSectionView){
|
if(NULL==pos){
|
if(NULL==pos){
|
pos=listSectionRect.GetTailPosition();
|
pos=listSectionRect.GetTailPosition();
|
}
|
}
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
OnLButtonDown(0, listSectionRect.GetPrev(pos).Rect.CenterPoint()-GetScrollPosition());
|
OnLButtonDown(0, listSectionRect.GetPrev(pos).Rect.CenterPoint()-GetScrollPosition());
|
break;
|
break;
|
case VK_DOWN:
|
case VK_DOWN:
|
pos = listRegionRect.GetHeadPosition ();
|
pos = listRegionRect.GetHeadPosition ();
|
if(!CConfigTool::GetConfigToolDoc()->strSelectedRegion.IsEmpty()){
|
if(!CConfigTool::GetConfigToolDoc()->strSelectedRegion.IsEmpty()){
|
while(NULL!=pos){
|
while(NULL!=pos){
|
if (listRegionRect.GetNext (pos).Region==m_riSelectedRegion){
|
if (listRegionRect.GetNext (pos).Region==m_riSelectedRegion){
|
if(NULL==pos){
|
if(NULL==pos){
|
pos=listRegionRect.GetHeadPosition();
|
pos=listRegionRect.GetHeadPosition();
|
}
|
}
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
OnLButtonDown(0, listRegionRect.GetNext(pos).Rect.TopLeft()-CPoint(1,1)-GetScrollPosition());
|
OnLButtonDown(0, listRegionRect.GetNext(pos).Rect.TopLeft()-CPoint(1,1)-GetScrollPosition());
|
break;
|
break;
|
case VK_UP:
|
case VK_UP:
|
pos = listRegionRect.GetTailPosition ();
|
pos = listRegionRect.GetTailPosition ();
|
if(!CConfigTool::GetConfigToolDoc()->strSelectedRegion.IsEmpty()){
|
if(!CConfigTool::GetConfigToolDoc()->strSelectedRegion.IsEmpty()){
|
while(NULL!=pos){
|
while(NULL!=pos){
|
if (listRegionRect.GetPrev (pos).Region==m_riSelectedRegion){
|
if (listRegionRect.GetPrev (pos).Region==m_riSelectedRegion){
|
if(NULL==pos){
|
if(NULL==pos){
|
pos=listRegionRect.GetTailPosition();
|
pos=listRegionRect.GetTailPosition();
|
}
|
}
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
OnLButtonDown(0, listRegionRect.GetPrev(pos).Rect.TopLeft()-CPoint(1,1)-GetScrollPosition());
|
OnLButtonDown(0, listRegionRect.GetPrev(pos).Rect.TopLeft()-CPoint(1,1)-GetScrollPosition());
|
break;
|
break;
|
default:
|
default:
|
break;
|
break;
|
}
|
}
|
|
|
CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
|
CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
|
}
|
}
|
|
|
|
|
BOOL CMLTView::OnHelpInfo(HELPINFO*)
|
BOOL CMLTView::OnHelpInfo(HELPINFO*)
|
{
|
{
|
return CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_MLT_VIEW_HELP));
|
return CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_MLT_VIEW_HELP));
|
}
|
}
|
|
|
LRESULT CMLTView::OnMenuChar(UINT, UINT, CMenu*)
|
LRESULT CMLTView::OnMenuChar(UINT, UINT, CMenu*)
|
{
|
{
|
const MSG *pMsg=GetCurrentMessage();
|
const MSG *pMsg=GetCurrentMessage();
|
// punt to the mainframe to deal with shortcuts in popups
|
// punt to the mainframe to deal with shortcuts in popups
|
return AfxGetMainWnd()->SendMessage(pMsg->message,pMsg->wParam,pMsg->lParam);
|
return AfxGetMainWnd()->SendMessage(pMsg->message,pMsg->wParam,pMsg->lParam);
|
}
|
}
|
|
|