NUKED skin support

CLEANED resource file
This commit is contained in:
spacy51 2008-01-17 13:20:50 +00:00
parent c1d8e1f9e4
commit 2a52c59d0e
14 changed files with 17 additions and 1434 deletions

15
VBA.sln
View File

@ -2,10 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VisualBoyAdvance", "VBA.vcproj", "{6D4C5EC8-933F-4C05-A1BF-498E658576DF}"
ProjectSection(ProjectDependencies) = postProject
{B1BB4620-E672-4D6B-AF90-08161EB18D4F} = {B1BB4620-E672-4D6B-AF90-08161EB18D4F}
{7AEC599C-7C82-4F00-AA60-411E0A359CB0} = {7AEC599C-7C82-4F00-AA60-411E0A359CB0}
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE} = {DB5C12E9-BCD3-4517-8708-475C0D1D88CE}
{B938FBD9-C7F9-4BF7-8C27-68865D1FA092} = {B938FBD9-C7F9-4BF7-8C27-68865D1FA092}
{7AEC599C-7C82-4F00-AA60-411E0A359CB0} = {7AEC599C-7C82-4F00-AA60-411E0A359CB0}
{B1BB4620-E672-4D6B-AF90-08161EB18D4F} = {B1BB4620-E672-4D6B-AF90-08161EB18D4F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\dependencies\zlib\zlib.vcproj", "{B938FBD9-C7F9-4BF7-8C27-68865D1FA092}"
@ -15,8 +14,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "..\dependencies\l
{B938FBD9-C7F9-4BF7-8C27-68865D1FA092} = {B938FBD9-C7F9-4BF7-8C27-68865D1FA092}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cximage", "..\dependencies\cximage\cximage.vcproj", "{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "File_Extractor", "..\dependencies\File_Extractor-0.4.3\File_Extractor.vcproj", "{7AEC599C-7C82-4F00-AA60-411E0A359CB0}"
EndProject
Global
@ -51,14 +48,6 @@ Global
{B1BB4620-E672-4D6B-AF90-08161EB18D4F}.Release|Win32.Build.0 = Release|Win32
{B1BB4620-E672-4D6B-AF90-08161EB18D4F}.Release|x64.ActiveCfg = Release|x64
{B1BB4620-E672-4D6B-AF90-08161EB18D4F}.Release|x64.Build.0 = Release|x64
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Debug|Win32.ActiveCfg = Debug|Win32
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Debug|Win32.Build.0 = Debug|Win32
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Debug|x64.ActiveCfg = Debug|x64
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Debug|x64.Build.0 = Debug|x64
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Release|Win32.ActiveCfg = Release|Win32
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Release|Win32.Build.0 = Release|Win32
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Release|x64.ActiveCfg = Release|x64
{DB5C12E9-BCD3-4517-8708-475C0D1D88CE}.Release|x64.Build.0 = Release|x64
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|Win32.ActiveCfg = Debug|Win32
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|Win32.Build.0 = Debug|Win32
{7AEC599C-7C82-4F00-AA60-411E0A359CB0}.Debug|x64.ActiveCfg = Debug|x64

View File

@ -55,7 +55,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
Optimization="0"
AdditionalIncludeDirectories="..\dependencies\zlib;..\dependencies\libpng\src;"..\dependencies\File_Extractor-0.4.3\fex";..\dependencies\cximage;..\dependencies\msvc"
AdditionalIncludeDirectories="..\dependencies\zlib;..\dependencies\libpng\src;"..\dependencies\File_Extractor-0.4.3\fex";..\dependencies\msvc"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_WARNINGS;MMX;BKPT_SUPPORT;GBA_LOGGING"
StringPooling="false"
MinimalRebuild="true"
@ -164,7 +164,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
Optimization="0"
AdditionalIncludeDirectories="..\dependencies\zlib;..\dependencies\libpng\src;"..\dependencies\File_Extractor-0.4.3\fex";..\dependencies\cximage;..\dependencies\msvc"
AdditionalIncludeDirectories="..\dependencies\zlib;..\dependencies\libpng\src;"..\dependencies\File_Extractor-0.4.3\fex";..\dependencies\msvc"
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_WARNINGS;BKPT_SUPPORT;GBA_LOGGING;C_CORE;NO_ASM"
StringPooling="false"
MinimalRebuild="true"
@ -278,7 +278,7 @@
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..\dependencies\zlib;..\dependencies\libpng\src;"..\dependencies\File_Extractor-0.4.3\fex";..\dependencies\cximage;..\dependencies\msvc"
AdditionalIncludeDirectories="..\dependencies\zlib;..\dependencies\libpng\src;"..\dependencies\File_Extractor-0.4.3\fex";..\dependencies\msvc"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_CRT_SECURE_NO_WARNINGS;MMX;BKPT_SUPPORT;GBA_LOGGING;FINAL_VERSION"
RuntimeLibrary="0"
BufferSecurityCheck="false"
@ -401,7 +401,7 @@
InlineFunctionExpansion="2"
FavorSizeOrSpeed="1"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..\dependencies\zlib;..\dependencies\libpng\src;"..\dependencies\File_Extractor-0.4.3\fex";..\dependencies\cximage;..\dependencies\msvc"
AdditionalIncludeDirectories="..\dependencies\zlib;..\dependencies\libpng\src;"..\dependencies\File_Extractor-0.4.3\fex";..\dependencies\msvc"
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_CRT_SECURE_NO_WARNINGS;BKPT_SUPPORT;GBA_LOGGING;FINAL_VERSION;C_CORE;NO_ASM"
RuntimeLibrary="0"
BufferSecurityCheck="false"
@ -997,14 +997,6 @@
RelativePath=".\src\win32\SelectPlugin.cpp"
>
</File>
<File
RelativePath=".\src\win32\skin.cpp"
>
</File>
<File
RelativePath=".\src\win32\skinButton.cpp"
>
</File>
<File
RelativePath=".\src\win32\StringTokenizer.cpp"
>
@ -1559,10 +1551,6 @@
RelativePath=".\src\win32\SelectPlugin.h"
>
</File>
<File
RelativePath=".\src\win32\skin.h"
>
</File>
<File
RelativePath=".\src\win32\StringTokenizer.h"
>

View File

@ -104,8 +104,6 @@ struct {
{ "OptionsVideoRenderDDRAW", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW },
{ "OptionsVideoRenderD3D", ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D },
{ "OptionsVideoRenderOGL", ID_OPTIONS_VIDEO_RENDERMETHOD_OPENGL },
{ "OptionsUserInterfaceSkinSelect", ID_SKIN_SELECT },
{ "OptionsUserInterfaceSkinUse", ID_SKIN_USE },
{ "OptionsVideoVsync", ID_OPTIONS_VIDEO_VSYNC },
{ "OptionsVideoX1", ID_OPTIONS_VIDEO_X1 },
{ "OptionsVideoX2", ID_OPTIONS_VIDEO_X2 },

View File

@ -48,7 +48,6 @@ class IDisplay {
virtual void resize(int w, int h) {};
virtual void setOption(const char *option, int value) {};
virtual DISPLAY_TYPE getType() = 0;
virtual bool isSkinSupported() { return false; }
virtual bool selectFullScreenMode( VIDEO_MODE &mode ) = 0;
};

View File

@ -424,10 +424,6 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd)
ON_UPDATE_COMMAND_UI(ID_OPTIONS_FILTER_LCDCOLORS, OnUpdateOptionsFilterLcdcolors)
ON_COMMAND_EX_RANGE(ID_OPTIONS_SOUND_PCMINTERPOLATION_NONE, ID_OPTIONS_SOUND_PCMINTERPOLATION_LIBRESAMPLE, OnOptionsSoundPcminterpolation)
ON_UPDATE_COMMAND_UI_RANGE(ID_OPTIONS_SOUND_PCMINTERPOLATION_NONE, ID_OPTIONS_SOUND_PCMINTERPOLATION_LIBRESAMPLE, OnUpdateOptionsSoundPcminterpolation)
ON_COMMAND(ID_SKIN_USE, &MainWnd::OnSkinUse)
ON_UPDATE_COMMAND_UI(ID_SKIN_USE, &MainWnd::OnUpdateSkinUse)
ON_COMMAND(ID_SKIN_SELECT, &MainWnd::OnSkinSelect)
ON_UPDATE_COMMAND_UI(ID_SKIN_SELECT, &MainWnd::OnUpdateSkinSelect)
ON_COMMAND(ID_OUTPUTAPI_DIRECTSOUND, &MainWnd::OnOutputapiDirectsound)
ON_UPDATE_COMMAND_UI(ID_OUTPUTAPI_DIRECTSOUND, &MainWnd::OnUpdateOutputapiDirectsound)
ON_COMMAND(ID_OUTPUTAPI_OPENAL, &MainWnd::OnOutputapiOpenal)
@ -1043,56 +1039,6 @@ bool MainWnd::writeSaveGame(const char *name)
void MainWnd::OnContextMenu(CWnd* pWnd, CPoint point)
{
winMouseOn();
if(theApp.skin) {
if(theApp.popup == NULL) {
theApp.winAccelMgr.UpdateMenu(theApp.menu);
theApp.popup = CreatePopupMenu();
if(theApp.menu != NULL) {
int count = GetMenuItemCount(theApp.menu);
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(info);
GetVersionEx(&info);
if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
for(int i = 0; i < count; i++) {
char buffer[256];
MENUITEMINFO info;
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info) - sizeof(HBITMAP);
info.fMask = MIIM_STRING | MIIM_SUBMENU;
info.dwTypeData = buffer;
info.cch = 256;
if(!GetMenuItemInfo(theApp.menu, i, MF_BYPOSITION, &info)) {
}
if(!AppendMenu(theApp.popup, MF_POPUP|MF_STRING, (UINT_PTR)info.hSubMenu, buffer)) {
}
}
} else {
for(int i = 0; i < count; i++) {
wchar_t buffer[256];
MENUITEMINFOW info;
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info) - sizeof(HBITMAP);
info.fMask = MIIM_STRING | MIIM_SUBMENU;
info.dwTypeData = buffer;
info.cch = 256;
if(!GetMenuItemInfoW(theApp.menu, i, MF_BYPOSITION, &info)) {
}
if(!AppendMenuW(theApp.popup, MF_POPUP|MF_STRING, (UINT_PTR)info.hSubMenu, buffer)) {
}
}
}
}
}
int x = point.x;
int y = point.y;
if(x == -1 && y == -1) {
x = (theApp.dest.left + theApp.dest.right) / 2;
y = (theApp.dest.top + theApp.dest.bottom) / 2;
}
if(!TrackPopupMenu(theApp.popup, 0, x, y, 0, m_hWnd, NULL)) {
}
}
}
void MainWnd::OnSystemMinimize()

View File

@ -200,10 +200,6 @@ class MainWnd : public CWnd
afx_msg void OnUpdateOptionsVideoRenderoptionsGlquads(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsGlpolygons();
afx_msg void OnUpdateOptionsVideoRenderoptionsGlpolygons(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsSelectskin();
afx_msg void OnUpdateOptionsVideoRenderoptionsSelectskin(CCmdUI* pCmdUI);
afx_msg void OnOptionsVideoRenderoptionsSkin();
afx_msg void OnUpdateOptionsVideoRenderoptionsSkin(CCmdUI* pCmdUI);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg void OnOptionsEmulatorAssociate();
afx_msg void OnOptionsEmulatorDirectories();
@ -418,10 +414,6 @@ public:
afx_msg void OnUpdateOptionsLinkRFU(CCmdUI* pCmdUI) ;
afx_msg void OnOptionsLinkEnable() ;
afx_msg void OnUpdateOptionsLinkEnable(CCmdUI* pCmdUI) ;
afx_msg void OnSkinUse();
afx_msg void OnUpdateSkinUse(CCmdUI *pCmdUI);
afx_msg void OnSkinSelect();
afx_msg void OnUpdateSkinSelect(CCmdUI *pCmdUI);
afx_msg void OnOutputapiDirectsound();
afx_msg void OnUpdateOutputapiDirectsound(CCmdUI *pCmdUI);
afx_msg void OnOutputapiOpenal();

View File

@ -29,7 +29,6 @@
#include "MaxScale.h"
#include "Reg.h"
#include "RewindInterval.h"
#include "skin.h"
#include "Throttle.h"
#include "WinResUtil.h"
#include "SelectPlugin.h"
@ -1744,77 +1743,6 @@ void MainWnd::OnOptionsSelectPlugin()
}
}
void MainWnd::OnSkinUse()
{
#ifndef NO_SKINS
theApp.skinEnabled = !theApp.skinEnabled;
theApp.updateRenderMethod(true);
theApp.winAccelMgr.UpdateMenu(theApp.menu);
#else
systemMessage( 0, _T("This build of VBA does not support skins!") );
#endif
}
void MainWnd::OnUpdateSkinUse(CCmdUI *pCmdUI)
{
#ifndef NO_SKINS
pCmdUI->SetCheck( theApp.skinEnabled );
pCmdUI->Enable( theApp.display && theApp.display->isSkinSupported() && theApp.videoOption <= VIDEO_4X );
#endif
}
void MainWnd::OnSkinSelect()
{
#ifndef NO_SKINS
LPCTSTR exts[] = { ".ini" };
CString filter = winLoadFilter( IDS_FILTER_INI );
CString title = winResLoadString( IDS_SELECT_SKIN_FILE );
FileDlg dlg(
this,
theApp.skinName,
filter,
0,
"INI",
exts,
"",
title,
false);
if( dlg.DoModal() == IDCANCEL ) {
return;
}
bool result = false;
if( !theApp.skinEnabled ) {
theApp.skinEnabled = !theApp.skinEnabled;
regSetDwordValue( "skinEnabled", theApp.skinEnabled );
}
if( theApp.skin && theApp.skinEnabled ) {
delete theApp.skin;
theApp.skin = NULL;
}
theApp.skinName = dlg.GetPathName();
theApp.winUpdateSkin();
theApp.winAccelMgr.UpdateMenu( theApp.menu );
#else
systemMessage( 0, _T("This build of VBA does not support skins!") );
#endif
}
void MainWnd::OnUpdateSkinSelect(CCmdUI *pCmdUI)
{
#ifndef NO_SKINS
pCmdUI->Enable(
theApp.display &&
theApp.display->isSkinSupported() &&
theApp.videoOption <= VIDEO_4X
);
#endif
}
void MainWnd::OnOutputapiDirectsound()
{

View File

@ -30,7 +30,6 @@
#include "MainWnd.h"
#include "Reg.h"
#include "resource.h"
#include "skin.h"
#include "WavWriter.h"
#include "WinResUtil.h"
#include "Logging.h"
@ -293,10 +292,6 @@ VBA::VBA()
#endif
glFilter = 0;
GLSLShaders = 0;
skin = NULL;
skinName = "";
skinEnabled = false;
skinButtons = 0;
regEnabled = false;
pauseWhenInactive = true;
speedupToggle = false;
@ -409,10 +404,6 @@ VBA::~VBA()
shutdownDisplay();
if(skin) {
delete skin;
}
if(rewindMemory)
free(rewindMemory);
@ -579,18 +570,10 @@ BOOL VBA::InitInstance()
void VBA::adjustDestRect()
{
POINT point;
RECT skinRect;
if(skin)
skinRect = skin->GetBlitRect();
point.x = 0;
point.y = 0;
if(skin) {
point.x = skinRect.left;
point.y = skinRect.top;
}
m_pMainWnd->ClientToScreen(&point);
dest.top = point.y;
dest.left = point.x;
@ -598,11 +581,6 @@ void VBA::adjustDestRect()
point.x = surfaceSizeX;
point.y = surfaceSizeY;
if(skin) {
point.x = skinRect.right;
point.y = skinRect.bottom;
}
m_pMainWnd->ClientToScreen(&point);
dest.bottom = point.y;
dest.right = point.x;
@ -615,9 +593,6 @@ void VBA::adjustDestRect()
dest.right -= windowPositionX;
}
if(skin)
return;
int menuSkip = 0;
if(videoOption >= VIDEO_320x240 && menuToggle) {
@ -953,9 +928,7 @@ void VBA::updateMenuBar()
m_menu.Attach(winResLoadMenu(MAKEINTRESOURCE(IDR_MENU)));
menu = (HMENU)m_menu;
// don't set a menu if skin is active
if(skin == NULL)
if(m_pMainWnd)
if(m_pMainWnd)
m_pMainWnd->SetMenu(&m_menu);
}
@ -1572,10 +1545,6 @@ void VBA::loadSettings()
winRtcEnable = regQueryDwordValue("rtcEnabled", 0) ? true : false;
rtcEnable(winRtcEnable);
skinEnabled = regQueryDwordValue("skinEnabled", 0) ? true : false;
skinName = regQueryStringValue("skinName", "");
switch(videoOption) {
case VIDEO_320x240:
fsWidth = 320;
@ -1906,7 +1875,6 @@ void VBA::updateWindowSize(int value)
winSizeX = dest.right-dest.left;
winSizeY = dest.bottom-dest.top;
if(skin == NULL) {
m_pMainWnd->SetWindowPos(0, //HWND_TOPMOST,
windowPositionX,
windowPositionY,
@ -1919,7 +1887,8 @@ void VBA::updateWindowSize(int value)
info.cbSize = sizeof(MENUBARINFO);
theApp.m_pMainWnd->GetMenuBarInfo(OBJID_MENU, 0, &info);
int menuHeight = GetSystemMetrics(SM_CYMENU); // includes white line
if((info.rcBar.bottom - info.rcBar.top) > menuHeight) {
if((info.rcBar.bottom - info.rcBar.top) > menuHeight)
{
winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1;
m_pMainWnd->SetWindowPos(
0, //HWND_TOPMOST,
@ -1929,7 +1898,6 @@ void VBA::updateWindowSize(int value)
winSizeY,
SWP_NOMOVE | SWP_SHOWWINDOW);
}
}
}
adjustDestRect();
@ -2100,10 +2068,6 @@ bool VBA::updateRenderMethod0(bool force)
if(display) {
if(display->getType() != renderMethod || force) {
if(skin) {
delete skin;
skin = NULL;
}
initInput = true;
changingVideoSize = true;
shutdownDisplay();
@ -2138,7 +2102,6 @@ bool VBA::updateRenderMethod0(bool force)
if( preInitialize() ) {
if( display->initialize() ) {
winUpdateSkin();
if( initInput ) {
if( !this->initInput() ) {
changingVideoSize = false;
@ -2183,33 +2146,6 @@ void VBA::directXMessage(const char *msg)
msg);
}
void VBA::winUpdateSkin()
{
#ifndef NO_SKINS
skinButtons = 0;
if(skin) {
delete skin;
skin = NULL;
}
if(!skinName.IsEmpty() && skinEnabled && display->isSkinSupported()) {
skin = new CSkin();
if(skin->Initialize(skinName)) {
skin->Hook(m_pMainWnd);
skin->Enable(true);
} else {
delete skin;
skin = NULL;
}
}
if(!skin) {
adjustDestRect();
updateMenuBar();
}
#endif
}
void VBA::updatePriority()
{
switch(threadPriority) {
@ -2561,10 +2497,6 @@ void VBA::saveSettings()
regSetDwordValue("rtcEnabled", winRtcEnable);
regSetDwordValue("skinEnabled", skinEnabled);
regSetStringValue("skinName", skinName);
regSetDwordValue("borderOn", winGbBorderOn);
regSetDwordValue("borderAutomatic", gbBorderAutomatic);
regSetDwordValue("emulatorType", gbEmulatorType);

View File

@ -38,8 +38,6 @@
#include "../System.h"
#include "../Util.h"
#include "skin.h"
/////////////////////////////////////////////////////////////////////////////
// VBA:
// See VBA.cpp for the implementation of this class
@ -67,7 +65,6 @@ enum pixelFilterType
#define REWIND_SIZE 400000
//class CSkin;
class AVIWrite;
class WavWriter;
@ -163,10 +160,6 @@ class VBA : public CWinApp
int glFilter;
int GLSLShaders;
bool dinputKeyFocus;
CSkin *skin;
CString skinName;
bool skinEnabled;
int skinButtons;
bool pauseWhenInactive;
bool speedupToggle;
bool winGbPrinterEnabled;
@ -259,7 +252,6 @@ class VBA : public CWinApp
bool detectMMX();
#endif
void updatePriority();
void winUpdateSkin();
void directXMessage(const char *msg);
void shutdownDisplay();
bool preInitialize();

View File

@ -1616,7 +1616,7 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "Screen Capture...", ID_FILE_SCREENCAPTURE
MENUITEM "ROM Information...", ID_FILE_ROMINFORMATION
MENUITEM "Toggle Menu", ID_FILE_TOGGLEMENU
MENUITEM "Toggle Fullscreen", ID_FILE_TOGGLEMENU
MENUITEM SEPARATOR
MENUITEM "Close", ID_FILE_CLOSE
MENUITEM SEPARATOR
@ -1859,12 +1859,18 @@ BEGIN
MENUITEM "Flash 64 KB", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K
MENUITEM "Flash 128 KB", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M
END
MENUITEM SEPARATOR
POPUP "Screenshot &Format"
BEGIN
MENUITEM "&PNG", ID_OPTIONS_EMULATOR_PNGFORMAT
MENUITEM "&BMP", ID_OPTIONS_EMULATOR_BMPFORMAT
END
MENUITEM SEPARATOR
POPUP "UI &Language"
BEGIN
MENUITEM "&System", ID_OPTIONS_LANGUAGE_SYSTEM
MENUITEM "&English", ID_OPTIONS_LANGUAGE_ENGLISH
MENUITEM "&Other...", ID_OPTIONS_LANGUAGE_OTHER
END
END
POPUP "&Gameboy"
BEGIN
@ -1885,20 +1891,6 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Colors...", ID_OPTIONS_GAMEBOY_COLORS
END
POPUP "&User Interface"
BEGIN
POPUP "&Language"
BEGIN
MENUITEM "&System", ID_OPTIONS_LANGUAGE_SYSTEM
MENUITEM "&English", ID_OPTIONS_LANGUAGE_ENGLISH
MENUITEM "&Other...", ID_OPTIONS_LANGUAGE_OTHER
END
POPUP "&Skin"
BEGIN
MENUITEM "&Use", ID_SKIN_USE
MENUITEM "&Select", ID_SKIN_SELECT
END
END
POPUP "&Link", GRAYED
BEGIN
MENUITEM "Enable GBA Linking", ID_OPTIONS_LINK_ENABLE

View File

@ -1,588 +0,0 @@
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//
// WINDOWS SKINNING TUTORIAL - by Vander Nunes - virtware.net
// This is the source-code that shows what is discussed in the tutorial.
// The code is simplified for the sake of clarity, but all the needed
// features for handling skinned windows is present. Please read
// the article for more information.
//
// skin.cpp : CSkin class implementation
// 28/02/2002 : initial release.
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#include "stdafx.h"
#include "skin.h"
#include <stdio.h>
#include "xImage.h"
#include "../System.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// ----------------------------------------------------------------------------
// constructor 1 - use it when you have not already created the app window.
// this one will not subclass automatically, you must call Hook() and Enable()
// to subclass the app window and enable the skin respectively.
// will throw an exception if unable to initialize skin from resource.
// ----------------------------------------------------------------------------
CSkin::CSkin()
{
// default starting values
m_bHooked = false;
m_OldWndProc = NULL;
m_rect.top = 0;
m_rect.bottom = 0;
m_rect.right = 0;
m_rect.left = 0;
m_dOldStyle = 0;
m_oldRect = m_rect;
m_nButtons = 0;
m_buttons = NULL;
}
// ----------------------------------------------------------------------------
// destructor - just call the destroyer
// ----------------------------------------------------------------------------
CSkin::~CSkin()
{
Destroy();
}
HBITMAP CSkin::LoadImage(const char *filename)
{
CxImage image;
image.Load(filename);
if(!image.IsValid()) {
return NULL;
}
return image.MakeBitmap(NULL);
}
// ----------------------------------------------------------------------------
// Initialize the skin
// ----------------------------------------------------------------------------
bool CSkin::Initialize(const char *skinFile)
{
// try to retrieve the skin data from resource.
bool res = GetSkinData(skinFile);
if(!res)
systemMessage(0, m_error);
return res;
}
// ----------------------------------------------------------------------------
// destroy skin resources and free allocated resources
// ----------------------------------------------------------------------------
void CSkin::Destroy()
{
if (m_buttons) {
delete[] m_buttons;
m_buttons = NULL;
}
// unhook the window
UnHook();
// free bitmaps and device context
if (m_dcSkin) { SelectObject(m_dcSkin, m_hOldBmp); DeleteDC(m_dcSkin); m_dcSkin = NULL; }
if (m_hBmp) { DeleteObject(m_hBmp); m_hBmp = NULL; }
// free skin region
if (m_rgnSkin) { DeleteObject(m_rgnSkin); m_rgnSkin = NULL; }
}
// ----------------------------------------------------------------------------
// toggle skin on/off - must be Hooked() before attempting to enable skin.
// ----------------------------------------------------------------------------
bool CSkin::Enable(bool bEnable)
{
// refuse to enable if there is no window subclassed yet.
if (!Hooked()) return false;
// toggle
m_bEnabled = bEnable;
// force window repainting
InvalidateRect(m_hWnd, NULL, TRUE);
return true;
}
// ----------------------------------------------------------------------------
// tell if the skinning is enabled
// ----------------------------------------------------------------------------
bool CSkin::Enabled()
{
return m_bEnabled;
}
// ----------------------------------------------------------------------------
// hook a window
// ----------------------------------------------------------------------------
bool CSkin::Hook(CWnd *pWnd)
{
// unsubclass any other window
if (Hooked()) UnHook();
// this will be our new subclassed window
m_hWnd = (HWND)*pWnd;
// --------------------------------------------------
// change window style (get rid of the caption bar)
// --------------------------------------------------
LONG_PTR dwStyle = GetWindowLongPtr(m_hWnd, GWL_STYLE);
m_dOldStyle = dwStyle;
dwStyle &= ~(WS_CAPTION|WS_SIZEBOX);
SetWindowLongPtr(m_hWnd, GWL_STYLE, dwStyle);
RECT r;
pWnd->GetWindowRect(&r);
m_oldRect = r;
pWnd->MoveWindow(r.left,
r.top,
m_iWidth,
m_iHeight,
FALSE);
pWnd->SetMenu(NULL);
if(m_rgnSkin != NULL)
// set the skin region to the window
pWnd->SetWindowRgn(m_rgnSkin, true);
// subclass the window procedure
m_OldWndProc = (WNDPROC)SetWindowLongPtr( m_hWnd, GWLP_WNDPROC, (LONG_PTR)SkinWndProc );
// store a pointer to our class instance inside the window procedure.
if (!SetProp(m_hWnd, "skin", (void*)this))
{
// if we fail to do so, we just can't activate the skin.
UnHook();
return false;
}
// update flag
m_bHooked = ( m_OldWndProc ? true : false );
for(int i = 0; i < m_nButtons; i++) {
RECT r;
m_buttons[i].GetRect(r);
m_buttons[i].CreateButton("", WS_VISIBLE, r, pWnd, 0);
}
// force window repainting
RedrawWindow(NULL,NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
// successful return if we're hooked.
return m_bHooked;
}
// ----------------------------------------------------------------------------
// unhook the window
// ----------------------------------------------------------------------------
bool CSkin::UnHook()
{
// just to be safe we'll check this
WNDPROC OurWnd;
// cannot unsubclass if there is no window subclassed
// returns true anyways.
if (!Hooked()) return true;
if(m_rgnSkin != NULL)
// remove the skin region from the window
SetWindowRgn(m_hWnd, NULL, true);
// unsubclass the window procedure
OurWnd = (WNDPROC)SetWindowLongPtr( m_hWnd, GWLP_WNDPROC, (LONG_PTR)m_OldWndProc );
// remove the pointer to our class instance, but if we fail we don't care.
RemoveProp(m_hWnd, "skin");
// update flag - if we can't get our window procedure address again,
// we failed to unhook the window.
m_bHooked = ( OurWnd ? false : true );
SetWindowLongPtr(m_hWnd, GWL_STYLE, m_dOldStyle);
RECT r;
GetWindowRect(m_hWnd, &r);
MoveWindow(m_hWnd,
r.left,
r.top,
m_oldRect.right - m_oldRect.left,
m_oldRect.bottom - m_oldRect.top,
FALSE);
// force window repainting
RedrawWindow(NULL,NULL,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
// successful return if we're unhooked.
return !m_bHooked;
}
// ----------------------------------------------------------------------------
// tell us if there is a window subclassed
// ----------------------------------------------------------------------------
bool CSkin::Hooked()
{
return m_bHooked;
}
// ----------------------------------------------------------------------------
// return the skin bitmap width
// ----------------------------------------------------------------------------
int CSkin::Width()
{
return m_iWidth;
}
// ----------------------------------------------------------------------------
// return the skin bitmap height
// ----------------------------------------------------------------------------
int CSkin::Height()
{
return m_iHeight;
}
// ----------------------------------------------------------------------------
// return the skin device context
// ----------------------------------------------------------------------------
HDC CSkin::HDC()
{
return m_dcSkin;
}
bool CSkin::ParseRect(char *buffer, RECT& rect)
{
char *token = strtok(buffer, ",");
if(token == NULL)
return false;
rect.left = atoi(token);
token = strtok(NULL, ",");
if(token == NULL)
return false;
rect.top = atoi(token);
token = strtok(NULL, ",");
if(token == NULL)
return false;
rect.right = rect.left + atoi(token);
token = strtok(NULL, ",");
if(token == NULL)
return false;
rect.bottom = rect.top + atoi(token);
token = strtok(NULL, ",");
if(token != NULL)
return false;
return true;
}
HRGN CSkin::LoadRegion(const char *rgn)
{
// -------------------------------------------------
// then, we retrieve the skin region from resource.
// -------------------------------------------------
FILE *f = fopen(rgn, "rb");
if(!f) return NULL;
fseek(f, 0, SEEK_END);
int size = ftell(f);
LPRGNDATA pSkinData = (LPRGNDATA)malloc(size);
if(!pSkinData) {
fclose(f);
return NULL;
}
fseek(f, 0, SEEK_SET);
fread(pSkinData, 1, size, f);
fclose(f);
// create the region using the binary data.
HRGN r = ExtCreateRegion(NULL, size, pSkinData);
// free the allocated resource
free(pSkinData);
return r;
}
// ----------------------------------------------------------------------------
// skin retrieval helper
// ----------------------------------------------------------------------------
bool CSkin::GetSkinData(const char *skinFile)
{
// -------------------------------------------------
// retrieve the skin bitmap from resource.
// -------------------------------------------------
char buffer[2048];
if(!GetPrivateProfileString("skin", "image", "", buffer, 2048, skinFile)) {
m_error = "Missing skin bitmap";
return false;
}
CString bmpName = buffer;
CString rgn = "";
if(GetPrivateProfileString("skin", "region", "", buffer, 2048, skinFile)) {
rgn = buffer;
}
if(!GetPrivateProfileString("skin", "draw", "", buffer, 2048, skinFile)) {
m_error = "Missing draw rectangle";
return false;
}
if(!ParseRect(buffer, m_rect)) {
m_error = "Invalid draw rectangle";
return false;
}
m_nButtons = GetPrivateProfileInt("skin", "buttons", 0, skinFile);
if(m_nButtons) {
m_buttons = new SkinButton[m_nButtons];
for(int i = 0; i < m_nButtons; i++) {
if(!ReadButton(skinFile, i))
return false;
}
}
CString path = skinFile;
int index = path.ReverseFind('\\');
if(index != -1) {
path = path.Left(index+1);
}
bmpName = path + bmpName;
if(strcmp(rgn, ""))
rgn = path + rgn;
m_hBmp = LoadImage(bmpName);
if (!m_hBmp) {
m_error = "Error loading skin bitmap " + bmpName;
return false;
}
// get skin info
BITMAP bmp;
GetObject(m_hBmp, sizeof(bmp), &bmp);
// get skin dimensions
m_iWidth = bmp.bmWidth;
m_iHeight = bmp.bmHeight;
if(strcmp(rgn, "")) {
m_rgnSkin = LoadRegion(rgn);
if(m_rgnSkin == NULL) {
m_error = "Error loading skin region " + rgn;
return false;
}
}
// -------------------------------------------------
// well, things are looking good...
// as a quick providence, just create and keep
// a device context for our later blittings.
// -------------------------------------------------
// create a context compatible with the user desktop
m_dcSkin = CreateCompatibleDC(0);
if (!m_dcSkin) return false;
// select our bitmap
m_hOldBmp = (HBITMAP)SelectObject(m_dcSkin, m_hBmp);
// -------------------------------------------------
// done
// -------------------------------------------------
return true;
}
bool CSkin::ReadButton(const char *skinFile, int num)
{
char buffer[2048];
CString path = skinFile;
int index = path.ReverseFind('\\');
if(index != -1) {
path = path.Left(index+1);
}
sprintf(buffer, "button-%d", num);
CString name = buffer;
if(!GetPrivateProfileString(name, "normal", "", buffer, 2048, skinFile)) {
m_error = "Missing button bitmap for " + name;
return false;
}
CString normalBmp = path + buffer;
HBITMAP bmp = LoadImage(normalBmp);
if(!bmp) {
m_error = "Error loading button bitmap " + normalBmp;
return false;
}
m_buttons[num].SetNormalBitmap(bmp);
if(!GetPrivateProfileString(name, "down", "", buffer, 2048, skinFile)) {
m_error = "Missing button down bitmap " + name;
return false;
}
CString downBmp = path + buffer;
bmp = LoadImage(downBmp);
if (!bmp) {
m_error = "Error loading button down bitmap " + downBmp;
return false;
}
m_buttons[num].SetDownBitmap(bmp);
if(GetPrivateProfileString(name, "over", "", buffer, 2048, skinFile)) {
CString overBmp = path + buffer;
bmp = LoadImage(overBmp);
if (!bmp) {
m_error = "Error loading button over bitmap " + overBmp;
return false;
}
m_buttons[num].SetOverBitmap(bmp);
}
if(GetPrivateProfileString(name, "region", "", buffer, 2048, skinFile)) {
CString region = path + buffer;
HRGN rgn = LoadRegion(region);
if(!rgn) {
m_error = "Error loading button region " + region;
return false;
}
m_buttons[num].SetRegion(rgn);
}
if(!GetPrivateProfileString(name, "id", "", buffer, 2048, skinFile)) {
"Missing button ID for " + name;
return false;
}
m_buttons[num].SetId(buffer);
if(!GetPrivateProfileString(name, "rect", "", buffer, 2048, skinFile)) {
m_error = "Missing button rectangle for " + name;
return false;
}
RECT r;
if(!ParseRect(buffer, r)) {
m_error = "Invalid button rectangle for " + name;
return false;
}
m_buttons[num].SetRect(r);
return true;
}
// ------------------------------------------------------------------------
// Default skin window procedure.
// Here the class will handle WM_PAINT and WM_LBUTTONDOWN, originally sent
// to the application window, but now subclassed. Any other messages will
// just pass through the procedure and reach the original app procedure.
// ------------------------------------------------------------------------
LRESULT CALLBACK SkinWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
// we will need a pointer to the associated class instance
// (it was stored in the window before, remember?)
CSkin *pSkin = (CSkin*)GetProp(hWnd, _T("skin"));
// to handle WM_PAINT
PAINTSTRUCT ps;
// if we fail to get our class instance, we can't handle anything.
if (!pSkin) return DefWindowProc(hWnd,uMessage,wParam,lParam);
switch(uMessage)
{
case WM_WINDOWPOSCHANGING:
{
LPWINDOWPOS pos = (LPWINDOWPOS)lParam;
pos->cx = pSkin->Width();
pos->cy = pSkin->Height();
return 0L;
}
break;
case WM_PAINT:
{
// ---------------------------------------------------------
// here we just need to blit our skin
// directly to the device context
// passed by the painting message.
// ---------------------------------------------------------
BeginPaint(hWnd,&ps);
// blit the skin
BitBlt(ps.hdc,0,0,pSkin->Width(),pSkin->Height(),pSkin->HDC(),0,0,SRCCOPY);
EndPaint(hWnd,&ps);
break;
}
case WM_LBUTTONDOWN:
{
// ---------------------------------------------------------
// this is a common trick for easy dragging of the window.
// this message fools windows telling that the user is
// actually dragging the application caption bar.
// ---------------------------------------------------------
SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION,NULL);
break;
}
}
// ---------------------------------------------------------
// call the default window procedure to keep things going.
// ---------------------------------------------------------
return CallWindowProc(pSkin->m_OldWndProc, hWnd, uMessage, wParam, lParam);
}

View File

@ -1,162 +0,0 @@
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//
// WINDOWS SKINNING TUTORIAL - by Vander Nunes - virtware.net
// This is the source-code that shows what is discussed in the tutorial.
// The code is simplified for the sake of clarity, but all the needed
// features for handling skinned windows is present. Please read
// the article for more information.
//
// skin.h : CSkin class declaration
// 28/02/2002 : initial release.
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#ifndef _SKIN_H_
#define _SKIN_H_
#include "skinButton.h"
// --------------------------------------------------------------------------
// The CSkin class will load the skin from a resource
// and subclass the associated window, so that the
// WM_PAINT message will be redirected to the provided
// window procedure. All the skin handling will be automatized.
// --------------------------------------------------------------------------
class CSkin
{
// --------------------------------------------------------------------------
// the skin window procedure, where the class
// will handle WM_PAINT and WM_LBUTTONDOWN automatically.
// --------------------------------------------------------------------------
friend LRESULT CALLBACK SkinWndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam);
private:
// the associated window handle
HWND m_hWnd;
// the old window procedure
WNDPROC m_OldWndProc;
// skin region
HRGN m_rgnSkin;
// the internal skin device context handle
HDC m_dcSkin;
// bitmap and old bitmap from the device context
HBITMAP m_hBmp, m_hOldBmp;
// skin dimensions
int m_iWidth, m_iHeight;
// on|off toggle
bool m_bEnabled;
// tell the class if it has a window subclassed.
bool m_bHooked;
// skin retrieval helper
bool GetSkinData(const char *skin);
RECT m_rect;
LONG_PTR m_dOldStyle;
RECT m_oldRect;
int m_nButtons;
SkinButton *m_buttons;
CString m_error;
public:
// ----------------------------------------------------------------------------
// constructor 1 - use it when you have not already created the app window.
// this one will not subclass automatically, you must call Hook() to subclass.
// will throw an exception if unable to initialize skin from resource.
// ----------------------------------------------------------------------------
CSkin();
// ----------------------------------------------------------------------------
// destructor - just call the destroyer
// ----------------------------------------------------------------------------
virtual ~CSkin();
// ----------------------------------------------------------------------------
// Initialize the skin
// ----------------------------------------------------------------------------
bool Initialize(const char *);
// ----------------------------------------------------------------------------
// destroy skin resources and free allocated resources
// ----------------------------------------------------------------------------
void Destroy();
// ----------------------------------------------------------------------------
// subclass a window.
// ----------------------------------------------------------------------------
bool Hook(CWnd *pWnd);
// ----------------------------------------------------------------------------
// unsubclass the subclassed window.
// ----------------------------------------------------------------------------
bool UnHook();
// ----------------------------------------------------------------------------
// tell us if we have a window subclassed.
// ----------------------------------------------------------------------------
bool Hooked();
// ----------------------------------------------------------------------------
// toggle skin on/off.
// ----------------------------------------------------------------------------
bool Enable(bool bEnable);
// ----------------------------------------------------------------------------
// tell if the skinning is enabled
// ----------------------------------------------------------------------------
bool Enabled();
// ----------------------------------------------------------------------------
// return the skin bitmap width.
// ----------------------------------------------------------------------------
int Width();
// ----------------------------------------------------------------------------
// return the skin bitmap height.
// ----------------------------------------------------------------------------
int Height();
// Return blit rect
RECT &GetBlitRect() { return m_rect; }
// ----------------------------------------------------------------------------
// return the skin device context.
// ----------------------------------------------------------------------------
HDC HDC();
private:
HBITMAP LoadImage(const char *);
bool ReadButton(const char *, int);
static bool ParseRect(char *, RECT &);
static HRGN LoadRegion(const char *);
};
#endif

View File

@ -1,330 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// 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, 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.
// skinButton.cpp : implementation file
//
#include "stdafx.h"
#include "vba.h"
#include "skinButton.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern bool winAccelGetID(const char *command, WORD& id);
/////////////////////////////////////////////////////////////////////////////
// SkinButton
SkinButton::SkinButton()
{
normalBmp = NULL;
downBmp = NULL;
overBmp = NULL;
mouseOver = false;
id = "";
idCommand = 0;
region = NULL;
buttonMask = 0;
menu = -1;
}
SkinButton::~SkinButton()
{
DestroyWindow();
if(normalBmp) {
DeleteObject(normalBmp);
normalBmp = NULL;
}
if(downBmp) {
DeleteObject(downBmp);
downBmp = NULL;
}
if(overBmp) {
DeleteObject(overBmp);
overBmp = NULL;
}
if(region) {
DeleteObject(region);
region = NULL;
}
}
BEGIN_MESSAGE_MAP(SkinButton, CWnd)
//{{AFX_MSG_MAP(SkinButton)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_KILLFOCUS()
ON_WM_CAPTURECHANGED()
ON_WM_CONTEXTMENU()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_LBUTTONUP, OnLButtonUpMsg)
ON_MESSAGE(WM_LBUTTONDOWN, OnLButtonDownMsg)
ON_MESSAGE(WM_MOUSEMOVE, OnMouseMoveMsg)
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeaveMsg)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SkinButton message handlers
BOOL SkinButton::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
void SkinButton::OnPaint()
{
PAINTSTRUCT ps;
HDC hDC = ::BeginPaint(m_hWnd, &ps);
HDC memDC = ::CreateCompatibleDC(hDC);
LRESULT state = ::SendMessage(m_hWnd, BM_GETSTATE, 0, 0);
HBITMAP oldBitmap;
if(state & BST_PUSHED)
oldBitmap = (HBITMAP)SelectObject(memDC, downBmp);
else if(mouseOver && overBmp != NULL)
oldBitmap = (HBITMAP)SelectObject(memDC, overBmp);
else
oldBitmap = (HBITMAP)SelectObject(memDC, normalBmp);
SelectClipRgn(hDC, region);
BitBlt(hDC, 0, 0, theApp.rect.right - theApp.rect.left,
theApp.rect.bottom - theApp.rect.top, memDC, 0, 0, SRCCOPY);
SelectClipRgn(hDC, NULL);
SelectObject(memDC, oldBitmap);
DeleteDC(memDC);
::EndPaint(m_hWnd, &ps);
}
LRESULT SkinButton::OnLButtonUpMsg(WPARAM wParam, LPARAM lParam)
{
POINT pt;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
RECT r;
GetClientRect(&r);
BOOL inside = PtInRect(&r, pt);
if(region != NULL)
inside &= PtInRegion(region, pt.x, pt.y);
if(inside) {
ReleaseCapture();
Invalidate();
HWND hWnd = m_hWnd;
if(idCommand != 0)
GetParent()->SendMessage(WM_COMMAND, idCommand, 0);
else if(buttonMask)
theApp.skinButtons = 0;
else if(menu != -1) {
HMENU m = GetSubMenu(theApp.menu, menu);
pt.x = r.left;
pt.y = r.bottom;
ClientToScreen(&pt);
theApp.m_pMainWnd->SendMessage(WM_INITMENUPOPUP, (WPARAM)m, menu);
TrackPopupMenu(m, 0, pt.x, pt.y, 0, *theApp.m_pMainWnd, NULL);
}
return ::DefWindowProc(hWnd, WM_LBUTTONUP, wParam, lParam);
}
return GetParent()->SendMessage(WM_LBUTTONUP, wParam, lParam);
}
LRESULT SkinButton::OnLButtonDownMsg(WPARAM wParam, LPARAM lParam)
{
if(idCommand != 0)
return Default();
POINT pt;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
RECT r;
GetClientRect(&r);
BOOL inside = PtInRect(&r, pt);
if(region != NULL)
inside &= PtInRegion(region, pt.x, pt.y);
if(inside) {
if(buttonMask)
theApp.skinButtons = buttonMask;
return Default();
}
return GetParent()->SendMessage(WM_LBUTTONDOWN, wParam, lParam);
}
LRESULT SkinButton::OnMouseMoveMsg(WPARAM wParam, LPARAM lParam)
{
if(wParam & MK_LBUTTON && !mouseOver)
return Default();
if(GetCapture() != this) {
SetCapture();
}
POINT pt;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
// ClientToScreen(getHandle(), &p);
RECT r;
GetClientRect(&r);
BOOL inside = PtInRect(&r, pt);
if(region != NULL)
inside &= PtInRegion(region, pt.x, pt.y);
if(!inside) {
// HWND h = WindowFromPoint(p);
// if(h != getHandle()) {
if(mouseOver) {
mouseOver = false;
Invalidate();
}
if(!(wParam & MK_LBUTTON))
ReleaseCapture();
} else {
if(!mouseOver) {
mouseOver = true;
Invalidate();
}
}
return Default();
}
void SkinButton::OnKillFocus(CWnd* pNewWnd)
{
mouseOver = false;
Invalidate();
CWnd::OnKillFocus(pNewWnd);
}
void SkinButton::OnCaptureChanged(CWnd *pWnd)
{
if(mouseOver) {
ReleaseCapture();
Invalidate();
}
CWnd::OnCaptureChanged(pWnd);
}
LRESULT SkinButton::OnMouseLeaveMsg(WPARAM wParam, LPARAM lParam)
{
if(mouseOver) {
ReleaseCapture();
mouseOver = false;
Invalidate();
}
return Default();
}
void SkinButton::OnContextMenu(CWnd* pWnd, CPoint point)
{
}
void SkinButton::SetNormalBitmap(HBITMAP bmp)
{
normalBmp = bmp;
}
void SkinButton::SetDownBitmap(HBITMAP bmp)
{
downBmp = bmp;
}
void SkinButton::SetOverBitmap(HBITMAP bmp)
{
overBmp = bmp;
}
void SkinButton::SetRect(const RECT& r)
{
rect = r;
}
void SkinButton::SetId(const char *id)
{
this->id = id;
if(!winAccelGetID(id, idCommand)) {
if(!strcmp(id, "A"))
buttonMask = 1;
else if(!strcmp("B", id))
buttonMask = 2;
else if(!strcmp("SEL", id))
buttonMask = 4;
else if(!strcmp("START", id))
buttonMask = 8;
else if(!strcmp("R", id))
buttonMask = 16;
else if(!strcmp("L", id))
buttonMask = 32;
else if(!strcmp("U", id))
buttonMask = 64;
else if(!strcmp("D", id))
buttonMask = 128;
else if(!strcmp("BR", id))
buttonMask = 256;
else if(!strcmp("BL", id))
buttonMask = 512;
else if(!strcmp("SPEED", id))
buttonMask = 1024;
else if(!strcmp("CAPTURE", id))
buttonMask = 2048;
else if(!strcmp("GS", id))
buttonMask = 4096;
else if(!strcmp("UR", id))
buttonMask = 64+16;
else if(!strcmp("UL", id))
buttonMask = 64+32;
else if(!strcmp("DR", id))
buttonMask = 128+16;
else if(!strcmp("DL", id))
buttonMask = 128+32;
else if(!strcmp("MENUFILE", id))
menu = 0;
else if(!strcmp("MENUOPTIONS", id))
menu = 1;
else if(!strcmp("MENUCHEATS", id))
menu = 2;
else if(!strcmp("MENUTOOLS", id))
menu = 3;
else if(!strcmp("MENUHELP", id))
menu = 4;
}
}
void SkinButton::SetRegion(HRGN rgn)
{
region = rgn;
}
void SkinButton::GetRect(RECT& r)
{
r = rect;
}
BOOL SkinButton::CreateButton(const char *name, DWORD style, const RECT& r,
CWnd *parent, UINT id)
{
return CWnd::Create("BUTTON",
name,
style|WS_CHILDWINDOW,
r,
parent,
id);
}

View File

@ -1,93 +0,0 @@
// -*- C++ -*-
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 1999-2003 Forgotten
// Copyright (C) 2004 Forgotten and the VBA development team
// 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, 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.
#if !defined(AFX_SKINBUTTON_H__E51B4507_EAD7_43EE_9F54_204BC485D59C__INCLUDED_)
#define AFX_SKINBUTTON_H__E51B4507_EAD7_43EE_9F54_204BC485D59C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// skinButton.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// SkinButton window
class SkinButton : public CWnd
{
// Construction
public:
SkinButton();
// Attributes
private:
HBITMAP normalBmp;
HBITMAP downBmp;
HBITMAP overBmp;
RECT rect;
bool mouseOver;
CString id;
HRGN region;
WORD idCommand;
int buttonMask;
int menu;
// Operations
public:
BOOL CreateButton(const char *, DWORD, const RECT&, CWnd *, UINT);
void SetNormalBitmap(HBITMAP);
void SetDownBitmap(HBITMAP);
void SetOverBitmap(HBITMAP);
void SetRect(const RECT &);
void GetRect(RECT& r);
void SetId(const char *);
void SetRegion(HRGN);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(SkinButton)
//}}AFX_VIRTUAL
// Implementation
public:
afx_msg LRESULT OnMouseLeaveMsg(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnMouseMoveMsg(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnLButtonDownMsg(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnLButtonUpMsg(WPARAM wParam, LPARAM lParam);
virtual ~SkinButton();
// Generated message map functions
protected:
//{{AFX_MSG(SkinButton)
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnPaint();
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnCaptureChanged(CWnd *pWnd);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SKINBUTTON_H__E51B4507_EAD7_43EE_9F54_204BC485D59C__INCLUDED_)