2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_TextEdit)
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
namespace hiro {
|
|
|
|
|
|
|
|
auto pTextEdit::construct() -> void {
|
|
|
|
hwnd = CreateWindowEx(
|
|
|
|
WS_EX_CLIENTEDGE, L"EDIT", L"",
|
|
|
|
WS_CHILD | WS_TABSTOP | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE | ES_WANTRETURN | (!state().wordWrap ? WS_HSCROLL | ES_AUTOHSCROLL : 0),
|
|
|
|
0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0
|
|
|
|
);
|
Update to v106r57 release.
byuu says:
I've added tool tips to hiro for Windows, GTK, and Qt. I'm unsure how to
add them for Cocoa. I wasted am embarrassing ~14 hours implementing tool
tips from scratch on Windows, because the `TOOLTIPS_CLASS` widget just
absolutely refused to show up, no matter what I tried. As such, they're
not quite 100% native, but I would really appreciate any patch
submissions to help improve my implementation.
I added tool tips to all of the confusing settings in bsnes. And of
course, for those of you who don't like them, there's a configuration
file setting to turn them off globally.
I also improved Mega Drive handling of the Game Genie a bit, and
restructured the way the Settings class works in bsnes.
Starting now, I'm feature-freezing bsnes and higan. From this point
forward:
- polishing up and fixing bugs caused by the ruby/hiro changes
- adding DRC to XAudio2, and maybe exclusive mode to WGL
- correcting FEoEZ (English) to load and work again out of the box
Once that's done, a final beta of bsnes will go out, I'll fix any
reported bugs that I'm able to, and then v107 should be ready. This time
with higan being functional, but marked as v107 beta. v108 will restore
higan to production status again, alongside bsnes.
2018-08-08 08:46:58 +00:00
|
|
|
pWidget::construct();
|
2015-06-12 13:14:38 +00:00
|
|
|
setBackgroundColor(state().backgroundColor);
|
|
|
|
setEditable(state().editable);
|
|
|
|
setText(state().text);
|
2019-07-07 09:44:09 +00:00
|
|
|
setTextCursor(state().textCursor);
|
2015-06-12 13:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto pTextEdit::destruct() -> void {
|
|
|
|
state().text = text();
|
|
|
|
if(backgroundBrush) { DeleteObject(backgroundBrush); backgroundBrush = 0; }
|
|
|
|
DestroyWindow(hwnd);
|
Update to v094r08 release.
byuu says:
Lots of changes this time around. FreeBSD stability and compilation is
still a work in progress.
FreeBSD 10 + Clang 3.3 = 108fps
FreeBSD 10 + GCC 4.7 = 130fps
Errata 1: I've been fighting that god-damned endian.h header for the
past nine WIPs now. The above WIP isn't building now because FreeBSD
isn't including headers before using certain types, and you end up with
a trillion error messages. So just delete all the endian.h includes from
nall/intrinsics.hpp to build.
Errata 2: I was trying to match g++ and g++47, so I used $(findstring
g++,$(compiler)), which ends up also matching clang++. Oops. Easy fix,
put Clang first and then else if g++ next. Not ideal, but oh well. All
it's doing for now is declaring -fwrapv twice, so you don't have to fix
it just yet. Probably just going to alias g++="g++47" and do exact
matching instead.
Errata 3: both OpenGL::term and VideoGLX::term are causing a core dump
on BSD. No idea why. The resources are initialized and valid, but
releasing them crashes the application.
Changelog:
- nall/Makefile is more flexible with overriding $(compiler), so you can
build with GCC or Clang on BSD (defaults to GCC now)
- PLATFORM_X was renamed to PLATFORM_XORG, and it's also declared with
PLATFORM_LINUX or PLATFORM_BSD
- PLATFORM_XORG probably isn't the best name ... still thinking about
what best to call LINUX|BSD|SOLARIS or ^(WINDOWS|MACOSX)
- fixed a few legitimate Clang warning messages in nall
- Compiler::VisualCPP is ugly as hell, renamed to Compiler::CL
- nall/platform includes nall/intrinsics first. Trying to move away from
testing for _WIN32, etc directly in all files. Work in progress.
- nall turns off Clang warnings that I won't "fix", because they aren't
broken. It's much less noisy to compile with warnings on now.
- phoenix gains the ability to set background and foreground colors on
various text container widgets (GTK only for now.)
- rewrote a lot of the MSU1 code to try and simplify it. Really hope
I didn't break anything ... I don't have any MSU1 test ROMs handy
- SNES coprocessor audio is now mixed as sclamp<16>(system_sample
+ coprocessor_sample) instead of sclamp<16>((sys + cop) / 2)
- allows for greater chance of aliasing (still low, SNES audio is
quiet), but doesn't cut base system volume in half anymore
- fixed Super Scope and Justifier cursor colors
- use input.xlib instead of input.x ... allows Xlib input driver to be
visible on Linux and BSD once again
- make install and make uninstall must be run as root again; no longer
using install but cp instead for BSD compatibility
- killed $(DESTDIR) ... use make prefix=$DESTDIR$prefix instead
- you can now set text/background colors for the loki console via (eg):
- settings.terminal.background-color 0x000000
- settings.terminal.foreground-color 0xffffff
2014-02-24 09:39:09 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTextEdit::setBackgroundColor(Color color) -> void {
|
|
|
|
if(backgroundBrush) { DeleteObject(backgroundBrush); backgroundBrush = 0; }
|
|
|
|
backgroundBrush = CreateSolidBrush(color ? CreateRGB(color) : GetSysColor(COLOR_WINDOW));
|
2018-08-05 09:00:15 +00:00
|
|
|
InvalidateRect(hwnd, 0, true);
|
2015-06-12 13:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
auto pTextEdit::setEditable(bool editable) -> void {
|
2011-02-24 09:25:20 +00:00
|
|
|
SendMessage(hwnd, EM_SETREADONLY, editable == false, (LPARAM)0);
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTextEdit::setForegroundColor(Color color) -> void {
|
2018-08-05 09:00:15 +00:00
|
|
|
InvalidateRect(hwnd, 0, true);
|
Update to v094r08 release.
byuu says:
Lots of changes this time around. FreeBSD stability and compilation is
still a work in progress.
FreeBSD 10 + Clang 3.3 = 108fps
FreeBSD 10 + GCC 4.7 = 130fps
Errata 1: I've been fighting that god-damned endian.h header for the
past nine WIPs now. The above WIP isn't building now because FreeBSD
isn't including headers before using certain types, and you end up with
a trillion error messages. So just delete all the endian.h includes from
nall/intrinsics.hpp to build.
Errata 2: I was trying to match g++ and g++47, so I used $(findstring
g++,$(compiler)), which ends up also matching clang++. Oops. Easy fix,
put Clang first and then else if g++ next. Not ideal, but oh well. All
it's doing for now is declaring -fwrapv twice, so you don't have to fix
it just yet. Probably just going to alias g++="g++47" and do exact
matching instead.
Errata 3: both OpenGL::term and VideoGLX::term are causing a core dump
on BSD. No idea why. The resources are initialized and valid, but
releasing them crashes the application.
Changelog:
- nall/Makefile is more flexible with overriding $(compiler), so you can
build with GCC or Clang on BSD (defaults to GCC now)
- PLATFORM_X was renamed to PLATFORM_XORG, and it's also declared with
PLATFORM_LINUX or PLATFORM_BSD
- PLATFORM_XORG probably isn't the best name ... still thinking about
what best to call LINUX|BSD|SOLARIS or ^(WINDOWS|MACOSX)
- fixed a few legitimate Clang warning messages in nall
- Compiler::VisualCPP is ugly as hell, renamed to Compiler::CL
- nall/platform includes nall/intrinsics first. Trying to move away from
testing for _WIN32, etc directly in all files. Work in progress.
- nall turns off Clang warnings that I won't "fix", because they aren't
broken. It's much less noisy to compile with warnings on now.
- phoenix gains the ability to set background and foreground colors on
various text container widgets (GTK only for now.)
- rewrote a lot of the MSU1 code to try and simplify it. Really hope
I didn't break anything ... I don't have any MSU1 test ROMs handy
- SNES coprocessor audio is now mixed as sclamp<16>(system_sample
+ coprocessor_sample) instead of sclamp<16>((sys + cop) / 2)
- allows for greater chance of aliasing (still low, SNES audio is
quiet), but doesn't cut base system volume in half anymore
- fixed Super Scope and Justifier cursor colors
- use input.xlib instead of input.x ... allows Xlib input driver to be
visible on Linux and BSD once again
- make install and make uninstall must be run as root again; no longer
using install but cp instead for BSD compatibility
- killed $(DESTDIR) ... use make prefix=$DESTDIR$prefix instead
- you can now set text/background colors for the loki console via (eg):
- settings.terminal.background-color 0x000000
- settings.terminal.foreground-color 0xffffff
2014-02-24 09:39:09 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTextEdit::setText(string text) -> void {
|
2018-08-05 09:00:15 +00:00
|
|
|
auto lock = acquire();
|
2015-06-12 13:14:38 +00:00
|
|
|
text.replace("\r", "");
|
|
|
|
text.replace("\n", "\r\n");
|
|
|
|
SetWindowText(hwnd, utf16_t(text));
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
2019-07-07 09:44:09 +00:00
|
|
|
auto pTextEdit::setTextCursor(TextCursor cursor) -> void {
|
|
|
|
signed end = GetWindowTextLength(hwnd);
|
|
|
|
signed offset = max(0, min(end, cursor.offset()));
|
|
|
|
signed length = max(0, min(end, cursor.offset() + cursor.length()));
|
|
|
|
Edit_SetSel(hwnd, offset, length);
|
|
|
|
Edit_ScrollCaret(hwnd);
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTextEdit::setWordWrap(bool wordWrap) -> void {
|
2011-02-24 09:25:20 +00:00
|
|
|
//ES_AUTOHSCROLL cannot be changed after widget creation.
|
|
|
|
//As a result, we must destroy and re-create widget to change this setting.
|
2015-06-12 13:14:38 +00:00
|
|
|
reconstruct();
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTextEdit::text() const -> string {
|
2011-02-24 09:25:20 +00:00
|
|
|
unsigned length = GetWindowTextLength(hwnd);
|
|
|
|
wchar_t buffer[length + 1];
|
|
|
|
GetWindowText(hwnd, buffer, length + 1);
|
|
|
|
buffer[length] = 0;
|
2011-03-17 12:49:46 +00:00
|
|
|
string text = (const char*)utf8_t(buffer);
|
2011-02-24 09:25:20 +00:00
|
|
|
text.replace("\r", "");
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2019-07-07 09:44:09 +00:00
|
|
|
auto pTextEdit::textCursor() const -> TextCursor {
|
|
|
|
return state().textCursor;
|
|
|
|
}
|
|
|
|
|
Update to 20180809 release.
byuu says:
The Windows port can now run the emulation while navigating menus,
moving windows, and resizing windows. The main window also doesn't try
so hard to constantly clear itself. This may leave a bit of unwelcome
residue behind in some video drivers during resize, but under most
drivers, it lets you resize without a huge amount of flickering.
On all platforms, I now also run the emulation during MessageWindow
modal events, where I didn't before.
I'm thinking we should probably mute the audio during modal periods,
since it can generate a good deal of distortion.
The tooltip timeout was increased to ten seconds.
On Windows, the enter key can now activate buttons, so you can more
quickly dismiss MessageDialog windows. This part may not actually work
... I'm in the middle of trying to get messages out of the global
`Application_windowProc` hook and into the individual `Widget_windowProc`
hooks, so I need to do some testing.
I fixed a bug where changing the input driver wouldn't immediately
reload the input/hotkey settings lists properly.
I also went from disabling the driver "Change" button when the currently
active driver is selected in the list, to instead setting it to say
"Reload", and I also added a tool tip to the input driver reload button,
advising that if you're using DirectInput or SDL, you can hit "Reload"
to rescan for hotplugged gamepads without needing to restart the
emulator. XInput and udev have auto hotswap support. If we can ever get
that into DirectInput and SDL, then I'll remove the tooltip. But
regardless, the reload functionality is nice to have for all drivers.
I'm not sure what should happen when a user changes their driver
selection while a game is loaded, gets the warning dialog, chooses not
to change it, and then closes the emulator. Currently, it will make the
change happen the next time you start the emulator. This feels a bit
unexpected, but when you change the selection without a game loaded, it
takes immediate effect. So I'm not really sure what's best here.
2018-08-10 05:02:59 +00:00
|
|
|
//
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pTextEdit::onChange() -> void {
|
|
|
|
if(!locked()) self().doChange();
|
2011-09-05 03:48:23 +00:00
|
|
|
}
|
|
|
|
|
Update to 20180809 release.
byuu says:
The Windows port can now run the emulation while navigating menus,
moving windows, and resizing windows. The main window also doesn't try
so hard to constantly clear itself. This may leave a bit of unwelcome
residue behind in some video drivers during resize, but under most
drivers, it lets you resize without a huge amount of flickering.
On all platforms, I now also run the emulation during MessageWindow
modal events, where I didn't before.
I'm thinking we should probably mute the audio during modal periods,
since it can generate a good deal of distortion.
The tooltip timeout was increased to ten seconds.
On Windows, the enter key can now activate buttons, so you can more
quickly dismiss MessageDialog windows. This part may not actually work
... I'm in the middle of trying to get messages out of the global
`Application_windowProc` hook and into the individual `Widget_windowProc`
hooks, so I need to do some testing.
I fixed a bug where changing the input driver wouldn't immediately
reload the input/hotkey settings lists properly.
I also went from disabling the driver "Change" button when the currently
active driver is selected in the list, to instead setting it to say
"Reload", and I also added a tool tip to the input driver reload button,
advising that if you're using DirectInput or SDL, you can hit "Reload"
to rescan for hotplugged gamepads without needing to restart the
emulator. XInput and udev have auto hotswap support. If we can ever get
that into DirectInput and SDL, then I'll remove the tooltip. But
regardless, the reload functionality is nice to have for all drivers.
I'm not sure what should happen when a user changes their driver
selection while a game is loaded, gets the warning dialog, chooses not
to change it, and then closes the emulator. Currently, it will make the
change happen the next time you start the emulator. This feels a bit
unexpected, but when you change the selection without a game loaded, it
takes immediate effect. So I'm not really sure what's best here.
2018-08-10 05:02:59 +00:00
|
|
|
auto pTextEdit::windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> maybe<LRESULT> {
|
|
|
|
if(msg == WM_KEYDOWN) {
|
|
|
|
if(wparam == 'A' && GetKeyState(VK_CONTROL) < 0) {
|
|
|
|
//Ctrl+A = select all text
|
|
|
|
//note: this is not a standard accelerator on Windows
|
|
|
|
Edit_SetSel(hwnd, 0, ~0);
|
|
|
|
return true;
|
|
|
|
} else if(wparam == 'V' && GetKeyState(VK_CONTROL) < 0) {
|
|
|
|
//Ctrl+V = paste text
|
|
|
|
//note: this formats Unix (LF) and OS9 (CR) line-endings to Windows (CR+LF) line-endings
|
|
|
|
//this is necessary as the EDIT control only supports Windows line-endings
|
|
|
|
OpenClipboard(hwnd);
|
|
|
|
if(auto handle = GetClipboardData(CF_UNICODETEXT)) {
|
|
|
|
if(auto text = (wchar_t*)GlobalLock(handle)) {
|
|
|
|
string data = (const char*)utf8_t(text);
|
|
|
|
data.replace("\r\n", "\n");
|
|
|
|
data.replace("\r", "\n");
|
|
|
|
data.replace("\n", "\r\n");
|
|
|
|
GlobalUnlock(handle);
|
|
|
|
utf16_t output(data);
|
|
|
|
if(auto resource = GlobalAlloc(GMEM_MOVEABLE, (wcslen(output) + 1) * sizeof(wchar_t))) {
|
|
|
|
if(auto write = (wchar_t*)GlobalLock(resource)) {
|
|
|
|
wcscpy(write, output);
|
|
|
|
GlobalUnlock(write);
|
|
|
|
if(SetClipboardData(CF_UNICODETEXT, resource) == nullptr) {
|
|
|
|
GlobalFree(resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CloseClipboard();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pWidget::windowProc(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
2011-09-05 03:48:23 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
#endif
|