summaryrefslogtreecommitdiff
path: root/spinbox_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-10-29 12:12:00 -0400
committerPietro Gagliardi <[email protected]>2014-10-29 12:12:00 -0400
commit6d58f434b74bb0119f493ba8e4508c93b14685d9 (patch)
treecefdc0fb71e5a00b86193eee9cf7e3612f2b3e09 /spinbox_darwin.m
parent765ccf00a36d379dcdb853173c0049f2bccc4cf3 (diff)
Added the initial implementaiton of Spinbox on Mac OS X. It doesn't quite work yet.
Diffstat (limited to 'spinbox_darwin.m')
-rw-r--r--spinbox_darwin.m40
1 files changed, 40 insertions, 0 deletions
diff --git a/spinbox_darwin.m b/spinbox_darwin.m
new file mode 100644
index 0000000..f9d6fe4
--- /dev/null
+++ b/spinbox_darwin.m
@@ -0,0 +1,40 @@
+// 29 october 2014
+
+#include "objc_darwin.h"
+#include "_cgo_export.h"
+#import <Cocoa/Cocoa.h>
+
+@interface goSpinbox : NSObject {
+@public
+ void *gospinbox;
+}
+@property NSInteger integerValue;
+@end
+
+@implementation goSpinbox
+@synthesize integerValue;
+@end
+
+id newSpinboxStepper(void)
+{
+ NSStepper *s;
+
+ s = [[NSStepper alloc] initWithFrame:NSZeroRect];
+ [s setMinValue:0];
+ [s setMaxValue:100];
+ [s setIncrement:1];
+ [s setAutorepeat:YES]; // hold mouse button to step repeatedly
+ return (id) s;
+}
+
+id spinboxSetup(id textfield, id stepper, void *gospinbox)
+{
+ goSpinbox *g;
+
+ g = [goSpinbox new];
+ g->gospinbox = gospinbox;
+ // TODO set any options?
+ [textfield bind:@"integerValue" toObject:g withKeyPath:@"integerValue" options:nil];
+ [stepper bind:@"integerValue" toObject:g withKeyPath:@"integerValue" options:nil];
+ return (id) g;
+}