2014-02-11 17:22:39 -06:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
var (
|
2014-02-12 09:43:57 -06:00
|
|
|
sysDatas = map[_HWND]*sysData{}
|
2014-02-11 18:09:10 -06:00
|
|
|
sysDatasLock sync.Mutex
|
2014-02-12 09:43:57 -06:00
|
|
|
sysDataIDs = map[_HMENU]*sysData{}
|
2014-02-12 09:35:15 -06:00
|
|
|
sysDataIDsLock sync.Mutex
|
2014-02-11 17:22:39 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func addSysData(hwnd _HWND, s *sysData) {
|
2014-02-11 21:41:55 -06:00
|
|
|
sysDatasLock.Lock()
|
|
|
|
defer sysDatasLock.Unlock()
|
2014-02-12 09:35:15 -06:00
|
|
|
sysDatas[hwnd] = s
|
2014-02-11 17:22:39 -06:00
|
|
|
}
|
|
|
|
|
2014-02-12 09:43:57 -06:00
|
|
|
func addSysDataID(id _HMENU, s *sysData) {
|
2014-02-12 09:35:15 -06:00
|
|
|
sysDataIDsLock.Lock()
|
|
|
|
defer sysDataIDsLock.Unlock()
|
|
|
|
sysDataIDs[id] = s
|
2014-02-11 17:22:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func getSysData(hwnd _HWND) *sysData {
|
|
|
|
sysDatasLock.Lock()
|
|
|
|
defer sysDatasLock.Unlock()
|
|
|
|
if ss, ok := sysDatas[hwnd]; ok {
|
2014-02-12 09:35:15 -06:00
|
|
|
return ss
|
2014-02-11 17:22:39 -06:00
|
|
|
}
|
2014-02-11 21:41:55 -06:00
|
|
|
return nil
|
2014-02-11 17:22:39 -06:00
|
|
|
}
|
|
|
|
|
2014-02-12 09:43:57 -06:00
|
|
|
func getSysDataID(id _HMENU) *sysData {
|
2014-02-12 09:35:15 -06:00
|
|
|
sysDataIDsLock.Lock()
|
|
|
|
defer sysDataIDsLock.Unlock()
|
|
|
|
if ss, ok := sysDataIDs[id]; ok {
|
|
|
|
return ss
|
2014-02-11 17:22:39 -06:00
|
|
|
}
|
2014-02-12 09:43:57 -06:00
|
|
|
panic(fmt.Sprintf("getting nonexistent ID %d\n", id))
|
2014-02-11 17:22:39 -06:00
|
|
|
}
|