From 8d48d4220188532414b96a39b908eabd8b5cd930 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 13 Jun 2016 20:55:50 -0400 Subject: [PATCH] More intmax_t elminiation. --- darwin/slider.m | 9 ++++----- darwin/spinbox.m | 8 ++++---- darwin/tab.m | 10 +++++----- ui.h | 24 +++++++++++++----------- unix/slider.c | 10 +++++----- unix/spinbox.c | 10 +++++----- unix/tab.c | 10 +++++----- windows/slider.cpp | 12 ++++++------ windows/spinbox.cpp | 16 ++++++++-------- windows/tab.cpp | 16 ++++++++-------- 10 files changed, 63 insertions(+), 62 deletions(-) diff --git a/darwin/slider.m b/darwin/slider.m index 53274574..f00da50f 100644 --- a/darwin/slider.m +++ b/darwin/slider.m @@ -88,13 +88,12 @@ static void uiSliderDestroy(uiControl *c) uiFreeControl(uiControl(s)); } -intmax_t uiSliderValue(uiSlider *s) +int uiSliderValue(uiSlider *s) { - // NSInteger is the most similar to intmax_t return [s->slider integerValue]; } -void uiSliderSetValue(uiSlider *s, intmax_t value) +void uiSliderSetValue(uiSlider *s, int value) { [s->slider setIntegerValue:value]; } @@ -110,11 +109,11 @@ static void defaultOnChanged(uiSlider *s, void *data) // do nothing } -uiSlider *uiNewSlider(intmax_t min, intmax_t max) +uiSlider *uiNewSlider(int min, int max) { uiSlider *s; NSSliderCell *cell; - intmax_t temp; + int temp; if (min >= max) { temp = min; diff --git a/darwin/spinbox.m b/darwin/spinbox.m index 30fbc00b..73474d04 100644 --- a/darwin/spinbox.m +++ b/darwin/spinbox.m @@ -169,12 +169,12 @@ static CGFloat stepperYDelta(void) uiDarwinControlAllDefaults(uiSpinbox, spinbox) -intmax_t uiSpinboxValue(uiSpinbox *s) +int uiSpinboxValue(uiSpinbox *s) { return [s->spinbox libui_value]; } -void uiSpinboxSetValue(uiSpinbox *s, intmax_t value) +void uiSpinboxSetValue(uiSpinbox *s, int value) { [s->spinbox libui_setValue:value]; } @@ -190,10 +190,10 @@ static void defaultOnChanged(uiSpinbox *s, void *data) // do nothing } -uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) +uiSpinbox *uiNewSpinbox(int min, int max) { uiSpinbox *s; - intmax_t temp; + int temp; if (min >= max) { temp = min; diff --git a/darwin/tab.m b/darwin/tab.m index c3fac1d1..0d03f3e6 100644 --- a/darwin/tab.m +++ b/darwin/tab.m @@ -185,7 +185,7 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child) uiTabInsertAt(t, name, [t->pages count], child); } -void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) +void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child) { tabPage *page; NSView *view; @@ -220,7 +220,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) tabRelayout(t); } -void uiTabDelete(uiTab *t, uintmax_t n) +void uiTabDelete(uiTab *t, int n) { tabPage *page; uiControl *child; @@ -244,12 +244,12 @@ void uiTabDelete(uiTab *t, uintmax_t n) tabRelayout(t); } -uintmax_t uiTabNumPages(uiTab *t) +int uiTabNumPages(uiTab *t) { return [t->pages count]; } -int uiTabMargined(uiTab *t, uintmax_t n) +int uiTabMargined(uiTab *t, int n) { tabPage *page; @@ -257,7 +257,7 @@ int uiTabMargined(uiTab *t, uintmax_t n) return [page isMargined]; } -void uiTabSetMargined(uiTab *t, uintmax_t n, int margined) +void uiTabSetMargined(uiTab *t, int n, int margined) { tabPage *page; diff --git a/ui.h b/ui.h index ee12efd4..50a76ed9 100644 --- a/ui.h +++ b/ui.h @@ -32,6 +32,8 @@ extern "C" { // This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796. #define uiPi 3.14159265358979323846264338327950288419716939937510582097494459 +// TODO uiBool? + typedef struct uiInitOptions uiInitOptions; struct uiInitOptions { @@ -148,11 +150,11 @@ _UI_EXTERN uiLabel *uiNewLabel(const char *text); typedef struct uiTab uiTab; #define uiTab(this) ((uiTab *) (this)) _UI_EXTERN void uiTabAppend(uiTab *t, const char *name, uiControl *c); -_UI_EXTERN void uiTabInsertAt(uiTab *t, const char *name, uintmax_t before, uiControl *c); -_UI_EXTERN void uiTabDelete(uiTab *t, uintmax_t index); -_UI_EXTERN uintmax_t uiTabNumPages(uiTab *t); -_UI_EXTERN int uiTabMargined(uiTab *t, uintmax_t page); -_UI_EXTERN void uiTabSetMargined(uiTab *t, uintmax_t page, int margined); +_UI_EXTERN void uiTabInsertAt(uiTab *t, const char *name, int before, uiControl *c); +_UI_EXTERN void uiTabDelete(uiTab *t, int index); +_UI_EXTERN int uiTabNumPages(uiTab *t); +_UI_EXTERN int uiTabMargined(uiTab *t, int page); +_UI_EXTERN void uiTabSetMargined(uiTab *t, int page, int margined); _UI_EXTERN uiTab *uiNewTab(void); typedef struct uiGroup uiGroup; @@ -171,17 +173,17 @@ _UI_EXTERN uiGroup *uiNewGroup(const char *title); typedef struct uiSpinbox uiSpinbox; #define uiSpinbox(this) ((uiSpinbox *) (this)) -_UI_EXTERN intmax_t uiSpinboxValue(uiSpinbox *s); -_UI_EXTERN void uiSpinboxSetValue(uiSpinbox *s, intmax_t value); +_UI_EXTERN int uiSpinboxValue(uiSpinbox *s); +_UI_EXTERN void uiSpinboxSetValue(uiSpinbox *s, int value); _UI_EXTERN void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data); -_UI_EXTERN uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max); +_UI_EXTERN uiSpinbox *uiNewSpinbox(int min, int max); typedef struct uiSlider uiSlider; #define uiSlider(this) ((uiSlider *) (this)) -_UI_EXTERN intmax_t uiSliderValue(uiSlider *s); -_UI_EXTERN void uiSliderSetValue(uiSlider *s, intmax_t value); +_UI_EXTERN int uiSliderValue(uiSlider *s); +_UI_EXTERN void uiSliderSetValue(uiSlider *s, int value); _UI_EXTERN void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data); -_UI_EXTERN uiSlider *uiNewSlider(intmax_t min, intmax_t max); +_UI_EXTERN uiSlider *uiNewSlider(int min, int max); typedef struct uiProgressBar uiProgressBar; #define uiProgressBar(this) ((uiProgressBar *) (this)) diff --git a/unix/slider.c b/unix/slider.c index 9ede700f..7f0cc24a 100644 --- a/unix/slider.c +++ b/unix/slider.c @@ -25,12 +25,12 @@ static void defaultOnChanged(uiSlider *s, void *data) // do nothing } -intmax_t uiSliderValue(uiSlider *s) +int uiSliderValue(uiSlider *s) { - return (intmax_t) gtk_range_get_value(s->range); + return gtk_range_get_value(s->range); } -void uiSliderSetValue(uiSlider *s, intmax_t value) +void uiSliderSetValue(uiSlider *s, int value) { // we need to inhibit sending of ::value-changed because this WILL send a ::value-changed otherwise g_signal_handler_block(s->range, s->onChangedSignal); @@ -44,10 +44,10 @@ void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *, void *), void *data) s->onChangedData = data; } -uiSlider *uiNewSlider(intmax_t min, intmax_t max) +uiSlider *uiNewSlider(int min, int max) { uiSlider *s; - intmax_t temp; + int temp; if (min >= max) { temp = min; diff --git a/unix/spinbox.c b/unix/spinbox.c index d819c21f..90a5d3c1 100644 --- a/unix/spinbox.c +++ b/unix/spinbox.c @@ -25,12 +25,12 @@ static void defaultOnChanged(uiSpinbox *s, void *data) // do nothing } -intmax_t uiSpinboxValue(uiSpinbox *s) +int uiSpinboxValue(uiSpinbox *s) { - return (intmax_t) gtk_spin_button_get_value(s->spinButton); + return gtk_spin_button_get_value(s->spinButton); } -void uiSpinboxSetValue(uiSpinbox *s, intmax_t value) +void uiSpinboxSetValue(uiSpinbox *s, int value) { // we need to inhibit sending of ::value-changed because this WILL send a ::value-changed otherwise g_signal_handler_block(s->spinButton, s->onChangedSignal); @@ -45,10 +45,10 @@ void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *, void *), void *data s->onChangedData = data; } -uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) +uiSpinbox *uiNewSpinbox(int min, int max) { uiSpinbox *s; - intmax_t temp; + int temp; if (min >= max) { temp = min; diff --git a/unix/tab.c b/unix/tab.c index 1ab7f6ad..552e0e31 100644 --- a/unix/tab.c +++ b/unix/tab.c @@ -34,7 +34,7 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child) uiTabInsertAt(t, name, t->pages->len, child); } -void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) +void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child) { struct child *page; @@ -47,7 +47,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) g_array_insert_val(t->pages, n, page); } -void uiTabDelete(uiTab *t, uintmax_t n) +void uiTabDelete(uiTab *t, int n) { struct child *page; @@ -57,12 +57,12 @@ void uiTabDelete(uiTab *t, uintmax_t n) g_array_remove_index(t->pages, n); } -uintmax_t uiTabNumPages(uiTab *t) +int uiTabNumPages(uiTab *t) { return t->pages->len; } -int uiTabMargined(uiTab *t, uintmax_t n) +int uiTabMargined(uiTab *t, int n) { struct child *page; @@ -70,7 +70,7 @@ int uiTabMargined(uiTab *t, uintmax_t n) return childFlag(page); } -void uiTabSetMargined(uiTab *t, uintmax_t n, int margined) +void uiTabSetMargined(uiTab *t, int n, int margined) { struct child *page; diff --git a/windows/slider.cpp b/windows/slider.cpp index 0783627c..5c671dda 100644 --- a/windows/slider.cpp +++ b/windows/slider.cpp @@ -32,7 +32,7 @@ uiWindowsControlAllDefaultsExceptDestroy(uiSlider); #define sliderWidth 107 /* this is actually the shorter progress bar width, but Microsoft doesn't indicate a width */ #define sliderHeight 15 -static void uiSliderMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height) +static void uiSliderMinimumSize(uiWindowsControl *c, int *width, int *height) { uiSlider *s = uiSlider(c); uiWindowsSizing sizing; @@ -51,12 +51,12 @@ static void defaultOnChanged(uiSlider *s, void *data) // do nothing } -intmax_t uiSliderValue(uiSlider *s) +int uiSliderValue(uiSlider *s) { - return (intmax_t) SendMessageW(s->hwnd, TBM_GETPOS, 0, 0); + return SendMessageW(s->hwnd, TBM_GETPOS, 0, 0); } -void uiSliderSetValue(uiSlider *s, intmax_t value) +void uiSliderSetValue(uiSlider *s, int value) { // don't use TBM_SETPOSNOTIFY; that triggers an event SendMessageW(s->hwnd, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) value); @@ -68,10 +68,10 @@ void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *, void *), void *data) s->onChangedData = data; } -uiSlider *uiNewSlider(intmax_t min, intmax_t max) +uiSlider *uiNewSlider(int min, int max) { uiSlider *s; - intmax_t temp; + int temp; if (min >= max) { temp = min; diff --git a/windows/spinbox.cpp b/windows/spinbox.cpp index 1857975d..2b6af66d 100644 --- a/windows/spinbox.cpp +++ b/windows/spinbox.cpp @@ -13,7 +13,7 @@ struct uiSpinbox { // utility functions -static intmax_t value(uiSpinbox *s) +static int value(uiSpinbox *s) { BOOL neededCap = FALSE; LRESULT val; @@ -27,7 +27,7 @@ static intmax_t value(uiSpinbox *s) SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) val); s->inhibitChanged = FALSE; } - return (intmax_t) val; + return val; } // control implementation @@ -76,7 +76,7 @@ uiWindowsControlAllDefaultsExceptDestroy(uiSpinbox) #define entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */ #define entryHeight 14 -static void uiSpinboxMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height) +static void uiSpinboxMinimumSize(uiWindowsControl *c, int *width, int *height) { uiSpinbox *s = uiSpinbox(c); uiWindowsSizing sizing; @@ -108,7 +108,7 @@ static void spinboxArrangeChildren(uiSpinbox *s) static void recreateUpDown(uiSpinbox *s) { BOOL preserve = FALSE; - intmax_t current; + int current; // Microsoft's commctrl.h says to use this type INT min, max; @@ -156,12 +156,12 @@ static void defaultOnChanged(uiSpinbox *s, void *data) // do nothing } -intmax_t uiSpinboxValue(uiSpinbox *s) +int uiSpinboxValue(uiSpinbox *s) { return value(s); } -void uiSpinboxSetValue(uiSpinbox *s, intmax_t value) +void uiSpinboxSetValue(uiSpinbox *s, int value) { s->inhibitChanged = TRUE; SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) value); @@ -179,10 +179,10 @@ static void onResize(uiWindowsControl *c) spinboxRelayout(uiSpinbox(c)); } -uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) +uiSpinbox *uiNewSpinbox(int min, int max) { uiSpinbox *s; - intmax_t temp; + int temp; if (min >= max) { temp = min; diff --git a/windows/tab.cpp b/windows/tab.cpp index 2dade325..2af2bff3 100644 --- a/windows/tab.cpp +++ b/windows/tab.cpp @@ -19,7 +19,7 @@ static LRESULT curpage(uiTab *t) return SendMessageW(t->tabHWND, TCM_GETCURSEL, 0, 0); } -static struct tabPage *tabPage(uiTab *t, intmax_t i) +static struct tabPage *tabPage(uiTab *t, int i) { return (*(t->pages))[i]; } @@ -127,10 +127,10 @@ static void uiTabSyncEnableState(uiWindowsControl *c, int enabled) uiWindowsControlDefaultSetParentHWND(uiTab) -static void uiTabMinimumSize(uiWindowsControl *c, intmax_t *width, intmax_t *height) +static void uiTabMinimumSize(uiWindowsControl *c, int *width, int *height) { uiTab *t = uiTab(c); - intmax_t pagewid, pageht; + int pagewid, pageht; struct tabPage *page; RECT r; @@ -182,7 +182,7 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child) uiTabInsertAt(t, name, t->pages->size(), child); } -void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) +void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child) { struct tabPage *page; LRESULT hide, show; @@ -216,7 +216,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) } } -void uiTabDelete(uiTab *t, uintmax_t n) +void uiTabDelete(uiTab *t, int n) { struct tabPage *page; @@ -233,17 +233,17 @@ void uiTabDelete(uiTab *t, uintmax_t n) t->pages->erase(t->pages->begin() + n); } -uintmax_t uiTabNumPages(uiTab *t) +int uiTabNumPages(uiTab *t) { return t->pages->size(); } -int uiTabMargined(uiTab *t, uintmax_t n) +int uiTabMargined(uiTab *t, int n) { return tabPage(t, n)->margined; } -void uiTabSetMargined(uiTab *t, uintmax_t n, int margined) +void uiTabSetMargined(uiTab *t, int n, int margined) { struct tabPage *page;