summaryrefslogtreecommitdiff
path: root/redo/basicctrls_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-30 23:02:02 -0400
committerPietro Gagliardi <[email protected]>2014-08-30 23:02:02 -0400
commit77bf566ebbcb62acd4d08d905d9542d6ff9b6b80 (patch)
treeeeb8e72bc3bf57f5be7f0c0af4319189ac6de838 /redo/basicctrls_darwin.m
parent155899c65ed32245e2ccad4197a10c77017d835b (diff)
...in with the new.
Diffstat (limited to 'redo/basicctrls_darwin.m')
-rw-r--r--redo/basicctrls_darwin.m219
1 files changed, 0 insertions, 219 deletions
diff --git a/redo/basicctrls_darwin.m b/redo/basicctrls_darwin.m
deleted file mode 100644
index e0e5f75..0000000
--- a/redo/basicctrls_darwin.m
+++ /dev/null
@@ -1,219 +0,0 @@
-// 16 july 2014
-
-#import "objc_darwin.h"
-#import "_cgo_export.h"
-#import <Cocoa/Cocoa.h>
-
-#define toNSButton(x) ((NSButton *) (x))
-#define toNSTextField(x) ((NSTextField *) (x))
-#define toNSView(x) ((NSView *) (x))
-#define toNSWindow(x) ((NSWindow *) (x))
-#define toNSBox(x) ((NSBox *) (x))
-
-@interface goControlDelegate : NSObject <NSTextFieldDelegate> {
-@public
- void *gocontrol;
-}
-@end
-
-@implementation goControlDelegate
-
-- (IBAction)buttonClicked:(id)sender
-{
- buttonClicked(self->gocontrol);
-}
-
-- (IBAction)checkboxToggled:(id)sender
-{
- checkboxToggled(self->gocontrol);
-}
-
-- (void)controlTextDidChange:(NSNotification *)note
-{
- textfieldChanged(self->gocontrol);
-}
-
-@end
-
-id newButton(void)
-{
- NSButton *b;
-
- b = [[NSButton alloc] initWithFrame:NSZeroRect];
- [b setButtonType:NSMomentaryPushInButton];
- [b setBordered:YES];
- [b setBezelStyle:NSRoundedBezelStyle];
- setStandardControlFont((id) b);
- return (id) b;
-}
-
-void buttonSetDelegate(id button, void *b)
-{
- goControlDelegate *d;
-
- d = [goControlDelegate new];
- d->gocontrol = b;
- [toNSButton(button) setTarget:d];
- [toNSButton(button) setAction:@selector(buttonClicked:)];
-}
-
-const char *buttonText(id button)
-{
- return [[toNSButton(button) title] UTF8String];
-}
-
-void buttonSetText(id button, char *text)
-{
- [toNSButton(button) setTitle:[NSString stringWithUTF8String:text]];
-}
-
-id newCheckbox(void)
-{
- NSButton *c;
-
- c = [[NSButton alloc] initWithFrame:NSZeroRect];
- [c setButtonType:NSSwitchButton];
- [c setBordered:NO];
- setStandardControlFont((id) c);
- return (id) c;
-}
-
-void checkboxSetDelegate(id checkbox, void *b)
-{
- goControlDelegate *d;
-
- d = [goControlDelegate new];
- d->gocontrol = b;
- [toNSButton(checkbox) setTarget:d];
- [toNSButton(checkbox) setAction:@selector(checkboxToggled:)];
-}
-
-BOOL checkboxChecked(id c)
-{
- if ([toNSButton(c) state] == NSOnState)
- return YES;
- return NO;
-}
-
-void checkboxSetChecked(id c, BOOL checked)
-{
- NSInteger state;
-
- state = NSOnState;
- if (checked == NO)
- state = NSOffState;
- [toNSButton(c) setState:state];
-}
-
-// also good for labels
-// not static because area_darwin.m uses it
-id finishNewTextField(id _t, BOOL bordered)
-{
- NSTextField *t = toNSTextField(_t);
-
- // same for text fields, password fields, and labels
- setStandardControlFont((id) t);
- // these three are the same across text fields, password fields, and labels; the only difference is the setBezeled: value, and it's only different on labels
- // THE ORDER OF THESE CALLS IS IMPORTANT; CHANGE IT AND THE BORDERS WILL DISAPPEAR
- [t setBordered:NO];
- [t setBezelStyle:NSTextFieldSquareBezel];
- [t setBezeled:bordered];
- // smart quotes and other autocorrect features are handled by the window; see newWindow() in window_darwin.m for details
- // Interface Builder does this to make the text box behave properly
- // this disables both word wrap AND ellipsizing in one fell swoop
- // however, we need to send it to the control's cell, not to the control directly
- [[t cell] setLineBreakMode:NSLineBreakByClipping];
- // Interface Builder also sets this to allow horizontal scrolling
- // it also sets this for labels, despite those not being scrollable
- [[t cell] setScrollable:YES];
- return (id) t;
-}
-
-id newTextField(void)
-{
- NSTextField *t;
-
- t = [[NSTextField alloc] initWithFrame:NSZeroRect];
- return finishNewTextField((id) t, YES);
-}
-
-id newPasswordField(void)
-{
- NSSecureTextField *t;
-
- t = [[NSSecureTextField alloc] initWithFrame:NSZeroRect];
- return finishNewTextField((id) t, YES);
-}
-
-void textfieldSetDelegate(id textfield, void *t)
-{
- goControlDelegate *d;
-
- d = [goControlDelegate new];
- d->gocontrol = t;
- [toNSTextField(textfield) setDelegate:d];
-}
-
-// also good for labels
-const char *textfieldText(id t)
-{
- return [[toNSTextField(t) stringValue] UTF8String];
-}
-
-// also good for labels
-void textfieldSetText(id t, char *text)
-{
- [toNSTextField(t) setStringValue:[NSString stringWithUTF8String:text]];
-}
-
-id textfieldOpenInvalidPopover(id textfield, char *reason)
-{
- id popover;
-
- popover = newWarningPopover(reason);
- warningPopoverShow(popover, textfield);
- NSBeep();
- return (id) popover;
-}
-
-void textfieldCloseInvalidPopover(id popover)
-{
- [toNSWindow(popover) close];
- // don't release; close does that already
-}
-
-id newLabel(void)
-{
- NSTextField *l;
-
- l = [[NSTextField alloc] initWithFrame:NSZeroRect];
- [l setEditable:NO];
- [l setSelectable:NO];
- [l setDrawsBackground:NO];
- return finishNewTextField((id) 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]];
-}