diff options
Diffstat (limited to 'label_windows.go')
| -rw-r--r-- | label_windows.go | 62 |
1 files changed, 15 insertions, 47 deletions
diff --git a/label_windows.go b/label_windows.go index df39e51..8f8f120 100644 --- a/label_windows.go +++ b/label_windows.go @@ -6,67 +6,37 @@ package ui import "C" type label struct { - _hwnd C.HWND - _textlen C.LONG + *controlSingleHWNDWithText standalone bool } var labelclass = toUTF16("STATIC") -func finishNewLabel(text string, standalone bool) *label { +func newLabel(text string) Label { hwnd := C.newControl(labelclass, // SS_NOPREFIX avoids accelerator translation; SS_LEFTNOWORDWRAP clips text past the end // controls are vertically aligned to the top by default (thanks Xeek in irc.freenode.net/#winapi) C.SS_NOPREFIX|C.SS_LEFTNOWORDWRAP, C.WS_EX_TRANSPARENT) l := &label{ - _hwnd: hwnd, - standalone: standalone, + controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd), + } + l.fpreferredSize = l.xpreferredSize + l.fnTabStops = func() int { + // labels are not tab stops + return 0 } l.SetText(text) - C.controlSetControlFont(l._hwnd) + C.controlSetControlFont(l.hwnd) return l } -func newLabel(text string) Label { - return finishNewLabel(text, false) -} - -func newStandaloneLabel(text string) Label { - return finishNewLabel(text, true) -} - func (l *label) Text() string { - return baseText(l) + return l.text() } func (l *label) SetText(text string) { - baseSetText(l, text) -} - -func (l *label) isStandalone() bool { - return l.standalone -} - -func (l *label) hwnd() C.HWND { - return l._hwnd -} - -func (l *label) textlen() C.LONG { - return l._textlen -} - -func (l *label) settextlen(len C.LONG) { - l._textlen = len -} - -func (l *label) setParent(p *controlParent) { - C.controlSetParent(l.hwnd(), p.c.hwnd) - // don't increment p.c.nchildren here because Labels aren't tab stops -} - -func (l *label) allocate(x int, y int, width int, height int, d *sizing) []*allocation { - return baseallocate(l, x, y, width, height, d) + l.setText(text) } const ( @@ -75,10 +45,11 @@ const ( labelYOffset = 3 ) -func (l *label) preferredSize(d *sizing) (width, height int) { - return int(l._textlen), fromdlgunitsY(labelHeight, d) +func (l *label) xpreferredSize(d *sizing) (width, height int) { + return int(l.textlen), fromdlgunitsY(labelHeight, d) } +/*TODO func (l *label) commitResize(c *allocation, d *sizing) { if !l.standalone { yoff := fromdlgunitsY(labelYOffset, d) @@ -93,7 +64,4 @@ func (l *label) commitResize(c *allocation, d *sizing) { } basecommitResize(l, c, d) } - -func (l *label) getAuxResizeInfo(d *sizing) { - basegetAuxResizeInfo(l, d) -} +*/ |
