summaryrefslogtreecommitdiff
path: root/sysdatacache_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-02-11 18:22:39 -0500
committerPietro Gagliardi <[email protected]>2014-02-11 18:22:39 -0500
commitb918496ae453d5e4e703f02d4a70474b9a84d67a (patch)
tree9849c9dd9995b0c001e53fdd4e8ee032747c1de3 /sysdatacache_windows.go
parentc6a8a4d2f799756fa83a9e556d363decd896e8f2 (diff)
Filled in the standard window procedure.
Diffstat (limited to 'sysdatacache_windows.go')
-rw-r--r--sysdatacache_windows.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/sysdatacache_windows.go b/sysdatacache_windows.go
new file mode 100644
index 0000000..1a45d97
--- /dev/null
+++ b/sysdatacache_windows.go
@@ -0,0 +1,58 @@
+// 11 february 2014
+package main
+
+import (
+ "fmt"
+ "sync"
+)
+
+// I need a way to get a sysData for a given HWND or a given HWND/control ID. So, this.
+
+type sdcEntry struct {
+ s *sysData
+ members map[_HMENU]*sysData
+}
+
+var (
+ sysDatas = map[_HWND]*sdcEntry{}
+ sysDatasLock sys.Mutex
+)
+
+func addSysData(hwnd _HWND, s *sysData) {
+ sysDatasLock.Lock()
+ defer sysDatasLock.Unlock()
+ sysDatas[hwnd] = &sdcEntry{
+ s: s,
+ members: map[_HMENU]*sysData{},
+ }
+}
+
+func addIDSysData(hwnd _HWND, id _HMENU, s *sysData) {
+ sysDatasLock.Lock()
+ defer sysDatasLock.Unlock()
+ if ss, ok := sysDatas[hwnd]; ok {
+ ss.members[id] = s
+ }
+ panic(fmt.Sprintf("adding ID %d to nonexistent HWND %d\n", id, hwnd))
+}
+
+func getSysData(hwnd _HWND) *sysData {
+ sysDatasLock.Lock()
+ defer sysDatasLock.Unlock()
+ if ss, ok := sysDatas[hwnd]; ok {
+ return ss.s
+ }
+ panic(fmt.Sprintf("getting nonexistent HWND %d\n", hwnd))
+}
+
+func getIDSysData(hwnd _HWND, id _HMENU) *sysData {
+ sysDatasLock.Lock()
+ defer sysDatasLock.Unlock()
+ if ss, ok := sysDatas[hwnd]; ok {
+ if xx, ok := ss.members[id]; ok {
+ return xx
+ }
+ panic(fmt.Sprintf("getting nonexistent ID %d for HWND %d\n", id, hwnd))
+ }
+ panic(fmt.Sprintf("getting nonexistent HWND %d\n", hwnd))
+}