mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 07:02:27 +01:00
byuu says: Finally!! Compilation works once again on Windows. However, it's pretty buggy. Modality isn't really working right, you can still poke at other windows, but when you select ListView items, they redraw as empty boxes (need to process WM_DRAWITEM before checking modality.) The program crashes when you close it (probably a ruby driver's term() function, that's what it usually is.) The Layout::setEnabled(false) call isn't working right, so you get that annoying chiming sound and cursor movement when mapping keyboard keys to game inputs. The column sizing seems off a bit on first display for the Hotkeys tab. And probably lots more.
74 lines
2.1 KiB
C++
74 lines
2.1 KiB
C++
#if defined(Hiro_TextEdit)
|
|
|
|
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
|
|
);
|
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
|
|
pWidget::_setState();
|
|
setBackgroundColor(state().backgroundColor);
|
|
setCursorPosition(state().cursorPosition);
|
|
setEditable(state().editable);
|
|
setText(state().text);
|
|
}
|
|
|
|
auto pTextEdit::destruct() -> void {
|
|
state().text = text();
|
|
if(backgroundBrush) { DeleteObject(backgroundBrush); backgroundBrush = 0; }
|
|
DestroyWindow(hwnd);
|
|
}
|
|
|
|
auto pTextEdit::setBackgroundColor(Color color) -> void {
|
|
if(backgroundBrush) { DeleteObject(backgroundBrush); backgroundBrush = 0; }
|
|
backgroundBrush = CreateSolidBrush(color ? CreateRGB(color) : GetSysColor(COLOR_WINDOW));
|
|
}
|
|
|
|
auto pTextEdit::setCursorPosition(unsigned position) -> void {
|
|
if(position == ~0) position >>= 1; //Edit_SetSel takes signed type
|
|
Edit_SetSel(hwnd, position, position);
|
|
Edit_ScrollCaret(hwnd);
|
|
}
|
|
|
|
auto pTextEdit::setEditable(bool editable) -> void {
|
|
SendMessage(hwnd, EM_SETREADONLY, editable == false, (LPARAM)0);
|
|
}
|
|
|
|
auto pTextEdit::setForegroundColor(Color color) -> void {
|
|
}
|
|
|
|
auto pTextEdit::setText(string text) -> void {
|
|
lock();
|
|
text.replace("\r", "");
|
|
text.replace("\n", "\r\n");
|
|
SetWindowText(hwnd, utf16_t(text));
|
|
unlock();
|
|
}
|
|
|
|
auto pTextEdit::setWordWrap(bool wordWrap) -> void {
|
|
//ES_AUTOHSCROLL cannot be changed after widget creation.
|
|
//As a result, we must destroy and re-create widget to change this setting.
|
|
reconstruct();
|
|
}
|
|
|
|
auto pTextEdit::text() const -> string {
|
|
unsigned length = GetWindowTextLength(hwnd);
|
|
wchar_t buffer[length + 1];
|
|
GetWindowText(hwnd, buffer, length + 1);
|
|
buffer[length] = 0;
|
|
string text = (const char*)utf8_t(buffer);
|
|
text.replace("\r", "");
|
|
return text;
|
|
}
|
|
|
|
auto pTextEdit::onChange() -> void {
|
|
if(!locked()) self().doChange();
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|