From 454b3ecb031e46f2bcc25f562558a2cf337b8645 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 2 May 2015 20:51:00 -0400 Subject: [PATCH] Changed the various OS-side control creation functions to use Make like uiMakeContainer() does instead of New. --- darwin/button.m | 2 +- darwin/checkbox.m | 2 +- darwin/entry.m | 2 +- darwin/label.m | 2 +- darwin/newcontrol.m | 2 +- darwin/tab.m | 2 +- ui.idl | 1 - ui_darwin.h | 4 ++-- ui_unix.h | 4 ++-- ui_windows.h | 8 ++++---- unix/button.c | 2 +- unix/checkbox.c | 2 +- unix/entry.c | 2 +- unix/label.c | 2 +- unix/newcontrol.c | 2 +- unix/tab.c | 2 +- windows/button.c | 4 ++-- windows/checkbox.c | 4 ++-- windows/entry.c | 4 ++-- windows/label.c | 4 ++-- windows/newcontrol.c | 6 +++--- windows/tab.c | 4 ++-- 22 files changed, 33 insertions(+), 34 deletions(-) diff --git a/darwin/button.m b/darwin/button.m index b05c65f3..b7caefd1 100644 --- a/darwin/button.m +++ b/darwin/button.m @@ -78,7 +78,7 @@ uiButton *uiNewButton(const char *text) b = uiNew(struct button); - uiDarwinNewControl(uiControl(b), [NSButton class], NO, NO, destroy, b); + uiDarwinMakeControl(uiControl(b), [NSButton class], NO, NO, destroy, b); b->button = (NSButton *) uiControlHandle(uiControl(b)); diff --git a/darwin/checkbox.m b/darwin/checkbox.m index 7d210f5f..3bc79b87 100644 --- a/darwin/checkbox.m +++ b/darwin/checkbox.m @@ -96,7 +96,7 @@ uiCheckbox *uiNewCheckbox(const char *text) c = uiNew(struct checkbox); - uiDarwinNewControl(uiControl(c), [NSButton class], NO, NO, destroy, c); + uiDarwinMakeControl(uiControl(c), [NSButton class], NO, NO, destroy, c); c->checkbox = (NSButton *) uiControlHandle(uiControl(c)); diff --git a/darwin/entry.m b/darwin/entry.m index f42d043f..90cf8202 100644 --- a/darwin/entry.m +++ b/darwin/entry.m @@ -49,7 +49,7 @@ uiEntry *uiNewEntry(void) e = uiNew(struct entry); - uiDarwinNewControl(uiControl(e), [NSTextField class], NO, NO, destroy, e); + uiDarwinMakeControl(uiControl(e), [NSTextField class], NO, NO, destroy, e); e->textfield = (NSTextField *) uiControlHandle(uiControl(e)); diff --git a/darwin/label.m b/darwin/label.m index 0b3cfc28..8160c2b4 100644 --- a/darwin/label.m +++ b/darwin/label.m @@ -33,7 +33,7 @@ uiLabel *uiNewLabel(const char *text) l = uiNew(struct label); - uiDarwinNewControl(uiControl(l), [NSTextField class], NO, NO, destroy, l); + uiDarwinMakeControl(uiControl(l), [NSTextField class], NO, NO, destroy, l); l->label = (NSTextField *) uiControlHandle(uiControl(l)); diff --git a/darwin/newcontrol.m b/darwin/newcontrol.m index 71146ac2..c16b2ab0 100644 --- a/darwin/newcontrol.m +++ b/darwin/newcontrol.m @@ -124,7 +124,7 @@ static void singleDisable(uiControl *c) [((NSControl *) (s->view)) setEnabled:NO]; } -void uiDarwinNewControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder, void (*onDestroy)(void *), void *onDestroyData) +void uiDarwinMakeControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder, void (*onDestroy)(void *), void *onDestroyData) { singleView *s; diff --git a/darwin/tab.m b/darwin/tab.m index a3f678c7..f72ce8e6 100644 --- a/darwin/tab.m +++ b/darwin/tab.m @@ -131,7 +131,7 @@ uiTab *uiNewTab(void) t = uiNew(struct tab); - uiDarwinNewControl(uiControl(t), [NSTabView class], NO, NO, destroy, t); + uiDarwinMakeControl(uiControl(t), [NSTabView class], NO, NO, destroy, t); t->tabview = (NSTabView *) uiControlHandle(uiControl(t)); diff --git a/ui.idl b/ui.idl index 110aaa35..2f44f58c 100644 --- a/ui.idl +++ b/ui.idl @@ -56,7 +56,6 @@ interface Container from Control { func ResizeChildren(x intmax_t, y intmax_t, width intmax_t, height intmax_t, d *Sizing); func Update(void); }; -// TODO change the various OS-side control functions to be Make func MakeContainer(c *Container); interface Window from Control { diff --git a/ui_darwin.h b/ui_darwin.h index cd0b14cb..b6ef7ae3 100644 --- a/ui_darwin.h +++ b/ui_darwin.h @@ -7,11 +7,11 @@ This file assumes that you have imported and "ui.h" beforehand. #ifndef __UI_UI_DARWIN_H__ #define __UI_UI_DARWIN_H__ -// uiDarwinNewControl() initializes the given uiControl with the given Cocoa control inside. +// uiDarwinMakeControl() initializes the given uiControl with the given Cocoa control inside. // The second parameter should come from [RealControlType class]. // The two scrollView parameters allow placing scrollbars on the new control. // The two onDestroy parameters define a function and its parameter to call when the widget is destroyed. -extern void uiDarwinNewControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder, void (*onDestroy)(void *), void *onDestroyData); +extern void uiDarwinMakeControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder, void (*onDestroy)(void *), void *onDestroyData); // You can use this function from within your control implementations to return text strings that can be freed with uiTextFree(). extern char *uiDarwinNSStringToText(NSString *); diff --git a/ui_unix.h b/ui_unix.h index 6453ddc9..7d0cf134 100644 --- a/ui_unix.h +++ b/ui_unix.h @@ -7,12 +7,12 @@ This file assumes that you have included and "ui.h" beforehand. It p #ifndef __UI_UI_UNIX_H__ #define __UI_UI_UNIX_H__ -// uiUnixNewControl() creates a new uiControl with the given GTK+ control inside, storing it in the uiControl at c. +// uiUnixMakeControl() creates a new uiControl with the given GTK+ control inside, storing it in the uiControl at c. // The second parameter is the type of the control, as passed to the first argument of g_object_new(). // The two scrolledWindow parameters allow placing scrollbars on the new control. // The destroy parameters are for a function that should be called when destroying the widget. // The firstProperty parameter and beyond allow passing construct properties to the new control, as with g_object_new(); end this list with NULL. -_UI_EXTERN void uiUnixNewControl(uiControl *c, GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, void (*destroy)(void *), void *onDestroyData, const char *firstProperty, ...); +_UI_EXTERN void uiUnixMakeControl(uiControl *c, GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, void (*destroy)(void *), void *onDestroyData, const char *firstProperty, ...); // uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). extern char *uiUnixStrdupText(const char *); diff --git a/ui_windows.h b/ui_windows.h index 8bd8c8c4..08a50ffc 100644 --- a/ui_windows.h +++ b/ui_windows.h @@ -7,10 +7,10 @@ This file assumes that you have included and "ui.h" beforehand. It p #ifndef __UI_UI_WINDOWS_H__ #define __UI_UI_WINDOWS_H__ -// uiWindowsNewControl() initializes the given uiControl with the given Windows API control inside. +// uiWindowsMakeControl() initializes the given uiControl with the given Windows API control inside. // You will need to provide the preferredSize() method yourself. -typedef struct uiWindowsNewControlParams uiWindowsNewControlParams; -struct uiWindowsNewControlParams { +typedef struct uiWindowsMakeControlParams uiWindowsMakeControlParams; +struct uiWindowsMakeControlParams { // These match the CreateWindowExW() function. DWORD dwExStyle; LPCWSTR lpClassName; @@ -33,7 +33,7 @@ struct uiWindowsNewControlParams { void (*onDestroy)(void *data); void *onDestroyData; }; -void uiWindowsNewControl(uiControl *c, uiWindowsNewControlParams *p); +void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p); // This contains the Windows-specific parts of the uiSizing structure. // baseX and baseY are the dialog base units. diff --git a/unix/button.c b/unix/button.c index 545e258f..3cc240a3 100644 --- a/unix/button.c +++ b/unix/button.c @@ -56,7 +56,7 @@ uiButton *uiNewButton(const char *text) b = uiNew(struct button); - uiUnixNewControl(uiControl(b), GTK_TYPE_BUTTON, + uiUnixMakeControl(uiControl(b), GTK_TYPE_BUTTON, FALSE, FALSE, onDestroy, b, "label", text, NULL); diff --git a/unix/checkbox.c b/unix/checkbox.c index 72eadcd9..7ecfe16c 100644 --- a/unix/checkbox.c +++ b/unix/checkbox.c @@ -80,7 +80,7 @@ uiCheckbox *uiNewCheckbox(const char *text) c = uiNew(struct checkbox); - uiUnixNewControl(uiControl(c), GTK_TYPE_CHECK_BUTTON, + uiUnixMakeControl(uiControl(c), GTK_TYPE_CHECK_BUTTON, FALSE, FALSE, onDestroy, c, "label", text, NULL); diff --git a/unix/entry.c b/unix/entry.c index 9c22d834..8bbf49d7 100644 --- a/unix/entry.c +++ b/unix/entry.c @@ -34,7 +34,7 @@ uiEntry *uiNewEntry(void) e = uiNew(struct entry); - uiUnixNewControl(uiControl(e), GTK_TYPE_ENTRY, + uiUnixMakeControl(uiControl(e), GTK_TYPE_ENTRY, FALSE, FALSE, onDestroy, e, NULL); diff --git a/unix/label.c b/unix/label.c index 182b55c3..5e4859c0 100644 --- a/unix/label.c +++ b/unix/label.c @@ -34,7 +34,7 @@ uiLabel *uiNewLabel(const char *text) l = uiNew(struct label); - uiUnixNewControl(uiControl(l), GTK_TYPE_LABEL, + uiUnixMakeControl(uiControl(l), GTK_TYPE_LABEL, FALSE, FALSE, onDestroy, l, "label", text, "xalign", 0.0, // note: must be a float constant, otherwise the ... will turn it into an int and we get segfaults on some platforms (thanks ebassi in irc.gimp.net/#gtk+) diff --git a/unix/newcontrol.c b/unix/newcontrol.c index f22843d2..5c7a1de7 100644 --- a/unix/newcontrol.c +++ b/unix/newcontrol.c @@ -124,7 +124,7 @@ static void singleDisable(uiControl *c) gtk_widget_set_sensitive(s->immediate, FALSE); } -void uiUnixNewControl(uiControl *c, GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, void (*onDestroy)(void *), void *onDestroyData, const char *firstProperty, ...) +void uiUnixMakeControl(uiControl *c, GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, void (*onDestroy)(void *), void *onDestroyData, const char *firstProperty, ...) { singleWidget *s; va_list ap; diff --git a/unix/tab.c b/unix/tab.c index 79bf57c5..8a04cb54 100644 --- a/unix/tab.c +++ b/unix/tab.c @@ -112,7 +112,7 @@ uiTab *uiNewTab(void) t = uiNew(struct tab); - uiUnixNewControl(uiControl(t), GTK_TYPE_NOTEBOOK, + uiUnixMakeControl(uiControl(t), GTK_TYPE_NOTEBOOK, FALSE, FALSE, onDestroy, t, NULL); diff --git a/windows/button.c b/windows/button.c index 7219ca60..812f5174 100644 --- a/windows/button.c +++ b/windows/button.c @@ -81,7 +81,7 @@ static void buttonOnClicked(uiButton *bb, void (*f)(uiButton *, void *), void *d uiButton *uiNewButton(const char *text) { struct button *b; - uiWindowsNewControlParams p; + uiWindowsMakeControlParams p; WCHAR *wtext; b = uiNew(struct button); @@ -97,7 +97,7 @@ uiButton *uiNewButton(const char *text) p.onWM_NOTIFY = onWM_NOTIFY; p.onDestroy = onDestroy; p.onDestroyData = b; - uiWindowsNewControl(uiControl(b), &p); + uiWindowsMakeControl(uiControl(b), &p); uiFree(wtext); b->hwnd = (HWND) uiControlHandle(uiControl(b)); diff --git a/windows/checkbox.c b/windows/checkbox.c index b5bd6c56..3ad2c75c 100644 --- a/windows/checkbox.c +++ b/windows/checkbox.c @@ -96,7 +96,7 @@ static void checkboxSetChecked(uiCheckbox *cc, int checked) uiCheckbox *uiNewCheckbox(const char *text) { struct checkbox *c; - uiWindowsNewControlParams p; + uiWindowsMakeControlParams p; WCHAR *wtext; c = uiNew(struct checkbox); @@ -112,7 +112,7 @@ uiCheckbox *uiNewCheckbox(const char *text) p.onWM_NOTIFY = onWM_NOTIFY; p.onDestroy = onDestroy; p.onDestroyData = c; - uiWindowsNewControl(uiControl(c), &p); + uiWindowsMakeControl(uiControl(c), &p); uiFree(wtext); c->hwnd = (HWND) uiControlHandle(uiControl(c)); diff --git a/windows/entry.c b/windows/entry.c index 62ab8cf3..634be397 100644 --- a/windows/entry.c +++ b/windows/entry.c @@ -46,7 +46,7 @@ static void entrySetText(uiEntry *e, const char *text) uiEntry *uiNewEntry(void) { struct entry *e; - uiWindowsNewControlParams p; + uiWindowsMakeControlParams p; e = uiNew(struct entry); @@ -60,7 +60,7 @@ uiEntry *uiNewEntry(void) p.onWM_NOTIFY = onWM_NOTIFY; p.onDestroy = onDestroy; p.onDestroyData = e; - uiWindowsNewControl(uiControl(e), &p); + uiWindowsMakeControl(uiControl(e), &p); e->hwnd = (HWND) uiControlHandle(uiControl(e)); diff --git a/windows/label.c b/windows/label.c index 95256fef..ef78dbdf 100644 --- a/windows/label.c +++ b/windows/label.c @@ -47,7 +47,7 @@ static void labelSetText(uiLabel *l, const char *text) uiLabel *uiNewLabel(const char *text) { struct label *l; - uiWindowsNewControlParams p; + uiWindowsMakeControlParams p; WCHAR *wtext; l = uiNew(struct label); @@ -65,7 +65,7 @@ uiLabel *uiNewLabel(const char *text) p.onWM_NOTIFY = onWM_NOTIFY; p.onDestroy = onDestroy; p.onDestroyData = l; - uiWindowsNewControl(uiControl(l), &p); + uiWindowsMakeControl(uiControl(l), &p); uiFree(wtext); l->hwnd = (HWND) uiControlHandle(uiControl(l)); diff --git a/windows/newcontrol.c b/windows/newcontrol.c index 9dc41e68..414decf0 100644 --- a/windows/newcontrol.c +++ b/windows/newcontrol.c @@ -124,7 +124,7 @@ static LRESULT CALLBACK singleSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam); } -void uiWindowsNewControl(uiControl *c, uiWindowsNewControlParams *p) +void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p) { singleHWND *s; @@ -137,7 +137,7 @@ void uiWindowsNewControl(uiControl *c, uiWindowsNewControlParams *p) 100, 100, initialParent, NULL, p->hInstance, NULL); if (s->hwnd == NULL) - logLastError("error creating control in uiWindowsNewControl()"); + logLastError("error creating control in uiWindowsMakeControl()"); s->onWM_COMMAND = p->onWM_COMMAND; s->onWM_NOTIFY = p->onWM_NOTIFY; @@ -149,7 +149,7 @@ void uiWindowsNewControl(uiControl *c, uiWindowsNewControlParams *p) // this handles redirected notification messages if ((*fv_SetWindowSubclass)(s->hwnd, singleSubclassProc, 0, (DWORD_PTR) c) == FALSE) - logLastError("error subclassing Windows control in uiWindowsNewControl()"); + logLastError("error subclassing Windows control in uiWindowsMakeControl()"); c->Internal = s; c->Destroy = singleDestroy; diff --git a/windows/tab.c b/windows/tab.c index dc439973..678d4a27 100644 --- a/windows/tab.c +++ b/windows/tab.c @@ -226,7 +226,7 @@ static void tabSetMargined(uiTab *tt, uintmax_t n, int margined) uiTab *uiNewTab(void) { struct tab *t; - uiWindowsNewControlParams p; + uiWindowsMakeControlParams p; t = uiNew(struct tab); @@ -240,7 +240,7 @@ uiTab *uiNewTab(void) p.onWM_NOTIFY = onWM_NOTIFY; p.onDestroy = onDestroy; p.onDestroyData = t; - uiWindowsNewControl(uiControl(t), &p); + uiWindowsMakeControl(uiControl(t), &p); t->hwnd = (HWND) uiControlHandle(uiControl(t));