summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-04-09 02:35:52 -0400
committerPietro Gagliardi <[email protected]>2015-04-09 02:35:52 -0400
commitccdbdf011a8aa5e158dc94ad204eddeb1f32aa44 (patch)
treec14d813c7a7107b7b9bd7b6fca55c5493f15b35a
parentd6decf0abe716d7cc66ac06286ae09f4bbafbb3a (diff)
Implemented uiEntry on Mac OS X. Now I can get to writing the text and title functions...
-rw-r--r--new/entry_darwin.m51
1 files changed, 51 insertions, 0 deletions
diff --git a/new/entry_darwin.m b/new/entry_darwin.m
new file mode 100644
index 0000000..b08d53b
--- /dev/null
+++ b/new/entry_darwin.m
@@ -0,0 +1,51 @@
+// 9 april 2015
+#import "uipriv_darwin.h"
+
+@interface uiNSTextField : NSTextField
+@property uiControl *uiC;
+@end
+
+@implementation uiNSTextField
+
+- (void)viewDidMoveToSuperview
+{
+ if (uiDarwinControlFreeWhenAppropriate(self.uiC, [self superview])) {
+ [self setTarget:nil];
+ self.uiC = NULL;
+ }
+ [super viewDidMoveToSuperview];
+}
+
+@end
+
+// TOOD move elsewhere
+// these are based on interface builder defaults; my comments in the old code weren't very good so I don't really know what talked about what, sorry :/
+void finishNewTextField(NSTextField *t, BOOL isLabel)
+{
+ setStandardControlFont((id) t);
+
+ // THE ORDER OF THESE CALLS IS IMPORTANT; CHANGE IT AND THE BORDERS WILL DISAPPEAR
+ [t setBordered:NO];
+ [t setBezelStyle:NSTextFieldSquareBezel];
+ [t setBezeled:isLabel];
+
+ // TODO autocorrect comment
+
+ [[t cell] setLineBreakMode:NSLineBreakByClipping];
+ [[t cell] setScrollable:YES];
+}
+
+uiControl *uiNewEntry(void)
+{
+ uiControl *c;
+ uiNSTextField *t;
+
+ c = uiDarwinNewControl([uiNSTextField class], NO, NO);
+ t = (uiNSTextField *) uiControlHandle(c);
+ t.uiC = c;
+
+ [t setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
+ finishNewTextField((NSTextField *) t, YES);
+
+ return t.uiC;
+}