Some TODO resolution in the Windows backend.

This commit is contained in:
Pietro Gagliardi 2016-05-06 16:06:55 -04:00
parent 4444b79c30
commit 9e0ff2e000
5 changed files with 18 additions and 13 deletions

View File

@ -4,6 +4,7 @@
// notes:
// - FOS_SUPPORTSTREAMABLEITEMS doesn't seem to be supported on windows vista, or at least not with the flags we use
// - even with FOS_NOVALIDATE the dialogs will reject invalid filenames (at least on Vista, anyway)
// - lack of FOS_NOREADONLYRETURN doesn't seem to matter on Windows 7
// TODO
// - http://blogs.msdn.com/b/wpfsdk/archive/2006/10/26/uncommon-dialogs--font-chooser-and-color-picker-dialogs.aspx
@ -35,6 +36,8 @@ char *commonItemDialog(HWND parent, REFCLSID clsid, REFIID iid, FILEOPENDIALOGOP
goto out;
}
opts |= optsadd;
// the other platforms don't check read-only; we won't either
opts &= ~FOS_NOREADONLYRETURN;
hr = d->SetOptions(opts);
if (hr != S_OK) {
logHRESULT(L"error setting options", hr);
@ -81,7 +84,6 @@ char *uiSaveFile(uiWindow *parent)
{
return commonItemDialog(windowHWND(parent),
CLSID_FileSaveDialog, IID_IFileSaveDialog,
// TODO strip FOS_NOREADONLYRETURN?
FOS_OVERWRITEPROMPT | FOS_NOCHANGEDIR | FOS_ALLNONSTORAGEITEMS | FOS_NOVALIDATE | FOS_SHAREAWARE | FOS_NOTESTFILECREATE | FOS_NODEREFERENCELINKS | FOS_FORCESHOWHIDDEN | FOS_DEFAULTNOMINIMODE);
}

View File

@ -1,10 +1,8 @@
// 16 may 2015
#include "uipriv_windows.hpp"
// TODO
// - write comment here about how tabs and parents work
// - make sure parent Z-orders are always above tab Z-orders
// - commit show/hide/enable/disable
// You don't add controls directly to a tab control on Windows; instead you make them siblings and swap between them on a TCN_SELCHANGING/TCN_SELCHANGE notification pair.
// In addition, you use dialogs because they can be textured properly; other controls cannot. (Things will look wrong if the tab background in the current theme is fancy if you just use the tab background by itself; see http://stackoverflow.com/questions/30087540/why-are-my-programss-tab-controls-rendering-their-background-in-a-blocky-way-b.)
struct uiTab {
uiWindowsControl c;
@ -200,7 +198,6 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
page = newTabPage(child);
uiWindowsEnsureSetParentHWND(page->hwnd, t->hwnd);
t->pages->insert(t->pages->begin() + n, page);
// TODO adjust tabpage.cpp to set the sole control ID
tabArrangePages(t);
ZeroMemory(&item, sizeof (TCITEMW));

View File

@ -91,7 +91,10 @@ struct tabPage *newTabPage(uiControl *child)
logLastError(L"error creating tab page");
tp->child = child;
uiWindowsEnsureSetParentHWND((HWND) uiControlHandle(tp->child), tp->hwnd);
if (tp->child != NULL) {
uiWindowsEnsureSetParentHWND((HWND) uiControlHandle(tp->child), tp->hwnd);
uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl(tp->child));
}
hr = EnableThemeDialogTexture(tp->hwnd, ETDT_ENABLE | ETDT_USETABTEXTURE | ETDT_ENABLETAB);
if (hr != S_OK)
@ -109,7 +112,7 @@ void tabPageDestroy(struct tabPage *tp)
// don't destroy the child with the page
if (tp->child != NULL)
uiWindowsControlSetParentHWND(uiWindowsControl(tp->child), NULL);
// TODO call EndDialog() instead?
// don't call EndDialog(); that's for the DialogBox() family of functions instead of CreateDialog()
uiWindowsEnsureDestroyWindow(tp->hwnd);
uiFree(tp);
}

View File

@ -13,7 +13,7 @@ enum {
msgNOTIFY,
msgHSCROLL,
msgQueued,
// TODO convert to a function like with container
// TODO convert to a function like with container?
msgD2DScratchPaint,
};

View File

@ -56,8 +56,7 @@ WCHAR *utf16dup(const WCHAR *orig)
len = wcslen(orig);
out = (WCHAR *) uiAlloc((len + 1) * sizeof (WCHAR), "WCHAR[]");
// TODO safer version
wcscpy(out, orig);
wcscpy_s(out, len + 1, orig);
return out;
}
@ -117,6 +116,7 @@ WCHAR *debugvstrf(const WCHAR *format, va_list ap)
}
// Let's shove these utility routines here too.
// Prerequisite: lfonly is UTF-8.
char *LFtoCRLF(const char *lfonly)
{
char *crlf;
@ -135,16 +135,19 @@ char *LFtoCRLF(const char *lfonly)
return out;
}
// Prerequisite: s is UTF-8.
void CRLFtoLF(char *s)
{
char *t = s;
for (; *s; s++) {
for (; *s != '\0'; s++) {
// be sure to preserve \rs that are genuinely there
if (*s == '\r' && *(s + 1) == '\n')
continue;
*t++ = *s;
}
*t = '\0';
// TODO null pad t to s?
// pad out the rest of t, just to be safe
while (t != s)
*t++ = '\0';
}