LunaHook-mirror/LunaHost/GUI/controls.cpp

493 lines
14 KiB
C++
Raw Normal View History

2024-07-21 19:28:47 +08:00
#include "controls.h"
#include "window.h"
#include <commdlg.h>
control::control(mainwindow *_parent)
{
if (_parent == 0)
return;
parent = _parent;
2024-02-07 20:59:24 +08:00
parent->controls.push_back(this);
}
2024-07-21 19:28:47 +08:00
void control::dispatch(WPARAM) {}
void control::dispatch_2(WPARAM wParam, LPARAM lParam) {};
button::button(mainwindow *parent) : control(parent) {}
button::button(mainwindow *parent, const std::wstring &text) : control(parent)
2024-03-28 11:01:44 +08:00
{
2024-07-21 19:28:47 +08:00
winId = CreateWindowEx(0, L"BUTTON", text.c_str(), WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, parent->winId, NULL, NULL, NULL);
2024-02-07 20:59:24 +08:00
}
2024-07-21 19:28:47 +08:00
void button::dispatch(WPARAM wparam)
{
if (wparam == BN_CLICKED)
{
2024-02-07 20:59:24 +08:00
onclick();
}
}
2024-07-21 19:28:47 +08:00
bool checkbox::ischecked()
{
2024-02-07 20:59:24 +08:00
int state = SendMessage(winId, BM_GETCHECK, 0, 0);
return (state == BST_CHECKED);
}
2024-07-21 19:28:47 +08:00
checkbox::checkbox(mainwindow *parent, const std::wstring &text) : button(parent)
2024-03-28 11:01:44 +08:00
{
2024-07-21 19:28:47 +08:00
winId = CreateWindowEx(0, L"BUTTON", text.c_str(), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_RIGHTBUTTON,
0, 0, 0, 0, parent->winId, NULL, NULL, NULL);
2024-02-09 09:25:26 +08:00
}
2024-07-21 19:28:47 +08:00
void checkbox::setcheck(bool b)
{
SendMessage(winId, BM_SETCHECK, (WPARAM)BST_CHECKED * b, 0);
2024-02-07 20:59:24 +08:00
}
2024-07-21 19:28:47 +08:00
int spinbox::getcurr()
{
2024-03-28 19:24:07 +08:00
return SendMessage(hUpDown, UDM_GETPOS32, 0, 0);
}
2024-07-21 19:28:47 +08:00
spinbox::spinbox(mainwindow *parent, int value) : control(parent)
{
winId = CreateWindowEx(0, L"EDIT", std::to_wstring(value).c_str(), WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER,
0, 0, 0, 0, parent->winId, NULL, NULL, NULL);
hUpDown = CreateWindowEx(0, UPDOWN_CLASS, NULL,
2024-07-21 19:28:47 +08:00
WS_CHILD | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,
0, 0, 0, 0,
parent->winId, NULL, NULL, NULL);
SendMessage(hUpDown, UDM_SETBUDDY, (WPARAM)winId, 0);
2024-07-21 19:28:47 +08:00
setminmax(0, 0x7fffffff);
std::tie(minv, maxv) = getminmax();
}
2024-07-21 19:28:47 +08:00
void spinbox::setgeo(int x, int y, int w, int h)
2024-03-28 11:01:44 +08:00
{
2024-07-21 19:28:47 +08:00
MoveWindow(winId, x, y, w, h, TRUE);
2024-03-28 11:01:44 +08:00
SendMessage(hUpDown, UDM_SETBUDDY, (WPARAM)winId, 0);
}
2024-07-21 19:28:47 +08:00
void spinbox::setcurr(int cur)
{
SendMessage(hUpDown, UDM_SETPOS32, 0, cur);
}
2024-07-21 19:28:47 +08:00
void spinbox::dispatch(WPARAM wparam)
{
if (HIWORD(wparam) == EN_CHANGE)
{
bool ok = false;
int value;
try
{
value = std::stoi(text());
ok = true;
}
catch (std::exception &)
{
}
2024-07-21 19:28:47 +08:00
if (ok)
{
if (value > maxv)
{
setcurr(maxv);
2024-07-21 19:28:47 +08:00
value = maxv;
}
2024-07-21 19:28:47 +08:00
else if (value < minv)
{
setcurr(minv);
2024-07-21 19:28:47 +08:00
value = minv;
}
2024-07-21 19:28:47 +08:00
else
{
onvaluechange(value);
}
}
}
}
2024-07-21 19:28:47 +08:00
std::pair<int, int> spinbox::getminmax()
{
int minValue, maxValue;
SendMessage(hUpDown, UDM_GETRANGE32, (WPARAM)&minValue, (LPARAM)&maxValue);
2024-07-21 19:28:47 +08:00
return {minValue, maxValue};
}
2024-07-21 19:28:47 +08:00
void spinbox::setminmax(int min, int max)
{
SendMessage(hUpDown, UDM_SETRANGE32, min, max);
std::tie(minv, maxv) = getminmax();
}
2024-07-21 19:28:47 +08:00
multilineedit::multilineedit(mainwindow *parent) : texteditbase(parent)
{
winId = CreateWindowEx(0, L"EDIT", L"", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL,
0, 0, 0, 0, parent->winId, NULL, NULL, NULL);
2024-02-20 23:24:33 +08:00
SendMessage(winId, EM_SETLIMITTEXT, 0, 0);
}
2024-07-21 19:28:47 +08:00
std::wstring multilineedit::getsel()
{
DWORD start, end;
SendMessage(winId, EM_GETSEL, reinterpret_cast<WPARAM>(&start), reinterpret_cast<LPARAM>(&end));
int length = end - start;
2024-07-21 19:28:47 +08:00
return text().substr(start, length);
}
2024-07-21 19:28:47 +08:00
lineedit::lineedit(mainwindow *parent) : texteditbase(parent)
{
winId = CreateWindowEx(0, L"EDIT", L"", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL,
0, 0, 0, 0, parent->winId, NULL, NULL, NULL);
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
texteditbase::texteditbase(mainwindow *parent) : control(parent) {}
void texteditbase::setreadonly(bool ro)
{
2024-02-20 23:24:33 +08:00
SendMessage(winId, EM_SETREADONLY, ro, 0);
2024-02-07 20:59:24 +08:00
}
2024-07-21 19:28:47 +08:00
void texteditbase::scrolltoend()
{
2024-02-07 20:59:24 +08:00
int textLength = GetWindowTextLength(winId);
SendMessage(winId, EM_SETSEL, (WPARAM)textLength, (LPARAM)textLength);
SendMessage(winId, EM_SCROLLCARET, 0, 0);
}
2024-07-21 19:28:47 +08:00
void texteditbase::appendtext(const std::wstring &text)
{
auto _ = std::wstring(L"\r\n") + text;
SendMessage(winId, EM_REPLACESEL, 0, (LPARAM)_.c_str());
2024-02-07 20:59:24 +08:00
}
2024-07-21 19:28:47 +08:00
void texteditbase::dispatch(WPARAM wparam)
{
if (HIWORD(wparam) == EN_CHANGE)
{
2024-02-07 20:59:24 +08:00
ontextchange(text());
}
}
2024-07-21 19:28:47 +08:00
label::label(mainwindow *parent, const std::wstring &text) : control(parent)
{
winId = CreateWindowEx(0, L"STATIC", text.c_str(), WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, parent->winId, NULL, NULL, NULL);
2024-02-07 20:59:24 +08:00
}
2024-07-21 19:28:47 +08:00
listbox::listbox(mainwindow *parent) : control(parent)
{
winId = CreateWindowEx(WS_EX_CLIENTEDGE, L"LISTBOX", L"", WS_CHILD | WS_VISIBLE | WS_VSCROLL | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,
0, 0, 0, 0, parent->winId, NULL, NULL, NULL);
}
void listbox::dispatch(WPARAM wparam)
{
if (HIWORD(wparam) == LBN_SELCHANGE)
{
auto idx = currentidx();
if (idx != -1)
oncurrentchange(idx);
2024-02-07 20:59:24 +08:00
}
}
2024-07-21 19:28:47 +08:00
void listbox::setcurrent(int idx)
{
2024-03-27 16:36:14 +08:00
SendMessage(winId, LB_SETCURSEL, idx, 0);
2024-07-21 19:28:47 +08:00
if (idx != -1)
2024-03-27 16:36:14 +08:00
oncurrentchange(idx);
}
2024-07-21 19:28:47 +08:00
int listbox::currentidx()
{
2024-02-07 20:59:24 +08:00
return SendMessage(winId, LB_GETCURSEL, 0, 0);
}
2024-07-21 19:28:47 +08:00
std::wstring listbox::text(int idx)
{
int textLength = SendMessage(winId, LB_GETTEXTLEN, idx, 0);
2024-02-07 20:59:24 +08:00
std::vector<wchar_t> buffer(textLength + 1);
SendMessage(winId, LB_GETTEXT, idx, (LPARAM)buffer.data());
return buffer.data();
}
2024-07-21 19:28:47 +08:00
void listbox::clear()
{
2024-02-07 20:59:24 +08:00
SendMessage(winId, LB_RESETCONTENT, 0, 0);
}
2024-07-21 19:28:47 +08:00
int listbox::additem(const std::wstring &text)
{
2024-02-12 00:17:58 +08:00
return SendMessage(winId, LB_ADDSTRING, 0, (LPARAM)text.c_str());
2024-02-07 20:59:24 +08:00
}
2024-07-21 19:28:47 +08:00
void listbox::deleteitem(int i)
{
2024-02-07 20:59:24 +08:00
SendMessage(winId, LB_DELETESTRING, (WPARAM)i, (LPARAM)i);
}
2024-07-21 19:28:47 +08:00
void listbox::setdata(int idx, LONG_PTR data)
{
SendMessage(winId, LB_SETITEMDATA, idx, (LPARAM)data);
2024-02-07 20:59:24 +08:00
}
2024-07-21 19:28:47 +08:00
LONG_PTR listbox::getdata(int idx)
{
2024-02-07 20:59:24 +08:00
return SendMessage(winId, LB_GETITEMDATA, idx, 0);
}
2024-07-21 19:28:47 +08:00
int listbox::count()
{
return SendMessage(winId, LB_GETCOUNT, 0, 0);
}
2024-07-21 19:28:47 +08:00
int listbox::insertitem(int i, const std::wstring &t)
{
2024-02-12 00:17:58 +08:00
return SendMessage(winId, LB_INSERTSTRING, i, (LPARAM)t.c_str());
2024-02-11 23:49:11 +08:00
}
2024-07-21 19:28:47 +08:00
void listview::deleteitem(int i)
{
2024-04-18 16:19:52 +08:00
std::lock_guard _(lockdataidx);
assodata.erase(assodata.begin() + i);
2024-07-21 19:28:47 +08:00
for (auto &data : remapidx)
{
if (data.second >= i)
data.second -= 1;
2024-04-18 16:19:52 +08:00
}
2024-07-21 19:28:47 +08:00
ListView_DeleteItem(winId, i);
2024-04-18 16:19:52 +08:00
}
2024-07-21 19:28:47 +08:00
listview::listview(mainwindow *parent, bool _addicon, bool notheader) : control(parent), addicon(_addicon)
{
auto style = WS_VISIBLE | WS_VSCROLL | WS_CHILD | LVS_REPORT | LVS_SINGLESEL;
if (notheader)
style |= LVS_NOCOLUMNHEADER;
winId = CreateWindowEx(0, WC_LISTVIEW, NULL, style, 0, 0, 0, 0, parent->winId, NULL, NULL, NULL);
2024-02-11 23:49:11 +08:00
ListView_SetExtendedListViewStyle(winId, LVS_EX_FULLROWSELECT); // Set extended styles
2024-07-21 19:28:47 +08:00
if (addicon)
{
hImageList = ImageList_Create(22, 22, // GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
ILC_COLOR32, 1, 1);
2024-04-18 16:19:52 +08:00
ListView_SetImageList(winId, hImageList, LVSIL_SMALL);
}
2024-02-11 23:49:11 +08:00
}
2024-07-21 19:28:47 +08:00
int listview::insertcol(int i, const std::wstring &text)
{
2024-02-11 23:49:11 +08:00
LVCOLUMN lvc;
lvc.mask = LVCF_TEXT;
lvc.pszText = const_cast<LPWSTR>(text.c_str());
2024-07-21 19:28:47 +08:00
// lvc.cx = 100;
2024-02-11 23:49:11 +08:00
return ListView_InsertColumn(winId, i, &lvc);
}
2024-07-21 19:28:47 +08:00
void listview::settext(int row, int col, const std::wstring &text)
{
ListView_SetItemText(winId, row, col, const_cast<LPWSTR>(text.c_str()));
2024-04-18 16:19:52 +08:00
}
2024-07-21 19:28:47 +08:00
int listview::insertitem(int row, const std::wstring &text, HICON hicon)
{
2024-02-11 23:49:11 +08:00
LVITEM lvi;
lvi.pszText = const_cast<LPWSTR>(text.c_str());
lvi.iItem = row;
lvi.iSubItem = 0;
2024-07-21 19:28:47 +08:00
lvi.mask = LVIF_TEXT;
if (addicon && hicon && hImageList)
{
2024-04-18 16:19:52 +08:00
lvi.mask |= LVIF_IMAGE;
lvi.iImage = ImageList_AddIcon(hImageList, hicon);
}
std::lock_guard _(lockdataidx);
2024-07-21 19:28:47 +08:00
assodata.resize(assodata.size() + 1);
2024-04-18 16:19:52 +08:00
std::rotate(assodata.begin() + row, assodata.begin() + row + 1, assodata.end());
2024-07-21 19:28:47 +08:00
for (auto &data : remapidx)
{
if (data.second >= row)
data.second += 1;
2024-04-18 16:19:52 +08:00
}
2024-02-11 23:49:11 +08:00
return ListView_InsertItem(winId, &lvi);
}
2024-07-21 19:28:47 +08:00
int listview::additem(const std::wstring &text, HICON hicon)
{
return insertitem(count(), text, hicon);
2024-02-11 23:49:11 +08:00
}
2024-07-21 19:28:47 +08:00
LONG_PTR listview::getdata(int idx)
{
2024-04-18 16:19:52 +08:00
std::lock_guard _(lockdataidx);
return assodata[idx];
}
2024-07-21 19:28:47 +08:00
int listview::querydataidx(LONG_PTR data)
{
2024-04-18 16:19:52 +08:00
std::lock_guard _(lockdataidx);
2024-07-21 19:28:47 +08:00
if (remapidx.find(data) == remapidx.end())
return -1;
2024-04-18 16:19:52 +08:00
return remapidx[data];
}
2024-07-21 19:28:47 +08:00
void listview::setdata(int idx, LONG_PTR data)
{
2024-04-18 16:19:52 +08:00
std::lock_guard _(lockdataidx);
2024-07-21 19:28:47 +08:00
assodata[idx] = data;
remapidx[data] = idx;
2024-04-18 16:19:52 +08:00
}
2024-07-21 19:28:47 +08:00
void listview::clear()
{
2024-02-11 23:49:11 +08:00
ListView_DeleteAllItems(winId);
2024-07-21 19:28:47 +08:00
if (addicon && hImageList)
2024-04-18 16:19:52 +08:00
ImageList_RemoveAll(hImageList);
2024-02-11 23:49:11 +08:00
}
2024-07-21 19:28:47 +08:00
int listview::count()
{
2024-02-11 23:49:11 +08:00
return ListView_GetItemCount(winId);
}
2024-07-21 19:28:47 +08:00
int listview::currentidx()
{
2024-04-18 16:19:52 +08:00
return ListView_GetNextItem(winId, -1, LVNI_SELECTED);
}
2024-07-21 19:28:47 +08:00
void listview::setcurrent(int idx)
{
ListView_SetItemState(winId, idx, LVIS_SELECTED, LVIS_SELECTED);
2024-04-18 16:19:52 +08:00
}
2024-07-21 19:28:47 +08:00
void listview::dispatch_2(WPARAM wParam, LPARAM lParam)
{
NMHDR *pnmhdr = (NMHDR *)lParam;
switch (pnmhdr->code)
{
case LVN_ITEMCHANGED:
{
NMLISTVIEW *pnmListView = (NMLISTVIEW *)lParam;
if ((pnmListView->uChanged & LVIF_STATE) && (pnmListView->uNewState & LVIS_SELECTED))
{
oncurrentchange(pnmListView->iItem);
}
break;
}
2024-02-11 23:49:11 +08:00
}
}
2024-07-21 19:28:47 +08:00
std::wstring listview::text(int row, int col)
{
std::wstring text;
text.resize(65535);
2024-02-11 23:49:11 +08:00
LV_ITEM _macro_lvi;
_macro_lvi.iSubItem = (col);
_macro_lvi.cchTextMax = (65535);
_macro_lvi.pszText = (text.data());
SNDMSG((winId), LVM_GETITEMTEXT, (WPARAM)(row), (LPARAM)(LV_ITEM *)&_macro_lvi);
return text.c_str();
}
2024-07-21 19:28:47 +08:00
void listview::setheader(const std::vector<std::wstring> &headers)
{
for (int i = 0; i < headers.size(); i++)
{
insertcol(i, headers[i]);
2024-02-11 23:49:11 +08:00
}
2024-07-21 19:28:47 +08:00
headernum = headers.size();
2024-04-18 16:19:52 +08:00
2024-07-21 19:28:47 +08:00
if (headernum == 1)
2024-04-18 16:19:52 +08:00
ListView_SetColumnWidth(winId, 0, LVSCW_AUTOSIZE_USEHEADER);
2024-07-21 19:28:47 +08:00
else if (headernum == 2)
{
2024-04-18 16:19:52 +08:00
ListView_SetColumnWidth(winId, 0, 0x180);
}
2024-02-11 23:49:11 +08:00
}
2024-07-21 19:28:47 +08:00
void listview::on_size(int w, int)
{
if (headernum == 1)
2024-04-18 16:19:52 +08:00
ListView_SetColumnWidth(winId, 0, LVSCW_AUTOSIZE_USEHEADER);
2024-07-21 19:28:47 +08:00
else if (headernum == 2)
{
auto w0 = ListView_GetColumnWidth(winId, 0);
ListView_SetColumnWidth(winId, 1, w - w0);
2024-02-11 23:49:11 +08:00
}
2024-07-21 19:28:47 +08:00
}
void gridlayout::setgeo(int x, int y, int w, int h)
{
auto dynarow = maxrow;
auto dynacol = maxcol;
for (auto fw : fixedwidth)
{
dynacol -= 1;
w -= fw.second + margin;
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
for (auto fh : fixedheight)
{
dynarow -= 1;
h -= fh.second + margin;
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
auto wpercol = (w - margin * (dynacol + 1)) / dynacol;
auto hperrow = (h - margin * (dynarow + 1)) / dynarow;
for (auto ctr : savecontrol)
{
int _x = 0, _y = 0, _w = 0, _h = 0;
for (int c = 0; c < ctr.col + ctr.colrange; c++)
2024-03-28 11:01:44 +08:00
{
2024-07-21 19:28:47 +08:00
if (fixedwidth.find(c) != fixedwidth.end())
if (c < ctr.col)
_x += fixedwidth[c];
2024-03-28 11:01:44 +08:00
else
2024-07-21 19:28:47 +08:00
_w += fixedwidth[c];
else if (c < ctr.col)
_x += wpercol;
2024-03-28 11:01:44 +08:00
else
2024-07-21 19:28:47 +08:00
_w += wpercol;
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
_x += (ctr.col + 1) * margin;
_w += (ctr.colrange - 1) * margin;
for (int r = 0; r < ctr.row + ctr.rowrange; r++)
2024-03-28 11:01:44 +08:00
{
2024-07-21 19:28:47 +08:00
if (fixedheight.find(r) != fixedheight.end())
if (r < ctr.row)
_y += fixedheight[r];
2024-03-28 11:01:44 +08:00
else
2024-07-21 19:28:47 +08:00
_h += fixedheight[r];
else if (r < ctr.row)
_y += hperrow;
2024-03-28 11:01:44 +08:00
else
2024-07-21 19:28:47 +08:00
_h += hperrow;
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
_y += (ctr.row + 1) * margin;
_h += (ctr.rowrange - 1) * margin;
ctr.ctr->setgeo(_x, _y, _w, _h);
2024-03-28 11:01:44 +08:00
}
}
2024-07-21 19:28:47 +08:00
void gridlayout::setfixedwidth(int col, int width)
{
fixedwidth.insert({col, width});
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
void gridlayout::setfixedheigth(int row, int height)
{
fixedheight.insert({row, height});
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
void gridlayout::addcontrol(control *_c, int row, int col, int rowrange, int colrange)
{
maxrow = max(maxrow, row + rowrange);
maxcol = max(maxcol, col + colrange);
2024-03-28 11:01:44 +08:00
savecontrol.push_back(
2024-07-21 19:28:47 +08:00
{_c, row, col, rowrange, colrange});
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
gridlayout::gridlayout(int row, int col) : control(0)
{
maxrow = row;
maxcol = col;
margin = 10;
2024-03-28 11:01:44 +08:00
}
2024-07-21 19:28:47 +08:00
void gridlayout::setmargin(int m)
{
margin = m;
2024-03-29 15:07:43 +08:00
}
2024-07-21 19:28:47 +08:00
void Menu::dispatch(WPARAM wparam)
{
auto idx = LOWORD(wparam);
2024-03-29 15:07:43 +08:00
menu_callbacks[idx].callback();
DestroyMenu(hmenu);
2024-03-29 15:07:43 +08:00
}
2024-07-21 19:28:47 +08:00
HMENU Menu::load()
{
hmenu = CreatePopupMenu();
2024-07-21 19:28:47 +08:00
for (int i = 0; i < menu_callbacks.size(); i++)
{
AppendMenuW(hmenu, menu_callbacks[i].type, i, menu_callbacks[i].str.c_str());
2024-03-29 15:07:43 +08:00
}
return hmenu;
2024-03-29 15:07:43 +08:00
}
2024-07-21 19:28:47 +08:00
void Menu::add(const std::wstring &str, std::function<void()> callback)
{
menu_callbacks.push_back({MF_STRING, callback, str});
2024-03-29 15:07:43 +08:00
}
2024-07-21 19:28:47 +08:00
void Menu::add_checkable(const std::wstring &str, bool check, std::function<void(bool)> callback)
{
menu_callbacks.push_back({(UINT)(MF_STRING | (check ? MF_CHECKED : MF_UNCHECKED)), std::bind(callback, !check), str});
}
2024-07-21 19:28:47 +08:00
void Menu::add_sep()
{
menu_callbacks.push_back({MF_SEPARATOR});
2024-04-18 16:19:52 +08:00
}
2024-07-21 19:28:47 +08:00
FontSelector::FontSelector(HWND hwnd, const Font &font, std::function<void(const Font &)> callback)
{
2024-04-25 15:44:28 +08:00
CHOOSEFONTW cf;
ZeroMemory(&cf, sizeof(CHOOSEFONTW));
2024-07-21 19:28:47 +08:00
LOGFONT lf = font.logfont();
2024-04-25 15:44:28 +08:00
cf.lStructSize = sizeof(CHOOSEFONTW);
cf.hwndOwner = hwnd;
cf.lpLogFont = &lf;
2024-07-21 19:28:47 +08:00
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS; // | CF_EFFECTS;
2024-04-25 15:44:28 +08:00
if (ChooseFontW(&cf))
{
2024-07-21 19:28:47 +08:00
Font f{lf.lfFaceName, cf.iPointSize / 10.0f, !!(cf.nFontType & BOLD_FONTTYPE), !!(cf.nFontType & ITALIC_FONTTYPE)};
callback(f);
2024-04-25 15:44:28 +08:00
}
}