home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / src / win32 / MemoryViewerAddressSize.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-05-13  |  3.3 KB  |  138 lines

  1. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
  2. // Copyright (C) 1999-2003 Forgotten
  3. // Copyright (C) 2004 Forgotten and the VBA development team
  4.  
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2, or(at your option)
  8. // any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software Foundation,
  17. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18.  
  19. // MemoryViewerAddressSize.cpp : implementation file
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "vba.h"
  24. #include "MemoryViewerAddressSize.h"
  25.  
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // MemoryViewerAddressSize dialog
  34.  
  35.  
  36. MemoryViewerAddressSize::MemoryViewerAddressSize(u32 a, int s, CWnd* pParent /*=NULL*/)
  37.   : CDialog(MemoryViewerAddressSize::IDD, pParent)
  38. {
  39.   //{{AFX_DATA_INIT(MemoryViewerAddressSize)
  40.   // NOTE: the ClassWizard will add member initialization here
  41.   //}}AFX_DATA_INIT
  42.   address = a;
  43.   size = s;
  44. }
  45.  
  46.  
  47. void MemoryViewerAddressSize::DoDataExchange(CDataExchange* pDX)
  48. {
  49.   CDialog::DoDataExchange(pDX);
  50.   //{{AFX_DATA_MAP(MemoryViewerAddressSize)
  51.   DDX_Control(pDX, IDC_SIZE_CONTROL, m_size);
  52.   DDX_Control(pDX, IDC_ADDRESS, m_address);
  53.   //}}AFX_DATA_MAP
  54. }
  55.  
  56.  
  57. BEGIN_MESSAGE_MAP(MemoryViewerAddressSize, CDialog)
  58.   //{{AFX_MSG_MAP(MemoryViewerAddressSize)
  59.   ON_BN_CLICKED(ID_OK, OnOk)
  60.   ON_BN_CLICKED(ID_CANCEL, OnCancel)
  61.   //}}AFX_MSG_MAP
  62.   END_MESSAGE_MAP()
  63.  
  64.   /////////////////////////////////////////////////////////////////////////////
  65. // MemoryViewerAddressSize message handlers
  66.  
  67. BOOL MemoryViewerAddressSize::OnInitDialog() 
  68. {
  69.   CDialog::OnInitDialog();
  70.   
  71.   CString buffer;
  72.   if(address != 0xFFFFFFFF) {
  73.     buffer.Format("%08X", address);
  74.     m_address.SetWindowText(buffer);
  75.   }
  76.   if(size != -1) {
  77.     buffer.Format("%08X", size);
  78.     m_size.SetWindowText(buffer);
  79.     m_size.EnableWindow(FALSE);
  80.   }
  81.  
  82.   if(size == -1 && address != 0xFFFFFFFF)
  83.     m_size.SetFocus();
  84.   
  85.   m_address.LimitText(9);
  86.   m_size.LimitText(9);
  87.   
  88.   return TRUE;  // return TRUE unless you set the focus to a control
  89.                 // EXCEPTION: OCX Property Pages should return FALSE
  90. }
  91.  
  92. void MemoryViewerAddressSize::OnOk() 
  93. {
  94.   CString buffer;
  95.  
  96.   m_address.GetWindowText(buffer);
  97.   if(buffer.IsEmpty()) {
  98.     m_address.SetFocus();
  99.     return;
  100.   }
  101.   sscanf(buffer, "%x", &address);
  102.   
  103.   m_size.GetWindowText(buffer);
  104.   if(buffer.IsEmpty()) {
  105.     m_size.SetFocus();
  106.     return;
  107.   }
  108.   sscanf(buffer, "%x", &size);
  109.   EndDialog(TRUE);
  110. }
  111.  
  112. void MemoryViewerAddressSize::OnCancel() 
  113. {
  114.   EndDialog(FALSE);
  115. }
  116.  
  117. void MemoryViewerAddressSize::setAddress(u32 a)
  118. {
  119.   address = a;
  120. }
  121.  
  122. void MemoryViewerAddressSize::setSize(int s)
  123. {
  124.   size = s;
  125. }
  126.  
  127.  
  128. u32 MemoryViewerAddressSize::getAddress()
  129. {
  130.   return address;
  131. }
  132. \
  133.  
  134. int MemoryViewerAddressSize::getSize()
  135. {
  136.   return size;
  137. }
  138.