Permalink
Browse files

Export InitWidget and InitChildWidget

  • Loading branch information...
1 parent 56df135 commit c0d49320aef2ea119363443043ae4cba89e639b3 @lxn committed Sep 15, 2012
Showing with 41 additions and 30 deletions.
  1. +1 −1 checkbox.go
  2. +1 −1 combobox.go
  3. +1 −1 composite.go
  4. +1 −1 customwidget.go
  5. +1 −1 dateedit.go
  6. +1 −1 dialog.go
  7. +1 −1 groupbox.go
  8. +1 −1 label.go
  9. +1 −1 lineedit.go
  10. +1 −1 listbox.go
  11. +1 −1 mainwindow.go
  12. +1 −1 numberedit.go
  13. +1 −1 progressbar.go
  14. +1 −1 pushbutton.go
  15. +1 −1 radiobutton.go
  16. +1 −1 spacer.go
  17. +1 −1 splitter.go
  18. +1 −1 splitterhandle.go
  19. +1 −1 tableview.go
  20. +1 −1 tabpage.go
  21. +1 −1 tabwidget.go
  22. +1 −1 textedit.go
  23. +1 −1 toolbar.go
  24. +1 −1 toolbutton.go
  25. +1 −1 tooltip.go
  26. +1 −1 treeview.go
  27. +1 −1 webview.go
  28. +14 −3 widget.go
View
2 checkbox.go
@@ -13,7 +13,7 @@ type CheckBox struct {
func NewCheckBox(parent Container) (*CheckBox, error) {
cb := &CheckBox{}
- if err := initChildWidget(
+ if err := InitChildWidget(
cb,
parent,
"BUTTON",
View
2 combobox.go
@@ -29,7 +29,7 @@ type ComboBox struct {
func NewComboBox(parent Container) (*ComboBox, error) {
cb := &ComboBox{prevCurIndex: -1, precision: 2}
- if err := initChildWidget(
+ if err := InitChildWidget(
cb,
parent,
"COMBOBOX",
View
2 composite.go
@@ -21,7 +21,7 @@ func newCompositeWithStyle(parent Container, style uint32) (*Composite, error) {
c.children = newWidgetList(c)
c.SetPersistent(true)
- if err := initChildWidget(
+ if err := InitChildWidget(
c,
parent,
compositeWindowClass,
View
2 customwidget.go
@@ -24,7 +24,7 @@ type CustomWidget struct {
func NewCustomWidget(parent Container, style uint, paint PaintFunc) (*CustomWidget, error) {
cw := &CustomWidget{paint: paint}
- if err := initChildWidget(
+ if err := InitChildWidget(
cw,
parent,
customWidgetWindowClass,
View
2 dateedit.go
@@ -39,7 +39,7 @@ type DateEdit struct {
func NewDateEdit(parent Container) (*DateEdit, error) {
de := &DateEdit{}
- if err := initChildWidget(
+ if err := InitChildWidget(
de,
parent,
"SysDateTimePick32",
View
2 dialog.go
@@ -52,7 +52,7 @@ func NewDialog(owner RootWidget) (*Dialog, error) {
},
}
- if err := initWidget(
+ if err := InitWidget(
dlg,
owner,
dialogWindowClass,
View
2 groupbox.go
@@ -23,7 +23,7 @@ type GroupBox struct {
func NewGroupBox(parent Container) (*GroupBox, error) {
gb := &GroupBox{}
- if err := initChildWidget(
+ if err := InitChildWidget(
gb,
parent,
groupBoxWindowClass,
View
2 label.go
@@ -13,7 +13,7 @@ type Label struct {
func NewLabel(parent Container) (*Label, error) {
l := &Label{}
- if err := initChildWidget(
+ if err := InitChildWidget(
l,
parent,
"STATIC",
View
2 lineedit.go
@@ -22,7 +22,7 @@ type LineEdit struct {
func newLineEdit(parent Widget) (*LineEdit, error) {
le := &LineEdit{}
- if err := initWidget(
+ if err := InitWidget(
le,
parent,
"EDIT",
View
2 listbox.go
@@ -29,7 +29,7 @@ type ListBox struct {
func NewListBox(parent Container) (*ListBox, error) {
lb := &ListBox{}
- err := initChildWidget(
+ err := InitChildWidget(
lb,
parent,
"LISTBOX",
View
2 mainwindow.go
@@ -22,7 +22,7 @@ type MainWindow struct {
func NewMainWindow() (*MainWindow, error) {
mw := &MainWindow{}
- if err := initWidget(
+ if err := InitWidget(
mw,
nil,
mainWindowWindowClass,
View
2 numberedit.go
@@ -31,7 +31,7 @@ type NumberEdit struct {
func NewNumberEdit(parent Container) (*NumberEdit, error) {
ne := &NumberEdit{increment: 1}
- if err := initChildWidget(
+ if err := InitChildWidget(
ne,
parent,
numberEditWindowClass,
View
2 progressbar.go
@@ -13,7 +13,7 @@ type ProgressBar struct {
func NewProgressBar(parent Container) (*ProgressBar, error) {
pb := &ProgressBar{}
- if err := initChildWidget(
+ if err := InitChildWidget(
pb,
parent,
"msctls_progress32",
View
2 pushbutton.go
@@ -15,7 +15,7 @@ type PushButton struct {
func NewPushButton(parent Container) (*PushButton, error) {
pb := &PushButton{}
- if err := initChildWidget(
+ if err := InitChildWidget(
pb,
parent,
"BUTTON",
View
2 radiobutton.go
@@ -13,7 +13,7 @@ type RadioButton struct {
func NewRadioButton(parent Container) (*RadioButton, error) {
rb := &RadioButton{}
- if err := initChildWidget(
+ if err := InitChildWidget(
rb,
parent,
"BUTTON",
View
2 spacer.go
@@ -22,7 +22,7 @@ func newSpacer(parent Container, layoutFlags LayoutFlags, sizeHint Size) (*Space
sizeHint: sizeHint,
}
- if err := initChildWidget(
+ if err := InitChildWidget(
s,
parent,
spacerWindowClass,
View
2 splitter.go
@@ -41,7 +41,7 @@ func NewSplitter(parent Container) (*Splitter, error) {
s.children = newWidgetList(s)
layout.container = s
- if err := initChildWidget(
+ if err := InitChildWidget(
s,
parent,
splitterWindowClass,
View
2 splitterhandle.go
@@ -24,7 +24,7 @@ func newSplitterHandle(splitter *Splitter) (*splitterHandle, error) {
sh := &splitterHandle{}
sh.parent = splitter
- if err := initWidget(
+ if err := InitWidget(
sh,
splitter,
splitterHandleWindowClass,
View
2 tableview.go
@@ -65,7 +65,7 @@ func NewTableView(parent Container) (*TableView, error) {
selectedIndexes: NewIndexList(nil),
}
- if err := initChildWidget(
+ if err := InitChildWidget(
tv,
parent,
"SysListView32",
View
2 tabpage.go
@@ -23,7 +23,7 @@ type TabPage struct {
func NewTabPage() (*TabPage, error) {
tp := &TabPage{}
- if err := initWidget(
+ if err := InitWidget(
tp,
nil,
tabPageWindowClass,
View
2 tabwidget.go
@@ -31,7 +31,7 @@ func NewTabWidget(parent Container) (*TabWidget, error) {
tw := &TabWidget{currentIndex: -1}
tw.pages = newTabPageList(tw)
- if err := initChildWidget(
+ if err := InitChildWidget(
tw,
parent,
tabWidgetWindowClass,
View
2 textedit.go
@@ -15,7 +15,7 @@ type TextEdit struct {
func NewTextEdit(parent Container) (*TextEdit, error) {
te := &TextEdit{}
- if err := initChildWidget(
+ if err := InitChildWidget(
te,
parent,
"EDIT",
View
2 toolbar.go
@@ -23,7 +23,7 @@ func newToolBar(parent Container, style uint32) (*ToolBar, error) {
tb := &ToolBar{}
tb.actions = newActionList(tb)
- if err := initChildWidget(
+ if err := InitChildWidget(
tb,
parent,
"ToolbarWindow32",
View
2 toolbutton.go
@@ -13,7 +13,7 @@ type ToolButton struct {
func NewToolButton(parent Container) (*ToolButton, error) {
tb := &ToolButton{}
- if err := initChildWidget(
+ if err := InitChildWidget(
tb,
parent,
"BUTTON",
View
2 tooltip.go
@@ -18,7 +18,7 @@ type ToolTip struct {
func NewToolTip(parent Container) (*ToolTip, error) {
tt := &ToolTip{}
- if err := initWidget(
+ if err := InitWidget(
tt,
parent,
"tooltips_class32",
View
2 treeview.go
@@ -25,7 +25,7 @@ type TreeView struct {
func NewTreeView(parent Container) (*TreeView, error) {
tv := &TreeView{}
- if err := initChildWidget(
+ if err := InitChildWidget(
tv,
parent,
"SysTreeView32",
View
2 webview.go
@@ -52,7 +52,7 @@ func NewWebView(parent Container) (*WebView, error) {
},
}
- if err := initChildWidget(
+ if err := InitChildWidget(
wv,
parent,
webViewWindowClass,
View
17 widget.go
@@ -309,6 +309,12 @@ var widgetWndProcPtr uintptr = syscall.NewCallback(widgetWndProc)
var registeredWindowClasses map[string]bool = make(map[string]bool)
+// MustRegisterWindowClass registers the specified window class.
+//
+// MustRegisterWindowClass must be called once for every widget type that is not
+// based on any system provided control, before calling InitChildWidget or
+// InitWidget. Calling MustRegisterWindowClass twice with the same className
+// results in a panic.
func MustRegisterWindowClass(className string) {
if registeredWindowClasses[className] {
panic("window class already registered")
@@ -345,7 +351,11 @@ func MustRegisterWindowClass(className string) {
registeredWindowClasses[className] = true
}
-func initWidget(widget, parent Widget, className string, style, exStyle uint32) error {
+// InitWidget initializes a widget.
+//
+// Most widgets have a parent and so are child widgets that should be
+// initialized using InitChildWidget instead.
+func InitWidget(widget, parent Widget, className string, style, exStyle uint32) error {
wb := widget.BaseWidget()
wb.widget = widget
@@ -399,12 +409,13 @@ func initWidget(widget, parent Widget, className string, style, exStyle uint32)
return nil
}
-func initChildWidget(widget, parent Widget, className string, style, exStyle uint32) error {
+// InitChildWidget initializes a child widget.
+func InitChildWidget(widget, parent Widget, className string, style, exStyle uint32) error {
if parent == nil {
return newError("parent cannot be nil")
}
- if err := initWidget(widget, parent, className, style|WS_CHILD, exStyle); err != nil {
+ if err := InitWidget(widget, parent, className, style|WS_CHILD, exStyle); err != nil {
return err
}

0 comments on commit c0d4932

Please sign in to comment.