More intmax_t elminiation.

This commit is contained in:
Pietro Gagliardi 2016-06-13 20:55:50 -04:00
parent b26354d1e7
commit 8d48d42201
10 changed files with 63 additions and 62 deletions

View File

@ -88,13 +88,12 @@ static void uiSliderDestroy(uiControl *c)
uiFreeControl(uiControl(s)); uiFreeControl(uiControl(s));
} }
intmax_t uiSliderValue(uiSlider *s) int uiSliderValue(uiSlider *s)
{ {
// NSInteger is the most similar to intmax_t
return [s->slider integerValue]; return [s->slider integerValue];
} }
void uiSliderSetValue(uiSlider *s, intmax_t value) void uiSliderSetValue(uiSlider *s, int value)
{ {
[s->slider setIntegerValue:value]; [s->slider setIntegerValue:value];
} }
@ -110,11 +109,11 @@ static void defaultOnChanged(uiSlider *s, void *data)
// do nothing // do nothing
} }
uiSlider *uiNewSlider(intmax_t min, intmax_t max) uiSlider *uiNewSlider(int min, int max)
{ {
uiSlider *s; uiSlider *s;
NSSliderCell *cell; NSSliderCell *cell;
intmax_t temp; int temp;
if (min >= max) { if (min >= max) {
temp = min; temp = min;

View File

@ -169,12 +169,12 @@ static CGFloat stepperYDelta(void)
uiDarwinControlAllDefaults(uiSpinbox, spinbox) uiDarwinControlAllDefaults(uiSpinbox, spinbox)
intmax_t uiSpinboxValue(uiSpinbox *s) int uiSpinboxValue(uiSpinbox *s)
{ {
return [s->spinbox libui_value]; return [s->spinbox libui_value];
} }
void uiSpinboxSetValue(uiSpinbox *s, intmax_t value) void uiSpinboxSetValue(uiSpinbox *s, int value)
{ {
[s->spinbox libui_setValue:value]; [s->spinbox libui_setValue:value];
} }
@ -190,10 +190,10 @@ static void defaultOnChanged(uiSpinbox *s, void *data)
// do nothing // do nothing
} }
uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) uiSpinbox *uiNewSpinbox(int min, int max)
{ {
uiSpinbox *s; uiSpinbox *s;
intmax_t temp; int temp;
if (min >= max) { if (min >= max) {
temp = min; temp = min;

View File

@ -185,7 +185,7 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child)
uiTabInsertAt(t, name, [t->pages count], 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; tabPage *page;
NSView *view; NSView *view;
@ -220,7 +220,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child)
tabRelayout(t); tabRelayout(t);
} }
void uiTabDelete(uiTab *t, uintmax_t n) void uiTabDelete(uiTab *t, int n)
{ {
tabPage *page; tabPage *page;
uiControl *child; uiControl *child;
@ -244,12 +244,12 @@ void uiTabDelete(uiTab *t, uintmax_t n)
tabRelayout(t); tabRelayout(t);
} }
uintmax_t uiTabNumPages(uiTab *t) int uiTabNumPages(uiTab *t)
{ {
return [t->pages count]; return [t->pages count];
} }
int uiTabMargined(uiTab *t, uintmax_t n) int uiTabMargined(uiTab *t, int n)
{ {
tabPage *page; tabPage *page;
@ -257,7 +257,7 @@ int uiTabMargined(uiTab *t, uintmax_t n)
return [page isMargined]; return [page isMargined];
} }
void uiTabSetMargined(uiTab *t, uintmax_t n, int margined) void uiTabSetMargined(uiTab *t, int n, int margined)
{ {
tabPage *page; tabPage *page;

24
ui.h
View File

@ -32,6 +32,8 @@ extern "C" {
// This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796. // This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796.
#define uiPi 3.14159265358979323846264338327950288419716939937510582097494459 #define uiPi 3.14159265358979323846264338327950288419716939937510582097494459
// TODO uiBool?
typedef struct uiInitOptions uiInitOptions; typedef struct uiInitOptions uiInitOptions;
struct uiInitOptions { struct uiInitOptions {
@ -148,11 +150,11 @@ _UI_EXTERN uiLabel *uiNewLabel(const char *text);
typedef struct uiTab uiTab; typedef struct uiTab uiTab;
#define uiTab(this) ((uiTab *) (this)) #define uiTab(this) ((uiTab *) (this))
_UI_EXTERN void uiTabAppend(uiTab *t, const char *name, uiControl *c); _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 uiTabInsertAt(uiTab *t, const char *name, int before, uiControl *c);
_UI_EXTERN void uiTabDelete(uiTab *t, uintmax_t index); _UI_EXTERN void uiTabDelete(uiTab *t, int index);
_UI_EXTERN uintmax_t uiTabNumPages(uiTab *t); _UI_EXTERN int uiTabNumPages(uiTab *t);
_UI_EXTERN int uiTabMargined(uiTab *t, uintmax_t page); _UI_EXTERN int uiTabMargined(uiTab *t, int page);
_UI_EXTERN void uiTabSetMargined(uiTab *t, uintmax_t page, int margined); _UI_EXTERN void uiTabSetMargined(uiTab *t, int page, int margined);
_UI_EXTERN uiTab *uiNewTab(void); _UI_EXTERN uiTab *uiNewTab(void);
typedef struct uiGroup uiGroup; typedef struct uiGroup uiGroup;
@ -171,17 +173,17 @@ _UI_EXTERN uiGroup *uiNewGroup(const char *title);
typedef struct uiSpinbox uiSpinbox; typedef struct uiSpinbox uiSpinbox;
#define uiSpinbox(this) ((uiSpinbox *) (this)) #define uiSpinbox(this) ((uiSpinbox *) (this))
_UI_EXTERN intmax_t uiSpinboxValue(uiSpinbox *s); _UI_EXTERN int uiSpinboxValue(uiSpinbox *s);
_UI_EXTERN void uiSpinboxSetValue(uiSpinbox *s, intmax_t value); _UI_EXTERN void uiSpinboxSetValue(uiSpinbox *s, int value);
_UI_EXTERN void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data); _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; typedef struct uiSlider uiSlider;
#define uiSlider(this) ((uiSlider *) (this)) #define uiSlider(this) ((uiSlider *) (this))
_UI_EXTERN intmax_t uiSliderValue(uiSlider *s); _UI_EXTERN int uiSliderValue(uiSlider *s);
_UI_EXTERN void uiSliderSetValue(uiSlider *s, intmax_t value); _UI_EXTERN void uiSliderSetValue(uiSlider *s, int value);
_UI_EXTERN void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data); _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; typedef struct uiProgressBar uiProgressBar;
#define uiProgressBar(this) ((uiProgressBar *) (this)) #define uiProgressBar(this) ((uiProgressBar *) (this))

View File

@ -25,12 +25,12 @@ static void defaultOnChanged(uiSlider *s, void *data)
// do nothing // 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 // we need to inhibit sending of ::value-changed because this WILL send a ::value-changed otherwise
g_signal_handler_block(s->range, s->onChangedSignal); 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; s->onChangedData = data;
} }
uiSlider *uiNewSlider(intmax_t min, intmax_t max) uiSlider *uiNewSlider(int min, int max)
{ {
uiSlider *s; uiSlider *s;
intmax_t temp; int temp;
if (min >= max) { if (min >= max) {
temp = min; temp = min;

View File

@ -25,12 +25,12 @@ static void defaultOnChanged(uiSpinbox *s, void *data)
// do nothing // 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 // we need to inhibit sending of ::value-changed because this WILL send a ::value-changed otherwise
g_signal_handler_block(s->spinButton, s->onChangedSignal); 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; s->onChangedData = data;
} }
uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) uiSpinbox *uiNewSpinbox(int min, int max)
{ {
uiSpinbox *s; uiSpinbox *s;
intmax_t temp; int temp;
if (min >= max) { if (min >= max) {
temp = min; temp = min;

View File

@ -34,7 +34,7 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child)
uiTabInsertAt(t, name, t->pages->len, 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; 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); g_array_insert_val(t->pages, n, page);
} }
void uiTabDelete(uiTab *t, uintmax_t n) void uiTabDelete(uiTab *t, int n)
{ {
struct child *page; struct child *page;
@ -57,12 +57,12 @@ void uiTabDelete(uiTab *t, uintmax_t n)
g_array_remove_index(t->pages, n); g_array_remove_index(t->pages, n);
} }
uintmax_t uiTabNumPages(uiTab *t) int uiTabNumPages(uiTab *t)
{ {
return t->pages->len; return t->pages->len;
} }
int uiTabMargined(uiTab *t, uintmax_t n) int uiTabMargined(uiTab *t, int n)
{ {
struct child *page; struct child *page;
@ -70,7 +70,7 @@ int uiTabMargined(uiTab *t, uintmax_t n)
return childFlag(page); return childFlag(page);
} }
void uiTabSetMargined(uiTab *t, uintmax_t n, int margined) void uiTabSetMargined(uiTab *t, int n, int margined)
{ {
struct child *page; struct child *page;

View File

@ -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 sliderWidth 107 /* this is actually the shorter progress bar width, but Microsoft doesn't indicate a width */
#define sliderHeight 15 #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); uiSlider *s = uiSlider(c);
uiWindowsSizing sizing; uiWindowsSizing sizing;
@ -51,12 +51,12 @@ static void defaultOnChanged(uiSlider *s, void *data)
// do nothing // 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 // don't use TBM_SETPOSNOTIFY; that triggers an event
SendMessageW(s->hwnd, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) value); 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; s->onChangedData = data;
} }
uiSlider *uiNewSlider(intmax_t min, intmax_t max) uiSlider *uiNewSlider(int min, int max)
{ {
uiSlider *s; uiSlider *s;
intmax_t temp; int temp;
if (min >= max) { if (min >= max) {
temp = min; temp = min;

View File

@ -13,7 +13,7 @@ struct uiSpinbox {
// utility functions // utility functions
static intmax_t value(uiSpinbox *s) static int value(uiSpinbox *s)
{ {
BOOL neededCap = FALSE; BOOL neededCap = FALSE;
LRESULT val; LRESULT val;
@ -27,7 +27,7 @@ static intmax_t value(uiSpinbox *s)
SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) val); SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) val);
s->inhibitChanged = FALSE; s->inhibitChanged = FALSE;
} }
return (intmax_t) val; return val;
} }
// control implementation // 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 entryWidth 107 /* this is actually the shorter progress bar width, but Microsoft only indicates as wide as necessary */
#define entryHeight 14 #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); uiSpinbox *s = uiSpinbox(c);
uiWindowsSizing sizing; uiWindowsSizing sizing;
@ -108,7 +108,7 @@ static void spinboxArrangeChildren(uiSpinbox *s)
static void recreateUpDown(uiSpinbox *s) static void recreateUpDown(uiSpinbox *s)
{ {
BOOL preserve = FALSE; BOOL preserve = FALSE;
intmax_t current; int current;
// Microsoft's commctrl.h says to use this type // Microsoft's commctrl.h says to use this type
INT min, max; INT min, max;
@ -156,12 +156,12 @@ static void defaultOnChanged(uiSpinbox *s, void *data)
// do nothing // do nothing
} }
intmax_t uiSpinboxValue(uiSpinbox *s) int uiSpinboxValue(uiSpinbox *s)
{ {
return value(s); return value(s);
} }
void uiSpinboxSetValue(uiSpinbox *s, intmax_t value) void uiSpinboxSetValue(uiSpinbox *s, int value)
{ {
s->inhibitChanged = TRUE; s->inhibitChanged = TRUE;
SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) value); SendMessageW(s->updown, UDM_SETPOS32, 0, (LPARAM) value);
@ -179,10 +179,10 @@ static void onResize(uiWindowsControl *c)
spinboxRelayout(uiSpinbox(c)); spinboxRelayout(uiSpinbox(c));
} }
uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) uiSpinbox *uiNewSpinbox(int min, int max)
{ {
uiSpinbox *s; uiSpinbox *s;
intmax_t temp; int temp;
if (min >= max) { if (min >= max) {
temp = min; temp = min;

View File

@ -19,7 +19,7 @@ static LRESULT curpage(uiTab *t)
return SendMessageW(t->tabHWND, TCM_GETCURSEL, 0, 0); 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]; return (*(t->pages))[i];
} }
@ -127,10 +127,10 @@ static void uiTabSyncEnableState(uiWindowsControl *c, int enabled)
uiWindowsControlDefaultSetParentHWND(uiTab) 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); uiTab *t = uiTab(c);
intmax_t pagewid, pageht; int pagewid, pageht;
struct tabPage *page; struct tabPage *page;
RECT r; RECT r;
@ -182,7 +182,7 @@ void uiTabAppend(uiTab *t, const char *name, uiControl *child)
uiTabInsertAt(t, name, t->pages->size(), 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; struct tabPage *page;
LRESULT hide, show; 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; struct tabPage *page;
@ -233,17 +233,17 @@ void uiTabDelete(uiTab *t, uintmax_t n)
t->pages->erase(t->pages->begin() + n); t->pages->erase(t->pages->begin() + n);
} }
uintmax_t uiTabNumPages(uiTab *t) int uiTabNumPages(uiTab *t)
{ {
return t->pages->size(); return t->pages->size();
} }
int uiTabMargined(uiTab *t, uintmax_t n) int uiTabMargined(uiTab *t, int n)
{ {
return tabPage(t, n)->margined; 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; struct tabPage *page;