Some TODO resolution.

This commit is contained in:
Pietro Gagliardi 2016-05-22 13:09:13 -04:00
parent 3705ef05d1
commit d060744f87
4 changed files with 12 additions and 6 deletions

View File

@ -932,8 +932,7 @@ static void fixupControlPositions(struct colorDialog *c)
labelA, c->editADouble, c->editAInt, labelA, c->editADouble, c->editAInt,
NULL); NULL);
// TODO this uses the message font, not the dialog font getSizing(c->hwnd, &sizing, (HFONT) SendMessageW(labelH, WM_GETFONT, 0, 0));
uiWindowsGetSizing(c->hwnd, &sizing);
offset = sizing.InternalLeading; offset = sizing.InternalLeading;
moveWindowsUp(c, offset, moveWindowsUp(c, offset,
labelH, labelS, labelV, labelH, labelS, labelV,

View File

@ -2,7 +2,7 @@
#include "uipriv_windows.hpp" #include "uipriv_windows.hpp"
// TODO rework the error handling // TODO rework the error handling
void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing) void getSizing(HWND hwnd, uiWindowsSizing *sizing, HFONT font)
{ {
HDC dc; HDC dc;
HFONT prevfont; HFONT prevfont;
@ -12,7 +12,7 @@ void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing)
dc = GetDC(hwnd); dc = GetDC(hwnd);
if (dc == NULL) if (dc == NULL)
logLastError(L"error getting DC"); logLastError(L"error getting DC");
prevfont = (HFONT) SelectObject(dc, hMessageFont); prevfont = (HFONT) SelectObject(dc, font);
if (prevfont == NULL) if (prevfont == NULL)
logLastError(L"error loading control font into device context"); logLastError(L"error loading control font into device context");
@ -26,12 +26,17 @@ void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing)
sizing->BaseY = (int) tm.tmHeight; sizing->BaseY = (int) tm.tmHeight;
sizing->InternalLeading = tm.tmInternalLeading; sizing->InternalLeading = tm.tmInternalLeading;
if (SelectObject(dc, prevfont) != hMessageFont) if (SelectObject(dc, prevfont) != font)
logLastError(L"error restoring previous font into device context"); logLastError(L"error restoring previous font into device context");
if (ReleaseDC(hwnd, dc) == 0) if (ReleaseDC(hwnd, dc) == 0)
logLastError(L"error releasing DC"); logLastError(L"error releasing DC");
} }
void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing)
{
return getSizing(hwnd, sizing, hMessageFont);
}
#define dlgUnitsToX(dlg, baseX) MulDiv((dlg), (baseX), 4) #define dlgUnitsToX(dlg, baseX) MulDiv((dlg), (baseX), 4)
#define dlgUnitsToY(dlg, baseY) MulDiv((dlg), (baseY), 8) #define dlgUnitsToY(dlg, baseY) MulDiv((dlg), (baseY), 8)

View File

@ -137,6 +137,9 @@ struct colorDialogRGBA {
}; };
extern BOOL showColorDialog(HWND parent, struct colorDialogRGBA *c); extern BOOL showColorDialog(HWND parent, struct colorDialogRGBA *c);
// sizing.cpp
extern void getSizing(HWND hwnd, uiWindowsSizing *sizing, HFONT font);

View File

@ -185,7 +185,6 @@ static void uiWindowShow(uiControl *c)
w->visible = 1; w->visible = 1;
// just in case the window's minimum size wasn't recalculated already // just in case the window's minimum size wasn't recalculated already
// TODO is it needed?
ensureMinimumWindowSize(w); ensureMinimumWindowSize(w);
if (w->shownOnce) { if (w->shownOnce) {
ShowWindow(w->hwnd, SW_SHOW); ShowWindow(w->hwnd, SW_SHOW);