From b2e9b646a4771bec3fb572567649285b9dad1622 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 4 May 2015 15:51:23 -0400 Subject: [PATCH] Got rid of typedefs in the various newcontrol files for consistency. --- darwin/newcontrol.m | 28 +++++++++++++--------------- unix/newcontrol.c | 27 ++++++++++++--------------- windows/newcontrol.c | 32 +++++++++++++++----------------- 3 files changed, 40 insertions(+), 47 deletions(-) diff --git a/darwin/newcontrol.m b/darwin/newcontrol.m index fd709d94..276e9b13 100644 --- a/darwin/newcontrol.m +++ b/darwin/newcontrol.m @@ -1,8 +1,6 @@ // 7 april 2015 #include "uipriv_darwin.h" -typedef struct singleView singleView; - struct singleView { NSView *view; NSScrollView *scrollView; @@ -17,7 +15,7 @@ struct singleView { static void singleDestroy(uiControl *c) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); if (s->parent != NULL) complain("attempt to destroy a uiControl at %p while it still has a parent", c); @@ -29,14 +27,14 @@ static void singleDestroy(uiControl *c) static uintptr_t singleHandle(uiControl *c) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); return (uintptr_t) (s->view); } static void singleSetParent(uiControl *c, uiContainer *parent) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); NSView *parentView; uiContainer *oldparent; @@ -57,7 +55,7 @@ static void singleSetParent(uiControl *c, uiContainer *parent) // also good for NSBox and NSProgressIndicator static void singlePreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); NSControl *control; NSRect r; @@ -71,7 +69,7 @@ static void singlePreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intm static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); NSRect frame; frame.origin.x = x; @@ -85,14 +83,14 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i static int singleVisible(uiControl *c) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); return !s->hidden; } static void singleShow(uiControl *c) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); [s->immediate setHidden:NO]; s->hidden = 0; @@ -102,7 +100,7 @@ static void singleShow(uiControl *c) static void singleHide(uiControl *c) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); [s->immediate setHidden:YES]; s->hidden = 1; @@ -112,7 +110,7 @@ static void singleHide(uiControl *c) static void singleEnable(uiControl *c) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); s->userDisabled = 0; if (!s->containerDisabled) @@ -122,7 +120,7 @@ static void singleEnable(uiControl *c) static void singleDisable(uiControl *c) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); s->userDisabled = 1; if ([s->view respondsToSelector:@selector(setEnabled:)]) @@ -131,7 +129,7 @@ static void singleDisable(uiControl *c) static void singleSysFunc(uiControl *c, uiControlSysFuncParams *p) { - singleView *s = (singleView *) (c->Internal); + struct singleView *s = (struct singleView *) (c->Internal); switch (p->Func) { case uiDarwinSysFuncContainerEnable: @@ -151,9 +149,9 @@ static void singleSysFunc(uiControl *c, uiControlSysFuncParams *p) void uiDarwinMakeControl(uiControl *c, Class class, BOOL inScrollView, BOOL scrollViewHasBorder, void (*onDestroy)(void *), void *onDestroyData) { - singleView *s; + struct singleView *s; - s = uiNew(singleView); + s = uiNew(struct singleView); // thanks to autoxr and arwyn in irc.freenode.net/#macdev s->view = (NSView *) [[class alloc] initWithFrame:NSZeroRect]; s->immediate = s->view; diff --git a/unix/newcontrol.c b/unix/newcontrol.c index 09c4911b..d53b8d9a 100644 --- a/unix/newcontrol.c +++ b/unix/newcontrol.c @@ -1,9 +1,6 @@ // 7 april 2015 #include "uipriv_unix.h" -// TODO get rid of this -typedef struct singleWidget singleWidget; - struct singleWidget { GtkWidget *widget; GtkWidget *scrolledWindow; @@ -16,7 +13,7 @@ struct singleWidget { static void singleDestroy(uiControl *c) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); if (s->parent != NULL) complain("attempt to destroy a uiControl at %p while it still has a parent", c); @@ -30,14 +27,14 @@ static void singleDestroy(uiControl *c) static uintptr_t singleHandle(uiControl *c) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); return (uintptr_t) (s->widget); } static void singleSetParent(uiControl *c, uiContainer *parent) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); uiContainer *oldparent; GtkContainer *oldcontainer; GtkContainer *newcontainer; @@ -60,7 +57,7 @@ static void singleSetParent(uiControl *c, uiContainer *parent) static void singlePreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); GtkRequisition natural; // use the natural size as the minimum size is an *absolute* minimum @@ -73,7 +70,7 @@ static void singlePreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intm static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); GtkAllocation a; a.x = x; @@ -85,14 +82,14 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i static int singleVisible(uiControl *c) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); return !s->hidden; } static void singleShow(uiControl *c) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); gtk_widget_show_all(s->immediate); s->hidden = 0; @@ -102,7 +99,7 @@ static void singleShow(uiControl *c) static void singleHide(uiControl *c) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); gtk_widget_hide(s->immediate); s->hidden = 1; @@ -112,24 +109,24 @@ static void singleHide(uiControl *c) static void singleEnable(uiControl *c) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); gtk_widget_set_sensitive(s->immediate, TRUE); } static void singleDisable(uiControl *c) { - singleWidget *s = (singleWidget *) (c->Internal); + struct singleWidget *s = (struct singleWidget *) (c->Internal); gtk_widget_set_sensitive(s->immediate, FALSE); } void uiUnixMakeControl(uiControl *c, GType type, gboolean inScrolledWindow, gboolean scrolledWindowHasBorder, void (*onDestroy)(void *), void *onDestroyData, const char *firstProperty, ...) { - singleWidget *s; + struct singleWidget *s; va_list ap; - s = uiNew(singleWidget); + s = uiNew(struct singleWidget); va_start(ap, firstProperty); s->widget = GTK_WIDGET(g_object_new_valist(type, firstProperty, ap)); diff --git a/windows/newcontrol.c b/windows/newcontrol.c index e592f1f5..a19b8cc8 100644 --- a/windows/newcontrol.c +++ b/windows/newcontrol.c @@ -1,8 +1,6 @@ // 6 april 2015 #include "uipriv_windows.h" -typedef struct singleHWND singleHWND; - struct singleHWND { HWND hwnd; BOOL (*onWM_COMMAND)(uiControl *, WORD, LRESULT *); @@ -17,7 +15,7 @@ struct singleHWND { static void singleDestroy(uiControl *c) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); if (s->parent != NULL) complain("attempt to destroy a uiControl at %p while it still has a parent", c); @@ -30,14 +28,14 @@ static void singleDestroy(uiControl *c) static uintptr_t singleHandle(uiControl *c) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); return (uintptr_t) (s->hwnd); } static void singleSetParent(uiControl *c, uiContainer *parent) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); uiContainer *oldparent; HWND newParentHWND; @@ -56,7 +54,7 @@ static void singleSetParent(uiControl *c, uiContainer *parent) static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); if (MoveWindow(s->hwnd, x, y, width, height, TRUE) == 0) logLastError("error moving control in singleResize()"); @@ -64,14 +62,14 @@ static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, i static int singleVisible(uiControl *c) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); return !s->hidden; } static void singleShow(uiControl *c) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); ShowWindow(s->hwnd, SW_SHOW); s->hidden = 0; @@ -81,7 +79,7 @@ static void singleShow(uiControl *c) static void singleHide(uiControl *c) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); ShowWindow(s->hwnd, SW_HIDE); s->hidden = 1; @@ -91,7 +89,7 @@ static void singleHide(uiControl *c) static void singleEnable(uiControl *c) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); s->userDisabled = 0; if (!s->containerDisabled) @@ -100,7 +98,7 @@ static void singleEnable(uiControl *c) static void singleDisable(uiControl *c) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); s->userDisabled = 1; EnableWindow(s->hwnd, FALSE); @@ -108,7 +106,7 @@ static void singleDisable(uiControl *c) static void singleSysFunc(uiControl *c, uiControlSysFuncParams *p) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); switch (p->Func) { case uiWindowsSysFuncContainerEnable: @@ -127,7 +125,7 @@ static void singleSysFunc(uiControl *c, uiControlSysFuncParams *p) static LRESULT CALLBACK singleSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { uiControl *c = (uiControl *) dwRefData; - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); LRESULT lResult; switch (uMsg) { @@ -149,9 +147,9 @@ static LRESULT CALLBACK singleSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p) { - singleHWND *s; + struct singleHWND *s; - s = uiNew(singleHWND); + s = uiNew(struct singleHWND); s->hwnd = CreateWindowExW(p->dwExStyle, p->lpClassName, p->lpWindowName, p->dwStyle | WS_CHILD | WS_VISIBLE, @@ -189,7 +187,7 @@ void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p) char *uiWindowsControlText(uiControl *c) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); WCHAR *wtext; char *text; @@ -201,7 +199,7 @@ char *uiWindowsControlText(uiControl *c) void uiWindowsControlSetText(uiControl *c, const char *text) { - singleHWND *s = (singleHWND *) (c->Internal); + struct singleHWND *s = (struct singleHWND *) (c->Internal); WCHAR *wtext; wtext = toUTF16(text);