aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/libui/windows/fontbutton.cpp
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2020-05-29 21:36:26 +0200
committerGitHub <noreply@github.com>2020-05-29 21:36:26 +0200
commit0cadd4bd12bc824d010396c855fa450774e6f619 (patch)
tree7f404a52ff372a1e2e785db2b8cf11736f2f3212 /src/libui_sdl/libui/windows/fontbutton.cpp
parentcd7487d53f8207277fc44f7983513fe6892a3409 (diff)
parent8ddd82ca2c7c8844a1d3c2cc7418d03976c9c52e (diff)
Merge pull request #635 from Arisotura/qt
Qt
Diffstat (limited to 'src/libui_sdl/libui/windows/fontbutton.cpp')
-rw-r--r--src/libui_sdl/libui/windows/fontbutton.cpp122
1 files changed, 0 insertions, 122 deletions
diff --git a/src/libui_sdl/libui/windows/fontbutton.cpp b/src/libui_sdl/libui/windows/fontbutton.cpp
deleted file mode 100644
index d2d4dab..0000000
--- a/src/libui_sdl/libui/windows/fontbutton.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-// 14 april 2016
-#include "uipriv_windows.hpp"
-
-struct uiFontButton {
- uiWindowsControl c;
- HWND hwnd;
- struct fontDialogParams params;
- BOOL already;
- void (*onChanged)(uiFontButton *, void *);
- void *onChangedData;
-};
-
-static void uiFontButtonDestroy(uiControl *c)
-{
- uiFontButton *b = uiFontButton(c);
-
- uiWindowsUnregisterWM_COMMANDHandler(b->hwnd);
- destroyFontDialogParams(&(b->params));
- uiWindowsEnsureDestroyWindow(b->hwnd);
- uiFreeControl(uiControl(b));
-}
-
-static void updateFontButtonLabel(uiFontButton *b)
-{
- WCHAR *text;
-
- text = fontDialogParamsToString(&(b->params));
- setWindowText(b->hwnd, text);
- uiFree(text);
-
- // changing the text might necessitate a change in the button's size
- uiWindowsControlMinimumSizeChanged(uiWindowsControl(b));
-}
-
-static BOOL onWM_COMMAND(uiControl *c, HWND hwnd, WORD code, LRESULT *lResult)
-{
- uiFontButton *b = uiFontButton(c);
- HWND parent;
-
- if (code != BN_CLICKED)
- return FALSE;
-
- parent = parentToplevel(b->hwnd);
- if (showFontDialog(parent, &(b->params))) {
- updateFontButtonLabel(b);
- (*(b->onChanged))(b, b->onChangedData);
- }
-
- *lResult = 0;
- return TRUE;
-}
-
-uiWindowsControlAllDefaultsExceptDestroy(uiFontButton)
-
-// from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing
-#define buttonHeight 14
-
-static void uiFontButtonMinimumSize(uiWindowsControl *c, int *width, int *height)
-{
- uiFontButton *b = uiFontButton(c);
- SIZE size;
- uiWindowsSizing sizing;
- int y;
-
- // try the comctl32 version 6 way
- size.cx = 0; // explicitly ask for ideal size
- size.cy = 0;
- if (SendMessageW(b->hwnd, BCM_GETIDEALSIZE, 0, (LPARAM) (&size)) != FALSE) {
- *width = size.cx;
- *height = size.cy;
- return;
- }
-
- // that didn't work; fall back to using Microsoft's metrics
- // Microsoft says to use a fixed width for all buttons; this isn't good enough
- // use the text width instead, with some edge padding
- *width = uiWindowsWindowTextWidth(b->hwnd) + (2 * GetSystemMetrics(SM_CXEDGE));
- y = buttonHeight;
- uiWindowsGetSizing(b->hwnd, &sizing);
- uiWindowsSizingDlgUnitsToPixels(&sizing, NULL, &y);
- *height = y;
-}
-
-static void defaultOnChanged(uiFontButton *b, void *data)
-{
- // do nothing
-}
-
-uiDrawTextFont *uiFontButtonFont(uiFontButton *b)
-{
- // we don't own b->params.font; we have to add a reference
- // we don't own b->params.familyName either; we have to copy it
- return mkTextFont(b->params.font, TRUE, b->params.familyName, TRUE, b->params.size);
-}
-
-void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data)
-{
- b->onChanged = f;
- b->onChangedData = data;
-}
-
-uiFontButton *uiNewFontButton(void)
-{
- uiFontButton *b;
-
- uiWindowsNewControl(uiFontButton, b);
-
- b->hwnd = uiWindowsEnsureCreateControlHWND(0,
- L"button", L"you should not be seeing this",
- BS_PUSHBUTTON | WS_TABSTOP,
- hInstance, NULL,
- TRUE);
-
- loadInitialFontDialogParams(&(b->params));
-
- uiWindowsRegisterWM_COMMANDHandler(b->hwnd, onWM_COMMAND, uiControl(b));
- uiFontButtonOnChanged(b, defaultOnChanged, NULL);
-
- updateFontButtonLabel(b);
-
- return b;
-}