diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-15 18:49:45 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-15 18:49:45 -0400 |
| commit | 518a5ddbf15d50a254c732a80d5907ef8878abe0 (patch) | |
| tree | 48cf259f98994e4570e65c389fcd9824272884ad /new/darwin/entry.m | |
| parent | 50ae3ca045e7f5f5744043df0a4506e2f6930bb1 (diff) | |
Split all OS backends into their own folders.
Diffstat (limited to 'new/darwin/entry.m')
| -rw-r--r-- | new/darwin/entry.m | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/new/darwin/entry.m b/new/darwin/entry.m new file mode 100644 index 0000000..f2b208b --- /dev/null +++ b/new/darwin/entry.m @@ -0,0 +1,67 @@ +// 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 isEntry) +{ + 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:isEntry]; + + // we don't need to worry about substitutions/autocorrect here; see window_darwin.m for details + + [[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; +} + +char *uiEntryText(uiControl *c) +{ + uiNSTextField *t; + + t = (uiNSTextField *) uiControlHandle(c); + return uiDarwinNSStringToText([t stringValue]); +} + +void uiEntrySetText(uiControl *c, const char *text) +{ + uiNSTextField *t; + + t = (uiNSTextField *) uiControlHandle(c); + [t setStringValue:toNSString(text)]; +} |
