InsertBefore -> InsertAt.

This commit is contained in:
Pietro Gagliardi 2015-05-18 10:32:08 -04:00
parent b2c0b631b7
commit d8624c87c9
7 changed files with 14 additions and 14 deletions

View File

@ -28,9 +28,9 @@ notes to self
- explicitly document label position at top-left corner - explicitly document label position at top-left corner
- mark that uiControlShow() on a uiWindow() will bring to front and give keyboard focus because of OS X - mark that uiControlShow() on a uiWindow() will bring to front and give keyboard focus because of OS X
- make sure ShowWindow() is sufficient for zorder on Windows - make sure ShowWindow() is sufficient for zorder on Windows
- document that you CAN use InsertBefore functions to insert at the first invalid index, even if the array is empty - document that you CAN use InsertAt functions to insert at the first invalid index, even if the array is empty
- add tests for this - add tests for this
- note that uiTabInsertPageBefore() does NOT change the current tab page (it may change its index if inserting before the current page) - note that uiTabInsertAt() does NOT change the current tab page (it may change its index if inserting before the current page)
- note that the default action for uiWindowOnClosing() is to return 0 (keep the window open) - note that the default action for uiWindowOnClosing() is to return 0 (keep the window open)
- note that uiInitOptions should be initialized to zero - note that uiInitOptions should be initialized to zero
- explicitly document that uiCheckboxSetChecked() and uiEntrySetText() do not fire uiCheckboxOnToggled() and uiEntryOnChanged(), respectively - explicitly document that uiCheckboxSetChecked() and uiEntrySetText() do not fire uiCheckboxOnToggled() and uiEntryOnChanged(), respectively

View File

@ -21,13 +21,13 @@ void ptrArrayDestroy(struct ptrArray *p)
void ptrArrayAppend(struct ptrArray *p, void *d) void ptrArrayAppend(struct ptrArray *p, void *d)
{ {
ptrArrayInsertBefore(p, p->len, d); ptrArrayInsertAt(p, p->len, d);
} }
void ptrArrayInsertBefore(struct ptrArray *p, uintmax_t i, void *d) void ptrArrayInsertAt(struct ptrArray *p, uintmax_t i, void *d)
{ {
if (i > p->len) if (i > p->len)
complain("index out of range in ptrArrayInsertBefore()"); complain("index out of range in ptrArrayInsertAt()");
if (p->len >= p->cap) { if (p->len >= p->cap) {
p->cap += grow; p->cap += grow;
p->ptrs = (void **) uiRealloc(p->ptrs, p->cap * sizeof (void *), "void *[]"); p->ptrs = (void **) uiRealloc(p->ptrs, p->cap * sizeof (void *), "void *[]");

View File

@ -26,7 +26,7 @@ static void movePage1(uiButton *b, void *data)
{ {
if (moveBack) { if (moveBack) {
uiBoxDelete(mainBox, 1); uiBoxDelete(mainBox, 1);
uiTabInsertBefore(mainTab, "Page 1", 0, uiControl(page1)); uiTabInsertAt(mainTab, "Page 1", 0, uiControl(page1));
uiButtonSetText(b, moveOutText); uiButtonSetText(b, moveOutText);
moveBack = 0; moveBack = 0;
return; return;

View File

@ -124,7 +124,7 @@ func NewLabel(text *const char) *Label;
interface Tab from Control { interface Tab from Control {
func Append(name *const char, c *Control); func Append(name *const char, c *Control);
func InsertBefore(name *const char, before uintmax_t, c *Control); func InsertAt(name *const char, before uintmax_t, c *Control);
func Delete(index uintmax_t); func Delete(index uintmax_t);
func NumPages(void) uintmax_t; func NumPages(void) uintmax_t;
func Margined(page uintmax_t) int; func Margined(page uintmax_t) int;

View File

@ -19,7 +19,7 @@ struct ptrArray {
struct ptrArray *newPtrArray(void); struct ptrArray *newPtrArray(void);
void ptrArrayDestroy(struct ptrArray *); void ptrArrayDestroy(struct ptrArray *);
void ptrArrayAppend(struct ptrArray *, void *); void ptrArrayAppend(struct ptrArray *, void *);
void ptrArrayInsertBefore(struct ptrArray *, uintmax_t, void *); void ptrArrayInsertAt(struct ptrArray *, uintmax_t, void *);
void ptrArrayDelete(struct ptrArray *, uintmax_t); void ptrArrayDelete(struct ptrArray *, uintmax_t);
#define ptrArrayIndex(p, T, i) ((T) ((p)->ptrs[(i)])) #define ptrArrayIndex(p, T, i) ((T) ((p)->ptrs[(i)]))

View File

@ -252,7 +252,7 @@ static void tabAppend(uiTab *tt, const char *name, uiControl *child)
uiControlQueueResize(page->control); uiControlQueueResize(page->control);
} }
static void tabInsertBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child) static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
{ {
struct tab *t = (struct tab *) tt; struct tab *t = (struct tab *) tt;
TCITEMW item; TCITEMW item;
@ -266,14 +266,14 @@ static void tabInsertBefore(uiTab *tt, const char *name, uintmax_t n, uiControl
// always hide; the current tab doesn't change // always hide; the current tab doesn't change
uiControlHide(page->control); uiControlHide(page->control);
ptrArrayInsertBefore(t->pages, n, page); ptrArrayInsertAt(t->pages, n, page);
ZeroMemory(&item, sizeof (TCITEMW)); ZeroMemory(&item, sizeof (TCITEMW));
item.mask = TCIF_TEXT; item.mask = TCIF_TEXT;
wname = toUTF16(name); wname = toUTF16(name);
item.pszText = wname; item.pszText = wname;
if (SendMessageW(t->hwnd, TCM_INSERTITEM, (WPARAM) n, (LPARAM) (&item)) == (LRESULT) -1) if (SendMessageW(t->hwnd, TCM_INSERTITEM, (WPARAM) n, (LPARAM) (&item)) == (LRESULT) -1)
logLastError("error adding tab to Tab in uiTabInsertBefore()"); logLastError("error adding tab to Tab in uiTabInsertAt()");
uiFree(wname); uiFree(wname);
} }
@ -363,7 +363,7 @@ uiTab *uiNewTab(void)
uiControl(t)->SysFunc = tabSysFunc; uiControl(t)->SysFunc = tabSysFunc;
uiTab(t)->Append = tabAppend; uiTab(t)->Append = tabAppend;
uiTab(t)->InsertBefore = tabInsertBefore; uiTab(t)->InsertAt = tabInsertAt;
uiTab(t)->Delete = tabDelete; uiTab(t)->Delete = tabDelete;
uiTab(t)->NumPages = tabNumPages; uiTab(t)->NumPages = tabNumPages;
uiTab(t)->Margined = tabMargined; uiTab(t)->Margined = tabMargined;

View File

@ -30,7 +30,7 @@ static void tabAppend(uiTab *tt, const char *name, uiControl *child)
{ {
} }
static void tabInsertBefore(uiTab *tt, const char *name, uintmax_t n, uiControl *child) static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *child)
{ {
} }
@ -78,7 +78,7 @@ uiTab *uiNewTab(void)
uiControl(t)->PreferredSize = tabPreferredSize; uiControl(t)->PreferredSize = tabPreferredSize;
uiTab(t)->Append = tabAppend; uiTab(t)->Append = tabAppend;
uiTab(t)->InsertBefore = tabInsertBefore; uiTab(t)->InsertAt = tabInsertAt;
uiTab(t)->Delete = tabDelete; uiTab(t)->Delete = tabDelete;
uiTab(t)->NumPages = tabNumPages; uiTab(t)->NumPages = tabNumPages;
uiTab(t)->Margined = tabMargined; uiTab(t)->Margined = tabMargined;