Removed unnecessary space if the secondaryText argument to MsgBox***() is an empty string. This doesn't change much on Mac OS X; it always shows the informational text field, showing an empty string by default. On GTK+ it seems to get rid of the bold over the primary text; I'm going to assume this is intentional (it looks that way on GTK+ 2; the HIG docs have outdated screenshots...).
This commit is contained in:
parent
9e185d815e
commit
013e8707da
|
@ -8,7 +8,8 @@ import (
|
|||
|
||||
// MsgBox displays an informational message box to the user with just an OK button.
|
||||
// primaryText should be a short string describing the message, and will be displayed with additional emphasis on platforms that support it.
|
||||
// secondaryText can be used to provide more information.
|
||||
// Optionally, secondaryText can be used to show additional information.
|
||||
// If you pass an empty string for secondaryText, neither additional information nor space for additional information will be shown.
|
||||
// On platforms that allow for the message box window to have a title, os.Args[0] is used.
|
||||
func MsgBox(primaryText string, secondaryText string) {
|
||||
msgBox(primaryText, secondaryText)
|
||||
|
|
|
@ -33,7 +33,9 @@ func _msgBox(primarytext string, secondarytext string, style uintptr, button0 st
|
|||
uitask <- func() {
|
||||
box := C.objc_msgSend_noargs(_NSAlert, _new)
|
||||
C.objc_msgSend_id(box, _setMessageText, toNSString(primarytext))
|
||||
C.objc_msgSend_id(box, _setInformativeText, toNSString(secondarytext))
|
||||
if secondarytext != "" {
|
||||
C.objc_msgSend_id(box, _setInformativeText, toNSString(secondarytext))
|
||||
}
|
||||
C.objc_msgSend_uint(box, _setAlertStyle, C.uintptr_t(style))
|
||||
C.objc_msgSend_id(box, _addButtonWithTitle, toNSString(button0))
|
||||
C.objc_msgSend_noargs(box, _runModal)
|
||||
|
|
|
@ -12,7 +12,15 @@ import (
|
|||
// #include "gtk_unix.h"
|
||||
// /* because cgo seems to choke on ... */
|
||||
// /* TODO does NULL parent make the box application-global? docs are unclear */
|
||||
// GtkWidget *gtkNewMsgBox(GtkMessageType type, GtkButtonsType buttons, char *title, char *text) { GtkWidget *k = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, type, buttons, "%s", (gchar *) title); gtk_message_dialog_format_secondary_text((GtkMessageDialog *) k, "%s", (gchar *) text); return k; }
|
||||
// GtkWidget *gtkNewMsgBox(GtkMessageType type, GtkButtonsType buttons, char *title, char *text)
|
||||
// {
|
||||
// GtkWidget *k;
|
||||
//
|
||||
// k = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, type, buttons, "%s", (gchar *) title);
|
||||
// if (text != NULL)
|
||||
// gtk_message_dialog_format_secondary_text((GtkMessageDialog *) k, "%s", (gchar *) text);
|
||||
// return k;
|
||||
// }
|
||||
import "C"
|
||||
|
||||
func _msgBox(primarytext string, secondarytext string, msgtype C.GtkMessageType, buttons C.GtkButtonsType) (result C.gint) {
|
||||
|
@ -21,8 +29,11 @@ func _msgBox(primarytext string, secondarytext string, msgtype C.GtkMessageType,
|
|||
uitask <- func() {
|
||||
cprimarytext := C.CString(primarytext)
|
||||
defer C.free(unsafe.Pointer(cprimarytext))
|
||||
csecondarytext := C.CString(secondarytext)
|
||||
defer C.free(unsafe.Pointer(csecondarytext))
|
||||
csecondarytext := (*C.char)(nil)
|
||||
if secondarytext != "" {
|
||||
csecondarytext = C.CString(secondarytext)
|
||||
defer C.free(unsafe.Pointer(csecondarytext))
|
||||
}
|
||||
box := C.gtkNewMsgBox(msgtype, buttons, cprimarytext, csecondarytext)
|
||||
response := C.gtk_dialog_run((*C.GtkDialog)(unsafe.Pointer(box)))
|
||||
C.gtk_widget_destroy(box)
|
||||
|
|
|
@ -79,7 +79,10 @@ 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
|
||||
text := primarytext
|
||||
if secondarytext != "" {
|
||||
text += "\n\n" + secondarytext
|
||||
}
|
||||
ret := make(chan uiret)
|
||||
defer close(ret)
|
||||
uitask <- &uimsg{
|
||||
|
|
|
@ -61,6 +61,7 @@ far off:
|
|||
- gtk+ HIG reference: https://developer.gnome.org/hig-book/3.4/controls-lists.html.en
|
||||
- mac HIG reference: ???
|
||||
- go over the old new thing's scrollbar series to make sure I'm doing everything right with scrollbars in Windows Areas
|
||||
- change the MsgBox() calls to encourage good alert dialog design??????? maybe? TODO
|
||||
|
||||
big things:
|
||||
- make sure every sysData function only performs a single invocation to uitask; see http://blogs.msdn.com/b/oldnewthing/archive/2005/10/10/479124.aspx#479182
|
||||
|
|
|
@ -248,7 +248,9 @@ func myMain() {
|
|||
w := NewWindow("Main Window", 320, 240)
|
||||
b := NewButton("Click Me")
|
||||
b2 := NewButton("Or Me")
|
||||
s2 := NewHorizontalStack(b, b2)
|
||||
bmsg := NewButton("Or Even Me!")
|
||||
s2 := NewHorizontalStack(b, b2, bmsg)
|
||||
s2.SetStretchy(2)
|
||||
c := NewCheckbox("Check Me")
|
||||
cb1 := NewEditableCombobox("You can edit me!", "Yes you can!", "Yes you will!")
|
||||
cb2 := NewCombobox("You can't edit me!", "No you can't!", "No you won't!")
|
||||
|
@ -371,6 +373,9 @@ _=curtime
|
|||
pbar.SetProgress(-1)
|
||||
case <-invalidButton.Clicked:
|
||||
invalidTest(cb1, lb1, nil, nil)
|
||||
case <-bmsg.Clicked:
|
||||
MsgBox("Title Only", "")
|
||||
MsgBox("Title and Text", "Text and Title")
|
||||
}
|
||||
}
|
||||
w.Hide()
|
||||
|
|
1
todo.md
1
todo.md
|
@ -1,6 +1,5 @@
|
|||
so I don't forget:
|
||||
- should Labels be selectable?
|
||||
- Message boxes should not show secondary text if none is specified. [TODO figure out what I meant by this]
|
||||
- add bounds checking to Area's sizing methods
|
||||
- describe thread-safety of Area.SetSize()
|
||||
- should all instances of -1 as error returns from Windows functions be changed to ^0 or does the uintptr() conversion handle sign extension?
|
||||
|
|
Loading…
Reference in New Issue