Skip to content

Commit

Permalink
examples: Apply 'go fmt'
Browse files Browse the repository at this point in the history
  • Loading branch information
k-takata committed Mar 13, 2018
1 parent ee81aec commit 2cd92cc
Show file tree
Hide file tree
Showing 10 changed files with 422 additions and 430 deletions.
213 changes: 105 additions & 108 deletions examples/src/aui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,121 +3,118 @@ package main
import "github.com/dontpanic92/wxGo/wx"

type MyFrame struct {
wx.Frame
auiManager wx.AuiManager
menuBar wx.MenuBar
wx.Frame
auiManager wx.AuiManager
menuBar wx.MenuBar
}

const (
ID_Settings = iota + wx.ID_HIGHEST + 1
ID_SampleItem
ID_Settings = iota + wx.ID_HIGHEST + 1
ID_SampleItem
)

func NewMyFrame() *MyFrame {
self := &MyFrame{}
self.Frame = wx.NewFrame(wx.NullWindow, wx.ID_ANY, "AUI Example")

// AUI Init

self.auiManager = wx.NewAuiManager()
self.auiManager.SetManagedWindow(self)

// We should call auiManager.UnInit() in frame's desructor, but unfortunately
// we can't get a callback when frame's destructor called. So we do this in the
// EVT_CLOSE_WINDOW. And also because we listen the CloseEvent, we have to call
// Destroy() manually.
wx.Bind(self, wx.EVT_CLOSE_WINDOW, func(e wx.Event){
self.auiManager.UnInit()
self.Destroy()
}, self.GetId())

// Menu

self.menuBar = wx.NewMenuBar()
fileMenu := wx.NewMenu()
fileMenu.Append(wx.ID_EXIT)

wx.Bind(self, wx.EVT_MENU, func(e wx.Event){
self.Close(true)
}, wx.ID_EXIT)

self.menuBar.Append(fileMenu, "&File")
self.SetMenuBar(self.menuBar)

// StatusBar

self.CreateStatusBar()
self.GetStatusBar().SetStatusText("Ready")

// AuiToolBar

toolBar1 := wx.NewAuiToolBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.AUI_TB_DEFAULT_STYLE | wx.AUI_TB_OVERFLOW)
toolBar1.SetToolBitmapSize(wx.NewSizeT(48,48))

toolBar1.AddTool(ID_SampleItem + 1, "Test", wx.ArtProviderGetBitmap(wx.ART_ERROR))
toolBar1.AddSeparator()
toolBar1.AddTool(ID_SampleItem + 2, "Test", wx.ArtProviderGetBitmap(wx.ART_QUESTION))
toolBar1.AddTool(ID_SampleItem + 3, "Test", wx.ArtProviderGetBitmap(wx.ART_INFORMATION))
toolBar1.AddTool(ID_SampleItem + 4, "Test", wx.ArtProviderGetBitmap(wx.ART_WARNING))
toolBar1.AddTool(ID_SampleItem + 5, "Test", wx.ArtProviderGetBitmap(wx.ART_MISSING_IMAGE))

separator := wx.NewAuiToolBarItemT()
separator.SetKind(wx.ITEM_SEPARATOR)
customButton := wx.NewAuiToolBarItemT()
customButton.SetKind(wx.ITEM_NORMAL)
customButton.SetLabel("Customize...")
wx.Bind(self, wx.EVT_MENU, func(e wx.Event) {
wx.MessageBox("Customize clicked!")
}, customButton.GetId())


toolBar1.SetCustomOverflowItems([]wx.AuiToolBarItem{}, []wx.AuiToolBarItem{separator, customButton})
toolBar1.Realize()


paneInfo := wx.NewAuiPaneInfoT().Name("tb1").Caption("Big Toolbar").ToolbarPane().Top()
self.auiManager.AddPane(toolBar1, paneInfo)

// Left pane - a tree control

treeCtrl := wx.NewTreeCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.NewSizeT(160, 250), wx.TR_DEFAULT_STYLE | wx.NO_BORDER);

treeRoot := treeCtrl.AddRoot("wxAUI Project", 0)

firstItem := treeCtrl.AppendItem(treeRoot, "Item 1", 0)
treeCtrl.AppendItem(treeRoot, "Item 2", 0)
treeCtrl.AppendItem(treeRoot, "Item 3", 0)
treeCtrl.AppendItem(treeRoot, "Item 4", 0)
treeCtrl.AppendItem(treeRoot, "Item 5", 0)
treeCtrl.AppendItem(firstItem, "Subitem 1", 1)
treeCtrl.AppendItem(firstItem, "Subitem 2", 1)
treeCtrl.AppendItem(firstItem, "Subitem 3", 1)
treeCtrl.AppendItem(firstItem, "Subitem 4", 1)
treeCtrl.AppendItem(firstItem, "Subitem 5", 1)
treeCtrl.Expand(treeRoot)

self.auiManager.AddPane(wx.ToWindow(treeCtrl), wx.LEFT, "Hello")
// wxTreeCtrl has an overloaded `GetNextSibling` function, which as a different
// signature with wxWindow. So we have to cast wxTreeCtrl to wxWindow manually.
// Equivalent: treeCtrl.SwigGetWindow()


// CenterPane - a text control

paneInfo = wx.NewAuiPaneInfoT().Name("notebook").CenterPane().PaneBorder(false)
notebook := wx.NewAuiNotebook(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.AUI_NB_DEFAULT_STYLE | wx.AUI_NB_CLOSE_BUTTON)
notebook.AddPage(wx.NewTextCtrl(notebook, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE), "Test", true)
self.auiManager.AddPane(notebook, paneInfo)

self.auiManager.Update()

return self
self := &MyFrame{}
self.Frame = wx.NewFrame(wx.NullWindow, wx.ID_ANY, "AUI Example")

// AUI Init

self.auiManager = wx.NewAuiManager()
self.auiManager.SetManagedWindow(self)

// We should call auiManager.UnInit() in frame's desructor, but unfortunately
// we can't get a callback when frame's destructor called. So we do this in the
// EVT_CLOSE_WINDOW. And also because we listen the CloseEvent, we have to call
// Destroy() manually.
wx.Bind(self, wx.EVT_CLOSE_WINDOW, func(e wx.Event) {
self.auiManager.UnInit()
self.Destroy()
}, self.GetId())

// Menu

self.menuBar = wx.NewMenuBar()
fileMenu := wx.NewMenu()
fileMenu.Append(wx.ID_EXIT)

wx.Bind(self, wx.EVT_MENU, func(e wx.Event) {
self.Close(true)
}, wx.ID_EXIT)

self.menuBar.Append(fileMenu, "&File")
self.SetMenuBar(self.menuBar)

// StatusBar

self.CreateStatusBar()
self.GetStatusBar().SetStatusText("Ready")

// AuiToolBar

toolBar1 := wx.NewAuiToolBar(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.AUI_TB_DEFAULT_STYLE|wx.AUI_TB_OVERFLOW)
toolBar1.SetToolBitmapSize(wx.NewSizeT(48, 48))

toolBar1.AddTool(ID_SampleItem+1, "Test", wx.ArtProviderGetBitmap(wx.ART_ERROR))
toolBar1.AddSeparator()
toolBar1.AddTool(ID_SampleItem+2, "Test", wx.ArtProviderGetBitmap(wx.ART_QUESTION))
toolBar1.AddTool(ID_SampleItem+3, "Test", wx.ArtProviderGetBitmap(wx.ART_INFORMATION))
toolBar1.AddTool(ID_SampleItem+4, "Test", wx.ArtProviderGetBitmap(wx.ART_WARNING))
toolBar1.AddTool(ID_SampleItem+5, "Test", wx.ArtProviderGetBitmap(wx.ART_MISSING_IMAGE))

separator := wx.NewAuiToolBarItemT()
separator.SetKind(wx.ITEM_SEPARATOR)
customButton := wx.NewAuiToolBarItemT()
customButton.SetKind(wx.ITEM_NORMAL)
customButton.SetLabel("Customize...")
wx.Bind(self, wx.EVT_MENU, func(e wx.Event) {
wx.MessageBox("Customize clicked!")
}, customButton.GetId())

toolBar1.SetCustomOverflowItems([]wx.AuiToolBarItem{}, []wx.AuiToolBarItem{separator, customButton})
toolBar1.Realize()

paneInfo := wx.NewAuiPaneInfoT().Name("tb1").Caption("Big Toolbar").ToolbarPane().Top()
self.auiManager.AddPane(toolBar1, paneInfo)

// Left pane - a tree control

treeCtrl := wx.NewTreeCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.NewSizeT(160, 250), wx.TR_DEFAULT_STYLE|wx.NO_BORDER)

treeRoot := treeCtrl.AddRoot("wxAUI Project", 0)

firstItem := treeCtrl.AppendItem(treeRoot, "Item 1", 0)
treeCtrl.AppendItem(treeRoot, "Item 2", 0)
treeCtrl.AppendItem(treeRoot, "Item 3", 0)
treeCtrl.AppendItem(treeRoot, "Item 4", 0)
treeCtrl.AppendItem(treeRoot, "Item 5", 0)
treeCtrl.AppendItem(firstItem, "Subitem 1", 1)
treeCtrl.AppendItem(firstItem, "Subitem 2", 1)
treeCtrl.AppendItem(firstItem, "Subitem 3", 1)
treeCtrl.AppendItem(firstItem, "Subitem 4", 1)
treeCtrl.AppendItem(firstItem, "Subitem 5", 1)
treeCtrl.Expand(treeRoot)

self.auiManager.AddPane(wx.ToWindow(treeCtrl), wx.LEFT, "Hello")
// wxTreeCtrl has an overloaded `GetNextSibling` function, which as a different
// signature with wxWindow. So we have to cast wxTreeCtrl to wxWindow manually.
// Equivalent: treeCtrl.SwigGetWindow()

// CenterPane - a text control

paneInfo = wx.NewAuiPaneInfoT().Name("notebook").CenterPane().PaneBorder(false)
notebook := wx.NewAuiNotebook(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.AUI_NB_DEFAULT_STYLE|wx.AUI_NB_CLOSE_BUTTON)
notebook.AddPage(wx.NewTextCtrl(notebook, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE), "Test", true)
self.auiManager.AddPane(notebook, paneInfo)

self.auiManager.Update()

return self
}

func main() {
wx1 := wx.NewApp()
frame := NewMyFrame()
frame.Show()
wx1.MainLoop()
return
wx1 := wx.NewApp()
frame := NewMyFrame()
frame.Show()
wx1.MainLoop()
return
}
109 changes: 54 additions & 55 deletions examples/src/controls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,64 @@ package main
import "github.com/dontpanic92/wxGo/wx"

type ControlDialog struct {
wx.Dialog
wx.Dialog
}

func NewControlDialog() ControlDialog {
f := ControlDialog{}
f.Dialog = wx.NewDialog(wx.NullWindow, -1, "Controls", wx.DefaultPosition, wx.NewSizeT(600, 400))

bSizer2 := wx.NewBoxSizer( wx.HORIZONTAL )
bSizer3 := wx.NewBoxSizer( wx.VERTICAL )


radioBox2 := wx.NewRadioBox( f, wx.ID_ANY, "wxRadioBox", wx.DefaultPosition, wx.DefaultSize, []string{"aaa", "bbb"}, 1, wx.HORIZONTAL )
radioBox2.SetSelection( 0 )
bSizer3.Add( radioBox2, 0, wx.ALL|wx.EXPAND, 5 )

checkBox2 := wx.NewCheckBox( f, wx.ID_ANY, "Check Me!", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer3.Add( checkBox2, 0, wx.ALL|wx.EXPAND, 5 )

staticText2 := wx.NewStaticText( f, wx.ID_ANY, "MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
staticText2.Wrap( -1 )
bSizer3.Add( staticText2, 0, wx.ALL|wx.EXPAND, 5 )

textCtrl2 := wx.NewTextCtrl( f, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer3.Add( textCtrl2, 0, wx.ALL|wx.EXPAND, 5 )

slider1 := wx.NewSlider( f, wx.ID_ANY, 50, 0, 100, wx.DefaultPosition, wx.DefaultSize, wx.HORIZONTAL )
bSizer3.Add( slider1, 0, wx.ALL|wx.EXPAND, 5 )

bSizer2.Add( bSizer3, 1, wx.EXPAND, 5 )
bSizer4 := wx.NewBoxSizer( wx.VERTICAL )

listBox2 := wx.NewListBox( f, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, []string{"aaa", "bbb"}, 0)
listBox2.InsertItems([]string{"ccc"}, 1)
bSizer4.Add( listBox2, 1, wx.ALL|wx.EXPAND, 5 )

gauge1 := wx.NewGauge( f, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.HORIZONTAL )
gauge1.SetValue( 50 )
bSizer4.Add( gauge1, 0, wx.ALL|wx.EXPAND, 5 )

button5 := wx.NewButton( f, wx.ID_ANY, "MyButton", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer4.Add( button5, 0, wx.ALL|wx.EXPAND, 5 )

button6 := wx.NewButton( f, wx.ID_ANY, "MyButton", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer4.Add( button6, 0, wx.ALL|wx.EXPAND, 5 )

bSizer2.Add( bSizer4, 1, wx.EXPAND, 5 )

f.SetSizer( bSizer2 )
f.Layout()

f.Centre( wx.BOTH )

return f
f := ControlDialog{}
f.Dialog = wx.NewDialog(wx.NullWindow, -1, "Controls", wx.DefaultPosition, wx.NewSizeT(600, 400))

bSizer2 := wx.NewBoxSizer(wx.HORIZONTAL)
bSizer3 := wx.NewBoxSizer(wx.VERTICAL)

radioBox2 := wx.NewRadioBox(f, wx.ID_ANY, "wxRadioBox", wx.DefaultPosition, wx.DefaultSize, []string{"aaa", "bbb"}, 1, wx.HORIZONTAL)
radioBox2.SetSelection(0)
bSizer3.Add(radioBox2, 0, wx.ALL|wx.EXPAND, 5)

checkBox2 := wx.NewCheckBox(f, wx.ID_ANY, "Check Me!", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer3.Add(checkBox2, 0, wx.ALL|wx.EXPAND, 5)

staticText2 := wx.NewStaticText(f, wx.ID_ANY, "MyLabel", wx.DefaultPosition, wx.DefaultSize, 0)
staticText2.Wrap(-1)
bSizer3.Add(staticText2, 0, wx.ALL|wx.EXPAND, 5)

textCtrl2 := wx.NewTextCtrl(f, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer3.Add(textCtrl2, 0, wx.ALL|wx.EXPAND, 5)

slider1 := wx.NewSlider(f, wx.ID_ANY, 50, 0, 100, wx.DefaultPosition, wx.DefaultSize, wx.HORIZONTAL)
bSizer3.Add(slider1, 0, wx.ALL|wx.EXPAND, 5)

bSizer2.Add(bSizer3, 1, wx.EXPAND, 5)
bSizer4 := wx.NewBoxSizer(wx.VERTICAL)

listBox2 := wx.NewListBox(f, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, []string{"aaa", "bbb"}, 0)
listBox2.InsertItems([]string{"ccc"}, 1)
bSizer4.Add(listBox2, 1, wx.ALL|wx.EXPAND, 5)

gauge1 := wx.NewGauge(f, wx.ID_ANY, 100, wx.DefaultPosition, wx.DefaultSize, wx.HORIZONTAL)
gauge1.SetValue(50)
bSizer4.Add(gauge1, 0, wx.ALL|wx.EXPAND, 5)

button5 := wx.NewButton(f, wx.ID_ANY, "MyButton", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer4.Add(button5, 0, wx.ALL|wx.EXPAND, 5)

button6 := wx.NewButton(f, wx.ID_ANY, "MyButton", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer4.Add(button6, 0, wx.ALL|wx.EXPAND, 5)

bSizer2.Add(bSizer4, 1, wx.EXPAND, 5)

f.SetSizer(bSizer2)
f.Layout()

f.Centre(wx.BOTH)

return f
}

func main() {
wx.NewApp()
f := NewControlDialog()
f.ShowModal()
f.Destroy()
return
wx.NewApp()
f := NewControlDialog()
f.ShowModal()
f.Destroy()
return
}
Loading

0 comments on commit 2cd92cc

Please sign in to comment.