diff --git a/redo/reredo/control.c b/redo/reredo/control.c index f91b6234..a5ad99f5 100644 --- a/redo/reredo/control.c +++ b/redo/reredo/control.c @@ -101,11 +101,11 @@ void uiControlDisable(uiControl *c) static void controlUpdateState(uiControl *c) { - if (uiControlContainerVisible(c)) + if (controlContainerVisible(c)) osCommitShow(c); else osCommitHide(c); - if (uiControlContainerEnabled(c)) + if (controlContainerEnabled(c)) osCommitEnable(c); else osCommitDisable(c); diff --git a/redo/reredo/darwin/GNUmakeinc.mk b/redo/reredo/darwin/GNUmakeinc.mk index 2f05c822..80158b03 100644 --- a/redo/reredo/darwin/GNUmakeinc.mk +++ b/redo/reredo/darwin/GNUmakeinc.mk @@ -7,6 +7,7 @@ osMFILES = \ darwin/button.m \ darwin/checkbox.m \ darwin/combobox.m \ + darwin/control.m \ darwin/datetimepicker.m \ darwin/entry.m \ darwin/group.m \ diff --git a/redo/reredo/darwin/box.m b/redo/reredo/darwin/box.m index 2eadf6c0..e78c8572 100644 --- a/redo/reredo/darwin/box.m +++ b/redo/reredo/darwin/box.m @@ -237,7 +237,7 @@ void uiBoxSetPadded(uiBox *ss, int padded) relayout(b); } -static uiBox *finishBox(BOOL vertical) +static uiBox *finishNewBox(BOOL vertical) { uiBox *b; diff --git a/redo/reredo/darwin/control.m b/redo/reredo/darwin/control.m new file mode 100644 index 00000000..da48f571 --- /dev/null +++ b/redo/reredo/darwin/control.m @@ -0,0 +1,49 @@ +// 16 august 2015 +#import "uipriv_darwin.h" + +void osCommitShow(uiControl *c) +{ + NSView *view; + + view = (NSView *) uiControlHandle(c); + [view setHidden:NO]; +} + +void osCommitHide(uiControl *c) +{ + NSView *view; + + view = (NSView *) uiControlHandle(c); + [view setHidden:YES]; +} + +void osCommitEnable(uiControl *c) +{ + NSControl *view; + + view = (NSControl *) uiControlHandle(c); + if ([view respondsToSelector:@selector(setEnabled:)]) + [view setEnabled:YES]; +} + +void osCommitDisable(uiControl *c) +{ + NSControl *view; + + view = (NSControl *) uiControlHandle(c); + if ([view respondsToSelector:@selector(setEnabled:)]) + [view setEnabled:NO]; +} + +void uiDarwinFinishControl(uiControl *c) +{ + NSView *view; + + view = (NSView *) uiControlHandle(c); + [view retain]; +} + +void uiDarwinSetControlFont(NSControl *c, NSControlSize size) +{ + [c setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:size]]]; +} diff --git a/redo/reredo/darwin/uipriv_darwin.h b/redo/reredo/darwin/uipriv_darwin.h index 0d59fac6..f2fe7796 100644 --- a/redo/reredo/darwin/uipriv_darwin.h +++ b/redo/reredo/darwin/uipriv_darwin.h @@ -9,11 +9,6 @@ #define toNSString(str) [NSString stringWithUTF8String:(str)] #define fromNSString(str) [(str) UTF8String] -// These are based on measurements from Interface Builder. -// These seem to be based on Auto Layout constants, but I don't see an API that exposes these... -#define macXMargin 20 -#define macYMargin 20 - // menu.m @interface menuManager : NSObject { // unfortunately NSMutableDictionary copies its keys, meaning we can't use it for pointers @@ -43,7 +38,6 @@ extern void uninitMenus(void); #define appDelegate() ((appDelegate *) [realNSApp() delegate]) // util.m -extern void setStandardControlFont(NSControl *); extern void disableAutocorrect(NSTextView *); // entry.m @@ -56,11 +50,13 @@ extern uiWindow *windowFromNSWindow(NSWindow *); extern void initAlloc(void); extern void uninitAlloc(void); -// bin.c -extern uiControl *newBin(void); -extern void binSetChild(uiControl *, uiControl *); -extern int binMargined(uiControl *); -extern void binSetMargined(uiControl *, int); +// autolayout.m +extern void addConstraint(NSView *, NSString *, NSDictionary *, NSDictionary *); +extern NSLayoutPriority horzHuggingPri(NSView *); +extern NSLayoutPriority vertHuggingPri(NSView *); +extern void setHuggingPri(NSView *, NSLayoutPriority, NSLayoutConstraintOrientation); +extern void layoutSingleView(NSView *, NSView *, int); +extern NSSize fittingAlignmentSize(NSView *); // TODO #define PUT_CODE_HERE 0 diff --git a/redo/reredo/darwin/util.m b/redo/reredo/darwin/util.m index 37af7c58..2eb9ea7e 100644 --- a/redo/reredo/darwin/util.m +++ b/redo/reredo/darwin/util.m @@ -1,12 +1,6 @@ // 7 april 2015 #import "uipriv_darwin.h" -// also fine for NSCells and NSTexts (NSTextViews) -void setStandardControlFont(NSControl *control) -{ - [control setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; -} - void disableAutocorrect(NSTextView *tv) { [tv setEnabledTextCheckingTypes:0]; diff --git a/redo/reredo/ui.h b/redo/reredo/ui.h index 11094f98..908443d0 100644 --- a/redo/reredo/ui.h +++ b/redo/reredo/ui.h @@ -135,12 +135,12 @@ _UI_EXTERN uintmax_t uiLabelType(void); #define uiLabel(this) ((uiLabel *) uiIsA((this), uiLabelType(), 1)) _UI_EXTERN char *uiLabelText(uiLabel *l); _UI_EXTERN void uiLabelSetText(uiLabel *l, const char *text); -_UI_EXTERN uiLable *uiNewLabel(const char *text); +_UI_EXTERN uiLabel *uiNewLabel(const char *text); typedef struct uiTab uiTab; _UI_EXTERN uintmax_t uiTabType(void); #define uiTab(this) ((uiTab *) uiIsA((this), uiTabType(), 1)) -_UI_EXTERN void uiTabAppend(uITab *t, const char *name uiControl *c); +_UI_EXTERN void uiTabAppend(uiTab *t, const char *name, uiControl *c); _UI_EXTERN void uiTabInsertAt(uiTab *t, const char *name, uintmax_t before, uiControl *c); _UI_EXTERN void uiTabDelete(uiTab *t, uintmax_t index); _UI_EXTERN uintmax_t uiTabNumPages(uiTab *t); @@ -166,7 +166,7 @@ _UI_EXTERN uiGroup *uiNewGroup(const char *title); typedef struct uiSpinbox uiSpinbox; _UI_EXTERN uintmax_t uiSpinboxType(void); #define uiSpinbox(this) ((uiSpinbox *) uiIsA((this), uiSpinboxType(), 1)) -_UI_EXTERN intmx_t uiSpinboxValue(uiSpinbox *s); +_UI_EXTERN intmax_t uiSpinboxValue(uiSpinbox *s); _UI_EXTERN void uiSpinboxSetValue(uiSpinbox *s, intmax_t value); _UI_EXTERN void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data); _UI_EXTERN uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max); @@ -175,13 +175,13 @@ typedef struct uiProgressBar uiProgressBar; _UI_EXTERN uintmax_t uiProgressBarType(void); #define uiProgressBar(this) ((uiProgressBar *) uiIsA((this), uiProgressBarType(), 1)) // TODO uiProgressBarValue() -_UI_EXTERN uiProgressBarSetValue(uiProgressBar *p, int n); +_UI_EXTERN void uiProgressBarSetValue(uiProgressBar *p, int n); _UI_EXTERN uiProgressBar *uiNewProgressBar(void); typedef struct uiSlider uiSlider; _UI_EXTERN uintmax_t uiSliderType(void); #define uiSlider(this) ((uiSlider *) uiIsA((this), uiSliderType(), 1)) -_UI_EXTERN intmx_t uiSliderValue(uiSlider *s); +_UI_EXTERN intmax_t uiSliderValue(uiSlider *s); _UI_EXTERN void uiSliderSetValue(uiSlider *s, intmax_t value); _UI_EXTERN void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data); _UI_EXTERN uiSlider *uiNewSlider(intmax_t min, intmax_t max); diff --git a/redo/reredo/ui_darwin.h b/redo/reredo/ui_darwin.h index 25a817d0..445cf9b7 100644 --- a/redo/reredo/ui_darwin.h +++ b/redo/reredo/ui_darwin.h @@ -35,9 +35,9 @@ This file assumes that you have imported and "ui.h" beforehand. uiDarwinDefineControlWithOnDestroy(type, typefn, handlefield, (void) this;) #define uiDarwinFinishNewControl(variable, type) \ - type(variable)->CommitDestroy = _ ## type ## CommitDestroy; \ - type(variable)->Handle = _ ## type ## Handle; \ - type(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \ + uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \ + uiControl(variable)->Handle = _ ## type ## Handle; \ + uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \ uiDarwinFinishControl(uiControl(variable)); // This is a function used to set up a control. diff --git a/redo/reredo/uipriv.h b/redo/reredo/uipriv.h index 662e7f85..f244031f 100644 --- a/redo/reredo/uipriv.h +++ b/redo/reredo/uipriv.h @@ -15,7 +15,10 @@ extern void uiFree(void *); extern void complain(const char *, ...); -extern void queueResize(uiControl *); +extern void osCommitShow(uiControl *); +extern void osCommitHide(uiControl *); +extern void osCommitEnable(uiControl *); +extern void osCommitDisable(uiControl *); // ptrarray.c struct ptrArray {