Merge branch 'master' into table
This commit is contained in:
commit
7b570a4026
|
@ -210,7 +210,7 @@ macro(_add_exec _name)
|
|||
add_executable(${_name}
|
||||
EXCLUDE_FROM_ALL
|
||||
${ARGN})
|
||||
target_link_libraries(${_name} libui ${_LIBUI_STATIC_RES})
|
||||
target_link_libraries(${_name} libui)
|
||||
_target_link_options_private(${_name}
|
||||
_COMMON_LDFLAGS)
|
||||
# make shared-linked executables PIC too
|
||||
|
|
|
@ -5,6 +5,12 @@ This README is being written.<br>
|
|||
|
||||
## Announcements
|
||||
|
||||
* **2 May 2018**
|
||||
* On Windows, you no longer need to carry around a `libui.res` file with static builds. You do need to link in the appropriate manifest file, such as the one in the `windows/` folder (I still need to figure out exactly what is needed apart from the Common Controls v6 dependency, or at least to create a complete-ish template), or at least include it alongside your executables. This also means you should no longer see random cmake errors when building the static libraries.
|
||||
|
||||
* **18 April 2018**
|
||||
* Introduced a new `uiTimer()` function for running code on a timer on the main thread. (Thanks to @cody271.)
|
||||
|
||||
* **18 March 2018**
|
||||
* Introduced an all-new formatted text API that allows you to process formatted text in ways that the old API wouldn't allow. You can read on the whole API [here](https://github.com/andlabs/libui/blob/8944a3fc5528445b9027b1294b6c86bae03eeb89/ui_attrstr.h). There is also a new examples for it: `drawtext`, which shows the whole API at a glance. It doesn't yet support measuring or manipulating text, nor does it currently support functions that would be necessary for things like text editors; all of this will be added back later.
|
||||
* libui also now uses my [utf library](https://github.com/andlabs/utf) for UTF-8 and UTF-16 processing, to allow consistent behavior across platforms. This usage is not completely propagated throughout libui, but the Windows port uses it in most places now, and eventually this will become what libui will use throughout.
|
||||
|
|
|
@ -195,3 +195,10 @@ more OS2 stuff
|
|||
https://www.google.com/search?q=%22ibm+graphics+development+toolkit%22&ie=utf-8&oe=utf-8&client=firefox-b-1
|
||||
https://www.google.com/search?q=%22os%2F2+graphics+development+toolkit%22&ie=utf-8&oe=utf-8&client=firefox-b-1
|
||||
http://www.edm2.com/index.php/IBM_OS/2_Developer%27s_Packages
|
||||
|
||||
[17:48:52] <Chloe> andlabs: I got splitView and NSWindow size restoration working btw
|
||||
[17:49:09] <Chloe> andlabs: see https://github.com/eintw1ck/mail/blob/master/Sources/mail/MainViewController.swift for splitView
|
||||
|
||||
old stuff
|
||||
font1.gif (GIF Image, 424 × 475 pixels) http://www.functionx.com/win32/controls/dlgboxes/font1.gif
|
||||
Inskcape’s Hidden Little Feature: Mesh Gradients | OCS-Mag http://www.ocsmag.com/2016/02/27/inskcapes-hidden-little-feature-mesh-gradients/ (near "When you’re done colouring in all the nodes, you may want to drag")
|
||||
|
|
50
common/utf.h
50
common/utf.h
|
@ -28,12 +28,52 @@ extern size_t uiprivUTF16UTF8Count(const uint16_t *s, size_t nElem);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
// Provide overloads on Windows for using these functions with wchar_t and WCHAR when wchar_t is a keyword in C++ mode (the default).
|
||||
// Otherwise, you'd need to cast to pass a wchar_t pointer, WCHAR pointer, or equivalent to these functions.
|
||||
// We use __wchar_t to be independent of the setting; see https://blogs.msdn.microsoft.com/oldnewthing/20161201-00/?p=94836 (ironically posted one day after I initially wrote this code!).
|
||||
// TODO check this on MinGW-w64
|
||||
// TODO sync this back to upstream (need copyright clearance first)
|
||||
|
||||
// On Windows, wchar_t is equivalent to uint16_t, but C++ requires
|
||||
// wchar_t to be a completely distinct type. These overloads allow
|
||||
// passing wchar_t pointers directly into these functions from C++
|
||||
// on Windows. Otherwise, you'd need to cast to pass a wchar_t
|
||||
// pointer, WCHAR pointer, or equivalent to these functions.
|
||||
//
|
||||
// This does not apply to MSVC because the situation there is
|
||||
// slightly more complicated; see below.
|
||||
#if defined(_WIN32) && !defined(_MSC_VER)
|
||||
|
||||
inline size_t uiprivUTF16EncodeRune(uint32_t rune, wchar_t *encoded)
|
||||
{
|
||||
return uiprivUTF16EncodeRune(rune, reinterpret_cast<uint16_t *>(encoded));
|
||||
}
|
||||
|
||||
inline const wchar_t *uiprivUTF16DecodeRune(const wchar_t *s, size_t nElem, uint32_t *rune)
|
||||
{
|
||||
const uint16_t *ret;
|
||||
|
||||
ret = uiprivUTF16DecodeRune(reinterpret_cast<const uint16_t *>(s), nElem, rune);
|
||||
return reinterpret_cast<const wchar_t *>(ret);
|
||||
}
|
||||
|
||||
inline size_t uiprivUTF16RuneCount(const wchar_t *s, size_t nElem)
|
||||
{
|
||||
return uiprivUTF16RuneCount(reinterpret_cast<const uint16_t *>(s), nElem);
|
||||
}
|
||||
|
||||
inline size_t uiprivUTF16UTF8Count(const wchar_t *s, size_t nElem)
|
||||
{
|
||||
return uiprivUTF16UTF8Count(reinterpret_cast<const uint16_t *>(s), nElem);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// This is the same as the above, except that with MSVC, whether
|
||||
// wchar_t is a keyword or not is controlled by a compiler option!
|
||||
// (At least with gcc, this is not the case; thanks redi in
|
||||
// irc.freenode.net/#gcc.) We use __wchar_t to be independent of
|
||||
// the option; see https://blogs.msdn.microsoft.com/oldnewthing/20161201-00/?p=94836
|
||||
// (ironically posted one day after I initially wrote this code!).
|
||||
// TODO should defined(_WIN32) be used too?
|
||||
// TODO check this under /Wall
|
||||
// TODO C-style casts enough? or will that fail in /Wall?
|
||||
// TODO are C-style casts enough? or will that fail in /Wall?
|
||||
// TODO same for UniChar/unichar on Mac? if both are unsigned then we have nothing to worry about
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
|
|
|
@ -242,3 +242,44 @@ void uiQueueMain(void (*f)(void *data), void *data)
|
|||
// the signature of f matches dispatch_function_t
|
||||
dispatch_async_f(dispatch_get_main_queue(), data, f);
|
||||
}
|
||||
|
||||
@interface uiprivTimerDelegate : NSObject {
|
||||
int (*f)(void *data);
|
||||
void *data;
|
||||
}
|
||||
- (id)initWithCallback:(int (*)(void *))callback data:(void *)callbackData;
|
||||
- (void)doTimer:(NSTimer *)timer;
|
||||
@end
|
||||
|
||||
@implementation uiprivTimerDelegate
|
||||
|
||||
- (id)initWithCallback:(int (*)(void *))callback data:(void *)callbackData
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self->f = callback;
|
||||
self->data = callbackData;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)doTimer:(NSTimer *)timer
|
||||
{
|
||||
if (!(*(self->f))(self->data))
|
||||
[timer invalidate];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void uiTimer(int milliseconds, int (*f)(void *data), void *data)
|
||||
{
|
||||
uiprivTimerDelegate *delegate;
|
||||
|
||||
delegate = [[uiprivTimerDelegate alloc] initWithCallback:f data:data];
|
||||
[NSTimer scheduledTimerWithTimeInterval:(milliseconds / 1000.0)
|
||||
target:delegate
|
||||
selector:@selector(doTimer:)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
[delegate release];
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// 1 november 2016
|
||||
#import "uipriv_darwin.h"
|
||||
|
||||
// TODO option while resizing resizes both opposing sides at once (thanks swillits in irc.freenode.net/#macdev for showing this to me); figure out how far back that behavior goes when we do implement it
|
||||
|
||||
// because we are changing the window frame each time the mouse moves, the successive -[NSEvent locationInWindow]s cannot be meaningfully used together
|
||||
// make sure they are all following some sort of standard to avoid this problem; the screen is the most obvious possibility since it requires only one conversion (the only one that a NSWindow provides)
|
||||
static NSPoint makeIndependent(NSPoint p, NSWindow *w)
|
||||
|
|
|
@ -42,9 +42,15 @@ _add_example(drawtext
|
|||
${_EXAMPLE_RESOURCES_RC}
|
||||
)
|
||||
|
||||
_add_example(timer
|
||||
timer/main.c
|
||||
${_EXAMPLE_RESOURCES_RC}
|
||||
)
|
||||
|
||||
add_custom_target(examples
|
||||
DEPENDS
|
||||
controlgallery
|
||||
histogram
|
||||
cpp-multithread
|
||||
drawtext)
|
||||
drawtext
|
||||
timer)
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "../../ui.h"
|
||||
|
||||
uiMultilineEntry *e;
|
||||
|
||||
int sayTime(void *data)
|
||||
{
|
||||
time_t t;
|
||||
char *s;
|
||||
|
||||
t = time(NULL);
|
||||
s = ctime(&t);
|
||||
|
||||
uiMultilineEntryAppend(e, s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int onClosing(uiWindow *w, void *data)
|
||||
{
|
||||
uiQuit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void saySomething(uiButton *b, void *data)
|
||||
{
|
||||
uiMultilineEntryAppend(e, "Saying something\n");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
uiInitOptions o;
|
||||
uiWindow *w;
|
||||
uiBox *b;
|
||||
uiButton *btn;
|
||||
|
||||
memset(&o, 0, sizeof (uiInitOptions));
|
||||
if (uiInit(&o) != NULL)
|
||||
abort();
|
||||
|
||||
w = uiNewWindow("Hello", 320, 240, 0);
|
||||
uiWindowSetMargined(w, 1);
|
||||
|
||||
b = uiNewVerticalBox();
|
||||
uiBoxSetPadded(b, 1);
|
||||
uiWindowSetChild(w, uiControl(b));
|
||||
|
||||
e = uiNewMultilineEntry();
|
||||
uiMultilineEntrySetReadOnly(e, 1);
|
||||
|
||||
btn = uiNewButton("Say Something");
|
||||
uiButtonOnClicked(btn, saySomething, NULL);
|
||||
uiBoxAppend(b, uiControl(btn), 0);
|
||||
|
||||
uiBoxAppend(b, uiControl(e), 1);
|
||||
|
||||
uiTimer(1000, sayTime, NULL);
|
||||
|
||||
uiWindowOnClosing(w, onClosing, NULL);
|
||||
uiControlShow(uiControl(w));
|
||||
uiMain();
|
||||
return 0;
|
||||
}
|
8
ui.h
8
ui.h
|
@ -62,6 +62,14 @@ _UI_EXTERN void uiQuit(void);
|
|||
|
||||
_UI_EXTERN void uiQueueMain(void (*f)(void *data), void *data);
|
||||
|
||||
// TODO standardize the looping behavior return type, either with some enum or something, and the test expressions throughout the code
|
||||
// TODO figure out what to do about looping and the exact point that the timer is rescheduled so we can document it; see https://github.com/andlabs/libui/pull/277
|
||||
// TODO (also in the above link) document that this cannot be called from any thread, unlike uiQueueMain()
|
||||
// TODO document that the minimum exact timing, either accuracy (timer burst, etc.) or granularity (15ms on Windows, etc.), is OS-defined
|
||||
// TODO also figure out how long until the initial tick is registered on all platforms to document
|
||||
// TODO also add a comment about how useful this could be in bindings, depending on the language being bound to
|
||||
_UI_EXTERN void uiTimer(int milliseconds, int (*f)(void *data), void *data);
|
||||
|
||||
_UI_EXTERN void uiOnShouldQuit(int (*f)(void *data), void *data);
|
||||
|
||||
_UI_EXTERN void uiFreeText(char *text);
|
||||
|
|
26
unix/main.c
26
unix/main.c
|
@ -106,3 +106,29 @@ void uiQueueMain(void (*f)(void *data), void *data)
|
|||
q->data = data;
|
||||
gdk_threads_add_idle(doqueued, q);
|
||||
}
|
||||
|
||||
struct timer {
|
||||
int (*f)(void *);
|
||||
void *data;
|
||||
};
|
||||
|
||||
static gboolean doTimer(gpointer data)
|
||||
{
|
||||
struct timer *t = (struct timer *) data;
|
||||
|
||||
if (!(*(t->f))(t->data)) {
|
||||
uiprivFree(t);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void uiTimer(int milliseconds, int (*f)(void *data), void *data)
|
||||
{
|
||||
struct timer *t;
|
||||
|
||||
t = uiprivNew(struct timer);
|
||||
t->f = f;
|
||||
t->data = data;
|
||||
g_timeout_add(milliseconds, doTimer, t);
|
||||
}
|
||||
|
|
|
@ -56,8 +56,17 @@ list(APPEND _LIBUI_SOURCES
|
|||
windows/window.cpp
|
||||
windows/winpublic.cpp
|
||||
windows/winutil.cpp
|
||||
windows/resources.rc
|
||||
)
|
||||
# resources.rc only contains the libui manifest.
|
||||
# For a DLL, we have to include this directly, so we do so.
|
||||
# Windows won't link resources in static libraries, so including this would have no effect.
|
||||
# In those cases, we just need them to include the manifest with the executable (or link it directly into the output executable themselves); they can also customize the manifest as they see fit (assuming nothing breaks in the process).
|
||||
# TODO make sure this gets added to both binary-only archives and install rules in this case
|
||||
if(BUILD_SHARED_LIBS)
|
||||
list(APPEND _LIBUI_SOURCES
|
||||
windows/resources.rc
|
||||
)
|
||||
endif()
|
||||
set(_LIBUI_SOURCES ${_LIBUI_SOURCES} PARENT_SCOPE)
|
||||
|
||||
list(APPEND _LIBUI_INCLUDEDIRS
|
||||
|
@ -65,18 +74,9 @@ list(APPEND _LIBUI_INCLUDEDIRS
|
|||
)
|
||||
set(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE)
|
||||
|
||||
# Windows won't link resources in static libraries; we need to provide the libui.res file in this case.
|
||||
set(_LIBUINAME libui PARENT_SCOPE)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
set(_LIBUI_STATIC_RES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libui.res PARENT_SCOPE)
|
||||
endif()
|
||||
macro(_handle_static)
|
||||
# TODO this full path feels hacky
|
||||
add_custom_command(
|
||||
TARGET libui POST_BUILD
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:libui,BINARY_DIR>/CMakeFiles/libui.dir/windows/resources.rc.* ${_LIBUI_STATIC_RES}
|
||||
COMMENT "Copying libui.res")
|
||||
# do nothing
|
||||
endmacro()
|
||||
|
||||
# TODO prune this list
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
@rem 2 may 2018
|
||||
@echo off
|
||||
|
||||
cl /nologo /TP /GR /EHsc /MDd /Ob0 /Od /RTC1 /W4 /wd4100 /bigobj /RTC1 /RTCs /RTCu /FS -c main.cpp
|
||||
if errorlevel 1 goto out
|
||||
rc -foresources.res resources.rc
|
||||
if errorlevel 1 goto out
|
||||
link /nologo main.obj resources.res /out:main.exe /LARGEADDRESSAWARE /NOLOGO /INCREMENTAL:NO /MANIFEST:NO /debug user32.lib kernel32.lib gdi32.lib comctl32.lib uxtheme.lib msimg32.lib comdlg32.lib d2d1.lib dwrite.lib ole32.lib oleaut32.lib oleacc.lib uuid.lib
|
||||
|
||||
:out
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="*"
|
||||
name="CompanyName.ProductName.YourApplication"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Your application description here.</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!--The ID below indicates application support for Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
<!--The ID below indicates application support for Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
// 2 may 2018
|
||||
#include "winapi.hpp"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "resources.hpp"
|
||||
|
||||
// TODO make sure there are no CRs in the output
|
||||
|
||||
void die(const char *f, const char *constname)
|
||||
{
|
||||
DWORD le;
|
||||
|
||||
le = GetLastError();
|
||||
fprintf(stderr, "error calling %s for %s: %I32d\n", f, constname, le);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void dumpResource(const char *constname, const WCHAR *name, const WCHAR *type)
|
||||
{
|
||||
HRSRC hrsrc;
|
||||
HGLOBAL res;
|
||||
uint8_t *b, *bp;
|
||||
DWORD i, n;
|
||||
DWORD j;
|
||||
|
||||
hrsrc = FindResourceW(NULL, name, type);
|
||||
if (hrsrc == NULL)
|
||||
die("FindResourceW()", constname);
|
||||
n = SizeofResource(NULL, hrsrc);
|
||||
if (n == 0)
|
||||
die("SizeofResource()", constname);
|
||||
res = LoadResource(NULL, hrsrc);
|
||||
if (res == NULL)
|
||||
die("LoadResource()", constname);
|
||||
b = (uint8_t *) LockResource(res);
|
||||
if (b == NULL)
|
||||
die("LockResource()", constname);
|
||||
|
||||
printf("static const uint8_t %s[] = {\n", constname);
|
||||
bp = b;
|
||||
j = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (j == 0)
|
||||
printf("\t");
|
||||
printf("0x%02I32X,", (uint32_t) (*bp));
|
||||
bp++;
|
||||
if (j == 7) {
|
||||
printf("\n");
|
||||
j = 0;
|
||||
} else {
|
||||
printf(" ");
|
||||
j++;
|
||||
}
|
||||
}
|
||||
if (j != 0)
|
||||
printf("\n");
|
||||
printf("};\n");
|
||||
printf("static_assert(ARRAYSIZE(%s) == %I32d, \"wrong size for resource %s\");\n", constname, n, constname);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
#define d(c, t) dumpResource(#c, MAKEINTRESOURCEW(c), t)
|
||||
d(rcTabPageDialog, RT_DIALOG);
|
||||
d(rcFontDialog, RT_DIALOG);
|
||||
d(rcColorDialog, RT_DIALOG);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// 30 may 2015
|
||||
|
||||
#define rcTabPageDialog 29000
|
||||
#define rcFontDialog 29001
|
||||
#define rcColorDialog 29002
|
||||
|
||||
// TODO normalize these
|
||||
|
||||
#define rcFontFamilyCombobox 1000
|
||||
#define rcFontStyleCombobox 1001
|
||||
#define rcFontSizeCombobox 1002
|
||||
#define rcFontSamplePlacement 1003
|
||||
|
||||
#define rcColorSVChooser 1100
|
||||
#define rcColorHSlider 1101
|
||||
#define rcPreview 1102
|
||||
#define rcOpacitySlider 1103
|
||||
#define rcH 1104
|
||||
#define rcS 1105
|
||||
#define rcV 1106
|
||||
#define rcRDouble 1107
|
||||
#define rcRInt 1108
|
||||
#define rcGDouble 1109
|
||||
#define rcGInt 1110
|
||||
#define rcBDouble 1111
|
||||
#define rcBInt 1112
|
||||
#define rcADouble 1113
|
||||
#define rcAInt 1114
|
||||
#define rcHex 1115
|
||||
#define rcHLabel 1116
|
||||
#define rcSLabel 1117
|
||||
#define rcVLabel 1118
|
||||
#define rcRLabel 1119
|
||||
#define rcGLabel 1120
|
||||
#define rcBLabel 1121
|
||||
#define rcALabel 1122
|
||||
#define rcHexLabel 1123
|
|
@ -0,0 +1,96 @@
|
|||
// 30 may 2015
|
||||
#include "winapi.hpp"
|
||||
#include "resources.hpp"
|
||||
|
||||
// this is a UTF-8 file
|
||||
#pragma code_page(65001)
|
||||
|
||||
// this is the Common Controls 6 manifest
|
||||
// we only define it in a shared build; static builds have to include the appropriate parts of the manifest in the output executable
|
||||
// LONGTERM set up the string values here
|
||||
#ifndef _UI_STATIC
|
||||
ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "libui.manifest"
|
||||
#endif
|
||||
|
||||
// this is the dialog template used by tab pages; see windows/tabpage.c for details
|
||||
rcTabPageDialog DIALOGEX 0, 0, 100, 100
|
||||
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE
|
||||
EXSTYLE WS_EX_CONTROLPARENT
|
||||
BEGIN
|
||||
// nothing
|
||||
END
|
||||
|
||||
// this is for our custom DirectWrite-based font dialog (see fontdialog.cpp)
|
||||
// this is based on the "New Font Dialog with Syslink" in Microsoft's font.dlg
|
||||
// LONGTERM look at localization
|
||||
// LONGTERM make it look tighter and nicer like the real one, including the actual heights of the font family and style comboboxes
|
||||
rcFontDialog DIALOGEX 13, 54, 243, 200
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK
|
||||
CAPTION "Font"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "&Font:", -1, 7, 7, 98, 9
|
||||
COMBOBOX rcFontFamilyCombobox, 7, 16, 98, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
LTEXT "Font st&yle:", -1, 114, 7, 74, 9
|
||||
COMBOBOX rcFontStyleCombobox, 114, 16, 74, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
LTEXT "&Size:", -1, 198, 7, 36, 9
|
||||
COMBOBOX rcFontSizeCombobox, 198, 16, 36, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
GROUPBOX "Sample", -1, 7, 97, 227, 70, WS_GROUP
|
||||
CTEXT "AaBbYyZz", rcFontSamplePlacement, 9, 106, 224, 60, SS_NOPREFIX | NOT WS_VISIBLE
|
||||
|
||||
DEFPUSHBUTTON "OK", IDOK, 141, 181, 45, 14, WS_GROUP
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 190, 181, 45, 14, WS_GROUP
|
||||
END
|
||||
|
||||
rcColorDialog DIALOGEX 13, 54, 344, 209
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK
|
||||
CAPTION "Color"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
// this size should be big enough to get at least 256x256 on font sizes >= 8 pt
|
||||
CTEXT "AaBbYyZz", rcColorSVChooser, 7, 7, 195, 195, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
// width is the suggested slider height since this is vertical
|
||||
CTEXT "AaBbYyZz", rcColorHSlider, 206, 7, 15, 195, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "Preview:", -1, 230, 7, 107, 9, SS_NOPREFIX
|
||||
CTEXT "AaBbYyZz", rcPreview, 230, 16, 107, 20, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "Opacity:", -1, 230, 45, 107, 9, SS_NOPREFIX
|
||||
CTEXT "AaBbYyZz", rcOpacitySlider, 230, 54, 107, 15, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "&H:", rcHLabel, 230, 81, 8, 8
|
||||
EDITTEXT rcH, 238, 78, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&S:", rcSLabel, 230, 95, 8, 8
|
||||
EDITTEXT rcS, 238, 92, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&V:", rcVLabel, 230, 109, 8, 8
|
||||
EDITTEXT rcV, 238, 106, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
LTEXT "&R:", rcRLabel, 277, 81, 8, 8
|
||||
EDITTEXT rcRDouble, 285, 78, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcRInt, 315, 78, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&G:", rcGLabel, 277, 95, 8, 8
|
||||
EDITTEXT rcGDouble, 285, 92, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcGInt, 315, 92, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&B:", rcBLabel, 277, 109, 8, 8
|
||||
EDITTEXT rcBDouble, 285, 106, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcBInt, 315, 106, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&A:", rcALabel, 277, 123, 8, 8
|
||||
EDITTEXT rcADouble, 285, 120, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcAInt, 315, 120, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
LTEXT "He&x:", rcHexLabel, 269, 146, 16, 8
|
||||
EDITTEXT rcHex, 285, 143, 50, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
DEFPUSHBUTTON "OK", IDOK, 243, 188, 45, 14, WS_GROUP
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 292, 188, 45, 14, WS_GROUP
|
||||
END
|
|
@ -0,0 +1,60 @@
|
|||
// 31 may 2015
|
||||
#define UNICODE
|
||||
#define _UNICODE
|
||||
#define STRICT
|
||||
#define STRICT_TYPED_ITEMIDS
|
||||
|
||||
// see https://github.com/golang/go/issues/9916#issuecomment-74812211
|
||||
// TODO get rid of this
|
||||
#define INITGUID
|
||||
|
||||
// for the manifest
|
||||
#ifndef _UI_STATIC
|
||||
#define ISOLATION_AWARE_ENABLED 1
|
||||
#endif
|
||||
|
||||
// get Windows version right; right now Windows Vista
|
||||
// unless otherwise stated, all values from Microsoft's sdkddkver.h
|
||||
// TODO is all of this necessary? how is NTDDI_VERSION used?
|
||||
// TODO plaform update sp2
|
||||
#define WINVER 0x0600 /* from Microsoft's winnls.h */
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#define _WIN32_WINDOWS 0x0600 /* from Microsoft's pdh.h */
|
||||
#define _WIN32_IE 0x0700
|
||||
#define NTDDI_VERSION 0x06000000
|
||||
|
||||
// The MinGW-w64 header has an unverified IDWriteTypography definition.
|
||||
// TODO I can confirm this myself, but I don't know how long it will take for them to note my adjustments... Either way, I have to confirm this myself.
|
||||
// TODO change the check from _MSC_VER to a MinGW-w64-specific check
|
||||
// TODO keep track of what else is guarded by this
|
||||
#ifndef _MSC_VER
|
||||
#define __MINGW_USE_BROKEN_INTERFACE
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle
|
||||
#ifndef RC_INVOKED
|
||||
#include <commctrl.h>
|
||||
#include <uxtheme.h>
|
||||
#include <windowsx.h>
|
||||
#include <shobjidl.h>
|
||||
#include <d2d1.h>
|
||||
#include <d2d1helper.h>
|
||||
#include <dwrite.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <sstream>
|
||||
#include <functional>
|
||||
#endif
|
|
@ -1249,9 +1249,202 @@ static INT_PTR CALLBACK colorDialogDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
// because Windows doesn't really support resources in static libraries, we have to embed this directly; oh well
|
||||
/*
|
||||
rcColorDialog DIALOGEX 13, 54, 344, 209
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK
|
||||
CAPTION "Color"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
// this size should be big enough to get at least 256x256 on font sizes >= 8 pt
|
||||
CTEXT "AaBbYyZz", rcColorSVChooser, 7, 7, 195, 195, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
// width is the suggested slider height since this is vertical
|
||||
CTEXT "AaBbYyZz", rcColorHSlider, 206, 7, 15, 195, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "Preview:", -1, 230, 7, 107, 9, SS_NOPREFIX
|
||||
CTEXT "AaBbYyZz", rcPreview, 230, 16, 107, 20, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "Opacity:", -1, 230, 45, 107, 9, SS_NOPREFIX
|
||||
CTEXT "AaBbYyZz", rcOpacitySlider, 230, 54, 107, 15, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "&H:", rcHLabel, 230, 81, 8, 8
|
||||
EDITTEXT rcH, 238, 78, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&S:", rcSLabel, 230, 95, 8, 8
|
||||
EDITTEXT rcS, 238, 92, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&V:", rcVLabel, 230, 109, 8, 8
|
||||
EDITTEXT rcV, 238, 106, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
LTEXT "&R:", rcRLabel, 277, 81, 8, 8
|
||||
EDITTEXT rcRDouble, 285, 78, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcRInt, 315, 78, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&G:", rcGLabel, 277, 95, 8, 8
|
||||
EDITTEXT rcGDouble, 285, 92, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcGInt, 315, 92, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&B:", rcBLabel, 277, 109, 8, 8
|
||||
EDITTEXT rcBDouble, 285, 106, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcBInt, 315, 106, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&A:", rcALabel, 277, 123, 8, 8
|
||||
EDITTEXT rcADouble, 285, 120, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcAInt, 315, 120, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
LTEXT "He&x:", rcHexLabel, 269, 146, 16, 8
|
||||
EDITTEXT rcHex, 285, 143, 50, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
DEFPUSHBUTTON "OK", IDOK, 243, 188, 45, 14, WS_GROUP
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 292, 188, 45, 14, WS_GROUP
|
||||
END
|
||||
*/
|
||||
static const uint8_t data_rcColorDialog[] = {
|
||||
0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC4, 0x00, 0xC8, 0x80,
|
||||
0x1C, 0x00, 0x0D, 0x00, 0x36, 0x00, 0x58, 0x01,
|
||||
0xD1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00,
|
||||
0x6F, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x72, 0x00,
|
||||
0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x53, 0x00, 0x65, 0x00, 0x67, 0x00, 0x6F, 0x00,
|
||||
0x65, 0x00, 0x20, 0x00, 0x55, 0x00, 0x49, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x02, 0x50,
|
||||
0x07, 0x00, 0x07, 0x00, 0xC3, 0x00, 0xC3, 0x00,
|
||||
0x4C, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x41, 0x00, 0x61, 0x00, 0x42, 0x00, 0x62, 0x00,
|
||||
0x59, 0x00, 0x79, 0x00, 0x5A, 0x00, 0x7A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x02, 0x50,
|
||||
0xCE, 0x00, 0x07, 0x00, 0x0F, 0x00, 0xC3, 0x00,
|
||||
0x4D, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x41, 0x00, 0x61, 0x00, 0x42, 0x00, 0x62, 0x00,
|
||||
0x59, 0x00, 0x79, 0x00, 0x5A, 0x00, 0x7A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x02, 0x50,
|
||||
0xE6, 0x00, 0x07, 0x00, 0x6B, 0x00, 0x09, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x50, 0x00, 0x72, 0x00, 0x65, 0x00, 0x76, 0x00,
|
||||
0x69, 0x00, 0x65, 0x00, 0x77, 0x00, 0x3A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x02, 0x50,
|
||||
0xE6, 0x00, 0x10, 0x00, 0x6B, 0x00, 0x14, 0x00,
|
||||
0x4E, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x41, 0x00, 0x61, 0x00, 0x42, 0x00, 0x62, 0x00,
|
||||
0x59, 0x00, 0x79, 0x00, 0x5A, 0x00, 0x7A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x02, 0x50,
|
||||
0xE6, 0x00, 0x2D, 0x00, 0x6B, 0x00, 0x09, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x4F, 0x00, 0x70, 0x00, 0x61, 0x00, 0x63, 0x00,
|
||||
0x69, 0x00, 0x74, 0x00, 0x79, 0x00, 0x3A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x85, 0x00, 0x02, 0x50,
|
||||
0xE6, 0x00, 0x36, 0x00, 0x6B, 0x00, 0x0F, 0x00,
|
||||
0x4F, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x41, 0x00, 0x61, 0x00, 0x42, 0x00, 0x62, 0x00,
|
||||
0x59, 0x00, 0x79, 0x00, 0x5A, 0x00, 0x7A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0xE6, 0x00, 0x51, 0x00, 0x08, 0x00, 0x08, 0x00,
|
||||
0x5C, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x26, 0x00, 0x48, 0x00, 0x3A, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x81, 0x50,
|
||||
0xEE, 0x00, 0x4E, 0x00, 0x1E, 0x00, 0x0E, 0x00,
|
||||
0x50, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0xE6, 0x00, 0x5F, 0x00, 0x08, 0x00, 0x08, 0x00,
|
||||
0x5D, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x26, 0x00, 0x53, 0x00, 0x3A, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x81, 0x50,
|
||||
0xEE, 0x00, 0x5C, 0x00, 0x1E, 0x00, 0x0E, 0x00,
|
||||
0x51, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0xE6, 0x00, 0x6D, 0x00, 0x08, 0x00, 0x08, 0x00,
|
||||
0x5E, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x26, 0x00, 0x56, 0x00, 0x3A, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x81, 0x50,
|
||||
0xEE, 0x00, 0x6A, 0x00, 0x1E, 0x00, 0x0E, 0x00,
|
||||
0x52, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0x15, 0x01, 0x51, 0x00, 0x08, 0x00, 0x08, 0x00,
|
||||
0x5F, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x26, 0x00, 0x52, 0x00, 0x3A, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x81, 0x50,
|
||||
0x1D, 0x01, 0x4E, 0x00, 0x1E, 0x00, 0x0E, 0x00,
|
||||
0x53, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x20, 0x81, 0x50,
|
||||
0x3B, 0x01, 0x4E, 0x00, 0x14, 0x00, 0x0E, 0x00,
|
||||
0x54, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0x15, 0x01, 0x5F, 0x00, 0x08, 0x00, 0x08, 0x00,
|
||||
0x60, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x26, 0x00, 0x47, 0x00, 0x3A, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x81, 0x50,
|
||||
0x1D, 0x01, 0x5C, 0x00, 0x1E, 0x00, 0x0E, 0x00,
|
||||
0x55, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x20, 0x81, 0x50,
|
||||
0x3B, 0x01, 0x5C, 0x00, 0x14, 0x00, 0x0E, 0x00,
|
||||
0x56, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0x15, 0x01, 0x6D, 0x00, 0x08, 0x00, 0x08, 0x00,
|
||||
0x61, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x26, 0x00, 0x42, 0x00, 0x3A, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x81, 0x50,
|
||||
0x1D, 0x01, 0x6A, 0x00, 0x1E, 0x00, 0x0E, 0x00,
|
||||
0x57, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x20, 0x81, 0x50,
|
||||
0x3B, 0x01, 0x6A, 0x00, 0x14, 0x00, 0x0E, 0x00,
|
||||
0x58, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0x15, 0x01, 0x7B, 0x00, 0x08, 0x00, 0x08, 0x00,
|
||||
0x62, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x26, 0x00, 0x41, 0x00, 0x3A, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x00, 0x81, 0x50,
|
||||
0x1D, 0x01, 0x78, 0x00, 0x1E, 0x00, 0x0E, 0x00,
|
||||
0x59, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x00, 0x00, 0x80, 0x20, 0x81, 0x50,
|
||||
0x3B, 0x01, 0x78, 0x00, 0x14, 0x00, 0x0E, 0x00,
|
||||
0x5A, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x81, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0x0D, 0x01, 0x92, 0x00, 0x10, 0x00, 0x08, 0x00,
|
||||
0x63, 0x04, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x48, 0x00, 0x65, 0x00, 0x26, 0x00, 0x78, 0x00,
|
||||
0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
|
||||
0x80, 0x00, 0x81, 0x50, 0x1D, 0x01, 0x8F, 0x00,
|
||||
0x32, 0x00, 0x0E, 0x00, 0x5B, 0x04, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x03, 0x50, 0xF3, 0x00, 0xBC, 0x00,
|
||||
0x2D, 0x00, 0x0E, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0x80, 0x00, 0x4F, 0x00, 0x4B, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x50,
|
||||
0x24, 0x01, 0xBC, 0x00, 0x2D, 0x00, 0x0E, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0x00,
|
||||
0x43, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x63, 0x00,
|
||||
0x65, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static_assert(ARRAYSIZE(data_rcColorDialog) == 1144, "wrong size for resource rcColorDialog");
|
||||
|
||||
BOOL showColorDialog(HWND parent, struct colorDialogRGBA *c)
|
||||
{
|
||||
switch (DialogBoxParamW(hInstance, MAKEINTRESOURCE(rcColorDialog), parent, colorDialogDlgProc, (LPARAM) c)) {
|
||||
switch (DialogBoxIndirectParamW(hInstance, (const DLGTEMPLATE *) data_rcColorDialog, parent, colorDialogDlgProc, (LPARAM) c)) {
|
||||
case 1: // cancel
|
||||
return FALSE;
|
||||
case 2: // ok
|
||||
|
|
|
@ -11,3 +11,85 @@
|
|||
// LONGTERM MinGW
|
||||
|
||||
// other compilers can be added here as necessary
|
||||
|
||||
/* TODO this should not be necessary, but I don't know
|
||||
|
||||
here's @bcampbell's original comment:
|
||||
// sanity check - make sure wchar_t is 16 bits (the assumption on windows)
|
||||
// (MinGW-w64 gcc does seem to define a 16bit wchar_t, but you never know. Other windows gcc ports might not)
|
||||
|
||||
here's what I got when I tried to investigate on irc.oftc.net/#mingw-w64:
|
||||
{
|
||||
[08:45:20] <lh_mouse> andlabs, the c++ standard requires `wchar_t` to be a distinct type. On Windows you can simply `static_assert(sizeof(wchar_t) == sizeof(unsigned short) && alignof(wchar_t) == alignof(unsigned short), "");` then reinterpret_cast those pointers.
|
||||
[09:22:16] <andlabs> lh_mouse: yes; that was the point of my question =P but whether that static_assert is always true is another question I have, because again, windows embeds the idea of wchar_t being UTF-16 throughout the API, but when I went to look, I found that the clang developers had a very heated debate about it :S
|
||||
[09:22:28] <andlabs> and I couldn't find any concrete information other than the msvc docs
|
||||
[09:23:04] <lh_mouse> Since Windows 2000 the NT kernel uses UTF-16.
|
||||
[09:23:50] <lh_mouse> If you don't care about Windows 9x you can just pretend non-UTF-16 APIs didn't exist.
|
||||
[09:24:04] <andlabs> that's not what I meant
|
||||
[09:24:06] <lh_mouse> Actually long long long ago Windows used UCS2.
|
||||
[09:24:15] <andlabs> I meant whether sizeof(wchar_t) must necessarily equal sizeof(uint16_t)
|
||||
[09:24:18] <andlabs> and likewise for alignof
|
||||
[09:24:27] <andlabs> for all windows compilers
|
||||
[09:24:29] <andlabs> anyway afk
|
||||
[09:24:31] <lh_mouse> Yes. That is what the ABI says.
|
||||
[09:24:40] <andlabs> is there a source for that I can point at other people
|
||||
[09:24:45] <lh_mouse> the ABI != on Windows
|
||||
[09:26:00] <andlabs> okay I really need to afk now but I was about to ask what you meant
|
||||
[09:26:06] <andlabs> and by source I meant URL
|
||||
[09:49:18] <m2bot> andlabs: Sent 17 minutes ago: <lh_mouse> Here is what Microsoft people describe `wchar_t`: https://docs.microsoft.com/en-us/cpp/cpp/char-wchar-t-char16-t-char32-t
|
||||
[09:49:19] <m2bot> andlabs: Sent 17 minutes ago: <lh_mouse> It is quite guaranteed: 'In the Microsoft compiler, it represents a 16-bit wide character used to store Unicode encoded as UTF-16LE, the native character type on Windows operating systems.'
|
||||
[09:50:08] <lh_mouse> andlabs, If you build for cygwin then `wchar_t` is probably `int`, just like what it is on Linux.
|
||||
[09:51:00] <andlabs> yes but that's still a compiler-specific reference; I still don't know hwere Microsoft keeps its ABI documentation, and I'm still wondering what you mean by "the ABI != on Windows" with regards to establishing that guarantee
|
||||
[09:52:13] <lh_mouse> This is already the ABI documentation: https://docs.microsoft.com/en-us/cpp/cpp/char-wchar-t-char16-t-char32-t
|
||||
[09:52:15] <m2bot> Title: char, wchar_t, char16_t, char32_t | Microsoft Docs (at docs.microsoft.com)
|
||||
[09:52:19] <lh_mouse> It describes C++ types,
|
||||
[09:53:09] <andlabs> oh, ok
|
||||
[09:54:47] <andlabs> I assume by the != statement you mean code that doesn't make any windows API calls can theoretically be compiled any which way, right
|
||||
[09:55:05] <lh_mouse> yes. think about MSYS and Cygwin.
|
||||
[09:55:21] <lh_mouse> They have 8-byte `long` and 4-byte `wchar_t`.
|
||||
[09:57:37] <andlabs> right, except the code I'm trying to compile does use the Windows API, so that wouldn't apply to me
|
||||
[09:57:43] <andlabs> I assume
|
||||
[09:57:53] <lh_mouse> it wouldn't.
|
||||
[09:59:12] <lh_mouse> On Windows it is sometimes necessary to assume specific ABI definition. For example, when a callback function returning a `DWORD` is to be declared in a header, in order to prevent `#include`'ing windows.h, you can just write `unsigned long` there.
|
||||
[09:59:32] <lh_mouse> This is guaranteed to work on Windows. Linux will say otherwise.
|
||||
[10:00:41] <lh_mouse> We all know `#include <windows.h>` in a public header lets the genie out of the bottle, doesn't it?
|
||||
[10:04:24] <andlabs> the zombie of win32_lean_and_mean lives forever
|
||||
[10:04:53] <andlabs> of course now we have stdint.h and cstdint (which took longer because lolC++03) which helps stuff
|
||||
[10:06:19] <lh_mouse> no `uint32_t` is `unsigned int` while `DWORD` is `unsigned long` hence they are incompatible. :(
|
||||
[10:06:39] <andlabs> in what sense
|
||||
[10:06:55] <lh_mouse> a `unsigned int *` cannot be converted to `unsigned long *` implicitly.
|
||||
[10:07:41] <lh_mouse> the C standard says they are distinct pointer types and are not compatible, although `unsigned int` and `unsigned long` might have the same bit representation and alignment requirement.
|
||||
[10:08:04] <andlabs> oh
|
||||
[10:08:22] <lh_mouse> casting would indeed make code compile, but I tend to keep away from them unless necessary.
|
||||
[10:08:24] <andlabs> wel yeah, but we haven't left the world of windows-specific code yet
|
||||
[10:08:38] <andlabs> my point was more we don't need to use names like DWORD anymore
|
||||
[10:08:51] <andlabs> of course it's easier to do so
|
||||
[10:09:04] <lh_mouse> just use `uint32_t`.
|
||||
[10:09:44] <lh_mouse> I just tested GCC 8 today and noticed they had added a warning for casting between incompatible function pointer types.
|
||||
[10:10:10] <lh_mouse> So casting from `unsigned (*)(void)` to `unsigned long (*)(void)` now results in a warning.
|
||||
[10:10:43] <lh_mouse> With `-Werror` it is a hard error. This can be worked around by casting the operand to an intermediate result of `intptr_t`.
|
||||
[10:10:59] <lh_mouse> ... not so serious.
|
||||
[10:11:42] <andlabs> oh good I wonder what else will break :D
|
||||
[10:12:19] <andlabs> though the docs for dlsym() tell you what you should do instead for systems that use libdl (cast the address of your destination variable to void**)
|
||||
[10:13:23] <lh_mouse> POSIX requires casting from `void *` to function pointers to work explicitly (see the docs for `dlsym()`). I am not sure what GCC people think about it.
|
||||
[10:13:45] <andlabs> yes that's what I just said =P it avoids the problem entirely
|
||||
[10:13:49] <lh_mouse> C++ says this is 'conditionally supported' and it is not a warning or error there.
|
||||
[10:13:50] <andlabs> dlsym already returns void*
|
||||
[10:14:13] <andlabs> something like dlsym would require an ABI guarantee on the matter anyway
|
||||
[10:14:16] <andlabs> by definition
|
||||
[10:14:32] <lh_mouse> Casting is evil. Double casting is double evil. So I keep myself away from them.
|
||||
[10:15:03] <andlabs> sadly this is C (and C++) =P
|
||||
[10:15:25] <lh_mouse> for `*-w64-mingw32` targets it is safe to cast between `unsigned short`, `wchar_t` and `char16_t`.
|
||||
[10:15:33] <lh_mouse> as well as pointers to them.
|
||||
[10:16:30] <lh_mouse> you just need to `static_assert` it, so something naughty will not compile.
|
||||
[12:36:14] <andlabs> actually I didn't notice that last message until just now
|
||||
[12:36:23] <andlabs> I was asking because I was sitting here thinking such a static_assert was unnecessary
|
||||
}
|
||||
clang debate: http://clang-developers.42468.n3.nabble.com/Is-that-getting-wchar-t-to-be-32bit-on-win32-a-good-idea-for-compatible-with-Unix-world-by-implement-td4045412.html
|
||||
|
||||
so I'm not sure what is correct, but I do need to find out
|
||||
*/
|
||||
#include <limits.h>
|
||||
#if WCHAR_MAX > 0xFFFF
|
||||
#error unexpected: wchar_t larger than 16-bit on a Windows ABI build; contact andlabs with your build setup information
|
||||
#endif
|
||||
|
|
|
@ -591,9 +591,106 @@ static INT_PTR CALLBACK fontDialogDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
// because Windows doesn't really support resources in static libraries, we have to embed this directly; oh well
|
||||
/*
|
||||
// this is for our custom DirectWrite-based font dialog (see fontdialog.cpp)
|
||||
// this is based on the "New Font Dialog with Syslink" in Microsoft's font.dlg
|
||||
// LONGTERM look at localization
|
||||
// LONGTERM make it look tighter and nicer like the real one, including the actual heights of the font family and style comboboxes
|
||||
rcFontDialog DIALOGEX 13, 54, 243, 200
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK
|
||||
CAPTION "Font"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "&Font:", -1, 7, 7, 98, 9
|
||||
COMBOBOX rcFontFamilyCombobox, 7, 16, 98, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
LTEXT "Font st&yle:", -1, 114, 7, 74, 9
|
||||
COMBOBOX rcFontStyleCombobox, 114, 16, 74, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
LTEXT "&Size:", -1, 198, 7, 36, 9
|
||||
COMBOBOX rcFontSizeCombobox, 198, 16, 36, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
GROUPBOX "Sample", -1, 7, 97, 227, 70, WS_GROUP
|
||||
CTEXT "AaBbYyZz", rcFontSamplePlacement, 9, 106, 224, 60, SS_NOPREFIX | NOT WS_VISIBLE
|
||||
|
||||
DEFPUSHBUTTON "OK", IDOK, 141, 181, 45, 14, WS_GROUP
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 190, 181, 45, 14, WS_GROUP
|
||||
END
|
||||
*/
|
||||
static const uint8_t data_rcFontDialog[] = {
|
||||
0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xC4, 0x00, 0xC8, 0x80,
|
||||
0x0A, 0x00, 0x0D, 0x00, 0x36, 0x00, 0xF3, 0x00,
|
||||
0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00,
|
||||
0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x00, 0x00,
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x53, 0x00,
|
||||
0x65, 0x00, 0x67, 0x00, 0x6F, 0x00, 0x65, 0x00,
|
||||
0x20, 0x00, 0x55, 0x00, 0x49, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x02, 0x50, 0x07, 0x00, 0x07, 0x00,
|
||||
0x62, 0x00, 0x09, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0x82, 0x00, 0x26, 0x00, 0x46, 0x00,
|
||||
0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00, 0x3A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x41, 0x0B, 0x21, 0x50,
|
||||
0x07, 0x00, 0x10, 0x00, 0x62, 0x00, 0x4C, 0x00,
|
||||
0xE8, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x85, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0x72, 0x00, 0x07, 0x00, 0x4A, 0x00, 0x09, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x46, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x74, 0x00,
|
||||
0x20, 0x00, 0x73, 0x00, 0x74, 0x00, 0x26, 0x00,
|
||||
0x79, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x3A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x41, 0x0A, 0x21, 0x50,
|
||||
0x72, 0x00, 0x10, 0x00, 0x4A, 0x00, 0x4C, 0x00,
|
||||
0xE9, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x85, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x50,
|
||||
0xC6, 0x00, 0x07, 0x00, 0x24, 0x00, 0x09, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x26, 0x00, 0x53, 0x00, 0x69, 0x00, 0x7A, 0x00,
|
||||
0x65, 0x00, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x41, 0x0B, 0x21, 0x50, 0xC6, 0x00, 0x10, 0x00,
|
||||
0x24, 0x00, 0x4C, 0x00, 0xEA, 0x03, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0x85, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x07, 0x00, 0x02, 0x50, 0x07, 0x00, 0x61, 0x00,
|
||||
0xE3, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0x80, 0x00, 0x53, 0x00, 0x61, 0x00,
|
||||
0x6D, 0x00, 0x70, 0x00, 0x6C, 0x00, 0x65, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x02, 0x40,
|
||||
0x09, 0x00, 0x6A, 0x00, 0xE0, 0x00, 0x3C, 0x00,
|
||||
0xEB, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0x82, 0x00,
|
||||
0x41, 0x00, 0x61, 0x00, 0x42, 0x00, 0x62, 0x00,
|
||||
0x59, 0x00, 0x79, 0x00, 0x5A, 0x00, 0x7A, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x50,
|
||||
0x8D, 0x00, 0xB5, 0x00, 0x2D, 0x00, 0x0E, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0x00,
|
||||
0x4F, 0x00, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x03, 0x50, 0xBE, 0x00, 0xB5, 0x00,
|
||||
0x2D, 0x00, 0x0E, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0xFF, 0xFF, 0x80, 0x00, 0x43, 0x00, 0x61, 0x00,
|
||||
0x6E, 0x00, 0x63, 0x00, 0x65, 0x00, 0x6C, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static_assert(ARRAYSIZE(data_rcFontDialog) == 476, "wrong size for resource rcFontDialog");
|
||||
|
||||
BOOL uiprivShowFontDialog(HWND parent, struct fontDialogParams *params)
|
||||
{
|
||||
switch (DialogBoxParamW(hInstance, MAKEINTRESOURCE(rcFontDialog), parent, fontDialogDlgProc, (LPARAM) params)) {
|
||||
switch (DialogBoxIndirectParamW(hInstance, (const DLGTEMPLATE *) data_rcFontDialog, parent, fontDialogDlgProc, (LPARAM) params)) {
|
||||
case 1: // cancel
|
||||
return FALSE;
|
||||
case 2: // ok
|
||||
|
|
|
@ -128,3 +128,15 @@ void uiQueueMain(void (*f)(void *data), void *data)
|
|||
// LONGTERM this is likely not safe to call across threads (allocates memory)
|
||||
logLastError(L"error queueing function to run on main thread");
|
||||
}
|
||||
|
||||
void uiTimer(int milliseconds, int (*f)(void *data), void *data)
|
||||
{
|
||||
uiprivTimer *timer;
|
||||
|
||||
timer = uiprivNew(uiprivTimer);
|
||||
timer->f = f;
|
||||
timer->data = data;
|
||||
// note that timer IDs are pointer sized precisely so we can use them as timer IDs; see https://blogs.msdn.microsoft.com/oldnewthing/20150924-00/?p=91521
|
||||
if (SetTimer(utilWindow, (UINT_PTR) timer, milliseconds, NULL) == 0)
|
||||
logLastError(L"error calling SetTimer() in uiTimer()");
|
||||
}
|
||||
|
|
|
@ -11,86 +11,3 @@
|
|||
#ifndef _UI_STATIC
|
||||
ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "libui.manifest"
|
||||
#endif
|
||||
|
||||
// this is the dialog template used by tab pages; see windows/tabpage.c for details
|
||||
rcTabPageDialog DIALOGEX 0, 0, 100, 100
|
||||
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE
|
||||
EXSTYLE WS_EX_CONTROLPARENT
|
||||
BEGIN
|
||||
// nothing
|
||||
END
|
||||
|
||||
// this is for our custom DirectWrite-based font dialog (see fontdialog.cpp)
|
||||
// this is based on the "New Font Dialog with Syslink" in Microsoft's font.dlg
|
||||
// LONGTERM look at localization
|
||||
// LONGTERM make it look tighter and nicer like the real one, including the actual heights of the font family and style comboboxes
|
||||
rcFontDialog DIALOGEX 13, 54, 243, 200
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK
|
||||
CAPTION "Font"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
LTEXT "&Font:", -1, 7, 7, 98, 9
|
||||
COMBOBOX rcFontFamilyCombobox, 7, 16, 98, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
LTEXT "Font st&yle:", -1, 114, 7, 74, 9
|
||||
COMBOBOX rcFontStyleCombobox, 114, 16, 74, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
LTEXT "&Size:", -1, 198, 7, 36, 9
|
||||
COMBOBOX rcFontSizeCombobox, 198, 16, 36, 76,
|
||||
CBS_SIMPLE | CBS_AUTOHSCROLL | CBS_DISABLENOSCROLL |
|
||||
CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_HASSTRINGS
|
||||
|
||||
GROUPBOX "Sample", -1, 7, 97, 227, 70, WS_GROUP
|
||||
CTEXT "AaBbYyZz", rcFontSamplePlacement, 9, 106, 224, 60, SS_NOPREFIX | NOT WS_VISIBLE
|
||||
|
||||
DEFPUSHBUTTON "OK", IDOK, 141, 181, 45, 14, WS_GROUP
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 190, 181, 45, 14, WS_GROUP
|
||||
END
|
||||
|
||||
rcColorDialog DIALOGEX 13, 54, 344, 209
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_3DLOOK
|
||||
CAPTION "Color"
|
||||
FONT 9, "Segoe UI"
|
||||
BEGIN
|
||||
// this size should be big enough to get at least 256x256 on font sizes >= 8 pt
|
||||
CTEXT "AaBbYyZz", rcColorSVChooser, 7, 7, 195, 195, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
// width is the suggested slider height since this is vertical
|
||||
CTEXT "AaBbYyZz", rcColorHSlider, 206, 7, 15, 195, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "Preview:", -1, 230, 7, 107, 9, SS_NOPREFIX
|
||||
CTEXT "AaBbYyZz", rcPreview, 230, 16, 107, 20, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "Opacity:", -1, 230, 45, 107, 9, SS_NOPREFIX
|
||||
CTEXT "AaBbYyZz", rcOpacitySlider, 230, 54, 107, 15, SS_NOPREFIX | SS_BLACKRECT
|
||||
|
||||
LTEXT "&H:", rcHLabel, 230, 81, 8, 8
|
||||
EDITTEXT rcH, 238, 78, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&S:", rcSLabel, 230, 95, 8, 8
|
||||
EDITTEXT rcS, 238, 92, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&V:", rcVLabel, 230, 109, 8, 8
|
||||
EDITTEXT rcV, 238, 106, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
LTEXT "&R:", rcRLabel, 277, 81, 8, 8
|
||||
EDITTEXT rcRDouble, 285, 78, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcRInt, 315, 78, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&G:", rcGLabel, 277, 95, 8, 8
|
||||
EDITTEXT rcGDouble, 285, 92, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcGInt, 315, 92, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&B:", rcBLabel, 277, 109, 8, 8
|
||||
EDITTEXT rcBDouble, 285, 106, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcBInt, 315, 106, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
LTEXT "&A:", rcALabel, 277, 123, 8, 8
|
||||
EDITTEXT rcADouble, 285, 120, 30, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
EDITTEXT rcAInt, 315, 120, 20, 14, ES_LEFT | ES_AUTOHSCROLL | ES_NUMBER | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
LTEXT "He&x:", rcHexLabel, 269, 146, 16, 8
|
||||
EDITTEXT rcHex, 285, 143, 50, 14, ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP, WS_EX_CLIENTEDGE
|
||||
|
||||
DEFPUSHBUTTON "OK", IDOK, 243, 188, 45, 14, WS_GROUP
|
||||
PUSHBUTTON "Cancel", IDCANCEL, 292, 188, 45, 14, WS_GROUP
|
||||
END
|
||||
|
|
|
@ -78,6 +78,24 @@ static INT_PTR CALLBACK dlgproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
// because Windows doesn't really support resources in static libraries, we have to embed this directly; oh well
|
||||
/*
|
||||
// this is the dialog template used by tab pages; see windows/tabpage.c for details
|
||||
rcTabPageDialog DIALOGEX 0, 0, 100, 100
|
||||
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE
|
||||
EXSTYLE WS_EX_CONTROLPARENT
|
||||
BEGIN
|
||||
// nothing
|
||||
END
|
||||
*/
|
||||
static const uint8_t data_rcTabPageDialog[] = {
|
||||
0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x00, 0x50,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00,
|
||||
0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static_assert(ARRAYSIZE(data_rcTabPageDialog) == 32, "wrong size for resource rcTabPageDialog");
|
||||
|
||||
struct tabPage *newTabPage(uiControl *child)
|
||||
{
|
||||
struct tabPage *tp;
|
||||
|
@ -86,7 +104,7 @@ struct tabPage *newTabPage(uiControl *child)
|
|||
tp = uiprivNew(struct tabPage);
|
||||
|
||||
// unfortunately this needs to be a proper dialog for EnableThemeDialogTexture() to work; CreateWindowExW() won't suffice
|
||||
if (CreateDialogParamW(hInstance, MAKEINTRESOURCE(rcTabPageDialog),
|
||||
if (CreateDialogIndirectParamW(hInstance, (const DLGTEMPLATE *) data_rcTabPageDialog,
|
||||
utilWindow, dlgproc, (LPARAM) tp) == NULL)
|
||||
logLastError(L"error creating tab page");
|
||||
|
||||
|
|
|
@ -95,6 +95,12 @@ extern const char *initUtilWindow(HICON hDefaultIcon, HCURSOR hDefaultCursor);
|
|||
extern void uninitUtilWindow(void);
|
||||
|
||||
// main.cpp
|
||||
// TODO how the hell did MSVC accept this without the second uiprivTimer???????
|
||||
typedef struct uiprivTimer uiprivTimer;
|
||||
struct uiprivTimer {
|
||||
int (*f)(void *);
|
||||
void *data;
|
||||
};
|
||||
extern int registerMessageFilter(void);
|
||||
extern void unregisterMessageFilter(void);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ static LRESULT CALLBACK utilWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
|
|||
{
|
||||
void (*qf)(void *);
|
||||
LRESULT lResult;
|
||||
uiprivTimer *timer;
|
||||
|
||||
if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
|
||||
return lResult;
|
||||
|
@ -36,6 +37,14 @@ static LRESULT CALLBACK utilWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
|
|||
qf = (void (*)(void *)) wParam;
|
||||
(*qf)((void *) lParam);
|
||||
return 0;
|
||||
case WM_TIMER:
|
||||
timer = (uiprivTimer *) wParam;
|
||||
if (!(*(timer->f))(timer->data)) {
|
||||
if (KillTimer(utilWindow, (UINT_PTR) timer) == 0)
|
||||
logLastError(L"error calling KillTimer() to end uiTimer() procedure");
|
||||
uiprivFree(timer);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
#define _WIN32_IE 0x0700
|
||||
#define NTDDI_VERSION 0x06000000
|
||||
|
||||
// The MinGW-w64 header has an unverified IDWriteTypography definition.
|
||||
// TODO I can confirm this myself, but I don't know how long it will take for them to note my adjustments... Either way, I have to confirm this myself.
|
||||
// TODO change the check from _MSC_VER to a MinGW-w64-specific check
|
||||
// TODO keep track of what else is guarded by this
|
||||
#ifndef _MSC_VER
|
||||
#define __MINGW_USE_BROKEN_INTERFACE
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle
|
||||
|
|
Loading…
Reference in New Issue