Made message boxes run on uitask on Windows; adjusted some related TODOs.

This commit is contained in:
Pietro Gagliardi 2014-03-12 12:21:50 -04:00
parent dd577010ca
commit 46c992f1dc
2 changed files with 17 additions and 11 deletions

View File

@ -79,15 +79,23 @@ var (
func _msgBox(primarytext string, secondarytext string, uType uint32) (result int) {
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa511267.aspx says "Use task dialogs whenever appropriate to achieve a consistent look and layout. Task dialogs require Windows Vista® or later, so they aren't suitable for earlier versions of Windows. If you must use a message box, separate the main instruction from the supplemental instruction with two line breaks."
text := primarytext + "\n\n" + secondarytext
r1, _, err := _messageBox.Call(
ret := make(chan uiret)
defer close(ret)
uitask <- &uimsg{
call: _messageBox,
p: []uintptr{
uintptr(_NULL),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))),
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(os.Args[0]))),
uintptr(uType))
if r1 == 0 { // failure
panic(fmt.Sprintf("error displaying message box to user: %v\nstyle: 0x%08X\ntitle: %q\ntext:\n%s", err, uType, os.Args[0], text))
uintptr(uType),
},
ret: ret,
}
return int(r1)
r := <-ret
if r.ret == 0 { // failure
panic(fmt.Sprintf("error displaying message box to user: %v\nstyle: 0x%08X\ntitle: %q\ntext:\n%s", r.err, uType, os.Args[0], text))
}
return int(r.ret)
}
func msgBox(primarytext string, secondarytext string) {

View File

@ -16,8 +16,6 @@ so I don't forget:
- Combobox/Listbox.Select (with Listbox.Select allowing bulk)
- Checkbox.Check or Checkbox.SetChecked
- Listbox.SelectAll
- make the Windows implementation of message boxes run on uitask
- ensure MsgBoxError can run if initialization failed if things change ever
- should Labels be selectable?
- should message box text be selectable on all platforms or only on those that make it the default?
- Listbox/Combobox.Index(n)
@ -25,7 +23,7 @@ so I don't forget:
- change sysData.make() so it does not take the initial window text as an argument and instead have the respective Control/Window.make() call sysData.setText() expressly; this would allow me to remove the "no such concept of text" checks from the GTK+ and Mac OS X backends
important things:
- because the main event loop is not called if initialization fails, it is presently impossible for MsgBoxError() to work if UI initialization fails; this basically means we cannot allow initializiation to fail on Mac OS X if we want to be able to report UI init failures to the user with one
- because the main event loop is not called if initialization fails, it is presently impossible for MsgBoxError() to work if UI initialization fails; this basically means we cannot allow initializiation to fail on Mac OS X if we want to be able to report UI init failures to the user with one (which would be desirable, maybe (would violate Windows HIG?))
- figure out where to auto-place windows in Cocoa (also window coordinates are still not flipped properly so (0,0) on screen is the bottom-left)
- also provide a method to center windows; Cocoa provides one for us but
- I think Cocoa NSButton text is not vertically aligned properly...?