summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--newctrl/area_unix.go4
-rw-r--r--newctrl/area_windows.go4
-rw-r--r--newctrl/button_windows.go4
-rw-r--r--newctrl/checkbox_windows.go4
-rw-r--r--newctrl/control.go2
-rw-r--r--newctrl/control_unix.go12
-rw-r--r--newctrl/control_windows.go8
-rw-r--r--newctrl/group_unix.go10
-rw-r--r--newctrl/group_windows.go13
-rw-r--r--newctrl/label_windows.go4
-rw-r--r--newctrl/tab_unix.go10
-rw-r--r--newctrl/tab_windows.go17
-rw-r--r--newctrl/table_windows.go13
-rw-r--r--newctrl/textfield_windows.go4
14 files changed, 59 insertions, 50 deletions
diff --git a/newctrl/area_unix.go b/newctrl/area_unix.go
index c865d6b..e434d50 100644
--- a/newctrl/area_unix.go
+++ b/newctrl/area_unix.go
@@ -65,7 +65,7 @@ func newArea(ab *areabase) Area {
textfield: (*C.GtkEntry)(unsafe.Pointer(textfieldw)),
textfielddone: newEvent(),
}
- a.fpreferredSize = a.preferredSize
+ a.fpreferredSize = a.xpreferredSize
for _, c := range areaCallbacks {
g_signal_connect(
C.gpointer(unsafe.Pointer(a.drawingarea)),
@@ -491,7 +491,7 @@ var modonlykeys = map[C.guint]Modifiers{
C.GDK_KEY_Super_R: Super,
}
-func (a *area) preferredSize(d *sizing) (width, height int) {
+func (a *area) xpreferredSize(d *sizing) (width, height int) {
// the preferred size of an Area is its size
return a.width, a.height
}
diff --git a/newctrl/area_windows.go b/newctrl/area_windows.go
index 19c0250..bf4b9e9 100644
--- a/newctrl/area_windows.go
+++ b/newctrl/area_windows.go
@@ -40,7 +40,7 @@ func newArea(ab *areabase) Area {
textfielddone: newEvent(),
}
a.controlSingleHWND = newControlSingleHWND(C.newArea(unsafe.Pointer(a)))
- a.fpreferredSize = a.preferredSize
+ a.fpreferredSize = a.xpreferredSize
a.SetSize(a.width, a.height)
a.textfield = C.newAreaTextField(a.hwnd, unsafe.Pointer(a))
C.controlSetControlFont(a.textfield)
@@ -330,7 +330,7 @@ func areaResetClickCounter(data unsafe.Pointer) {
a.clickCounter.reset()
}
-func (a *area) preferredSize(d *sizing) (width, height int) {
+func (a *area) xpreferredSize(d *sizing) (width, height int) {
// the preferred size of an Area is its size
return a.width, a.height
}
diff --git a/newctrl/button_windows.go b/newctrl/button_windows.go
index 6937473..ff5a251 100644
--- a/newctrl/button_windows.go
+++ b/newctrl/button_windows.go
@@ -24,7 +24,7 @@ func newButton(text string) *button {
controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
clicked: newEvent(),
}
- b.fpreferredSize = b.preferredSize
+ b.fpreferredSize = b.xpreferredSize
b.SetText(text)
C.controlSetControlFont(b.hwnd)
C.setButtonSubclass(b.hwnd, unsafe.Pointer(b))
@@ -54,7 +54,7 @@ const (
buttonHeight = 14
)
-func (b *button) preferredSize(d *sizing) (width, height int) {
+func (b *button) xpreferredSize(d *sizing) (width, height int) {
// comctl32.dll version 6 thankfully provides a method to grab this...
var size C.SIZE
diff --git a/newctrl/checkbox_windows.go b/newctrl/checkbox_windows.go
index ffabbdc..4ccd5e2 100644
--- a/newctrl/checkbox_windows.go
+++ b/newctrl/checkbox_windows.go
@@ -24,7 +24,7 @@ func newCheckbox(text string) *checkbox {
controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
toggled: newEvent(),
}
- c.fpreferredSize = c.preferredSize
+ c.fpreferredSize = c.xpreferredSize
c.SetText(text)
C.controlSetControlFont(c.hwnd)
C.setCheckboxSubclass(c.hwnd, unsafe.Pointer(c))
@@ -68,7 +68,7 @@ const (
checkboxXFromLeftOfBoxToLeftOfLabel = 12
)
-func (c *checkbox) preferredSize(d *sizing) (width, height int) {
+func (c *checkbox) xpreferredSize(d *sizing) (width, height int) {
return fromdlgunitsX(checkboxXFromLeftOfBoxToLeftOfLabel, d) + int(c.textlen),
fromdlgunitsY(checkboxHeight, d)
}
diff --git a/newctrl/control.go b/newctrl/control.go
index 3a03a54..34e5c84 100644
--- a/newctrl/control.go
+++ b/newctrl/control.go
@@ -17,6 +17,8 @@ type controlbase struct {
fnTabStops func() int
}
+// children should not use the same name as these, otherwise weird things will happen
+
func (c *controlbase) setParent(p *controlParent) {
c.fsetParent(p)
}
diff --git a/newctrl/control_unix.go b/newctrl/control_unix.go
index 363be55..6aa2278 100644
--- a/newctrl/control_unix.go
+++ b/newctrl/control_unix.go
@@ -23,22 +23,22 @@ type controlSingleWidget struct {
func newControlSingleWidget(widget *C.GtkWidget) *controlSingleWidget {
c := new(controlSingleWidget)
c.controlbase = &controlbase{
- fsetParent: c.setParent,
- fpreferredSize: c.preferredSize,
- fresize: c.resize,
+ fsetParent: c.xsetParent,
+ fpreferredSize: c.xpreferredSize,
+ fresize: c.xresize,
}
c.widget = widget
return c
}
-func (c *controlSingleWidget) setParent(p *controlParent) {
+func (c *controlSingleWidget) xsetParent(p *controlParent) {
C.gtk_container_add(p.c, c.widget)
// make sure the new widget is shown if not explicitly hidden
// TODO why did I have this again?
C.gtk_widget_show_all(c.widget)
}
-func (c *controlSingleWidget) preferredSize(d *sizing) (int, int) {
+func (c *controlSingleWidget) xpreferredSize(d *sizing) (int, int) {
// GTK+ 3 makes this easy: controls can tell us what their preferred size is!
// ...actually, it tells us two things: the "minimum size" and the "natural size".
// The "minimum size" is the smallest size we /can/ display /anything/. The "natural size" is the smallest size we would /prefer/ to display.
@@ -51,7 +51,7 @@ func (c *controlSingleWidget) preferredSize(d *sizing) (int, int) {
return int(r.width), int(r.height)
}
-func (c *controlSingleWidget) resize(x int, y int, width int, height int, d *sizing) {
+func (c *controlSingleWidget) xresize(x int, y int, width int, height int, d *sizing) {
// as we resize on size-allocate, we have to also use size-allocate on our children
// this is fine anyway; in fact, this allows us to move without knowing what the container is!
// this is what GtkBox does anyway
diff --git a/newctrl/control_windows.go b/newctrl/control_windows.go
index f0cb590..ffe0222 100644
--- a/newctrl/control_windows.go
+++ b/newctrl/control_windows.go
@@ -19,8 +19,8 @@ type controlSingleHWND struct {
func newControlSingleHWND(hwnd C.HWND) *controlSingleHWND {
c := new(controlSingleHWND)
c.controlbase = &controlbase{
- fsetParent: c.setParent,
- fresize: c.resize,
+ fsetParent: c.xsetParent,
+ fresize: c.xresize,
fnTabStops: func() int {
// most controls count as one tab stop
return 1
@@ -30,11 +30,11 @@ func newControlSingleHWND(hwnd C.HWND) *controlSingleHWND {
return c
}
-func (c *controlSingleHWND) setParent(p *controlParent) {
+func (c *controlSingleHWND) xsetParent(p *controlParent) {
C.controlSetParent(c.hwnd, p.hwnd)
}
-func (c *controlSingleHWND) resize(x int, y int, width int, height int, d *sizing) {
+func (c *controlSingleHWND) xresize(x int, y int, width int, height int, d *sizing) {
C.moveWindow(c.hwnd, C.int(x), C.int(y), C.int(width), C.int(height))
}
diff --git a/newctrl/group_unix.go b/newctrl/group_unix.go
index dc6191b..681ec75 100644
--- a/newctrl/group_unix.go
+++ b/newctrl/group_unix.go
@@ -20,6 +20,8 @@ type group struct {
container *container
margined bool
+
+ chainresize func(x int, y int, width int, height int, d *sizing)
}
func newGroup(text string, control Control) Group {
@@ -54,7 +56,8 @@ func newGroup(text string, control Control) Group {
g.child.setParent(g.container.parent())
g.container.setParent(&controlParent{g.gcontainer})
- g.fresize = g.resize
+ g.chainresize = g.fresize
+ g.fresize = g.xresize
return g
}
@@ -77,10 +80,9 @@ func (g *group) SetMargined(margined bool) {
g.margined = margined
}
-func (g *group) resize(x int, y int, width int, height int, d *sizing) {
+func (g *group) xresize(x int, y int, width int, height int, d *sizing) {
// first, chain up to change the GtkFrame and its child container
- // TODO use a variable for this
- g.controlSingleWidget.resize(x, y, width, height, d)
+ g.chainresize(x, y, width, height, d)
// now that the container has the correct size, we can resize the child
a := g.container.allocation(g.margined)
diff --git a/newctrl/group_windows.go b/newctrl/group_windows.go
index ee406d8..d4acdda 100644
--- a/newctrl/group_windows.go
+++ b/newctrl/group_windows.go
@@ -9,6 +9,7 @@ type group struct {
*controlSingleHWNDWithText
child Control
margined bool
+ chainresize func(x int, y int, width int, height int, d *sizing)
}
func newGroup(text string, control Control) Group {
@@ -19,8 +20,9 @@ func newGroup(text string, control Control) Group {
controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
child: control,
}
- g.fpreferredSize = g.preferredSize
- g.fresize = g.resize
+ g.fpreferredSize = g.xpreferredSize
+ g.chainresize = g.fresize
+ g.fresize = g.xresize
g.fnTabStops = control.nTabStops // groupbox itself is not tabbable but the contents might be
g.SetText(text)
C.controlSetControlFont(g.hwnd)
@@ -50,7 +52,7 @@ const (
groupYMarginBottom = 7
)
-func (g *group) preferredSize(d *sizing) (width, height int) {
+func (g *group) xpreferredSize(d *sizing) (width, height int) {
var r C.RECT
width, height = g.child.preferredSize(d)
@@ -73,10 +75,9 @@ func (g *group) preferredSize(d *sizing) (width, height int) {
return int(r.right - r.left), int(r.bottom - r.top)
}
-func (g *group) resize(x int, y int, width int, height int, d *sizing) {
+func (g *group) xresize(x int, y int, width int, height int, d *sizing) {
// first, chain up to the container base to keep the Z-order correct
- // TODO use a variable for this
- g.controlSingleHWNDWithText.resize(x, y, width, height, d)
+ g.chainresize(x, y, width, height, d)
// now resize the child container
var r C.RECT
diff --git a/newctrl/label_windows.go b/newctrl/label_windows.go
index 61d842f..8f8f120 100644
--- a/newctrl/label_windows.go
+++ b/newctrl/label_windows.go
@@ -21,7 +21,7 @@ func newLabel(text string) Label {
l := &label{
controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
}
- l.fpreferredSize = l.preferredSize
+ l.fpreferredSize = l.xpreferredSize
l.fnTabStops = func() int {
// labels are not tab stops
return 0
@@ -45,7 +45,7 @@ const (
labelYOffset = 3
)
-func (l *label) preferredSize(d *sizing) (width, height int) {
+func (l *label) xpreferredSize(d *sizing) (width, height int) {
return int(l.textlen), fromdlgunitsY(labelHeight, d)
}
diff --git a/newctrl/tab_unix.go b/newctrl/tab_unix.go
index 608e3a6..064f17f 100644
--- a/newctrl/tab_unix.go
+++ b/newctrl/tab_unix.go
@@ -18,6 +18,8 @@ type tab struct {
tabs []*container
children []Control
+
+ chainresize func(x int, y int, width int, height int, d *sizing)
}
func newTab() Tab {
@@ -27,7 +29,8 @@ func newTab() Tab {
container: (*C.GtkContainer)(unsafe.Pointer(widget)),
notebook: (*C.GtkNotebook)(unsafe.Pointer(widget)),
}
- t.fresize = t.resize
+ t.chainresize = t.fresize
+ t.fresize = t.xresize
// there are no scrolling arrows by default; add them in case there are too many tabs
C.gtk_notebook_set_scrollable(t.notebook, C.TRUE)
return t
@@ -48,10 +51,9 @@ func (t *tab) Append(name string, control Control) {
cname)
}
-func (t *tab) resize(x int, y int, width int, height int, d *sizing) {
+func (t *tab) xresize(x int, y int, width int, height int, d *sizing) {
// first, chain up to change the GtkFrame and its child container
- // TODO use a variable for this
- t.controlSingleWidget.resize(x, y, width, height, d)
+ t.chainresize(x, y, width, height, d)
// now that the containers have the correct size, we can resize the children
for i, _ := range t.tabs {
diff --git a/newctrl/tab_windows.go b/newctrl/tab_windows.go
index e3fe01e..7203166 100644
--- a/newctrl/tab_windows.go
+++ b/newctrl/tab_windows.go
@@ -17,8 +17,9 @@ We'll create a dummy window using the container window class for each tab page.
type tab struct {
*controlSingleHWND
- tabs []*container
- children []Control
+ tabs []*container
+ children []Control
+ chainresize func(x int, y int, width int, height int, d *sizing)
}
func newTab() Tab {
@@ -28,8 +29,9 @@ func newTab() Tab {
t := &tab{
controlSingleHWND: newControlSingleHWND(hwnd),
}
- t.fpreferredSize = t.preferredSize
- t.fresize = t.resize
+ t.fpreferredSize = t.xpreferredSize
+ t.chainresize = t.fresize
+ t.fresize = t.xresize
// count tabs as 1 tab stop; the actual number of tab stops varies
C.controlSetControlFont(t.hwnd)
C.setTabSubclass(t.hwnd, unsafe.Pointer(t))
@@ -74,7 +76,7 @@ func tabTabHasChildren(data unsafe.Pointer, which C.LRESULT) C.BOOL {
return C.FALSE
}
-func (t *tab) preferredSize(d *sizing) (width, height int) {
+func (t *tab) xpreferredSize(d *sizing) (width, height int) {
for _, c := range t.children {
w, h := c.preferredSize(d)
if width < w {
@@ -88,10 +90,9 @@ func (t *tab) preferredSize(d *sizing) (width, height int) {
}
// a tab control contains other controls; size appropriately
-func (t *tab) resize(x int, y int, width int, height int, d *sizing) {
+func (t *tab) xresize(x int, y int, width int, height int, d *sizing) {
// first, chain up to the container base to keep the Z-order correct
- // TODO use a variable for this
- t.controlSingleHWND.resize(x, y, width, height, d)
+ t.chainresize(x, y, width, height, d)
// now resize the children
var r C.RECT
diff --git a/newctrl/table_windows.go b/newctrl/table_windows.go
index 054a29b..ceeb504 100644
--- a/newctrl/table_windows.go
+++ b/newctrl/table_windows.go
@@ -21,6 +21,7 @@ type table struct {
pushedrow C.int
pushedcol C.int
selected *event
+ chainresize func(x int, y int, width int, height int, d *sizing)
}
func finishNewTable(b *tablebase, ty reflect.Type) Table {
@@ -36,8 +37,9 @@ func finishNewTable(b *tablebase, ty reflect.Type) Table {
pushedcol: -1,
selected: newEvent(),
}
- t.fpreferredSize = t.preferredSize
- t.fresize = t.resize
+ t.fpreferredSize = t.xpreferredSize
+ t.chainresize = t.fresize
+ t.fresize = t.xresize
C.setTableSubclass(t.hwnd, unsafe.Pointer(t))
// LVS_EX_FULLROWSELECT gives us selection across the whole row, not just the leftmost column; this makes the list view work like on other platforms
// LVS_EX_SUBITEMIMAGES gives us images in subitems, which will be important when both images and checkboxes are added
@@ -221,13 +223,12 @@ const (
tableHeight = 50
)
-func (t *table) preferredSize(d *sizing) (width, height int) {
+func (t *table) xpreferredSize(d *sizing) (width, height int) {
return fromdlgunitsX(tableWidth, d), fromdlgunitsY(tableHeight, d)
}
-func (t *table) commitResize(x int, y int, width int, height int, d *sizing) {
- // TODO use a variable for this
- t.controlSingleHWND.resize(x, y, width, height, d)
+func (t *table) xresize(x int, y int, width int, height int, d *sizing) {
+ t.chainresize(x, y, width, height, d)
t.RLock()
defer t.RUnlock()
t.autoresize()
diff --git a/newctrl/textfield_windows.go b/newctrl/textfield_windows.go
index 8b30a26..76ec882 100644
--- a/newctrl/textfield_windows.go
+++ b/newctrl/textfield_windows.go
@@ -24,7 +24,7 @@ func startNewTextField(style C.DWORD) *textfield {
controlSingleHWNDWithText: newControlSingleHWNDWithText(hwnd),
changed: newEvent(),
}
- t.fpreferredSize = t.preferredSize
+ t.fpreferredSize = t.xpreferredSize
C.controlSetControlFont(t.hwnd)
C.setTextFieldSubclass(t.hwnd, unsafe.Pointer(t))
return t
@@ -70,6 +70,6 @@ const (
textfieldHeight = 14
)
-func (t *textfield) preferredSize(d *sizing) (width, height int) {
+func (t *textfield) xpreferredSize(d *sizing) (width, height int) {
return fromdlgunitsX(textfieldWidth, d), fromdlgunitsY(textfieldHeight, d)
}