summaryrefslogtreecommitdiff
path: root/basicctrls_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-10-24 16:11:53 -0400
committerPietro Gagliardi <[email protected]>2014-10-24 16:11:53 -0400
commitd82a6bc36d029c89cd677276fcab65db28992414 (patch)
treeb2909ea690e29104742ed71de1be420e917483f1 /basicctrls_darwin.m
parentcbcf77fb6d2729fa377e820238672b30c564c43f (diff)
Started the OS X implementation of Textbox.
Diffstat (limited to 'basicctrls_darwin.m')
-rw-r--r--basicctrls_darwin.m54
1 files changed, 54 insertions, 0 deletions
diff --git a/basicctrls_darwin.m b/basicctrls_darwin.m
index e0e5f75..c4b90c6 100644
--- a/basicctrls_darwin.m
+++ b/basicctrls_darwin.m
@@ -9,6 +9,7 @@
#define toNSView(x) ((NSView *) (x))
#define toNSWindow(x) ((NSWindow *) (x))
#define toNSBox(x) ((NSBox *) (x))
+#define toNSTextView(x) ((NSTextView *) (x))
@interface goControlDelegate : NSObject <NSTextFieldDelegate> {
@public
@@ -217,3 +218,56 @@ void groupSetText(id group, char *text)
{
[toNSBox(group) setTitle:[NSString stringWithUTF8String:text]];
}
+
+id newTextbox(void)
+{
+ NSTextView *tv;
+
+ tv = [[NSTextView alloc] initWithFrame:NSZeroRect];
+ // verified against Interface Builder, except for rich text options
+ [tv setAllowsDocumentBackgroundColorChange:NO];
+ [tv setBackgroundColor:[NSColor textBackgroundColor]];
+ [tv setTextColor:[NSColor textColor]];
+ [tv setAllowsUndo:YES];
+ [tv setEditable:YES];
+ [tv setSelectable:YES];
+ [tv setRichText:NO];
+ [tv setImportsGraphics:NO];
+ [tv setBaseWritingDirection:NSWritingDirectionNatural];
+ // TODO default paragraph format
+ [tv setAllowsImageEditing:NO];
+ [tv setAutomaticQuoteSubstitutionEnabled:NO];
+ [tv setAutomaticLinkDetectionEnabled:NO];
+ [tv setUsesRuler:NO];
+ [tv setRulerVisible:NO];
+ [tv setUsesInspectorBar:NO];
+ [tv setSelectionGranularity:NSSelectByCharacter];
+//TODO [tv setInsertionPointColor:[NSColor insertionColor]];
+ [tv setContinuousSpellCheckingEnabled:NO];
+ [tv setGrammarCheckingEnabled:NO];
+ [tv setUsesFontPanel:NO];
+ [tv setEnabledTextCheckingTypes:0];
+ [tv setAutomaticDashSubstitutionEnabled:NO];
+ [tv setAutomaticSpellingCorrectionEnabled:NO];
+ [tv setAutomaticTextReplacementEnabled:NO];
+ [tv setSmartInsertDeleteEnabled:NO];
+ [tv setLayoutOrientation:NSTextLayoutOrientationHorizontal];
+ // TODO default find panel behavior
+ // now just to be safe; this will do some of the above but whatever
+ disableAutocorrect((id) tv);
+ // this option is complex; just set it to the Interface Builder default
+ [[tv layoutManager] setAllowsNonContiguousLayout:YES];
+ // this will work because it's the same selector
+ setStandardControlFont((id) tv);
+ return (id) tv;
+}
+
+char *textboxText(id tv)
+{
+ return [[toNSTextView(tv) string] UTF8String];
+}
+
+void textboxSetText(id tv, char *text)
+{
+ [toNSTextView(tv) setString:[NSString stringWithUTF8String:text]];
+}