2013-03-15 13:11:33 +00:00
|
|
|
namespace phoenix {
|
|
|
|
|
2012-02-13 11:44:02 +00:00
|
|
|
#ifndef Button_SetImageList
|
|
|
|
//MinGW/32-bit has painfully outdated platform headers ...
|
|
|
|
typedef struct {
|
|
|
|
HIMAGELIST himl;
|
|
|
|
RECT margin;
|
|
|
|
UINT uAlign;
|
|
|
|
} BUTTON_IMAGELIST, *PBUTTON_IMAGELIST;
|
|
|
|
|
|
|
|
#define BUTTON_IMAGELIST_ALIGN_LEFT 0
|
|
|
|
#define BUTTON_IMAGELIST_ALIGN_RIGHT 1
|
|
|
|
#define BUTTON_IMAGELIST_ALIGN_TOP 2
|
|
|
|
#define BUTTON_IMAGELIST_ALIGN_BOTTOM 3
|
|
|
|
#define BUTTON_IMAGELIST_ALIGN_CENTER 4
|
|
|
|
|
|
|
|
#define BCM_FIRST 0x1600
|
|
|
|
#define BCM_SETIMAGELIST (BCM_FIRST+2)
|
|
|
|
#define Button_SetImageList(hwnd, pbuttonImagelist) (WINBOOL)SNDMSG((hwnd),BCM_SETIMAGELIST,0,(LPARAM)(pbuttonImagelist))
|
|
|
|
#endif
|
|
|
|
|
2013-03-15 13:11:33 +00:00
|
|
|
Size pButton::minimumSize() {
|
|
|
|
Size size = pFont::size(hfont, button.state.text);
|
2012-01-15 08:29:57 +00:00
|
|
|
|
|
|
|
if(button.state.orientation == Orientation::Horizontal) {
|
2013-03-15 13:11:33 +00:00
|
|
|
size.width += button.state.image.width;
|
|
|
|
size.height = max(button.state.image.height, size.height);
|
2012-01-15 08:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(button.state.orientation == Orientation::Vertical) {
|
2013-03-15 13:11:33 +00:00
|
|
|
size.width = max(button.state.image.width, size.width);
|
|
|
|
size.height += button.state.image.height;
|
2012-01-15 08:29:57 +00:00
|
|
|
}
|
|
|
|
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 10:10:46 +00:00
|
|
|
return {size.width + (button.state.text ? 20 : 10), size.height + 10};
|
|
|
|
}
|
|
|
|
|
|
|
|
void pButton::setBordered(bool bordered) {
|
2011-03-22 12:56:49 +00:00
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
void pButton::setImage(const image& image, Orientation orientation) {
|
2012-01-15 08:29:57 +00:00
|
|
|
nall::image nallImage = image;
|
|
|
|
nallImage.transform(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0);
|
|
|
|
|
|
|
|
if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; }
|
|
|
|
if(himagelist) { ImageList_Destroy(himagelist); himagelist = 0; }
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
//Windows XP and earlier do not support translucent images
|
|
|
|
//so we must blend with the button background color (which does not look great with XP gradient-button themes)
|
|
|
|
if(OsVersion() < WindowsVista) nallImage.alphaBlend(GetSysColor(COLOR_BTNFACE));
|
|
|
|
hbitmap = CreateBitmap(nallImage);
|
|
|
|
himagelist = ImageList_Create(nallImage.width, nallImage.height, ILC_COLOR32, 1, 0);
|
|
|
|
ImageList_Add(himagelist, hbitmap, NULL);
|
|
|
|
BUTTON_IMAGELIST list;
|
|
|
|
list.himl = himagelist;
|
|
|
|
switch(orientation) {
|
|
|
|
case Orientation::Horizontal: SetRect(&list.margin, 5, 0, 0, 0); list.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT; break;
|
|
|
|
case Orientation::Vertical: SetRect(&list.margin, 0, 5, 0, 0); list.uAlign = BUTTON_IMAGELIST_ALIGN_TOP; break;
|
2012-01-15 08:29:57 +00:00
|
|
|
}
|
2013-11-28 10:29:01 +00:00
|
|
|
Button_SetImageList(hwnd, &list);
|
2013-01-05 09:19:04 +00:00
|
|
|
|
|
|
|
setText(button.state.text); //update text to display nicely with image (or lack thereof)
|
2012-01-15 08:29:57 +00:00
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
void pButton::setText(string text) {
|
2013-01-05 09:19:04 +00:00
|
|
|
if(text.empty()) {
|
|
|
|
//bitmaps will not show up if text is empty
|
|
|
|
SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | BS_BITMAP);
|
|
|
|
} else {
|
|
|
|
//text will not show up if BS_BITMAP is set
|
|
|
|
SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) & ~BS_BITMAP);
|
|
|
|
}
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
SetWindowText(hwnd, utf16_t(text));
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pButton::constructor() {
|
2013-11-28 10:29:01 +00:00
|
|
|
hwnd = CreateWindow(L"BUTTON", L"", WS_CHILD | WS_TABSTOP, 0, 0, 0, 0, parentHwnd, (HMENU)id, GetModuleHandle(0), 0);
|
2011-02-24 09:25:20 +00:00
|
|
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&button);
|
|
|
|
setDefaultFont();
|
Update to v094r09 release.
byuu says:
This will easily be the biggest diff in the history of higan. And not in
a good way.
* target-higan and target-loki have been blown away completely
* nall and ruby massively updated
* phoenix replaced with hiro (pretty near a total rewrite)
* target-higan restarted using hiro (just a window for now)
* all emulation cores updated to compile again
* installation changed to not require root privileges (installs locally)
For the foreseeable future (maybe even permanently?), the new higan UI
will only build under Linux/BSD with GTK+ 2.20+. Probably the most
likely route for Windows/OS X will be to try and figure out how to build
hiro/GTK on those platforms, as awful as that would be. The other
alternative would be to produce new UIs for those platforms ... which
would actually be a good opportunity to make something much more user
friendly.
Being that I just started on this a few hours ago, that means that for
at least a few weeks, don't expect to be able to actually play any
games. Right now, you can pretty much just compile the binary and that's
it. It's quite possible that some nall changes didn't produce
compilation errors, but will produce runtime errors. So until the UI can
actually load games, we won't know if anything is broken. But we should
mostly be okay. It was mostly just trim<1> -> trim changes, moving to
Hash::SHA256 (much cleaner), and patching some reckless memory copy
functions enough to compile.
Progress isn't going to be like it was before: I'm now dividing my time
much thinner between studying and other hobbies.
My aim this time is not to produce a binary for everyone to play games
on. Rather, it's to keep the emulator alive. I want to be able to apply
critical patches again. And I would also like the base of the emulator
to live on, for use in other emulator frontends that utilize higan.
2015-02-26 10:10:46 +00:00
|
|
|
setBordered(button.state.bordered);
|
2012-01-15 08:29:57 +00:00
|
|
|
setImage(button.state.image, button.state.orientation);
|
2013-01-05 09:19:04 +00:00
|
|
|
//setText(button.state.text); //called by setImage();
|
2011-09-05 03:48:23 +00:00
|
|
|
synchronize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pButton::destructor() {
|
2012-01-15 08:29:57 +00:00
|
|
|
if(hbitmap) { DeleteObject(hbitmap); hbitmap = 0; }
|
|
|
|
if(himagelist) { ImageList_Destroy(himagelist); himagelist = 0; }
|
2011-09-05 03:48:23 +00:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pButton::orphan() {
|
|
|
|
destructor();
|
|
|
|
constructor();
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
void pButton::onActivate() {
|
|
|
|
if(button.onActivate) button.onActivate();
|
|
|
|
}
|
|
|
|
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|