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));
}
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;

View File

@ -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;

View File

@ -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;

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.
#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))

View File

@ -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;

View File

@ -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;

View File

@ -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;

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 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;

View File

@ -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;

View File

@ -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;