Added a user bug for calling SetParent() on a uiWindow.

This commit is contained in:
Pietro Gagliardi 2016-05-22 20:02:47 -04:00
parent b957558ef4
commit ab0a9102b4
7 changed files with 43 additions and 14 deletions

View File

@ -21,6 +21,7 @@ This README is being written.<br>
* Added `uiNewNonWrappingMultilineEntry()`, which creates a uiMultilineEntry that scrolls horizontally instead of wrapping lines. (This is not documented as being changeable after the fact on Windows, hence it's a creation-time choice.)
* uiAreas on Windows and some internal Direct2D areas now respond to `WM_PRINTCLIENT` properly, which should hopefully increase the quality of screenshots.
* uiDateTimePicker on GTK+ works properly on RTL layouts and no longer disappears off the bottom of the screen if not enough room is available. It will also no longer be marked for localization of the time format (what the separator should be and whether to use 24-hour time), as that information is not provided by the locale system. :(
* Added `uiUserBugCannotSetParentOnToplevel()`, which should be used by implementations of toplevel controls in their `SetParent()` implementations. This will also be the beginning of consolidating common user bug messages into a single place, though this will be one of the only few exported user bug functions.
## Runtime Requirements

View File

@ -5,7 +5,8 @@ CFILES += \
common/control.c \
common/debug.c \
common/matrix.c \
common/shouldquit.c
common/shouldquit.c \
common/userbugs.c
HFILES += \
common/controlsigs.h \

8
common/userbugs.c Normal file
View File

@ -0,0 +1,8 @@
// 22 may 2016
#include "../ui.h"
#include "uipriv.h"
void uiUserBugCannotSetParentOnToplevel(const char *type)
{
userbug("You cannot make a %s a child of another uiControl,", type);
}

View File

@ -98,10 +98,16 @@ static void uiWindowDestroy(uiControl *c)
}
uiDarwinControlDefaultHandle(uiWindow, window)
// TODO?
uiDarwinControlDefaultParent(uiWindow, window)
uiDarwinControlDefaultSetParent(uiWindow, window)
// end TODO
uiControl *uiWindowParent(uiControl *c)
{
return NULL;
}
void uiWindowSetParent(uiControl *c, uiControl *parent)
{
uiUserBugCannotSetParentOnToplevel("uiWindow");
}
static int uiWindowToplevel(uiControl *c)
{

3
ui.h
View File

@ -38,7 +38,6 @@ _UI_EXTERN void uiFreeInitError(const char *err);
_UI_EXTERN void uiMain(void);
_UI_EXTERN void uiQuit(void);
// TODO write a test for this after adding multiline entries
_UI_EXTERN void uiQueueMain(void (*f)(void *data), void *data);
_UI_EXTERN void uiOnShouldQuit(int (*f)(void *data), void *data);
@ -84,6 +83,8 @@ _UI_EXTERN void uiFreeControl(uiControl *);
_UI_EXTERN void uiControlVerifySetParent(uiControl *, uiControl *);
_UI_EXTERN int uiControlEnabledToUser(uiControl *);
_UI_EXTERN void uiUserBugCannotSetParentOnToplevel(const char *type);
typedef struct uiWindow uiWindow;
#define uiWindow(this) ((uiWindow *) (this))
_UI_EXTERN char *uiWindowTitle(uiWindow *w);

View File

@ -56,10 +56,16 @@ static void uiWindowDestroy(uiControl *c)
}
uiUnixControlDefaultHandle(uiWindow)
// TODO?
uiUnixControlDefaultParent(uiWindow)
uiUnixControlDefaultSetParent(uiWindow)
// end TODO
uiControl *uiWindowParent(uiControl *c)
{
return NULL;
}
void uiWindowSetParent(uiControl *c, uiControl *parent)
{
uiUserBugCannotSetParentOnToplevel("uiWindow");
}
static int uiWindowToplevel(uiControl *c)
{

View File

@ -161,10 +161,16 @@ static void uiWindowDestroy(uiControl *c)
}
uiWindowsControlDefaultHandle(uiWindow)
// TODO?
uiWindowsControlDefaultParent(uiWindow)
uiWindowsControlDefaultSetParent(uiWindow)
// end TODO
uiControl *uiWindowParent(uiControl *c)
{
return NULL;
}
void uiWindowSetParent(uiControl *c, uiControl *parent)
{
uiUserBugCannotSetParentOnToplevel("uiWindow");
}
static int uiWindowToplevel(uiControl *c)
{