summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-02-12 10:43:57 -0500
committerPietro Gagliardi <[email protected]>2014-02-12 10:43:57 -0500
commit3f8fe0e7108c1cd87e177bed22e3307c9df03e63 (patch)
treee34a7dd419bf2649dc24f5dbf89e6d825179f55d
parentf93bebfeec42aeee07f43fcf6466b93f073b6111 (diff)
Separated initial text from sysData and fixed errors in the previous commits.
-rw-r--r--sysdata.go3
-rw-r--r--sysdata_windows.go6
-rw-r--r--sysdatacache_windows.go10
-rw-r--r--window.go7
4 files changed, 13 insertions, 13 deletions
diff --git a/sysdata.go b/sysdata.go
index 854e1a0..b17f506 100644
--- a/sysdata.go
+++ b/sysdata.go
@@ -8,12 +8,11 @@ import (
// The sysData type contains all system data. It provides the system-specific underlying implementation. It is guaranteed to have the following by embedding:
type cSysData struct {
ctype int
- text string
// for Window
closing chan struct{}
}
-func (c *cSysData) make() error {
+func (c *cSysData) make(initText string) error {
panic(runtime.GOOS + " sysData does not define make()")
}
func (c *cSysData) show() error {
diff --git a/sysdata_windows.go b/sysdata_windows.go
index acc7070..2d0796e 100644
--- a/sysdata_windows.go
+++ b/sysdata_windows.go
@@ -42,7 +42,7 @@ var classTypes = [nctypes]*classData{
var (
cid _HMENU = 0
- cidLock sys.Mutex
+ cidLock sync.Mutex
)
func nextID() _HMENU {
@@ -52,7 +52,7 @@ func nextID() _HMENU {
return cid
}
-func (s *sysData) make() (err error) {
+func (s *sysData) make(initText string) (err error) {
ret := make(chan uiret)
defer close(ret)
ct := classTypes[s.ctype]
@@ -64,7 +64,7 @@ func (s *sysData) make() (err error) {
p: []uintptr{
uintptr(ct.xstyle),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(ct.name))),
- uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(s.text))),
+ uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(initText))),
uintptr(ct.style),
uintptr(_CW_USEDEFAULT), // TODO
uintptr(_CW_USEDEFAULT),
diff --git a/sysdatacache_windows.go b/sysdatacache_windows.go
index 16848e2..5ec299b 100644
--- a/sysdatacache_windows.go
+++ b/sysdatacache_windows.go
@@ -9,9 +9,9 @@ import (
// I need a way to get a sysData for a given HWND or a given HWND/control ID. So, this.
var (
- sysDatas = map[_HWND]*sdcEntry{}
+ sysDatas = map[_HWND]*sysData{}
sysDatasLock sync.Mutex
- sysDataIDs = map[_HMENU]*sdcEntry{}
+ sysDataIDs = map[_HMENU]*sysData{}
sysDataIDsLock sync.Mutex
)
@@ -21,7 +21,7 @@ func addSysData(hwnd _HWND, s *sysData) {
sysDatas[hwnd] = s
}
-func addIDSysData(id _HMENU, s *sysData) {
+func addSysDataID(id _HMENU, s *sysData) {
sysDataIDsLock.Lock()
defer sysDataIDsLock.Unlock()
sysDataIDs[id] = s
@@ -36,11 +36,11 @@ func getSysData(hwnd _HWND) *sysData {
return nil
}
-func getIDSysData(id _HMENU) *sysData {
+func getSysDataID(id _HMENU) *sysData {
sysDataIDsLock.Lock()
defer sysDataIDsLock.Unlock()
if ss, ok := sysDataIDs[id]; ok {
return ss
}
- panic(fmt.Sprintf("getting nonexistent ID %d for HWND %d\n", id, hwnd))
+ panic(fmt.Sprintf("getting nonexistent ID %d\n", id))
}
diff --git a/window.go b/window.go
index 50d4dbb..77dc674 100644
--- a/window.go
+++ b/window.go
@@ -18,6 +18,7 @@ type Window struct {
created bool
control Control
sysData *sysData
+ initText string
}
// NewWindow creates a new window with the given title. The window is not constructed at the OS level until a call to Open().
@@ -26,9 +27,9 @@ func NewWindow(title string) *Window {
sysData: &sysData{
cSysData: cSysData{
ctype: c_window,
- text: title,
},
},
+ initText: title,
}
}
@@ -54,7 +55,7 @@ func (w *Window) Open() (err error) {
// If the window has already been created, show it.
if !w.created {
w.sysData.closing = w.Closing
- err = w.sysData.make()
+ err = w.sysData.make(w.initText)
if err != nil {
return err
}
@@ -82,6 +83,6 @@ func (w *Window) apply() error {
func (w *Window) setParent(c Control) {
panic("Window.setParent() should never be called")
}
-func (w *Window) setParentWindow(w *Window) {
+func (w *Window) setParentWindow(w2 *Window) {
panic("Window.setParent() should never be called")
}