Skip to content

Commit

Permalink
Add several components
Browse files Browse the repository at this point in the history
  • Loading branch information
dontpanic92 committed May 15, 2016
1 parent e1e38a4 commit c978fc5
Show file tree
Hide file tree
Showing 37 changed files with 165,619 additions and 57,546 deletions.
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ wxGo

Golang wxWidgets Wrapper

Issues
----

<del>Since GoLang only supports static-link currently,</del> the size of the final executalble program grows larger as more classes are added into wxGo. Is GoLang really suitable for user applications?

Note
----

Expand All @@ -16,16 +11,6 @@ Note
- Currently wxWidgets is statically linked into wxGo and for convenience (go build-able) a pre-compiled version of wxWidgets is used
- To use your customized version of wxWidgets, please modify `src/define.i` where the `CPPFLAGS` and `LDFALGS` are
- Only linux_amd64 supported and tested now
- Exe file size will be ~40MB

**About types**

Golang is strongly typed, so there are some tips about types:

- Anywhere a `long` type required by a function of wxWidgets, there should be a `int64` type in go
- All named enums (for example `enum wxItemKind {...}`) will produce a new type (`type WxItemKind int`)

So sometimes a typecast will be needed.

Usage
----
Expand All @@ -40,7 +25,18 @@ You can add `-x` option to print each command it executes. Then
import "github.com/dontpanic92/wxGo/wx"
```

and have fun! Please refer to `example/test.go` for details.
and have fun!

Examples
----

Examples are in `examples` folder. `Dapeton` is a simple notepad, and `controls` is a dialog that contains several widgets.


Issues
----

The size of the final executalble program grows larger as more classes added into wxGo. Both examples are ~50MB large. You can use `strip` command to reduce the size, but it will remove the symbols.

ScreenShot
----
Expand Down
22 changes: 22 additions & 0 deletions SWIG/swig-3.0.9.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Binary files swig_original/.git/index and swig/.git/index differ
diff -uNr swig_original/.git/ORIG_HEAD swig/.git/ORIG_HEAD
--- swig_original/.git/ORIG_HEAD 2016-05-15 18:24:45.679568751 +0800
+++ swig/.git/ORIG_HEAD 1970-01-01 08:00:00.000000000 +0800
@@ -1 +0,0 @@
-809d54b13a1e032857838efbcbf6162b64c63984
diff -uNr swig_original/Source/Modules/go.cxx swig/Source/Modules/go.cxx
--- swig_original/Source/Modules/go.cxx 2016-05-15 18:24:45.666235417 +0800
+++ swig/Source/Modules/go.cxx 2016-05-15 18:11:11.339536341 +0800
@@ -6525,8 +6525,10 @@
break;
}
}
-
- if (Getattr(undefined_types, ty) && !Getattr(defined_types, ty)) {
+
+ String* go_type = goType(n, ty);
+
+ if (Getattr(undefined_types, go_type) && !Getattr(defined_types, go_type)) {
return goWrapperType(n, type, true);
}

121 changes: 0 additions & 121 deletions example/test.go

This file was deleted.

File renamed without changes
75 changes: 75 additions & 0 deletions examples/src/controls/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package main

import "wx"

type ControlDialog struct {
wx.Dialog
}

func NewControlDialog() ControlDialog {
var f ControlDialog
f.Dialog = wx.NewDialog()
f.Create(wx.NullWindow, -1, "Controls")


f.SetSizeHints( wx.DefaultSize, wx.DefaultSize )

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


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

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

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

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

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


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

bSizer4 := wx.NewBoxSizer( wx.VERTICAL )


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

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

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

m_button6 := wx.NewButton( f, wx.ID_ANY, "MyButton", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer4.Add( m_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()
return
}
127 changes: 127 additions & 0 deletions examples/src/dapeton/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package main

import "wx"

//Frame Struct def
type MyFrame struct {
wx.Frame
statusbar wx.StatusBar
toolbar wx.ToolBar
menubar wx.MenuBar
notebook wx.AuiNotebook
}

//Menu Event Functions def
func (f *MyFrame)evtColour(wx.Event) {
colourdlg := wx.NewColourDialog(f)
if colourdlg.ShowModal() == wx.ID_OK{
colour := colourdlg.GetColourData().GetColour()
f.notebook.GetCurrentPage().SetForegroundColour(colour)
}
colourdlg.Destroy()
}

func (f *MyFrame)evtFont(wx.Event) {
fontdlg := wx.NewFontDialog(f)
if fontdlg.ShowModal() == wx.ID_OK{
font := fontdlg.GetFontData().GetChosenFont()
f.notebook.GetCurrentPage().SetFont(font)
}
fontdlg.Destroy()
}

func (f *MyFrame)evtOpenFile(wx.Event) {
path := wx.LoadFileSelector("Text", "*")
if path != "" {
textCtrl := wx.NewTextCtrl(f.notebook, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE)
textCtrl.SetMinSize(wx.NewSize(600, 400))
f.notebook.AddPage(textCtrl, path)
textCtrl.LoadFile(path)
textCtrl.SetFocus()
}
}

func (f *MyFrame)evtAbout(wx.Event) {
aboutinfo := wx.NewAboutDialogInfo()
aboutinfo.SetName("Dapeton")
aboutinfo.AddDeveloper("dontpanic")
aboutinfo.SetDescription("Dapeton is a notepad using wxGo.")
aboutinfo.SetWebSite("http://github.com/dontpanic92/wxGo")
aboutinfo.SetVersion("0.1")
wx.AboutBox(aboutinfo)
}

//Frame Init def
func NewMyFrame() MyFrame {
var f MyFrame
f.Frame = wx.NewFrame()
f.Create(wx.NullWindow, -1, "Dapeton")

f.statusbar = f.CreateStatusBar()
f.statusbar.SetStatusText("Welcome to wxWidgets")

f.statusbar.SetFieldsCount(2)
f.statusbar.SetStatusText("This is a statusbar!", 1)

f.menubar = wx.NewMenuBar()
menuFile := wx.NewMenu()
menuEdit := wx.NewMenu()
menuHelp := wx.NewMenu()

menuItemOpenFile := wx.NewMenuItem(menuFile, wx.ID_ANY, "&Open...", "Open a File", wx.ITEM_NORMAL)
menuFile.Append(menuItemOpenFile)
menuItemExit := wx.NewMenuItem(menuFile, wx.ID_ANY, "&Exit", "Exit", wx.ITEM_NORMAL)
menuFile.Append(menuItemExit)
menuItemFont := wx.NewMenuItem(menuFile, wx.ID_ANY, "&Font...", "Select a Font", wx.ITEM_NORMAL)
menuEdit.Append(menuItemFont)
menuItemColour := wx.NewMenuItem(menuFile, wx.ID_ANY, "&Colour...", "Select a Colour", wx.ITEM_NORMAL)
menuEdit.Append(menuItemColour)
menuItemAbout := wx.NewMenuItem(menuFile, wx.ID_ANY, "&About", "About", wx.ITEM_NORMAL)
menuHelp.Append(menuItemAbout)

f.menubar.Append(menuFile, "&File")
f.menubar.Append(menuEdit, "&Edit")
f.menubar.Append(menuHelp, "&Help")
f.SetMenuBar(f.menubar)


f.toolbar = f.CreateToolBar( wx.TB_HORIZONTAL, wx.ID_ANY )
//f.toolbar.AddTool( wx.ID_ANY, "tool", wx.GetNullBitmap())
f.toolbar.AddSeparator()
//f.toolbar.AddTool( wx.ID_ANY, "tool", wx.GetNullBitmap())
f.toolbar.Realize()


mainSizer := wx.NewBoxSizer(wx.HORIZONTAL )
f.SetSizer(mainSizer)

f.notebook = wx.NewAuiNotebook(f, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.AUI_NB_DEFAULT_STYLE | wx.AUI_NB_CLOSE_BUTTON)

mainSizer.Add(f.notebook, 1, wx.EXPAND, 5)

textCtrl := wx.NewTextCtrl(f.notebook, wx.ID_ANY, "", wx.DefaultPosition, wx.DefaultSize, wx.TE_MULTILINE)
textCtrl.SetMinSize(wx.NewSize(600, 400))

f.notebook.AddPage(textCtrl, "Untitled", true)
textCtrl.SetFocus()

f.Layout()

wx.Bind( f, wx.EVT_MENU, f.evtFont, menuItemFont.GetId() )
wx.Bind( f, wx.EVT_MENU, f.evtColour, menuItemColour.GetId() )
wx.Bind( f, wx.EVT_MENU, f.evtOpenFile, menuItemOpenFile.GetId() )
wx.Bind( f, wx.EVT_MENU, f.evtAbout, menuItemAbout.GetId() )

//wx.Unbind( f, wx.EVT_MENU, f.evtAbout, menuItemAbout.GetId() )

return f
}

//Main Function
func main() {
wx1 := wx.NewApp()
f := NewMyFrame()
f.Show()
wx1.MainLoop()
return
}
Loading

0 comments on commit c978fc5

Please sign in to comment.