From cd030aba96dfb8c12c6129a8e4babf467827494d Mon Sep 17 00:00:00 2001 From: BQ Date: Tue, 31 May 2016 13:28:39 +0100 Subject: [PATCH 1/2] Make control visible and enabled const correct. --- common/control.c | 4 ++-- darwin/window.m | 2 +- ui.h | 10 +++++----- ui_darwin.h | 4 ++-- ui_unix.h | 4 ++-- ui_windows.h | 4 ++-- windows/window.cpp | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common/control.c b/common/control.c index 28066461..49fcc249 100644 --- a/common/control.c +++ b/common/control.c @@ -27,7 +27,7 @@ int uiControlToplevel(uiControl *c) return (*(c->Toplevel))(c); } -int uiControlVisible(uiControl *c) +int uiControlVisible(const uiControl *c) { return (*(c->Visible))(c); } @@ -42,7 +42,7 @@ void uiControlHide(uiControl *c) (*(c->Hide))(c); } -int uiControlEnabled(uiControl *c) +int uiControlEnabled(const uiControl *c) { return (*(c->Enabled))(c); } diff --git a/darwin/window.m b/darwin/window.m index 2d8d2e45..0e319593 100644 --- a/darwin/window.m +++ b/darwin/window.m @@ -114,7 +114,7 @@ static int uiWindowToplevel(uiControl *c) return 1; } -static int uiWindowVisible(uiControl *c) +static int uiWindowVisible(const uiControl *c) { uiWindow *w = uiWindow(c); diff --git a/ui.h b/ui.h index 34527918..2585c547 100644 --- a/ui.h +++ b/ui.h @@ -56,10 +56,10 @@ struct uiControl { uiControl *(*Parent)(uiControl *); void (*SetParent)(uiControl *, uiControl *); int (*Toplevel)(uiControl *); - int (*Visible)(uiControl *); + int (*Visible)(const uiControl *); void (*Show)(uiControl *); void (*Hide)(uiControl *); - int (*Enabled)(uiControl *); + int (*Enabled)(const uiControl *); void (*Enable)(uiControl *); void (*Disable)(uiControl *); }; @@ -70,10 +70,10 @@ _UI_EXTERN uintptr_t uiControlHandle(uiControl *); _UI_EXTERN uiControl *uiControlParent(uiControl *); _UI_EXTERN void uiControlSetParent(uiControl *, uiControl *); _UI_EXTERN int uiControlToplevel(uiControl *); -_UI_EXTERN int uiControlVisible(uiControl *); +_UI_EXTERN int uiControlVisible(const uiControl *); _UI_EXTERN void uiControlShow(uiControl *); _UI_EXTERN void uiControlHide(uiControl *); -_UI_EXTERN int uiControlEnabled(uiControl *); +_UI_EXTERN int uiControlEnabled(const uiControl *); _UI_EXTERN void uiControlEnable(uiControl *); _UI_EXTERN void uiControlDisable(uiControl *); @@ -150,7 +150,7 @@ typedef struct uiGroup uiGroup; #define uiGroup(this) ((uiGroup *) (this)) _UI_EXTERN char *uiGroupTitle(uiGroup *g); _UI_EXTERN void uiGroupSetTitle(uiGroup *g, const char *title); -_UI_EXTERN void uiGroupSetChild(uiGroup *g, uiControl *c); +_UI_EXTERN void uiGroSetChildup(uiGroup *g, uiControl *c); _UI_EXTERN int uiGroupMargined(uiGroup *g); _UI_EXTERN void uiGroupSetMargined(uiGroup *g, int margined); _UI_EXTERN uiGroup *uiNewGroup(const char *title); diff --git a/ui_darwin.h b/ui_darwin.h index 81e71f2c..793688aa 100644 --- a/ui_darwin.h +++ b/ui_darwin.h @@ -63,7 +63,7 @@ _UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPri return 0; \ } #define uiDarwinControlDefaultVisible(type, handlefield) \ - static int type ## Visible(uiControl *c) \ + static int type ## Visible(const uiControl *c) \ { \ return uiDarwinControl(c)->visible; \ } @@ -80,7 +80,7 @@ _UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPri [type(c)->handlefield setHidden:YES]; \ } #define uiDarwinControlDefaultEnabled(type, handlefield) \ - static int type ## Enabled(uiControl *c) \ + static int type ## Enabled(const uiControl *c) \ { \ return uiDarwinControl(c)->enabled; \ } diff --git a/ui_unix.h b/ui_unix.h index f8cdf3dd..a9f80108 100644 --- a/ui_unix.h +++ b/ui_unix.h @@ -51,7 +51,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool return 0; \ } #define uiUnixControlDefaultVisible(type) \ - static int type ## Visible(uiControl *c) \ + static int type ## Visible(const uiControl *c) \ { \ return gtk_widget_get_visible(type(c)->widget); \ } @@ -66,7 +66,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool gtk_widget_hide(type(c)->widget); \ } #define uiUnixControlDefaultEnabled(type) \ - static int type ## Enabled(uiControl *c) \ + static int type ## Enabled(const uiControl *c) \ { \ return gtk_widget_get_sensitive(type(c)->widget); \ } diff --git a/ui_windows.h b/ui_windows.h index 81185f51..e824e293 100644 --- a/ui_windows.h +++ b/ui_windows.h @@ -66,7 +66,7 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P return 0; \ } #define uiWindowsControlDefaultVisible(type) \ - static int type ## Visible(uiControl *c) \ + static int type ## Visible(const uiControl *c) \ { \ return uiWindowsControl(c)->visible; \ } @@ -83,7 +83,7 @@ _UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_P ShowWindow(type(c)->hwnd, SW_HIDE); \ } #define uiWindowsControlDefaultEnabled(type) \ - static int type ## Enabled(uiControl *c) \ + static int type ## Enabled(const uiControl *c) \ { \ return uiWindowsControl(c)->enabled; \ } diff --git a/windows/window.cpp b/windows/window.cpp index 0906619a..e3b931c4 100644 --- a/windows/window.cpp +++ b/windows/window.cpp @@ -178,7 +178,7 @@ static int uiWindowToplevel(uiControl *c) } // TODO initial state of windows is hidden; ensure this here and make it so on other platforms -static int uiWindowVisible(uiControl *c) +static int uiWindowVisible(const uiControl *c) { uiWindow *w = uiWindow(c); From 24f11703b361015e23ce85d2b9c1d7fb7cc5178a Mon Sep 17 00:00:00 2001 From: BQ Date: Tue, 31 May 2016 14:24:37 +0100 Subject: [PATCH 2/2] Fix typo. --- ui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui.h b/ui.h index 2585c547..c0c03158 100644 --- a/ui.h +++ b/ui.h @@ -150,7 +150,7 @@ typedef struct uiGroup uiGroup; #define uiGroup(this) ((uiGroup *) (this)) _UI_EXTERN char *uiGroupTitle(uiGroup *g); _UI_EXTERN void uiGroupSetTitle(uiGroup *g, const char *title); -_UI_EXTERN void uiGroSetChildup(uiGroup *g, uiControl *c); +_UI_EXTERN void uiGroupSetChild(uiGroup *g, uiControl *c); _UI_EXTERN int uiGroupMargined(uiGroup *g); _UI_EXTERN void uiGroupSetMargined(uiGroup *g, int margined); _UI_EXTERN uiGroup *uiNewGroup(const char *title);