Got rid of toplevelOwning(); I didn't like that one.

This commit is contained in:
Pietro Gagliardi 2016-04-24 18:23:00 -04:00
parent bc0a1d43c9
commit cf51ec823f
7 changed files with 25 additions and 28 deletions

View File

@ -33,26 +33,12 @@ uiControl *uiControlParent(uiControl *c)
return cb->parent;
}
// TODO ask the control instead
int isToplevel(uiControl *c)
{
return c->TypeSignature == uiWindowSignature;
}
// returns self if self is a window
uiControl *toplevelOwning(uiControl *c)
{
struct controlBase *cb;
for (;;) {
if (isToplevel(c))
return c;
cb = controlBase(c);
if (cb->parent == NULL)
return NULL;
c = cb->parent;
}
}
void uiControlSetParent(uiControl *c, uiControl *parent)
{
struct controlBase *cb = controlBase(c);

View File

@ -17,7 +17,6 @@ extern void uiFree(void *);
extern void complain(const char *, ...);
extern int isToplevel(uiControl *);
extern uiControl *toplevelOwning(uiControl *);
extern int controlSelfVisible(uiControl *);
extern void controlUpdateState(uiControl *);

View File

@ -1,13 +1,20 @@
// 16 august 2015
#import "uipriv_darwin.h"
// TODO refine this
void uiDarwinControlTriggerRelayout(uiDarwinControl *c)
{
uiControl *p;
NSView *view;
uiWindow *p;
p = toplevelOwning(uiControl(c));
if (p == NULL) // not in a window
return;
view = (NSView *) uiControlHandle(uiControl(c));
// this can be a NSWindow
if (![view isKindOfClass:[NSWindow class]]) {
p = windowFromNSWindow([view window]);
if (p == NULL) // not in a window
return;
} else
p = uiWindow(c);
c = uiDarwinControl(p);
(*(c->Relayout))(uiDarwinControl(c));
}

View File

@ -111,12 +111,14 @@ uiFontButton *uiNewFontButton(void)
TRUE);
loadInitialFontDialogParams(&(b->params));
updateFontButtonLabel(b);
uiWindowsRegisterWM_COMMANDHandler(b->hwnd, onWM_COMMAND, uiControl(b));
uiFontButtonOnChanged(b, defaultOnChanged, NULL);
uiWindowsFinishNewControl(b, uiFontButton);
// TODO move this back above the previous when merging with uiNewControl(); it's here because this calls Handle()
updateFontButtonLabel(b);
return b;
}

View File

@ -3,17 +3,20 @@
static std::map<uiWindowsControl *, bool> resizes;
// TODO clicking buttons doesn't get rid of anything?
void uiWindowsControlQueueRelayout(uiWindowsControl *c)
{
uiControl *cc;
HWND hwnd;
HWND parent;
uintmax_t i;
// resizing a control requires us to reocmpute the sizes of everything in the top-level window
// TODO get rid of this call, make one for finding the root through the HWND
cc = toplevelOwning(uiControl(c));
if (cc == NULL)
hwnd = (HWND) uiControlHandle(uiControl(c));
// TODO what if this is toplevel
parent = parentToplevel(hwnd);
if (parent == utilWindow) // not in a parent
return;
c = uiWindowsControl(cc);
c = uiWindowsControl(SendMessageW(parent, msgGetuiWindow, 0, 0));
resizes[c] = true;
}

View File

@ -44,6 +44,8 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
return lResult;
switch (uMsg) {
case msgGetuiWindow:
return (LRESULT) w;
case WM_COMMAND:
// not a menu
if (lParam != 0)

View File

@ -135,8 +135,6 @@ HWND parentToplevel(HWND child)
return GetAncestor(child, GA_ROOT);
}
/////////////
void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
{
RECT r;