Changed the font loading on Windows to always load the control font unless a flag to not load any font is set; when menus and statusbars are added, they need special casing. This also means the preferred size calculations reads controlFont directly (it will need the same change).
This commit is contained in:
parent
8cb3991ef9
commit
cbf439223b
|
@ -82,7 +82,7 @@ func (s *sysData) preferredSize() (width int, height int) {
|
||||||
dc = _HANDLE(r1)
|
dc = _HANDLE(r1)
|
||||||
r1, _, err = _selectObject.Call(
|
r1, _, err = _selectObject.Call(
|
||||||
uintptr(dc),
|
uintptr(dc),
|
||||||
uintptr(unsafe.Pointer(*classTypes[s.ctype].font)))
|
uintptr(controlFont))
|
||||||
if r1 == 0 { // failure
|
if r1 == 0 { // failure
|
||||||
panic(fmt.Errorf("error loading control font into device context for preferred size calculation: %v", err))
|
panic(fmt.Errorf("error loading control font into device context for preferred size calculation: %v", err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ type classData struct {
|
||||||
xstyle uint32
|
xstyle uint32
|
||||||
mkid bool
|
mkid bool
|
||||||
altStyle uint32
|
altStyle uint32
|
||||||
font *_HANDLE
|
doNotLoadFont bool
|
||||||
appendMsg uintptr
|
appendMsg uintptr
|
||||||
insertBeforeMsg uintptr
|
insertBeforeMsg uintptr
|
||||||
deleteMsg uintptr
|
deleteMsg uintptr
|
||||||
|
@ -47,25 +47,23 @@ var classTypes = [nctypes]*classData{
|
||||||
register: registerStdWndClass,
|
register: registerStdWndClass,
|
||||||
style: _WS_OVERLAPPEDWINDOW,
|
style: _WS_OVERLAPPEDWINDOW,
|
||||||
xstyle: 0,
|
xstyle: 0,
|
||||||
|
doNotLoadFont: true,
|
||||||
},
|
},
|
||||||
c_button: &classData{
|
c_button: &classData{
|
||||||
name: "BUTTON",
|
name: "BUTTON",
|
||||||
style: _BS_PUSHBUTTON | controlstyle,
|
style: _BS_PUSHBUTTON | controlstyle,
|
||||||
xstyle: 0 | controlxstyle,
|
xstyle: 0 | controlxstyle,
|
||||||
font: &controlFont,
|
|
||||||
},
|
},
|
||||||
c_checkbox: &classData{
|
c_checkbox: &classData{
|
||||||
name: "BUTTON",
|
name: "BUTTON",
|
||||||
style: _BS_AUTOCHECKBOX | controlstyle,
|
style: _BS_AUTOCHECKBOX | controlstyle,
|
||||||
xstyle: 0 | controlxstyle,
|
xstyle: 0 | controlxstyle,
|
||||||
font: &controlFont,
|
|
||||||
},
|
},
|
||||||
c_combobox: &classData{
|
c_combobox: &classData{
|
||||||
name: "COMBOBOX",
|
name: "COMBOBOX",
|
||||||
style: _CBS_DROPDOWNLIST | _WS_VSCROLL | controlstyle,
|
style: _CBS_DROPDOWNLIST | _WS_VSCROLL | controlstyle,
|
||||||
xstyle: 0 | controlxstyle,
|
xstyle: 0 | controlxstyle,
|
||||||
altStyle: _CBS_DROPDOWN | _CBS_AUTOHSCROLL | _WS_VSCROLL | controlstyle,
|
altStyle: _CBS_DROPDOWN | _CBS_AUTOHSCROLL | _WS_VSCROLL | controlstyle,
|
||||||
font: &controlFont,
|
|
||||||
appendMsg: _CB_ADDSTRING,
|
appendMsg: _CB_ADDSTRING,
|
||||||
insertBeforeMsg: _CB_INSERTSTRING,
|
insertBeforeMsg: _CB_INSERTSTRING,
|
||||||
deleteMsg: _CB_DELETESTRING,
|
deleteMsg: _CB_DELETESTRING,
|
||||||
|
@ -79,13 +77,11 @@ var classTypes = [nctypes]*classData{
|
||||||
style: _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
|
style: _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
|
||||||
xstyle: 0 | controlxstyle,
|
xstyle: 0 | controlxstyle,
|
||||||
altStyle: _ES_PASSWORD | _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
|
altStyle: _ES_PASSWORD | _ES_AUTOHSCROLL | _WS_BORDER | controlstyle,
|
||||||
font: &controlFont,
|
|
||||||
},
|
},
|
||||||
c_label: &classData{
|
c_label: &classData{
|
||||||
name: "STATIC",
|
name: "STATIC",
|
||||||
style: _SS_NOPREFIX | controlstyle,
|
style: _SS_NOPREFIX | controlstyle,
|
||||||
xstyle: 0 | controlxstyle,
|
xstyle: 0 | controlxstyle,
|
||||||
font: &controlFont,
|
|
||||||
},
|
},
|
||||||
c_listbox: &classData{
|
c_listbox: &classData{
|
||||||
name: "LISTBOX",
|
name: "LISTBOX",
|
||||||
|
@ -94,7 +90,6 @@ var classTypes = [nctypes]*classData{
|
||||||
style: _LBS_NOTIFY | _WS_BORDER | _WS_VSCROLL | controlstyle,
|
style: _LBS_NOTIFY | _WS_BORDER | _WS_VSCROLL | controlstyle,
|
||||||
xstyle: 0 | controlxstyle,
|
xstyle: 0 | controlxstyle,
|
||||||
altStyle: _LBS_EXTENDEDSEL | _LBS_NOTIFY | _WS_BORDER | _WS_VSCROLL | controlstyle,
|
altStyle: _LBS_EXTENDEDSEL | _LBS_NOTIFY | _WS_BORDER | _WS_VSCROLL | controlstyle,
|
||||||
font: &controlFont,
|
|
||||||
appendMsg: _LB_ADDSTRING,
|
appendMsg: _LB_ADDSTRING,
|
||||||
insertBeforeMsg: _LB_INSERTSTRING,
|
insertBeforeMsg: _LB_INSERTSTRING,
|
||||||
deleteMsg: _LB_DELETESTRING,
|
deleteMsg: _LB_DELETESTRING,
|
||||||
|
@ -107,13 +102,13 @@ var classTypes = [nctypes]*classData{
|
||||||
name: _PROGRESS_CLASS,
|
name: _PROGRESS_CLASS,
|
||||||
style: _PBS_SMOOTH | controlstyle,
|
style: _PBS_SMOOTH | controlstyle,
|
||||||
xstyle: 0 | controlxstyle,
|
xstyle: 0 | controlxstyle,
|
||||||
font: &controlFont,
|
doNotLoadFont: true,
|
||||||
},
|
},
|
||||||
c_area: &classData{
|
c_area: &classData{
|
||||||
register: registerAreaWndClass,
|
register: registerAreaWndClass,
|
||||||
style: areastyle,
|
style: areastyle,
|
||||||
xstyle: areaxstyle,
|
xstyle: areaxstyle,
|
||||||
font: &controlFont,
|
doNotLoadFont: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,20 +177,18 @@ func (s *sysData) make(window *sysData) (err error) {
|
||||||
return fmt.Errorf("error actually creating window/control: %v", r.err)
|
return fmt.Errorf("error actually creating window/control: %v", r.err)
|
||||||
}
|
}
|
||||||
s.hwnd = _HWND(r.ret)
|
s.hwnd = _HWND(r.ret)
|
||||||
if ct.font != nil {
|
if !ct.doNotLoadFont {
|
||||||
uitask <- &uimsg{
|
uitask <- &uimsg{
|
||||||
call: _sendMessage,
|
call: _sendMessage,
|
||||||
p: []uintptr{
|
p: []uintptr{
|
||||||
uintptr(s.hwnd),
|
uintptr(s.hwnd),
|
||||||
uintptr(_WM_SETFONT),
|
uintptr(_WM_SETFONT),
|
||||||
uintptr(_WPARAM(*ct.font)),
|
uintptr(_WPARAM(controlFont)),
|
||||||
uintptr(_LPARAM(_TRUE)),
|
uintptr(_LPARAM(_TRUE)),
|
||||||
},
|
},
|
||||||
ret: ret,
|
ret: ret,
|
||||||
}
|
}
|
||||||
<-ret
|
<-ret
|
||||||
} else if s.ctype != c_window {
|
|
||||||
panic(fmt.Errorf("internal ui package error: control type %d does not have a font (needed for preferred size calculations)", s.ctype))
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
2
todo.md
2
todo.md
|
@ -36,7 +36,7 @@ important things:
|
||||||
- NSComboBox scans the entered text to see if it matches one of the items and returns the index of that item if it does; find out how to suppress this so that it returns -1 unless the item was chosen from the list (like the other platforms)
|
- NSComboBox scans the entered text to see if it matches one of the items and returns the index of that item if it does; find out how to suppress this so that it returns -1 unless the item was chosen from the list (like the other platforms)
|
||||||
- some Cocoa controls don't seem to resize correctly: Buttons have space around the edges and don't satisfy stretchiness
|
- some Cocoa controls don't seem to resize correctly: Buttons have space around the edges and don't satisfy stretchiness
|
||||||
- make sure GTK+ documentation version point differences (x in 4.3.x) don't matter
|
- make sure GTK+ documentation version point differences (x in 4.3.x) don't matter
|
||||||
- LineEdit heights on Windows seem too big; either that or LineEdit and Button text is not vertically centered properly
|
- LineEdit heights on Windows seem too big; either that or LineEdit, Button, and Label text is not vertically centered properly
|
||||||
- are Checkboxes too small?
|
- are Checkboxes too small?
|
||||||
- Cocoa has similar margining issues (like Comboboxes having margins)
|
- Cocoa has similar margining issues (like Comboboxes having margins)
|
||||||
- sometimes the size of the drop-down part of a Combobox becomes 0 or 1 or some other impossibly small value on Windows
|
- sometimes the size of the drop-down part of a Combobox becomes 0 or 1 or some other impossibly small value on Windows
|
||||||
|
|
Loading…
Reference in New Issue