Fixed some build issues and added the OS X uiControl code.

This commit is contained in:
Pietro Gagliardi 2015-08-16 23:08:00 -04:00
parent d5f2cae243
commit fa659395c8
9 changed files with 72 additions and 29 deletions

View File

@ -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);

View File

@ -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 \

View File

@ -237,7 +237,7 @@ void uiBoxSetPadded(uiBox *ss, int padded)
relayout(b);
}
static uiBox *finishBox(BOOL vertical)
static uiBox *finishNewBox(BOOL vertical)
{
uiBox *b;

View File

@ -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]]];
}

View File

@ -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

View File

@ -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];

View File

@ -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);

View File

@ -35,9 +35,9 @@ This file assumes that you have imported <Cocoa/Cocoa.h> 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.

View File

@ -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 {