// Copyright 2011 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build windows
package walk
import (
"encoding/json"
"fmt"
"math/big"
"reflect"
"syscall"
"time"
"unsafe"
"github.com/lxn/win"
)
const tableViewWindowClass = `\o/ Walk_TableView_Class \o/`
func init() {
MustRegisterWindowClass(tableViewWindowClass)
}
var (
defaultTVRowBGColor = Color(win.GetSysColor(win.COLOR_WINDOW))
white = win.COLORREF(RGB(255, 255, 255))
checkmark = string([]byte{0xE2, 0x9C, 0x94})
tableViewFrozenLVWndProcPtr = syscall.NewCallback(tableViewFrozenLVWndProc)
tableViewNormalLVWndProcPtr = syscall.NewCallback(tableViewNormalLVWndProc)
)
const (
tableViewCurrentIndexChangedTimerId = 1 + iota
tableViewSelectedIndexesChangedTimerId
)
// TableView is a model based widget for record centric, tabular data.
//
// TableView is implemented as a virtual mode list view to support quite large
// amounts of data.
type TableView struct {
WidgetBase
hwndFrozen win.HWND
frozenLVOrigWndProcPtr uintptr
hwndNormal win.HWND
normalLVOrigWndProcPtr uintptr
columns *TableViewColumnList
model TableModel
providedModel interface{}
itemChecker ItemChecker
imageProvider ImageProvider
styler CellStyler
style CellStyle
customDrawItemHot bool
hIml win.HIMAGELIST
usingSysIml bool
imageUintptr2Index map[uintptr]int32
filePath2IconIndex map[string]int32
rowsResetHandlerHandle int
rowChangedHandlerHandle int
rowsInsertedHandlerHandle int
rowsRemovedHandlerHandle int
sortChangedHandlerHandle int
selectedIndexes []int
prevIndex int
currentIndex int
currentIndexChangedPublisher EventPublisher
selectedIndexesChangedPublisher EventPublisher
itemActivatedPublisher EventPublisher
columnClickedPublisher IntEventPublisher
columnsOrderableChangedPublisher EventPublisher
columnsSizableChangedPublisher EventPublisher
publishNextSelClear bool
inSetSelectedIndexes bool
lastColumnStretched bool
inEraseBkgnd bool
persistent bool
itemStateChangedEventDelay int
alternatingRowBGColor Color
hasDarkAltBGColor bool
delayedCurrentIndexChangedCanceled bool
sortedColumnIndex int
sortOrder SortOrder
formActivatingHandle int
scrolling bool
inSetCurrentIndex bool
inMouseEvent bool
hasFrozenColumn bool
}
// NewTableView creates and returns a *TableView as child of the specified
// Container.
func NewTableView(parent Container) (*TableView, error) {
return NewTableViewWithStyle(parent, win.LVS_SHOWSELALWAYS)
}
// NewTableViewWithStyle creates and returns a *TableView as child of the specified
// Container and with the provided additional style bits set.
func NewTableViewWithStyle(parent Container, style uint32) (*TableView, error) {
tv := &TableView{
alternatingRowBGColor: defaultTVRowBGColor,
imageUintptr2Index: make(map[uintptr]int32),
filePath2IconIndex: make(map[string]int32),
formActivatingHandle: -1,
}
tv.columns = newTableViewColumnList(tv)
if err := InitWidget(
tv,
parent,
tableViewWindowClass,
win.WS_BORDER|win.WS_VISIBLE,
win.WS_EX_CONTROLPARENT); err != nil {
return nil, err
}
succeeded := false
defer func() {
if !succeeded {
tv.Dispose()
}
}()
if tv.hwndFrozen = win.CreateWindowEx(
0,
syscall.StringToUTF16Ptr("SysListView32"),
nil,
win.WS_CHILD|win.WS_CLIPSIBLINGS|win.WS_TABSTOP|win.WS_VISIBLE|win.LVS_OWNERDATA|win.LVS_REPORT|style,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
tv.hWnd,
0,
0,
nil,
); tv.hwndFrozen == 0 {
return nil, newErr("creating frozen lv failed")
}
tv.frozenLVOrigWndProcPtr = win.SetWindowLongPtr(tv.hwndFrozen, win.GWLP_WNDPROC, tableViewFrozenLVWndProcPtr)
if tv.frozenLVOrigWndProcPtr == 0 {
return nil, lastError("SetWindowLongPtr")
}
if tv.hwndNormal = win.CreateWindowEx(
0,
syscall.StringToUTF16Ptr("SysListView32"),
nil,
win.WS_CHILD|win.WS_CLIPSIBLINGS|win.WS_TABSTOP|win.WS_VISIBLE|win.LVS_OWNERDATA|win.LVS_REPORT|style,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
win.CW_USEDEFAULT,
tv.hWnd,
0,
0,
nil,
); tv.hwndNormal == 0 {
return nil, newErr("creating normal lv failed")
}
tv.normalLVOrigWndProcPtr = win.SetWindowLongPtr(tv.hwndNormal, win.GWLP_WNDPROC, tableViewNormalLVWndProcPtr)
if tv.normalLVOrigWndProcPtr == 0 {
return nil, lastError("SetWindowLongPtr")
}
tv.SetPersistent(true)
exStyle := win.SendMessage(tv.hwndFrozen, win.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
exStyle |= win.LVS_EX_DOUBLEBUFFER | win.LVS_EX_FULLROWSELECT | win.LVS_EX_HEADERDRAGDROP | win.LVS_EX_LABELTIP | win.LVS_EX_SUBITEMIMAGES
win.SendMessage(tv.hwndFrozen, win.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, exStyle)
win.SendMessage(tv.hwndNormal, win.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, exStyle)
if hr := win.SetWindowTheme(tv.hwndFrozen, syscall.StringToUTF16Ptr("Explorer"), nil); win.FAILED(hr) {
return nil, errorFromHRESULT("SetWindowTheme", hr)
}
if hr := win.SetWindowTheme(tv.hwndNormal, syscall.StringToUTF16Ptr("Explorer"), nil); win.FAILED(hr) {
return nil, errorFromHRESULT("SetWindowTheme", hr)
}
win.SendMessage(tv.hwndFrozen, win.WM_CHANGEUISTATE, uintptr(win.MAKELONG(win.UIS_SET, win.UISF_HIDEFOCUS)), 0)
win.SendMessage(tv.hwndNormal, win.WM_CHANGEUISTATE, uintptr(win.MAKELONG(win.UIS_SET, win.UISF_HIDEFOCUS)), 0)
tv.currentIndex = -1
tv.GraphicsEffects().Add(InteractionEffect)
tv.GraphicsEffects().Add(FocusEffect)
tv.MustRegisterProperty("ColumnsOrderable", NewBoolProperty(
func() bool {
return tv.ColumnsOrderable()
},
func(b bool) error {
tv.SetColumnsOrderable(b)
return nil
},
tv.columnsOrderableChangedPublisher.Event()))
tv.MustRegisterProperty("ColumnsSizable", NewBoolProperty(
func() bool {
return tv.ColumnsSizable()
},
func(b bool) error {
return tv.SetColumnsSizable(b)
},
tv.columnsSizableChangedPublisher.Event()))
tv.MustRegisterProperty("CurrentIndex", NewProperty(
func() interface{} {
return tv.CurrentIndex()
},
func(v interface{}) error {
return tv.SetCurrentIndex(v.(int))
},
tv.CurrentIndexChanged()))
tv.MustRegisterProperty("CurrentItem", NewReadOnlyProperty(
func() interface{} {
if i := tv.CurrentIndex(); i > -1 {
if rm, ok := tv.providedModel.(reflectModel); ok {
return reflect.ValueOf(rm.Items()).Index(i).Interface()
}
}
return nil
},
tv.CurrentIndexChanged()))
tv.MustRegisterProperty("HasCurrentItem", NewReadOnlyBoolProperty(
func() bool {
return tv.CurrentIndex() != -1
},
tv.CurrentIndexChanged()))
tv.MustRegisterProperty("SelectedCount", NewReadOnlyProperty(
func() interface{} {
return len(tv.selectedIndexes)
},
tv.SelectedIndexesChanged()))
succeeded = true
return tv, nil
}
// Dispose releases the operating system resources, associated with the
// *TableView.
func (tv *TableView) Dispose() {
tv.columns.unsetColumnsTV()
tv.disposeImageListAndCaches()
if tv.hWnd != 0 {
if !win.KillTimer(tv.hWnd, tableViewCurrentIndexChangedTimerId) {
lastError("KillTimer")
}
if !win.KillTimer(tv.hWnd, tableViewSelectedIndexesChangedTimerId) {
没有合适的资源?快使用搜索试试~ 我知道了~
golang windowns界面开发框架
共239个文件
go:177个
manifest:23个
syso:23个
需积分: 27 38 下载量 124 浏览量
2018-03-28
00:05:14
上传
评论 3
收藏 420KB ZIP 举报
温馨提示
golang windowns界面开发框架,目前对golang对windowns界面最好的一款框架
资源推荐
资源详情
资源评论
收起资源包目录
golang windowns界面开发框架 (239个子文件)
AUTHORS 929B
update.bat 49B
tableview.go 48KB
window.go 45KB
ui2walk.go 29KB
numberedit.go 18KB
gridlayout.go 16KB
form.go 15KB
builder.go 15KB
combobox.go 15KB
tabwidget.go 14KB
keyboard.go 14KB
models.go 13KB
treeview.go 13KB
canvas.go 12KB
widget.go 11KB
splitter.go 11KB
bitmap.go 11KB
boxlayout.go 11KB
container.go 10KB
toolbar.go 10KB
brush.go 10KB
listbox.go 10KB
databinding.go 9KB
tableviewcolumn.go 8KB
statusbar.go 8KB
scrollview.go 8KB
splitterlayout.go 8KB
reflectmodels.go 8KB
notifyicon.go 8KB
lineedit.go 7KB
groupbox.go 7KB
util.go 7KB
webview.go 7KB
action.go 7KB
property.go 7KB
graphicseffects.go 6KB
filebrowser.go 6KB
multipagemainwindow.go 6KB
dateedit.go 5KB
tooltip.go 5KB
tableview.go 5KB
webview_idochostuihandler.go 5KB
inifilesettings.go 5KB
font.go 5KB
databinding.go 5KB
imageview.go 5KB
gradientcomposite.go 5KB
action.go 5KB
mainwindow.go 4KB
linklabel.go 4KB
commondialogs.go 4KB
mainwindow.go 4KB
customwidget.go 4KB
textedit.go 4KB
webview_ioleinplacesite.go 4KB
lineerrorpresenter.go 4KB
actions.go 4KB
dialog.go 4KB
tableview.go 4KB
menu.go 4KB
icon.go 4KB
button.go 4KB
checkbox.go 4KB
imagelist.go 4KB
tooltiperrorpresenter.go 4KB
dialog.go 4KB
webview_dwebbrowserevents2.go 3KB
webview_ioleinplaceframe.go 3KB
drawing.go 3KB
clipboard.go 3KB
pen.go 3KB
slider.go 3KB
radiobutton.go 3KB
actionlist.go 3KB
resourcemanager.go 3KB
validators.go 3KB
splitter.go 3KB
condition.go 3KB
dialog_ui.go 3KB
main.go 3KB
widgetlist.go 3KB
tabpagelist.go 3KB
imageviewer.go 3KB
webview_ioleclientsite.go 3KB
combobox.go 3KB
tabpage.go 3KB
cursor.go 3KB
tableviewcolumnlist.go 3KB
pushbutton.go 3KB
listbox.go 2KB
gradientcomposite.go 2KB
lineedit.go 2KB
logview.go 2KB
separator.go 2KB
error.go 2KB
layouts.go 2KB
interfaces.go 2KB
metafile.go 2KB
settings.go 2KB
共 239 条
- 1
- 2
- 3
资源评论
普通网友
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功