diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-24 17:56:48 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-24 18:18:41 +0200 |
commit | daf0a47a045a93457eca5a862077cfcc58dae473 (patch) | |
tree | 8d40d14258f87031ac0d075e07891504797202ee | |
parent | WindowBase: Don't ignore layout request only because the requesting window is invisible (diff) | |
download | wireguard-windows-daf0a47a045a93457eca5a862077cfcc58dae473.tar.xz wireguard-windows-daf0a47a045a93457eca5a862077cfcc58dae473.zip |
TableView: allow disabling scrollbars
-rw-r--r-- | boxlayout.go | 5 | ||||
-rw-r--r-- | tableview.go | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/boxlayout.go b/boxlayout.go index f1b7e26f..5fc20cab 100644 --- a/boxlayout.go +++ b/boxlayout.go @@ -16,8 +16,9 @@ import ( type Orientation byte const ( - Horizontal Orientation = iota - Vertical + NoOrientation Orientation = 0 + Horizontal = 1 << 0 + Vertical = 1 << 1 ) type BoxLayout struct { diff --git a/tableview.go b/tableview.go index cb536819..b82f786f 100644 --- a/tableview.go +++ b/tableview.go @@ -121,6 +121,7 @@ type TableView struct { focused bool ignoreNowhere bool updateLVSizesNeedsSpecialCare bool + scrollbarOrientation Orientation } // NewTableView creates and returns a *TableView as child of the specified @@ -144,6 +145,7 @@ func NewTableViewWithCfg(parent Container, cfg *TableViewCfg) (*TableView, error formActivatingHandle: -1, customHeaderHeight: cfg.CustomHeaderHeight, customRowHeight: cfg.CustomRowHeight, + scrollbarOrientation: Horizontal | Vertical, } tv.columns = newTableViewColumnList(tv) @@ -1749,6 +1751,17 @@ func tableViewFrozenLVWndProc(hwnd win.HWND, msg uint32, wp, lp uintptr) uintptr func tableViewNormalLVWndProc(hwnd win.HWND, msg uint32, wp, lp uintptr) uintptr { tv := (*TableView)(unsafe.Pointer(windowFromHandle(win.GetParent(hwnd)).AsWindowBase())) + var off uint32 = win.WS_HSCROLL | win.WS_VSCROLL + if tv.scrollbarOrientation&Horizontal != 0 { + off &^= win.WS_HSCROLL + } + if tv.scrollbarOrientation&Vertical != 0 { + off &^= win.WS_VSCROLL + } + if off != 0 { + ensureWindowLongBits(hwnd, win.GWL_STYLE, off, false) + } + switch msg { case win.WM_LBUTTONDOWN, win.WM_RBUTTONDOWN: win.SetFocus(tv.hwndFrozenLV) @@ -2475,3 +2488,11 @@ func (tv *TableView) updateLVSizesWithSpecialCare(needSpecialCare bool) { func (*TableView) CreateLayoutItem(ctx *LayoutContext) LayoutItem { return NewGreedyLayoutItem() } + +func (tv *TableView) SetScrollbarOrientation(orientation Orientation) { + tv.scrollbarOrientation = orientation +} + +func (tv *TableView) ScrollbarOrientation() Orientation { + return tv.scrollbarOrientation +} |