2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_TabFrame)
|
2013-11-28 10:29:01 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
namespace hiro {
|
|
|
|
|
|
|
|
static auto CALLBACK TabFrame_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
|
|
|
if(auto object = (mObject*)GetWindowLongPtr(hwnd, GWLP_USERDATA)) {
|
|
|
|
if(auto tabFrame = dynamic_cast<mTabFrame*>(object)) {
|
2015-06-15 22:16:43 +00:00
|
|
|
if(auto self = tabFrame->self()) {
|
|
|
|
return Shared_windowProc(self->windowProc, hwnd, msg, wparam, lparam);
|
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
}
|
|
|
|
}
|
2015-06-15 22:16:43 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::construct() -> void {
|
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
|
|
|
hwnd = CreateWindow(
|
|
|
|
WC_TABCONTROL, L"", WS_CHILD | WS_TABSTOP,
|
|
|
|
0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0
|
|
|
|
);
|
2015-06-12 13:14:38 +00:00
|
|
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
|
|
|
|
windowProc = (WindowProc)GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
|
|
|
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)TabFrame_windowProc);
|
|
|
|
pWidget::_setState();
|
|
|
|
for(auto& item : state().items) append(item);
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::destruct() -> void {
|
|
|
|
if(imageList) { ImageList_Destroy(imageList); imageList = nullptr; }
|
|
|
|
DestroyWindow(hwnd);
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::append(sTabFrameItem item) -> void {
|
|
|
|
wchar_t text[] = L"";
|
|
|
|
TCITEM tcItem;
|
|
|
|
tcItem.mask = TCIF_TEXT;
|
|
|
|
tcItem.pszText = text;
|
|
|
|
TabCtrl_InsertItem(hwnd, item->offset(), &tcItem);
|
|
|
|
if(auto self = item->self()) {
|
|
|
|
self->setClosable(item->state.closable);
|
2016-01-07 08:14:33 +00:00
|
|
|
self->setIcon(item->state.icon);
|
2015-06-12 13:14:38 +00:00
|
|
|
self->setMovable(item->state.movable);
|
|
|
|
self->setText(item->state.text);
|
|
|
|
if(item->selected()) self->setSelected();
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
_buildImageList();
|
|
|
|
_synchronizeLayout();
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::remove(sTabFrameItem item) -> void {
|
|
|
|
TabCtrl_DeleteItem(hwnd, item->offset());
|
|
|
|
_buildImageList();
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::setEnabled(bool enabled) -> void {
|
|
|
|
pWidget::setEnabled(enabled);
|
|
|
|
for(auto& item : state().items) {
|
|
|
|
if(auto layout = item->state.layout) {
|
|
|
|
if(auto self = layout->self()) self->setEnabled(layout->enabled(true));
|
|
|
|
}
|
|
|
|
}
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::setGeometry(Geometry geometry) -> void {
|
|
|
|
pWidget::setGeometry(geometry);
|
|
|
|
geometry.setX(geometry.x() + 1);
|
|
|
|
geometry.setY(geometry.y() + 21);
|
|
|
|
geometry.setWidth(geometry.width() - 4);
|
|
|
|
geometry.setHeight(geometry.height() - 23);
|
|
|
|
for(auto& item : state().items) {
|
|
|
|
if(auto layout = item->state.layout) {
|
|
|
|
layout->setGeometry(geometry);
|
|
|
|
}
|
|
|
|
}
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
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 pTabFrame::setNavigation(Navigation navigation) -> void {
|
|
|
|
//unsupported
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::setVisible(bool visible) -> void {
|
2013-11-28 10:29:01 +00:00
|
|
|
pWidget::setVisible(visible);
|
2015-06-12 13:14:38 +00:00
|
|
|
for(auto& item : state().items) {
|
|
|
|
if(auto layout = item->state.layout) {
|
|
|
|
if(auto self = layout->self()) self->setVisible(layout->visible(true));
|
|
|
|
}
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::_buildImageList() -> void {
|
|
|
|
unsigned size = pFont::size(hfont, " ").height();
|
2013-11-28 10:29:01 +00:00
|
|
|
|
|
|
|
if(imageList) { ImageList_Destroy(imageList); imageList = nullptr; }
|
|
|
|
imageList = ImageList_Create(size, size, ILC_COLOR32, 1, 0);
|
2015-06-12 13:14:38 +00:00
|
|
|
for(auto& item : state().items) {
|
2016-01-07 08:14:33 +00:00
|
|
|
ImageList_Append(imageList, item->state.icon, size);
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
TabCtrl_SetImageList(hwnd, imageList);
|
2015-06-12 13:14:38 +00:00
|
|
|
for(auto offset : range(state().items)) {
|
|
|
|
TCITEM tcItem;
|
|
|
|
tcItem.mask = TCIF_IMAGE;
|
2016-01-07 08:14:33 +00:00
|
|
|
tcItem.iImage = state().items[offset]->state.icon ? offset : -1;
|
2015-06-12 13:14:38 +00:00
|
|
|
TabCtrl_SetItem(hwnd, offset, &tcItem);
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::_synchronizeLayout() -> void {
|
|
|
|
for(auto& item : state().items) {
|
|
|
|
if(auto layout = item->state.layout) {
|
|
|
|
layout->setVisible(item->selected());
|
|
|
|
}
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::onChange() -> void {
|
|
|
|
unsigned selected = TabCtrl_GetCurSel(hwnd);
|
|
|
|
for(auto& item : state().items) item->state.selected = false;
|
|
|
|
if(auto item = self().item(selected)) item->state.selected = true;
|
|
|
|
_synchronizeLayout();
|
|
|
|
self().doChange();
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//called only if TCS_OWNERDRAWFIXED style is used
|
|
|
|
//this style disables XP/Vista theming of the TabFrame
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTabFrame::onDrawItem(LPARAM lparam) -> void {
|
|
|
|
/*
|
|
|
|
auto item = (LPDRAWITEMSTRUCT)lparam;
|
2013-11-28 10:29:01 +00:00
|
|
|
FillRect(item->hDC, &item->rcItem, GetSysColorBrush(COLOR_3DFACE));
|
|
|
|
SetBkMode(item->hDC, TRANSPARENT);
|
|
|
|
SetTextColor(item->hDC, GetSysColor(COLOR_BTNTEXT));
|
|
|
|
|
|
|
|
unsigned selection = item->itemID;
|
|
|
|
if(selection < tabFrame.state.text.size()) {
|
|
|
|
string text = tabFrame.state.text[selection];
|
|
|
|
Size size = pFont::size(hfont, text);
|
|
|
|
unsigned width = item->rcItem.right - item->rcItem.left + 1;
|
|
|
|
if(!tabFrame.state.image[selection].empty()) {
|
|
|
|
width += size.height + 2;
|
|
|
|
ImageList_Draw(imageList, selection, item->hDC, item->rcItem.left + (width - size.width) / 2 - (size.height + 3), item->rcItem.top + 2, ILD_NORMAL);
|
|
|
|
}
|
|
|
|
TextOut(item->hDC, item->rcItem.left + (width - size.width) / 2, item->rcItem.top + 2, utf16_t(text), text.size());
|
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
*/
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
|
|
|
|
#endif
|