bsnes/hiro/windows/widget/widget.cpp

94 lines
2.3 KiB
C++
Raw Normal View History

#if defined(Hiro_Widget)
namespace hiro {
auto pWidget::construct() -> void {
abstract = true;
//todo: create hiroWidget
hwnd = CreateWindow(L"hiroLabel", L"", WS_CHILD, 0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
_setState();
}
auto pWidget::destruct() -> void {
DeleteObject(hfont);
DestroyWindow(hwnd);
}
auto pWidget::focused() const -> bool {
auto focused = GetFocus();
return hwnd == focused || IsChild(hwnd, focused);
Update to higan v091r14 and ananke v00r03 releases. byuu says: higan changelog: - generates title displayed in emulator window by asking the core - core builds title solely from "information/title" ... if it's not there, you don't get a title at all - sub-system load menu is gone ... since there are multiple revisions of the SGB, this never really worked well anyway - to load an SGB, BS-X or ST cartridge, load the base cartridge first - "File->Load Game" moved to "Load->Import Game" ... may cause a bit of confusion to new users, but I don't like having a single-item menu, we'll just have to explain it to new users - browser window redone to look like ananke - home button here goes to ~/Emulation rather than just ~ like ananke, since this is the home of game folders - game folder icon is now the executable icon for the Tango theme (orange diamond), meant to represent a complete game rather than a game file or archive ananke changelog: - outputs GBC games to "Game Boy Color/" instead of "Game Boy/" - adds the file basename to "information/title" Known issues: - using ananke to load a GB game trips the Super Famicom SGB mode and fails (need to make the full-path auto-detection ignore non-bootable systems) - need to dump and test some BS-X media before releasing - ananke lacks BS-X Satellaview cartridge support - v092 isn't going to let you retarget the ananke/higan game folder path of ~/Emulation, you will have to wait for a future version if that bothers you so greatly [Later, after the v092 release, byuu posted this additional changelog: - kill laevateinn - add title() - add bootable, remove load - combine file, library - combine [][][] paths - fix SFC subtype handling XML->BML - update file browser to use buttons - update file browser keyboard handling - update system XML->BML - fix sufami turbo hashing - remove Cartridge::manifest ]
2012-12-25 05:31:55 +00:00
}
auto pWidget::minimumSize() -> Size {
return {0, 0};
}
auto pWidget::setEnabled(bool enabled) -> void {
if(!self().parentWindow(true)) enabled = false;
if(!self().enabled(true)) enabled = false;
if(abstract) enabled = false;
EnableWindow(hwnd, enabled);
}
auto pWidget::setFocused() -> void {
SetFocus(hwnd);
}
Update to v094r43 release. byuu says: Updated to compile with all of the new hiro changes. My next step is to write up hiro API documentation, and move the API from alpha (constantly changing) to beta (rarely changing), in preparation for the first stable release (backward-compatible changes only.) Added "--fullscreen" command-line option. I like this over a configuration file option. Lets you use the emulator in both modes without having to modify the config file each time. Also enhanced the command-line game loading. You can now use any of these methods: higan /path/to/game-folder.sfc higan /path/to/game-folder.sfc/ higan /path/to/game-folder.sfc/program.rom The idea is to support launchers that insist on loading files only. Technically, the file can be any name (manifest.bml also works); the only criteria is that the file actually exists and is a file, and not a directory. This is a requirement to support the first version (a directory lacking the trailing / identifier), because I don't want my nall::string class to query the file system to determine if the string is an actual existing file or directory for its pathname() / dirname() functions. Anyway, every game folder I've made so far has program.rom, and that's very unlikely to change, so this should be fine. Now, of course, if you drop a regular "game.sfc" file on the emulator, it won't even try to load it, unless it's in a folder that ends in .fc, .sfc, etc. In which case, it'll bail out immediately by being unable to produce a manifest for what is obviously not really a game folder.
2015-08-30 02:08:26 +00:00
auto pWidget::setFont(const Font&) -> void {
if(hfont) DeleteObject(hfont);
Update to v094r43 release. byuu says: Updated to compile with all of the new hiro changes. My next step is to write up hiro API documentation, and move the API from alpha (constantly changing) to beta (rarely changing), in preparation for the first stable release (backward-compatible changes only.) Added "--fullscreen" command-line option. I like this over a configuration file option. Lets you use the emulator in both modes without having to modify the config file each time. Also enhanced the command-line game loading. You can now use any of these methods: higan /path/to/game-folder.sfc higan /path/to/game-folder.sfc/ higan /path/to/game-folder.sfc/program.rom The idea is to support launchers that insist on loading files only. Technically, the file can be any name (manifest.bml also works); the only criteria is that the file actually exists and is a file, and not a directory. This is a requirement to support the first version (a directory lacking the trailing / identifier), because I don't want my nall::string class to query the file system to determine if the string is an actual existing file or directory for its pathname() / dirname() functions. Anyway, every game folder I've made so far has program.rom, and that's very unlikely to change, so this should be fine. Now, of course, if you drop a regular "game.sfc" file on the emulator, it won't even try to load it, unless it's in a folder that ends in .fc, .sfc, etc. In which case, it'll bail out immediately by being unable to produce a manifest for what is obviously not really a game folder.
2015-08-30 02:08:26 +00:00
hfont = pFont::create(self().font(true));
SendMessage(hwnd, WM_SETFONT, (WPARAM)hfont, 0);
}
auto pWidget::setGeometry(Geometry geometry) -> void {
if(auto parent = _parentWidget()) {
auto displacement = parent->self().geometry().position();
geometry.setX(geometry.x() - displacement.x());
geometry.setY(geometry.y() - displacement.y());
}
SetWindowPos(hwnd, nullptr, geometry.x(), geometry.y(), geometry.width(), geometry.height(), SWP_NOZORDER);
self().doSize();
}
auto pWidget::setVisible(bool visible) -> void {
if(!self().parentWindow(true)) visible = false;
if(!self().visible(true)) visible = false;
if(abstract) visible = false;
ShowWindow(hwnd, visible ? SW_SHOWNORMAL : SW_HIDE);
}
//
auto pWidget::_parentHandle() -> HWND {
if(auto parent = _parentWidget()) return parent->hwnd;
if(auto parent = _parentWindow()) return parent->hwnd;
return nullptr;
}
auto pWidget::_parentWidget() -> maybe<pWidget&> {
#if defined(Hiro_TabFrame)
if(auto parent = self().parentTabFrame(true)) {
if(auto self = parent->self()) return *self;
}
#endif
return nothing;
}
auto pWidget::_parentWindow() -> maybe<pWindow&> {
if(auto parent = self().parentWindow(true)) {
if(auto self = parent->self()) return *self;
}
return nothing;
}
auto pWidget::_setState() -> void {
setEnabled(self().enabled());
setFont(self().font());
setVisible(self().visible());
}
}
#endif