Okay, I made a mistake: we want uiFontButton to return uiDrawFonts, not uiDrawFontDescriptors. Started the work to change the Windows one likewise.
This commit is contained in:
parent
ccfa3d41a3
commit
b19a8c9c46
|
@ -20,7 +20,6 @@ CFILES += \
|
||||||
windows/draw.c \
|
windows/draw.c \
|
||||||
windows/entry.c \
|
windows/entry.c \
|
||||||
windows/events.c \
|
windows/events.c \
|
||||||
windows/fontbutton.c \
|
|
||||||
windows/group.c \
|
windows/group.c \
|
||||||
windows/init.c \
|
windows/init.c \
|
||||||
windows/label.c \
|
windows/label.c \
|
||||||
|
@ -45,6 +44,7 @@ CFILES += \
|
||||||
CXXFILES += \
|
CXXFILES += \
|
||||||
windows/drawtext.cpp \
|
windows/drawtext.cpp \
|
||||||
windows/dwrite.cpp \
|
windows/dwrite.cpp \
|
||||||
|
windows/fontbutton.cpp \
|
||||||
windows/fontdialog.cpp
|
windows/fontdialog.cpp
|
||||||
|
|
||||||
HFILES += \
|
HFILES += \
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// 14 april 2016
|
// 14 april 2016
|
||||||
#include "uipriv_windows.h"
|
#include "uipriv_windows.h"
|
||||||
|
|
||||||
// TODO implement a custom font dialog that uses DirectWrite?
|
|
||||||
|
|
||||||
struct uiFontButton {
|
struct uiFontButton {
|
||||||
uiWindowsControl c;
|
uiWindowsControl c;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
@ -10,24 +8,28 @@ struct uiFontButton {
|
||||||
BOOL already;
|
BOOL already;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void onDestroy(uiFontButton *);
|
||||||
|
|
||||||
uiWindowsDefineControlWithOnDestroy(
|
uiWindowsDefineControlWithOnDestroy(
|
||||||
uiFontButton, // type name
|
uiFontButton, // type name
|
||||||
uiFontButtonType, // type function
|
uiFontButtonType, // type function
|
||||||
uiWindowsUnregisterWM_COMMANDHandler(this->hwnd); // on destroy
|
onDestroy(this); // on destroy
|
||||||
)
|
)
|
||||||
|
|
||||||
|
static void onDestroy(uiFontButton *b)
|
||||||
|
{
|
||||||
|
uiWindowsUnregisterWM_COMMANDHandler(b->hwnd);
|
||||||
|
destroyFontDialogParams(&(b->params));
|
||||||
|
}
|
||||||
|
|
||||||
static void updateFontButtonLabel(uiFontButton *b)
|
static void updateFontButtonLabel(uiFontButton *b)
|
||||||
{
|
{
|
||||||
// TODO make this dynamically sized
|
WCHAR *text;
|
||||||
// TODO also include the style, but from where? libui or DirectWrite?
|
|
||||||
WCHAR text[1024];
|
|
||||||
WCHAR *family;
|
|
||||||
|
|
||||||
family = toUTF16(b->params.desc.Family);
|
text = fontDialogParamsToString(&(b->params));
|
||||||
_snwprintf(text, 1024, L"%s %s %g", family, b->params.outStyleName, b->params.desc.Size);
|
|
||||||
uiFree(family);
|
|
||||||
// TODO error check
|
// TODO error check
|
||||||
SendMessageW(b->hwnd, WM_SETTEXT, 0, (LPARAM) text);
|
SendMessageW(b->hwnd, WM_SETTEXT, 0, (LPARAM) text);
|
||||||
|
uiFree(text);
|
||||||
|
|
||||||
// changing the text might necessitate a change in the button's size
|
// changing the text might necessitate a change in the button's size
|
||||||
uiWindowsControlQueueRelayout(uiWindowsControl(b));
|
uiWindowsControlQueueRelayout(uiWindowsControl(b));
|
||||||
|
@ -83,6 +85,9 @@ static void defaultOnClicked(uiButton *b, void *data)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// TODO document that GetFont returns a NEW instance each time
|
||||||
|
// TODO document that the Handle of a Font may not be unique
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
TODO
|
TODO
|
||||||
void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data)
|
void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data)
|
|
@ -170,12 +170,18 @@ extern void dwriteAttrToAttr(struct dwriteAttr *attr);
|
||||||
extern void doDrawText(ID2D1RenderTarget *rt, ID2D1Brush *black, double x, double y, uiDrawTextLayout *layout);
|
extern void doDrawText(ID2D1RenderTarget *rt, ID2D1Brush *black, double x, double y, uiDrawTextLayout *layout);
|
||||||
|
|
||||||
// fontdialog.cpp
|
// fontdialog.cpp
|
||||||
|
#ifdef __cplusplus
|
||||||
struct fontDialogParams {
|
struct fontDialogParams {
|
||||||
uiDrawTextFontDescriptor desc;
|
IDWriteFont *font;
|
||||||
WCHAR *outStyleName;
|
double size;
|
||||||
|
WCHAR *familyName;
|
||||||
|
WCHAR *styleName;
|
||||||
};
|
};
|
||||||
extern BOOL showFontDialog(HWND parent, struct fontDialogParams *params);
|
extern BOOL showFontDialog(HWND parent, struct fontDialogParams *params);
|
||||||
extern void loadInitialFontDialogParams(struct fontDialogParams *params);
|
extern void loadInitialFontDialogParams(struct fontDialogParams *params);
|
||||||
|
extern void destroyFontDialogParams(struct fontDialogParams *params);
|
||||||
|
extern WCHAR fontDialogParamsToString(struct fontDialogParams *params);
|
||||||
|
#endif
|
||||||
|
|
||||||
// d2dscratch.c
|
// d2dscratch.c
|
||||||
extern ATOM registerD2DScratchClass(HICON, HCURSOR);
|
extern ATOM registerD2DScratchClass(HICON, HCURSOR);
|
||||||
|
|
Loading…
Reference in New Issue