Fixed up AddColumn parameter and private fields names; made them consistent.

This commit is contained in:
Pietro Gagliardi 2018-06-24 09:52:01 -04:00
parent 4dbf1994a6
commit 72c7c05f04
7 changed files with 46 additions and 46 deletions

View File

@ -57,7 +57,7 @@ struct textColumnCreateParams {
BOOL makeTextField; BOOL makeTextField;
int textModelColumn; int textModelColumn;
int textEditableColumn; int textEditableModelColumn;
uiTableTextColumnOptionalParams textParams; uiTableTextColumnOptionalParams textParams;
BOOL makeImage; BOOL makeImage;
@ -65,7 +65,7 @@ struct textColumnCreateParams {
BOOL makeCheckbox; BOOL makeCheckbox;
int checkboxModelColumn; int checkboxModelColumn;
int checkboxEditableColumn; int checkboxEditableModelColumn;
}; };
@interface uiprivTextImageCheckboxTableCellView : uiprivTableCellView { @interface uiprivTextImageCheckboxTableCellView : uiprivTableCellView {
@ -74,7 +74,7 @@ struct textColumnCreateParams {
NSTextField *tf; NSTextField *tf;
int textModelColumn; int textModelColumn;
int textEditableColumn; int textEditableModelColumn;
uiTableTextColumnOptionalParams textParams; uiTableTextColumnOptionalParams textParams;
NSImageView *iv; NSImageView *iv;
@ -82,7 +82,7 @@ struct textColumnCreateParams {
NSButton *cb; NSButton *cb;
int checkboxModelColumn; int checkboxModelColumn;
int checkboxEditableColumn; int checkboxEditableModelColumn;
} }
- (id)initWithFrame:(NSRect)r params:(struct textColumnCreateParams *)p; - (id)initWithFrame:(NSRect)r params:(struct textColumnCreateParams *)p;
- (IBAction)uiprivOnTextFieldAction:(id)sender; - (IBAction)uiprivOnTextFieldAction:(id)sender;
@ -104,7 +104,7 @@ struct textColumnCreateParams {
self->tf = nil; self->tf = nil;
if (p->makeTextField) { if (p->makeTextField) {
self->textModelColumn = p->textModelColumn; self->textModelColumn = p->textModelColumn;
self->textEditableColumn = p->textEditableColumn; self->textEditableModelColumn = p->textEditableModelColumn;
self->textParams = p->textParams; self->textParams = p->textParams;
self->tf = uiprivNewLabel(@""); self->tf = uiprivNewLabel(@"");
@ -189,7 +189,7 @@ struct textColumnCreateParams {
self->cb = nil; self->cb = nil;
if (p->makeCheckbox) { if (p->makeCheckbox) {
self->checkboxModelColumn = p->checkboxModelColumn; self->checkboxModelColumn = p->checkboxModelColumn;
self->checkboxEditableColumn = p->checkboxEditableColumn; self->checkboxEditableModelColumn = p->checkboxEditableModelColumn;
self->cb = [[NSButton alloc] initWithFrame:NSZeroRect]; self->cb = [[NSButton alloc] initWithFrame:NSZeroRect];
[self->cb setTitle:@""]; [self->cb setTitle:@""];
@ -272,7 +272,7 @@ struct textColumnCreateParams {
uiFreeTableValue(value); uiFreeTableValue(value);
[self->tf setStringValue:str]; [self->tf setStringValue:str];
[self->tf setEditable:isCellEditable(self->m, row, self->textEditableColumn)]; [self->tf setEditable:isCellEditable(self->m, row, self->textEditableModelColumn)];
color = nil; color = nil;
if (self->textParams.ColorModelColumn != -1) { if (self->textParams.ColorModelColumn != -1) {
@ -307,7 +307,7 @@ struct textColumnCreateParams {
[self->cb setState:NSOffState]; [self->cb setState:NSOffState];
uiFreeTableValue(value); uiFreeTableValue(value);
[self->cb setEnabled:isCellEditable(self->m, row, self->checkboxEditableColumn)]; [self->cb setEnabled:isCellEditable(self->m, row, self->checkboxEditableModelColumn)];
} }
} }
@ -606,7 +606,7 @@ struct textColumnCreateParams {
@end @end
void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *params) void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams)
{ {
struct textColumnCreateParams p; struct textColumnCreateParams p;
uiprivTableColumn *col; uiprivTableColumn *col;
@ -618,9 +618,9 @@ void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn,
p.makeTextField = YES; p.makeTextField = YES;
p.textModelColumn = textModelColumn; p.textModelColumn = textModelColumn;
p.textEditableColumn = textEditableModelColumn; p.textEditableModelColumn = textEditableModelColumn;
if (params != NULL) if (textParams != NULL)
p.textParams = *params; p.textParams = *textParams;
else else
p.textParams = uiprivDefaultTextColumnOptionalParams; p.textParams = uiprivDefaultTextColumnOptionalParams;
@ -661,7 +661,7 @@ void uiTableAppendImageTextColumn(uiTable *t, const char *name, int imageModelCo
p.makeTextField = YES; p.makeTextField = YES;
p.textModelColumn = textModelColumn; p.textModelColumn = textModelColumn;
p.textEditableColumn = textEditableModelColumn; p.textEditableModelColumn = textEditableModelColumn;
if (textParams != NULL) if (textParams != NULL)
p.textParams = *textParams; p.textParams = *textParams;
else else
@ -688,7 +688,7 @@ void uiTableAppendCheckboxColumn(uiTable *t, const char *name, int checkboxModel
p.makeCheckbox = YES; p.makeCheckbox = YES;
p.checkboxModelColumn = checkboxModelColumn; p.checkboxModelColumn = checkboxModelColumn;
p.checkboxEditableColumn = checkboxEditableModelColumn; p.checkboxEditableModelColumn = checkboxEditableModelColumn;
str = [NSString stringWithUTF8String:name]; str = [NSString stringWithUTF8String:name];
col = [[uiprivTextImageCheckboxTableColumn alloc] initWithIdentifier:str params:&p]; col = [[uiprivTextImageCheckboxTableColumn alloc] initWithIdentifier:str params:&p];
@ -708,7 +708,7 @@ void uiTableAppendCheckboxTextColumn(uiTable *t, const char *name, int checkboxM
p.makeTextField = YES; p.makeTextField = YES;
p.textModelColumn = textModelColumn; p.textModelColumn = textModelColumn;
p.textEditableColumn = textEditableModelColumn; p.textEditableModelColumn = textEditableModelColumn;
if (textParams != NULL) if (textParams != NULL)
p.textParams = *textParams; p.textParams = *textParams;
else else
@ -716,7 +716,7 @@ void uiTableAppendCheckboxTextColumn(uiTable *t, const char *name, int checkboxM
p.makeCheckbox = YES; p.makeCheckbox = YES;
p.checkboxModelColumn = checkboxModelColumn; p.checkboxModelColumn = checkboxModelColumn;
p.checkboxEditableColumn = checkboxEditableModelColumn; p.checkboxEditableModelColumn = checkboxEditableModelColumn;
str = [NSString stringWithUTF8String:name]; str = [NSString stringWithUTF8String:name];
col = [[uiprivTextImageCheckboxTableColumn alloc] initWithIdentifier:str params:&p]; col = [[uiprivTextImageCheckboxTableColumn alloc] initWithIdentifier:str params:&p];
@ -735,13 +735,13 @@ void uiTableAppendProgressBarColumn(uiTable *t, const char *name, int progressMo
[t->tv addTableColumn:col]; [t->tv addTableColumn:col];
} }
void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonTextModelColumn, int buttonClickableModelColumn) void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonModelColumn, int buttonClickableModelColumn)
{ {
uiprivTableColumn *col; uiprivTableColumn *col;
NSString *str; NSString *str;
str = [NSString stringWithUTF8String:name]; str = [NSString stringWithUTF8String:name];
col = [[uiprivButtonTableColumn alloc] initWithIdentifier:str table:t model:t->m modelColumn:buttonTextModelColumn editableColumn:buttonClickableModelColumn]; col = [[uiprivButtonTableColumn alloc] initWithIdentifier:str table:t model:t->m modelColumn:buttonModelColumn editableColumn:buttonClickableModelColumn];
[col setTitle:str]; [col setTitle:str];
[t->tv addTableColumn:col]; [t->tv addTableColumn:col];
} }

View File

@ -69,7 +69,7 @@ _UI_EXTERN void uiTableAppendTextColumn(uiTable *t,
const char *name, const char *name,
int textModelColumn, int textModelColumn,
int textEditableModelColumn, int textEditableModelColumn,
uiTableTextColumnOptionalParams *params); uiTableTextColumnOptionalParams *textParams);
_UI_EXTERN void uiTableAppendImageColumn(uiTable *t, _UI_EXTERN void uiTableAppendImageColumn(uiTable *t,
const char *name, const char *name,
int imageModelColumn); int imageModelColumn);
@ -95,7 +95,7 @@ _UI_EXTERN void uiTableAppendProgressBarColumn(uiTable *t,
int progressModelColumn); int progressModelColumn);
_UI_EXTERN void uiTableAppendButtonColumn(uiTable *t, _UI_EXTERN void uiTableAppendButtonColumn(uiTable *t,
const char *name, const char *name,
int buttonTextModelColumn, int buttonModelColumn,
int buttonClickableModelColumn); int buttonClickableModelColumn);
// TODO getter? // TODO getter?
_UI_EXTERN void uiTableSetRowBackgroundColorModelColumn(uiTable *t, int modelColumn); _UI_EXTERN void uiTableSetRowBackgroundColorModelColumn(uiTable *t, int modelColumn);

View File

@ -263,7 +263,7 @@ static GtkTreeViewColumn *addColumn(uiTable *t, const char *name)
return c; return c;
} }
static void addTextColumn(uiTable *t, GtkTreeViewColumn *c, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *params) static void addTextColumn(uiTable *t, GtkTreeViewColumn *c, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams)
{ {
struct textColumnParams *p; struct textColumnParams *p;
GtkCellRenderer *r; GtkCellRenderer *r;
@ -274,8 +274,8 @@ static void addTextColumn(uiTable *t, GtkTreeViewColumn *c, int textModelColumn,
p->m = t->model; p->m = t->model;
p->modelColumn = textModelColumn; p->modelColumn = textModelColumn;
p->editableColumn = textEditableModelColumn; p->editableColumn = textEditableModelColumn;
if (params != NULL) if (textParams != NULL)
p->params = *params; p->params = *textParams;
else else
p->params = uiprivDefaultTextColumnOptionalParams; p->params = uiprivDefaultTextColumnOptionalParams;
@ -287,12 +287,12 @@ static void addTextColumn(uiTable *t, GtkTreeViewColumn *c, int textModelColumn,
} }
// TODO rename modelCOlumn and params everywhere // TODO rename modelCOlumn and params everywhere
void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *params) void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams)
{ {
GtkTreeViewColumn *c; GtkTreeViewColumn *c;
c = addColumn(t, name); c = addColumn(t, name);
addTextColumn(t, c, textModelColumn, textEditableModelColumn, params); addTextColumn(t, c, textModelColumn, textEditableModelColumn, textParams);
} }
static void addImageColumn(uiTable *t, GtkTreeViewColumn *c, int imageModelColumn) static void addImageColumn(uiTable *t, GtkTreeViewColumn *c, int imageModelColumn)
@ -381,7 +381,7 @@ void uiTableAppendProgressBarColumn(uiTable *t, const char *name, int progressMo
g_ptr_array_add(t->columnParams, p); g_ptr_array_add(t->columnParams, p);
} }
void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonTextModelColumn, int buttonClickableModelColumn) void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonModelColumn, int buttonClickableModelColumn)
{ {
GtkTreeViewColumn *c; GtkTreeViewColumn *c;
struct buttonColumnParams *p; struct buttonColumnParams *p;
@ -392,7 +392,7 @@ void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonTextModel
p = uiprivNew(struct buttonColumnParams); p = uiprivNew(struct buttonColumnParams);
p->t = t; p->t = t;
p->m = t->model; p->m = t->model;
p->modelColumn = buttonTextModelColumn; p->modelColumn = buttonModelColumn;
p->clickableColumn = buttonClickableModelColumn; p->clickableColumn = buttonClickableModelColumn;
r = uiprivNewCellRendererButton(); r = uiprivNewCellRendererButton();

View File

@ -396,26 +396,26 @@ static uiprivTableColumnParams *appendColumn(uiTable *t, const char *name, int c
p = uiprivNew(uiprivTableColumnParams); p = uiprivNew(uiprivTableColumnParams);
p->textModelColumn = -1; p->textModelColumn = -1;
p->textEditableColumn = -1; p->textEditableModelColumn = -1;
p->textParams = uiprivDefaultTextColumnOptionalParams; p->textParams = uiprivDefaultTextColumnOptionalParams;
p->imageModelColumn = -1; p->imageModelColumn = -1;
p->checkboxModelColumn = -1; p->checkboxModelColumn = -1;
p->checkboxEditableColumn = -1; p->checkboxEditableModelColumn = -1;
p->progressBarModelColumn = -1; p->progressBarModelColumn = -1;
p->buttonModelColumn = -1; p->buttonModelColumn = -1;
t->columns->push_back(p); t->columns->push_back(p);
return p; return p;
} }
void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *params) void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams)
{ {
uiprivTableColumnParams *p; uiprivTableColumnParams *p;
p = appendColumn(t, name, LVCFMT_LEFT); p = appendColumn(t, name, LVCFMT_LEFT);
p->textModelColumn = textModelColumn; p->textModelColumn = textModelColumn;
p->textEditableColumn = textEditableModelColumn; p->textEditableModelColumn = textEditableModelColumn;
if (params != NULL) if (textParams != NULL)
p->textParams = *params; p->textParams = *textParams;
} }
void uiTableAppendImageColumn(uiTable *t, const char *name, int imageModelColumn) void uiTableAppendImageColumn(uiTable *t, const char *name, int imageModelColumn)
@ -432,7 +432,7 @@ void uiTableAppendImageTextColumn(uiTable *t, const char *name, int imageModelCo
p = appendColumn(t, name, LVCFMT_LEFT); p = appendColumn(t, name, LVCFMT_LEFT);
p->textModelColumn = textModelColumn; p->textModelColumn = textModelColumn;
p->textEditableColumn = textEditableModelColumn; p->textEditableModelColumn = textEditableModelColumn;
if (textParams != NULL) if (textParams != NULL)
p->textParams = *textParams; p->textParams = *textParams;
p->imageModelColumn = imageModelColumn; p->imageModelColumn = imageModelColumn;
@ -444,7 +444,7 @@ void uiTableAppendCheckboxColumn(uiTable *t, const char *name, int checkboxModel
p = appendColumn(t, name, LVCFMT_LEFT); p = appendColumn(t, name, LVCFMT_LEFT);
p->checkboxModelColumn = checkboxModelColumn; p->checkboxModelColumn = checkboxModelColumn;
p->checkboxEditableColumn = checkboxEditableModelColumn; p->checkboxEditableModelColumn = checkboxEditableModelColumn;
} }
void uiTableAppendCheckboxTextColumn(uiTable *t, const char *name, int checkboxModelColumn, int checkboxEditableModelColumn, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams) void uiTableAppendCheckboxTextColumn(uiTable *t, const char *name, int checkboxModelColumn, int checkboxEditableModelColumn, int textModelColumn, int textEditableModelColumn, uiTableTextColumnOptionalParams *textParams)
@ -453,11 +453,11 @@ void uiTableAppendCheckboxTextColumn(uiTable *t, const char *name, int checkboxM
p = appendColumn(t, name, LVCFMT_LEFT); p = appendColumn(t, name, LVCFMT_LEFT);
p->textModelColumn = textModelColumn; p->textModelColumn = textModelColumn;
p->textEditableColumn = textEditableModelColumn; p->textEditableModelColumn = textEditableModelColumn;
if (textParams != NULL) if (textParams != NULL)
p->textParams = *textParams; p->textParams = *textParams;
p->checkboxModelColumn = checkboxModelColumn; p->checkboxModelColumn = checkboxModelColumn;
p->checkboxEditableColumn = checkboxEditableModelColumn; p->checkboxEditableModelColumn = checkboxEditableModelColumn;
} }
void uiTableAppendProgressBarColumn(uiTable *t, const char *name, int progressModelColumn) void uiTableAppendProgressBarColumn(uiTable *t, const char *name, int progressModelColumn)
@ -468,13 +468,13 @@ void uiTableAppendProgressBarColumn(uiTable *t, const char *name, int progressMo
p->progressBarModelColumn = progressModelColumn; p->progressBarModelColumn = progressModelColumn;
} }
void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonTextModelColumn, int buttonClickableModelColumn) void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonModelColumn, int buttonClickableModelColumn)
{ {
uiprivTableColumnParams *p; uiprivTableColumnParams *p;
// TODO see if we can get rid of this parameter // TODO see if we can get rid of this parameter
p = appendColumn(t, name, LVCFMT_LEFT); p = appendColumn(t, name, LVCFMT_LEFT);
p->buttonModelColumn = buttonTextModelColumn; p->buttonModelColumn = buttonModelColumn;
p->buttonClickableModelColumn = buttonClickableModelColumn; p->buttonClickableModelColumn = buttonClickableModelColumn;
} }

View File

@ -10,13 +10,13 @@ struct uiTableModel {
typedef struct uiprivTableColumnParams uiprivTableColumnParams; typedef struct uiprivTableColumnParams uiprivTableColumnParams;
struct uiprivTableColumnParams { struct uiprivTableColumnParams {
int textModelColumn; int textModelColumn;
int textEditableColumn; int textEditableModelColumn;
uiTableTextColumnOptionalParams textParams; uiTableTextColumnOptionalParams textParams;
int imageModelColumn; int imageModelColumn;
int checkboxModelColumn; int checkboxModelColumn;
int checkboxEditableColumn; int checkboxEditableModelColumn;
int progressBarModelColumn; int progressBarModelColumn;

View File

@ -197,7 +197,7 @@ static HRESULT drawCheckboxPart(HRESULT hr, struct drawState *s)
value = uiprivTableModelCellValue(s->model, s->iItem, s->p->checkboxModelColumn); value = uiprivTableModelCellValue(s->model, s->iItem, s->p->checkboxModelColumn);
checked = uiTableValueInt(value); checked = uiTableValueInt(value);
uiFreeTableValue(value); uiFreeTableValue(value);
switch (s->p->checkboxEditableColumn) { switch (s->p->checkboxEditableModelColumn) {
case uiTableModelColumnNeverEditable: case uiTableModelColumnNeverEditable:
enabled = 0; enabled = 0;
break; break;
@ -205,7 +205,7 @@ static HRESULT drawCheckboxPart(HRESULT hr, struct drawState *s)
enabled = 1; enabled = 1;
break; break;
default: default:
value = uiprivTableModelCellValue(s->model, s->iItem, s->p->checkboxEditableColumn); value = uiprivTableModelCellValue(s->model, s->iItem, s->p->checkboxEditableModelColumn);
enabled = uiTableValueInt(value); enabled = uiTableValueInt(value);
uiFreeTableValue(value); uiFreeTableValue(value);
} }
@ -422,7 +422,7 @@ static HRESULT drawButtonPart(HRESULT hr, struct drawState *s)
enabled = 1; enabled = 1;
break; break;
default: default:
value = uiprivTableModelCellValue(s->model, s->iItem, s->p->checkboxEditableColumn); value = uiprivTableModelCellValue(s->model, s->iItem, s->p->checkboxEditableModelColumn);
enabled = uiTableValueInt(value); enabled = uiTableValueInt(value);
uiFreeTableValue(value); uiFreeTableValue(value);
} }

View File

@ -215,11 +215,11 @@ HRESULT uiprivTableHandleNM_CLICK(uiTable *t, NMITEMACTIVATE *nm, LRESULT *lResu
p = (*(t->columns))[ht.iSubItem]; p = (*(t->columns))[ht.iSubItem];
if (p->textModelColumn != -1) { if (p->textModelColumn != -1) {
modelColumn = p->textModelColumn; modelColumn = p->textModelColumn;
editableColumn = p->textEditableColumn; editableColumn = p->textEditableModelColumn;
text = true; text = true;
} else if (p->checkboxModelColumn != -1) { } else if (p->checkboxModelColumn != -1) {
modelColumn = p->checkboxModelColumn; modelColumn = p->checkboxModelColumn;
editableColumn = p->checkboxEditableColumn; editableColumn = p->checkboxEditableModelColumn;
checkbox = true; checkbox = true;
} else if (p->buttonModelColumn != -1) { } else if (p->buttonModelColumn != -1) {
modelColumn = p->buttonModelColumn; modelColumn = p->buttonModelColumn;