further style consistency tweaks
This commit is contained in:
parent
4246ae5549
commit
ba13227bed
|
@ -1,9 +1,5 @@
|
||||||
#include "uipriv_windows.hpp"
|
#include "uipriv_windows.hpp"
|
||||||
|
|
||||||
//static void uiTableMinimumSize(uiWindowsControl *c, int *width, int *height);
|
|
||||||
|
|
||||||
struct uiTable;
|
|
||||||
|
|
||||||
struct uiTableModel {
|
struct uiTableModel {
|
||||||
uiTableModelHandler *mh;
|
uiTableModelHandler *mh;
|
||||||
std::vector<uiTable *> tables;
|
std::vector<uiTable *> tables;
|
||||||
|
@ -42,7 +38,6 @@ uiTableModel *uiNewTableModel(uiTableModelHandler *mh)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void uiFreeTableModel(uiTableModel *m)
|
void uiFreeTableModel(uiTableModel *m)
|
||||||
{
|
{
|
||||||
delete m;
|
delete m;
|
||||||
|
@ -55,28 +50,25 @@ void uiTableModelRowInserted(uiTableModel *m, int newIndex)
|
||||||
ZeroMemory(&item, sizeof (LVITEMW));
|
ZeroMemory(&item, sizeof (LVITEMW));
|
||||||
item.mask = 0;
|
item.mask = 0;
|
||||||
item.iItem = newIndex;
|
item.iItem = newIndex;
|
||||||
item.iSubItem = 0; //?
|
item.iSubItem = 0;
|
||||||
for (auto t : m->tables) {
|
for (auto t : m->tables)
|
||||||
if (SendMessageW(t->hwnd, LVM_INSERTITEM, 0, (LPARAM) (&item)) == (LRESULT) (-1))
|
if (SendMessageW(t->hwnd, LVM_INSERTITEM, 0, (LPARAM) (&item)) == (LRESULT) (-1))
|
||||||
logLastError(L"error calling LVM_INSERTITEM in uiTableModelRowInserted()");
|
logLastError(L"error calling LVM_INSERTITEM in uiTableModelRowInserted()");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void uiTableModelRowChanged(uiTableModel *m, int index)
|
void uiTableModelRowChanged(uiTableModel *m, int index)
|
||||||
{
|
{
|
||||||
for (auto t : m->tables) {
|
for (auto t : m->tables)
|
||||||
if (SendMessageW(t->hwnd, LVM_UPDATE, (WPARAM) index, 0) == (LRESULT) (-1))
|
if (SendMessageW(t->hwnd, LVM_UPDATE, (WPARAM) index, 0) == (LRESULT) (-1))
|
||||||
logLastError(L"error calling LVM_UPDATE in uiTableModelRowChanged()");
|
logLastError(L"error calling LVM_UPDATE in uiTableModelRowChanged()");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void uiTableModelRowDeleted(uiTableModel *m, int oldIndex)
|
void uiTableModelRowDeleted(uiTableModel *m, int oldIndex)
|
||||||
{
|
{
|
||||||
for (auto t : m->tables) {
|
for (auto t : m->tables)
|
||||||
if (SendMessageW(t->hwnd, LVM_DELETEITEM, (WPARAM) oldIndex, 0) == (LRESULT) (-1))
|
if (SendMessageW(t->hwnd, LVM_DELETEITEM, (WPARAM) oldIndex, 0) == (LRESULT) (-1))
|
||||||
logLastError(L"error calling LVM_DELETEITEM in uiTableModelRowDeleted()");
|
logLastError(L"error calling LVM_DELETEITEM in uiTableModelRowDeleted()");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand)
|
void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand)
|
||||||
{
|
{
|
||||||
|
@ -84,20 +76,17 @@ void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand)
|
||||||
int lvIndex = 0;
|
int lvIndex = 0;
|
||||||
LVCOLUMNW lvc;
|
LVCOLUMNW lvc;
|
||||||
|
|
||||||
if (c->modelColumn >=0) {
|
if (c->modelColumn >= 0)
|
||||||
return; // multiple parts not implemented
|
return; // multiple parts not implemented
|
||||||
}
|
|
||||||
c->modelColumn = modelColumn;
|
c->modelColumn = modelColumn;
|
||||||
|
|
||||||
// work out appropriate listview index for the column
|
// work out appropriate listview index for the column
|
||||||
for (auto candidate : t->columns) {
|
for (auto candidate : t->columns) {
|
||||||
if (candidate == c) {
|
if (candidate == c)
|
||||||
break;
|
break;
|
||||||
}
|
if (candidate->modelColumn >= 0)
|
||||||
if (candidate->modelColumn >= 0) {
|
|
||||||
lvIndex++;
|
lvIndex++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ZeroMemory(&lvc, sizeof (LVCOLUMNW));
|
ZeroMemory(&lvc, sizeof (LVCOLUMNW));
|
||||||
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; /* | LVCF_SUBITEM; */
|
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; /* | LVCF_SUBITEM; */
|
||||||
|
@ -130,7 +119,7 @@ void uiTableColumnAppendProgressBarPart(uiTableColumn *c, int modelColumn, int e
|
||||||
|
|
||||||
void uiTableColumnPartSetEditable(uiTableColumn *c, int part, int editable)
|
void uiTableColumnPartSetEditable(uiTableColumn *c, int part, int editable)
|
||||||
{
|
{
|
||||||
// TODO
|
// not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTableColumnPartSetTextColor(uiTableColumn *c, int part, int modelColumn)
|
void uiTableColumnPartSetTextColor(uiTableColumn *c, int part, int modelColumn)
|
||||||
|
@ -187,7 +176,8 @@ static void uiTableDestroy(uiControl *c)
|
||||||
// suggested listview sizing from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing:
|
// suggested listview sizing from http://msdn.microsoft.com/en-us/library/windows/desktop/dn742486.aspx#sizingandspacing:
|
||||||
// "columns widths that avoid truncated data x an integral number of items"
|
// "columns widths that avoid truncated data x an integral number of items"
|
||||||
// Don't think that'll cut it when some cells have overlong data (eg
|
// Don't think that'll cut it when some cells have overlong data (eg
|
||||||
// stupidly long URLs). So for now, just hardcode a minimum:
|
// stupidly long URLs). So for now, just hardcode a minimum.
|
||||||
|
// TODO: Investigate using LVM_GETHEADER/HDM_LAYOUT here...
|
||||||
#define tableMinWidth 107 /* in line with other controls */
|
#define tableMinWidth 107 /* in line with other controls */
|
||||||
#define tableMinHeight (14*3) /* header + 2 lines (roughly) */
|
#define tableMinHeight (14*3) /* header + 2 lines (roughly) */
|
||||||
|
|
||||||
|
@ -205,7 +195,6 @@ static void uiTableMinimumSize(uiWindowsControl *c, int *width, int *height)
|
||||||
*height = y;
|
*height = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nmhdr, LRESULT *lResult)
|
static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nmhdr, LRESULT *lResult)
|
||||||
{
|
{
|
||||||
uiTable *t = uiTable(c);
|
uiTable *t = uiTable(c);
|
||||||
|
@ -252,12 +241,10 @@ static BOOL onWM_NOTIFY(uiControl *c, HWND hwnd, NMHDR *nmhdr, LRESULT *lResult)
|
||||||
sprintf(buf, "%d", (int)data);
|
sprintf(buf, "%d", (int)data);
|
||||||
n = MultiByteToWideChar(CP_UTF8, 0, buf, -1, item->pszText, item->cchTextMax);
|
n = MultiByteToWideChar(CP_UTF8, 0, buf, -1, item->pszText, item->cchTextMax);
|
||||||
// make sure clipped strings are nul-terminated
|
// make sure clipped strings are nul-terminated
|
||||||
if (n>=item->cchTextMax) {
|
if (n >= item->cchTextMax)
|
||||||
item->pszText[item->cchTextMax-1] = L'\0';
|
item->pszText[item->cchTextMax-1] = L'\0';
|
||||||
}
|
} else
|
||||||
} else {
|
|
||||||
item->pszText[0] = L'\0';
|
item->pszText[0] = L'\0';
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -283,10 +270,10 @@ uiTable *uiNewTable(uiTableModel *model)
|
||||||
model->tables.push_back(t);
|
model->tables.push_back(t);
|
||||||
uiWindowsRegisterWM_NOTIFYHandler(t->hwnd, onWM_NOTIFY, uiControl(t));
|
uiWindowsRegisterWM_NOTIFYHandler(t->hwnd, onWM_NOTIFY, uiControl(t));
|
||||||
|
|
||||||
|
// TODO: try LVS_EX_AUTOSIZECOLUMNS
|
||||||
SendMessageW(t->hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE,
|
SendMessageW(t->hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE,
|
||||||
(WPARAM) (LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP),
|
(WPARAM) (LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP),
|
||||||
(LPARAM) (LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP));
|
(LPARAM) (LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP));
|
||||||
// TODO: try LVS_EX_AUTOSIZECOLUMNS
|
|
||||||
n = (*(model->mh->NumRows))(model->mh, model);
|
n = (*(model->mh->NumRows))(model->mh, model);
|
||||||
if (SendMessageW(t->hwnd, LVM_SETITEMCOUNT, (WPARAM) n, 0) == 0)
|
if (SendMessageW(t->hwnd, LVM_SETITEMCOUNT, (WPARAM) n, 0) == 0)
|
||||||
logLastError(L"error calling LVM_SETITEMCOUNT in uiNewTable()");
|
logLastError(L"error calling LVM_SETITEMCOUNT in uiNewTable()");
|
||||||
|
|
Loading…
Reference in New Issue