2013-03-15 13:11:33 +00:00
|
|
|
namespace phoenix {
|
|
|
|
|
|
|
|
Size pLineEdit::minimumSize() {
|
|
|
|
Size size = pFont::size(hfont, lineEdit.state.text);
|
|
|
|
return {size.width + 12, size.height + 10};
|
2011-03-22 12:56:49 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 09:25:20 +00:00
|
|
|
void pLineEdit::setEditable(bool editable) {
|
|
|
|
SendMessage(hwnd, EM_SETREADONLY, editable == false, 0);
|
|
|
|
}
|
|
|
|
|
2013-07-29 09:42:45 +00:00
|
|
|
void pLineEdit::setText(string text) {
|
2011-02-24 09:25:20 +00:00
|
|
|
locked = true;
|
|
|
|
SetWindowText(hwnd, utf16_t(text));
|
|
|
|
locked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
string pLineEdit::text() {
|
|
|
|
unsigned length = GetWindowTextLength(hwnd);
|
|
|
|
wchar_t text[length + 1];
|
|
|
|
GetWindowText(hwnd, text, length + 1);
|
|
|
|
text[length] = 0;
|
2011-03-17 12:49:46 +00:00
|
|
|
return (const char*)utf8_t(text);
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pLineEdit::constructor() {
|
|
|
|
hwnd = CreateWindowEx(
|
|
|
|
WS_EX_CLIENTEDGE, L"EDIT", L"",
|
2011-09-05 03:48:23 +00:00
|
|
|
WS_CHILD | WS_TABSTOP | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
|
|
|
|
0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0
|
2011-02-24 09:25:20 +00:00
|
|
|
);
|
|
|
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&lineEdit);
|
|
|
|
setDefaultFont();
|
|
|
|
setEditable(lineEdit.state.editable);
|
|
|
|
setText(lineEdit.state.text);
|
2011-09-05 03:48:23 +00:00
|
|
|
synchronize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pLineEdit::destructor() {
|
|
|
|
lineEdit.state.text = text();
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pLineEdit::orphan() {
|
|
|
|
destructor();
|
|
|
|
constructor();
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
|
|
|
|
}
|