Implemented Group on Mac OS X.
This commit is contained in:
parent
5a1fc98fc3
commit
1d117b7965
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#define toNSButton(x) ((NSButton *) (x))
|
#define toNSButton(x) ((NSButton *) (x))
|
||||||
#define toNSTextField(x) ((NSTextField *) (x))
|
#define toNSTextField(x) ((NSTextField *) (x))
|
||||||
|
#define toNSView(x) ((NSView *) (x))
|
||||||
|
#define toNSBox(x) ((NSBox *) (x))
|
||||||
|
|
||||||
@interface goControlDelegate : NSObject {
|
@interface goControlDelegate : NSObject {
|
||||||
@public
|
@public
|
||||||
|
@ -156,3 +158,28 @@ id newLabel(void)
|
||||||
[l setDrawsBackground:NO];
|
[l setDrawsBackground:NO];
|
||||||
return finishNewTextField(l, NO);
|
return finishNewTextField(l, NO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id newGroup(id container)
|
||||||
|
{
|
||||||
|
NSBox *group;
|
||||||
|
|
||||||
|
group = [[NSBox alloc] initWithFrame:NSZeroRect];
|
||||||
|
[group setBorderType:NSLineBorder];
|
||||||
|
[group setBoxType:NSBoxPrimary];
|
||||||
|
[group setTransparent:NO];
|
||||||
|
// can't use setSmallControlFont() here because the selector is different
|
||||||
|
[group setTitleFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
|
||||||
|
[group setTitlePosition:NSAtTop];
|
||||||
|
[group setContentView:toNSView(container)];
|
||||||
|
return (id) group;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *groupText(id group)
|
||||||
|
{
|
||||||
|
return [[toNSBox(group) title] UTF8String];
|
||||||
|
}
|
||||||
|
|
||||||
|
void groupSetText(id group, char *text)
|
||||||
|
{
|
||||||
|
[toNSBox(group) setTitle:[NSString stringWithUTF8String:text]];
|
||||||
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ void setSmallControlFont(id control)
|
||||||
[toNSControl(control) setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
|
[toNSControl(control) setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// also good for NSProgressIndicator
|
// also good for NSBox and NSProgressIndicator
|
||||||
struct xsize controlPreferredSize(id control)
|
struct xsize controlPreferredSize(id control)
|
||||||
{
|
{
|
||||||
NSControl *c;
|
NSControl *c;
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
// 16 august 2014
|
||||||
|
|
||||||
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// #include "objc_darwin.h"
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
type group struct {
|
||||||
|
_id C.id
|
||||||
|
|
||||||
|
*container
|
||||||
|
}
|
||||||
|
|
||||||
|
func newGroup(text string, control Control) Group {
|
||||||
|
g := new(group)
|
||||||
|
g.container = newContainer(control)
|
||||||
|
g._id = C.newGroup(g.container.id)
|
||||||
|
g.SetText(text)
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *group) Text() string {
|
||||||
|
return C.GoString(C.groupText(g._id))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *group) SetText(text string) {
|
||||||
|
ctext := C.CString(text)
|
||||||
|
defer C.free(unsafe.Pointer(ctext))
|
||||||
|
C.groupSetText(g._id, ctext)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *group) id() C.id {
|
||||||
|
return g._id
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *group) setParent(p *controlParent) {
|
||||||
|
basesetParent(g, p)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *group) allocate(x int, y int, width int, height int, d *sizing) []*allocation {
|
||||||
|
return baseallocate(g, x, y, width, height, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *group) preferredSize(d *sizing) (width, height int) {
|
||||||
|
return basepreferredSize(g, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *group) commitResize(a *allocation, d *sizing) {
|
||||||
|
basecommitResize(g, a, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *group) getAuxResizeInfo(d *sizing) {
|
||||||
|
basegetAuxResizeInfo(g, d)
|
||||||
|
}
|
|
@ -69,6 +69,9 @@ extern id newPasswordField(void);
|
||||||
extern const char *textFieldText(id);
|
extern const char *textFieldText(id);
|
||||||
extern void textFieldSetText(id, char *);
|
extern void textFieldSetText(id, char *);
|
||||||
extern id newLabel(void);
|
extern id newLabel(void);
|
||||||
|
extern id newGroup(id);
|
||||||
|
extern const char *groupText(id);
|
||||||
|
extern void groupSetText(id, char *);
|
||||||
|
|
||||||
/* container_darwin.m */
|
/* container_darwin.m */
|
||||||
extern id newContainerView(void *);
|
extern id newContainerView(void *);
|
||||||
|
|
Loading…
Reference in New Issue