Add new API functions to get/set table column widths.
uiTableColumnWidth uiTableColumnSetWidth Implementations provided for darwin, unix, and windows.
This commit is contained in:
parent
5577159fe1
commit
30a5533c34
|
@ -216,3 +216,16 @@ uiTable *uiNewTable(uiTableParams *p)
|
|||
|
||||
return t;
|
||||
}
|
||||
|
||||
int uiTableColumnWidth(uiTable *t, int column)
|
||||
{
|
||||
NSTableColumn *tc = [t->tv tableColumnWithIdentifier:[@(column) stringValue]];
|
||||
return [tc width];
|
||||
}
|
||||
|
||||
void uiTableColumnSetWidth(uiTable *t, int column, int width)
|
||||
{
|
||||
NSTableColumn *tc = [t->tv tableColumnWithIdentifier:[@(column) stringValue]];
|
||||
[tc setWidth: width];
|
||||
}
|
||||
|
||||
|
|
|
@ -98,11 +98,26 @@ static void modelSetCellValue(uiTableModelHandler *mh, uiTableModel *m, int row,
|
|||
checkStates[row] = uiTableValueInt(val);
|
||||
}
|
||||
|
||||
uiSpinbox *columnID;
|
||||
uiSpinbox *columnWidth;
|
||||
static void changedColumnID(uiSpinbox *s, void *data)
|
||||
{
|
||||
uiTable *t = data;
|
||||
uiSpinboxSetValue(columnWidth, uiTableColumnWidth(t, uiSpinboxValue(columnID)));
|
||||
}
|
||||
|
||||
static void changedColumnWidth(uiSpinbox *s, void *data)
|
||||
{
|
||||
uiTable *t = data;
|
||||
uiTableColumnSetWidth(t, uiSpinboxValue(columnID), uiSpinboxValue(columnWidth));
|
||||
}
|
||||
|
||||
static uiTableModel *m;
|
||||
|
||||
uiBox *makePage16(void)
|
||||
{
|
||||
uiBox *page16;
|
||||
uiBox *controls;
|
||||
uiTable *t;
|
||||
uiTableParams p;
|
||||
uiTableTextColumnOptionalParams tp;
|
||||
|
@ -119,6 +134,8 @@ uiBox *makePage16(void)
|
|||
memset(checkStates, 0, 15 * sizeof (int));
|
||||
|
||||
page16 = newVerticalBox();
|
||||
controls = newHorizontalBox();
|
||||
uiBoxAppend(page16, uiControl(controls), 0);
|
||||
|
||||
mh.NumColumns = modelNumColumns;
|
||||
mh.ColumnType = modelColumnType;
|
||||
|
@ -152,6 +169,16 @@ uiBox *makePage16(void)
|
|||
uiTableAppendProgressBarColumn(t, "Progress Bar",
|
||||
8);
|
||||
|
||||
uiBoxAppend(controls, uiControl(uiNewLabel("Column")), 0);
|
||||
columnID = uiNewSpinbox(0, INT_MAX);
|
||||
uiBoxAppend(controls, uiControl(columnID), 0);
|
||||
uiBoxAppend(controls, uiControl(uiNewLabel("Width")), 0);
|
||||
columnWidth = uiNewSpinbox(0, INT_MAX);
|
||||
uiBoxAppend(controls, uiControl(columnWidth), 0);
|
||||
|
||||
uiSpinboxOnChanged(columnID, changedColumnID, t);
|
||||
uiSpinboxOnChanged(columnWidth, changedColumnWidth, t);
|
||||
|
||||
return page16;
|
||||
}
|
||||
|
||||
|
|
6
ui.h
6
ui.h
|
@ -1458,6 +1458,12 @@ _UI_EXTERN void uiTableAppendButtonColumn(uiTable *t,
|
|||
// uiNewTable() creates a new uiTable with the specified parameters.
|
||||
_UI_EXTERN uiTable *uiNewTable(uiTableParams *params);
|
||||
|
||||
// uiTableColumnWidth() return current table column width
|
||||
_UI_EXTERN int uiTableColumnWidth(uiTable *t, int column);
|
||||
|
||||
// uiTableColumnSetWidth() set table column width
|
||||
_UI_EXTERN void uiTableColumnSetWidth(uiTable *t, int column, int width);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
13
unix/table.c
13
unix/table.c
|
@ -522,3 +522,16 @@ uiTable *uiNewTable(uiTableParams *p)
|
|||
|
||||
return t;
|
||||
}
|
||||
|
||||
int uiTableColumnWidth(uiTable *t, int column)
|
||||
{
|
||||
GtkTreeViewColumn *c = gtk_tree_view_get_column(t->tv, column);
|
||||
return gtk_tree_view_column_get_width(c);
|
||||
}
|
||||
|
||||
void uiTableColumnSetWidth(uiTable *t, int column, int width)
|
||||
{
|
||||
GtkTreeViewColumn *c = gtk_tree_view_get_column(t->tv, column);
|
||||
gtk_tree_view_column_set_fixed_width(c, width);
|
||||
}
|
||||
|
||||
|
|
|
@ -520,3 +520,14 @@ uiTable *uiNewTable(uiTableParams *p)
|
|||
|
||||
return t;
|
||||
}
|
||||
|
||||
int uiTableColumnWidth(uiTable *t, int column)
|
||||
{
|
||||
return ListView_GetColumnWidth(t->hwnd, column);
|
||||
}
|
||||
|
||||
void uiTableColumnSetWidth(uiTable *t, int column, int width)
|
||||
{
|
||||
ListView_SetColumnWidth(t->hwnd, column, width);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue