diff options
| author | Pietro Gagliardi <[email protected]> | 2014-10-02 10:05:53 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-10-02 10:05:53 -0400 |
| commit | 982004d05052ef6aadd22dd5c4e7dbca85ab324a (patch) | |
| tree | 517a0f5a5397e6fb886b5e4741aff4fa18ba10d8 /table_windows.go | |
| parent | 09db0bffffded1a68c562b2d6451c2a2b29ac279 (diff) | |
go fmt. Precursor to bug report filing.
Diffstat (limited to 'table_windows.go')
| -rw-r--r-- | table_windows.go | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/table_windows.go b/table_windows.go index f69cc14..c606654 100644 --- a/table_windows.go +++ b/table_windows.go @@ -4,8 +4,8 @@ package ui import ( "fmt" - "unsafe" "reflect" + "unsafe" ) // #include "winapi_windows.h" @@ -13,32 +13,32 @@ import "C" type table struct { *tablebase - _hwnd C.HWND - noautosize bool - colcount C.int - hotrow C.int - hotcol C.int - pushedrow C.int - pushedcol C.int - selected *event + _hwnd C.HWND + noautosize bool + colcount C.int + hotrow C.int + hotcol C.int + pushedrow C.int + pushedcol C.int + selected *event } func finishNewTable(b *tablebase, ty reflect.Type) Table { t := &table{ - _hwnd: C.newControl(C.xWC_LISTVIEW, - C.LVS_REPORT | C.LVS_OWNERDATA | C.LVS_NOSORTHEADER | C.LVS_SHOWSELALWAYS | C.LVS_SINGLESEL | C.WS_HSCROLL | C.WS_VSCROLL | C.WS_TABSTOP, - C.WS_EX_CLIENTEDGE), // WS_EX_CLIENTEDGE without WS_BORDER will show the canonical visual styles border (thanks to MindChild in irc.efnet.net/#winprog) - tablebase: b, - hotrow: -1, - hotcol: -1, - pushedrow: -1, - pushedcol: -1, - selected: newEvent(), + _hwnd: C.newControl(C.xWC_LISTVIEW, + C.LVS_REPORT|C.LVS_OWNERDATA|C.LVS_NOSORTHEADER|C.LVS_SHOWSELALWAYS|C.LVS_SINGLESEL|C.WS_HSCROLL|C.WS_VSCROLL|C.WS_TABSTOP, + C.WS_EX_CLIENTEDGE), // WS_EX_CLIENTEDGE without WS_BORDER will show the canonical visual styles border (thanks to MindChild in irc.efnet.net/#winprog) + tablebase: b, + hotrow: -1, + hotcol: -1, + pushedrow: -1, + pushedcol: -1, + selected: newEvent(), } C.setTableSubclass(t._hwnd, unsafe.Pointer(t)) // LVS_EX_FULLROWSELECT gives us selection across the whole row, not just the leftmost column; this makes the list view work like on other platforms // LVS_EX_SUBITEMIMAGES gives us images in subitems, which will be important when both images and checkboxes are added - C.tableAddExtendedStyles(t._hwnd, C.LVS_EX_FULLROWSELECT | C.LVS_EX_SUBITEMIMAGES) + C.tableAddExtendedStyles(t._hwnd, C.LVS_EX_FULLROWSELECT|C.LVS_EX_SUBITEMIMAGES) // this must come after the subclass because it uses one of our private messages C.SendMessageW(t._hwnd, C.msgTableMakeInitialCheckboxImageList, 0, 0) for i := 0; i < ty.NumField(); i++ { @@ -89,18 +89,18 @@ func tableGetCell(data unsafe.Pointer, item *C.LVITEMW) { d := reflect.Indirect(reflect.ValueOf(t.data)) datum := d.Index(int(item.iItem)).Field(int(item.iSubItem)) isText := true - if item.mask & C.LVIF_IMAGE != 0 { + if item.mask&C.LVIF_IMAGE != 0 { if datum.Type() == reflect.TypeOf(ImageIndex(0)) { item.iImage = C.int(datum.Interface().(ImageIndex)) isText = false } // else let the default behavior work } - if item.mask & C.LVIF_INDENT != 0 { + if item.mask&C.LVIF_INDENT != 0 { // always have an indent of zero item.iIndent = 0 } - if item.mask & C.LVIF_STATE != 0 { + if item.mask&C.LVIF_STATE != 0 { // start by not changing any state item.stateMask = 0 if datum.Kind() == reflect.Bool { @@ -129,7 +129,7 @@ func tableGetCell(data unsafe.Pointer, item *C.LVITEMW) { isText = false } } - if item.mask & C.LVIF_TEXT != 0 { + if item.mask&C.LVIF_TEXT != 0 { if isText { s := fmt.Sprintf("%v", datum) item.pszText = toUTF16(s) @@ -190,10 +190,10 @@ func tableToggled(data unsafe.Pointer, row C.int, col C.int) { // and THEN unlock so the reset takes effect t.Unlock() }() - if row == -1 || col == -1 { // discard extras sent by handle() in table_windows.c + if row == -1 || col == -1 { // discard extras sent by handle() in table_windows.c return } - if row != t.pushedrow || col != t.pushedcol { // mouse moved out + if row != t.pushedrow || col != t.pushedcol { // mouse moved out return } d := reflect.Indirect(reflect.ValueOf(t.data)) @@ -226,7 +226,7 @@ func (t *table) allocate(x int, y int, width int, height int, d *sizing) []*allo const ( // from C++ Template 05 in http://msdn.microsoft.com/en-us/library/windows/desktop/bb226818%28v=vs.85%29.aspx as this is the best I can do for now // there IS a message LVM_APPROXIMATEVIEWRECT that can do calculations, but it doesn't seem to work right when asked to base its calculations on the current width/height on Windows and wine... - tableWidth = 183 + tableWidth = 183 tableHeight = 50 ) |
