From c9643ea5a6ee6d188bb7c9f5043d71cd22d83994 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 8 Apr 2019 20:55:06 -0400 Subject: [PATCH] Gutted the existing header files, started trimming things that remain in the backups, and renamed _UI_EXTERN and _UI_ENUM and the include guards and libui_EXPORTS to start with uipriv instead. --- meson.build | 6 +- ui.h | 1448 +-------------------------------------------- ui_darwin.h | 210 +------ ui_unix.h | 130 +--- ui_windows.h | 253 +------- zOLD_ui.h | 590 +++++++++--------- zOLD_ui_darwin.h | 51 +- zOLD_ui_unix.h | 25 +- zOLD_ui_windows.h | 89 ++- 9 files changed, 348 insertions(+), 2454 deletions(-) diff --git a/meson.build b/meson.build index 9199a7ea..21e99f37 100644 --- a/meson.build +++ b/meson.build @@ -158,9 +158,9 @@ libui_libui = library('ui', libui_sources, name_prefix: 'lib', # always call it libui, even in Windows DLLs install: true, gnu_symbol_visibility: 'hidden', - c_args: ['-Dlibui_EXPORTS'], - cpp_args: ['-Dlibui_EXPORTS'], - objc_args: ['-Dlibui_EXPORTS'], + c_args: ['-DuiprivBuildingLibui'], + cpp_args: ['-DuiprivBuildingLibui'], + objc_args: ['-DuiprivBuildingLibui'], link_args: libui_libui_link_args, soversion: libui_soversion, darwin_versions: []) # TODO diff --git a/ui.h b/ui.h index 40aea949..a4ac70fe 100644 --- a/ui.h +++ b/ui.h @@ -1,14 +1,7 @@ // 6 april 2015 -// TODO add a uiVerifyControlType() function that can be used by control implementations to verify controls - -// TODOs -// - make getters that return whether something exists accept a NULL pointer to discard the value (and thus only return that the thing exists?) -// - const-correct everything -// - normalize documentation between typedefs and structs - -#ifndef __LIBUI_UI_H__ -#define __LIBUI_UI_H__ +#ifndef uiprivIncludeGuard_ui_h +#define uiprivIncludeGuard_ui_h #include #include @@ -17,1446 +10,19 @@ extern "C" { #endif -// this macro is generated by cmake -#ifdef libui_EXPORTS +#ifdef uiprivBuildingLibui #ifdef _WIN32 -#define _UI_EXTERN __declspec(dllexport) extern +#define uiprivExtern __declspec(dllexport) extern #else -#define _UI_EXTERN __attribute__((visibility("default"))) extern +#define uiprivExtern __attribute__((visibility("default"))) extern #endif #else -// TODO add __declspec(dllimport) on windows, but only if not static -#define _UI_EXTERN extern +// TODO add __declspec(dllimport) on windows, but only if not static#define uiprivExtern extern #endif // C++ is really really really really really really dumb about enums, so screw that and just make them anonymous // This has the advantage of being ABI-able should we ever need an ABI... -#define _UI_ENUM(s) typedef unsigned int s; enum - -// This constant is provided because M_PI is nonstandard. -// This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796. -#define uiPi 3.14159265358979323846264338327950288419716939937510582097494459 - -// TODO uiBool? - -// uiForEach represents the return value from one of libui's various ForEach functions. -_UI_ENUM(uiForEach) { - uiForEachContinue, - uiForEachStop, -}; - -typedef struct uiInitOptions uiInitOptions; - -struct uiInitOptions { - size_t Size; -}; - -_UI_EXTERN const char *uiInit(uiInitOptions *options); -_UI_EXTERN void uiUninit(void); -_UI_EXTERN void uiFreeInitError(const char *err); - -_UI_EXTERN void uiMain(void); -_UI_EXTERN void uiMainSteps(void); -_UI_EXTERN int uiMainStep(int wait); -_UI_EXTERN void uiQuit(void); - -_UI_EXTERN void uiQueueMain(void (*f)(void *data), void *data); - -// TODO standardize the looping behavior return type, either with some enum or something, and the test expressions throughout the code -// TODO figure out what to do about looping and the exact point that the timer is rescheduled so we can document it; see https://github.com/andlabs/libui/pull/277 -// TODO (also in the above link) document that this cannot be called from any thread, unlike uiQueueMain() -// TODO document that the minimum exact timing, either accuracy (timer burst, etc.) or granularity (15ms on Windows, etc.), is OS-defined -// TODO also figure out how long until the initial tick is registered on all platforms to document -// TODO also add a comment about how useful this could be in bindings, depending on the language being bound to -_UI_EXTERN void uiTimer(int milliseconds, int (*f)(void *data), void *data); - -_UI_EXTERN void uiOnShouldQuit(int (*f)(void *data), void *data); - -_UI_EXTERN void uiFreeText(char *text); - -typedef struct uiControl uiControl; - -struct uiControl { - uint32_t Signature; - uint32_t OSSignature; - uint32_t TypeSignature; - void (*Destroy)(uiControl *); - uintptr_t (*Handle)(uiControl *); - uiControl *(*Parent)(uiControl *); - void (*SetParent)(uiControl *, uiControl *); - int (*Toplevel)(uiControl *); - int (*Visible)(uiControl *); - void (*Show)(uiControl *); - void (*Hide)(uiControl *); - int (*Enabled)(uiControl *); - void (*Enable)(uiControl *); - void (*Disable)(uiControl *); -}; -// TOOD add argument names to all arguments -#define uiControl(this) ((uiControl *) (this)) -_UI_EXTERN void uiControlDestroy(uiControl *); -_UI_EXTERN uintptr_t uiControlHandle(uiControl *); -_UI_EXTERN uiControl *uiControlParent(uiControl *); -_UI_EXTERN void uiControlSetParent(uiControl *, uiControl *); -_UI_EXTERN int uiControlToplevel(uiControl *); -_UI_EXTERN int uiControlVisible(uiControl *); -_UI_EXTERN void uiControlShow(uiControl *); -_UI_EXTERN void uiControlHide(uiControl *); -_UI_EXTERN int uiControlEnabled(uiControl *); -_UI_EXTERN void uiControlEnable(uiControl *); -_UI_EXTERN void uiControlDisable(uiControl *); - -_UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr); -_UI_EXTERN void uiFreeControl(uiControl *); - -// TODO make sure all controls have these -_UI_EXTERN void uiControlVerifySetParent(uiControl *, uiControl *); -_UI_EXTERN int uiControlEnabledToUser(uiControl *); - -_UI_EXTERN void uiUserBugCannotSetParentOnToplevel(const char *type); - -typedef struct uiWindow uiWindow; -#define uiWindow(this) ((uiWindow *) (this)) -_UI_EXTERN char *uiWindowTitle(uiWindow *w); -_UI_EXTERN void uiWindowSetTitle(uiWindow *w, const char *title); -_UI_EXTERN void uiWindowContentSize(uiWindow *w, int *width, int *height); -_UI_EXTERN void uiWindowSetContentSize(uiWindow *w, int width, int height); -_UI_EXTERN int uiWindowFullscreen(uiWindow *w); -_UI_EXTERN void uiWindowSetFullscreen(uiWindow *w, int fullscreen); -_UI_EXTERN void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data); -_UI_EXTERN void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data); -_UI_EXTERN int uiWindowBorderless(uiWindow *w); -_UI_EXTERN void uiWindowSetBorderless(uiWindow *w, int borderless); -_UI_EXTERN void uiWindowSetChild(uiWindow *w, uiControl *child); -_UI_EXTERN int uiWindowMargined(uiWindow *w); -_UI_EXTERN void uiWindowSetMargined(uiWindow *w, int margined); -_UI_EXTERN uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar); - -typedef struct uiButton uiButton; -#define uiButton(this) ((uiButton *) (this)) -_UI_EXTERN char *uiButtonText(uiButton *b); -_UI_EXTERN void uiButtonSetText(uiButton *b, const char *text); -_UI_EXTERN void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *b, void *data), void *data); -_UI_EXTERN uiButton *uiNewButton(const char *text); - -typedef struct uiBox uiBox; -#define uiBox(this) ((uiBox *) (this)) -_UI_EXTERN void uiBoxAppend(uiBox *b, uiControl *child, int stretchy); -_UI_EXTERN void uiBoxDelete(uiBox *b, int index); -_UI_EXTERN int uiBoxPadded(uiBox *b); -_UI_EXTERN void uiBoxSetPadded(uiBox *b, int padded); -_UI_EXTERN uiBox *uiNewHorizontalBox(void); -_UI_EXTERN uiBox *uiNewVerticalBox(void); - -typedef struct uiCheckbox uiCheckbox; -#define uiCheckbox(this) ((uiCheckbox *) (this)) -_UI_EXTERN char *uiCheckboxText(uiCheckbox *c); -_UI_EXTERN void uiCheckboxSetText(uiCheckbox *c, const char *text); -_UI_EXTERN void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *c, void *data), void *data); -_UI_EXTERN int uiCheckboxChecked(uiCheckbox *c); -_UI_EXTERN void uiCheckboxSetChecked(uiCheckbox *c, int checked); -_UI_EXTERN uiCheckbox *uiNewCheckbox(const char *text); - -typedef struct uiEntry uiEntry; -#define uiEntry(this) ((uiEntry *) (this)) -_UI_EXTERN char *uiEntryText(uiEntry *e); -_UI_EXTERN void uiEntrySetText(uiEntry *e, const char *text); -_UI_EXTERN void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *e, void *data), void *data); -_UI_EXTERN int uiEntryReadOnly(uiEntry *e); -_UI_EXTERN void uiEntrySetReadOnly(uiEntry *e, int readonly); -_UI_EXTERN uiEntry *uiNewEntry(void); -_UI_EXTERN uiEntry *uiNewPasswordEntry(void); -_UI_EXTERN uiEntry *uiNewSearchEntry(void); - -typedef struct uiLabel uiLabel; -#define uiLabel(this) ((uiLabel *) (this)) -_UI_EXTERN char *uiLabelText(uiLabel *l); -_UI_EXTERN void uiLabelSetText(uiLabel *l, const char *text); -_UI_EXTERN uiLabel *uiNewLabel(const char *text); - -typedef struct uiTab uiTab; -#define uiTab(this) ((uiTab *) (this)) -_UI_EXTERN void uiTabAppend(uiTab *t, const char *name, uiControl *c); -_UI_EXTERN void uiTabInsertAt(uiTab *t, const char *name, int before, uiControl *c); -_UI_EXTERN void uiTabDelete(uiTab *t, int index); -_UI_EXTERN int uiTabNumPages(uiTab *t); -_UI_EXTERN int uiTabMargined(uiTab *t, int page); -_UI_EXTERN void uiTabSetMargined(uiTab *t, int page, int margined); -_UI_EXTERN uiTab *uiNewTab(void); - -typedef struct uiGroup uiGroup; -#define uiGroup(this) ((uiGroup *) (this)) -_UI_EXTERN char *uiGroupTitle(uiGroup *g); -_UI_EXTERN void uiGroupSetTitle(uiGroup *g, const char *title); -_UI_EXTERN void uiGroupSetChild(uiGroup *g, uiControl *c); -_UI_EXTERN int uiGroupMargined(uiGroup *g); -_UI_EXTERN void uiGroupSetMargined(uiGroup *g, int margined); -_UI_EXTERN uiGroup *uiNewGroup(const char *title); - -// spinbox/slider rules: -// setting value outside of range will automatically clamp -// initial value is minimum -// complaint if min >= max? - -typedef struct uiSpinbox uiSpinbox; -#define uiSpinbox(this) ((uiSpinbox *) (this)) -_UI_EXTERN int uiSpinboxValue(uiSpinbox *s); -_UI_EXTERN void uiSpinboxSetValue(uiSpinbox *s, int value); -_UI_EXTERN void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data); -_UI_EXTERN uiSpinbox *uiNewSpinbox(int min, int max); - -typedef struct uiSlider uiSlider; -#define uiSlider(this) ((uiSlider *) (this)) -_UI_EXTERN int uiSliderValue(uiSlider *s); -_UI_EXTERN void uiSliderSetValue(uiSlider *s, int value); -_UI_EXTERN void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data); -_UI_EXTERN uiSlider *uiNewSlider(int min, int max); - -typedef struct uiProgressBar uiProgressBar; -#define uiProgressBar(this) ((uiProgressBar *) (this)) -_UI_EXTERN int uiProgressBarValue(uiProgressBar *p); -_UI_EXTERN void uiProgressBarSetValue(uiProgressBar *p, int n); -_UI_EXTERN uiProgressBar *uiNewProgressBar(void); - -typedef struct uiSeparator uiSeparator; -#define uiSeparator(this) ((uiSeparator *) (this)) -_UI_EXTERN uiSeparator *uiNewHorizontalSeparator(void); -_UI_EXTERN uiSeparator *uiNewVerticalSeparator(void); - -typedef struct uiCombobox uiCombobox; -#define uiCombobox(this) ((uiCombobox *) (this)) -_UI_EXTERN void uiComboboxAppend(uiCombobox *c, const char *text); -_UI_EXTERN int uiComboboxSelected(uiCombobox *c); -_UI_EXTERN void uiComboboxSetSelected(uiCombobox *c, int n); -_UI_EXTERN void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data); -_UI_EXTERN uiCombobox *uiNewCombobox(void); - -typedef struct uiEditableCombobox uiEditableCombobox; -#define uiEditableCombobox(this) ((uiEditableCombobox *) (this)) -_UI_EXTERN void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text); -_UI_EXTERN char *uiEditableComboboxText(uiEditableCombobox *c); -_UI_EXTERN void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text); -// TODO what do we call a function that sets the currently selected item and fills the text field with it? editable comboboxes have no consistent concept of selected item -_UI_EXTERN void uiEditableComboboxOnChanged(uiEditableCombobox *c, void (*f)(uiEditableCombobox *c, void *data), void *data); -_UI_EXTERN uiEditableCombobox *uiNewEditableCombobox(void); - -typedef struct uiRadioButtons uiRadioButtons; -#define uiRadioButtons(this) ((uiRadioButtons *) (this)) -_UI_EXTERN void uiRadioButtonsAppend(uiRadioButtons *r, const char *text); -_UI_EXTERN int uiRadioButtonsSelected(uiRadioButtons *r); -_UI_EXTERN void uiRadioButtonsSetSelected(uiRadioButtons *r, int n); -_UI_EXTERN void uiRadioButtonsOnSelected(uiRadioButtons *r, void (*f)(uiRadioButtons *, void *), void *data); -_UI_EXTERN uiRadioButtons *uiNewRadioButtons(void); - -struct tm; -typedef struct uiDateTimePicker uiDateTimePicker; -#define uiDateTimePicker(this) ((uiDateTimePicker *) (this)) -// TODO document that tm_wday and tm_yday are undefined, and tm_isdst should be -1 -// TODO document that for both sides -// TODO document time zone conversions or lack thereof -// TODO for Time: define what values are returned when a part is missing -_UI_EXTERN void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time); -_UI_EXTERN void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time); -_UI_EXTERN void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data); -_UI_EXTERN uiDateTimePicker *uiNewDateTimePicker(void); -_UI_EXTERN uiDateTimePicker *uiNewDatePicker(void); -_UI_EXTERN uiDateTimePicker *uiNewTimePicker(void); - -// TODO provide a facility for entering tab stops? -typedef struct uiMultilineEntry uiMultilineEntry; -#define uiMultilineEntry(this) ((uiMultilineEntry *) (this)) -_UI_EXTERN char *uiMultilineEntryText(uiMultilineEntry *e); -_UI_EXTERN void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text); -_UI_EXTERN void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text); -_UI_EXTERN void uiMultilineEntryOnChanged(uiMultilineEntry *e, void (*f)(uiMultilineEntry *e, void *data), void *data); -_UI_EXTERN int uiMultilineEntryReadOnly(uiMultilineEntry *e); -_UI_EXTERN void uiMultilineEntrySetReadOnly(uiMultilineEntry *e, int readonly); -_UI_EXTERN uiMultilineEntry *uiNewMultilineEntry(void); -_UI_EXTERN uiMultilineEntry *uiNewNonWrappingMultilineEntry(void); - -typedef struct uiMenuItem uiMenuItem; -#define uiMenuItem(this) ((uiMenuItem *) (this)) -_UI_EXTERN void uiMenuItemEnable(uiMenuItem *m); -_UI_EXTERN void uiMenuItemDisable(uiMenuItem *m); -_UI_EXTERN void uiMenuItemOnClicked(uiMenuItem *m, void (*f)(uiMenuItem *sender, uiWindow *window, void *data), void *data); -_UI_EXTERN int uiMenuItemChecked(uiMenuItem *m); -_UI_EXTERN void uiMenuItemSetChecked(uiMenuItem *m, int checked); - -typedef struct uiMenu uiMenu; -#define uiMenu(this) ((uiMenu *) (this)) -_UI_EXTERN uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name); -_UI_EXTERN uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name); -_UI_EXTERN uiMenuItem *uiMenuAppendQuitItem(uiMenu *m); -_UI_EXTERN uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m); -_UI_EXTERN uiMenuItem *uiMenuAppendAboutItem(uiMenu *m); -_UI_EXTERN void uiMenuAppendSeparator(uiMenu *m); -_UI_EXTERN uiMenu *uiNewMenu(const char *name); - -_UI_EXTERN char *uiOpenFile(uiWindow *parent); -_UI_EXTERN char *uiSaveFile(uiWindow *parent); -_UI_EXTERN void uiMsgBox(uiWindow *parent, const char *title, const char *description); -_UI_EXTERN void uiMsgBoxError(uiWindow *parent, const char *title, const char *description); - -typedef struct uiArea uiArea; -typedef struct uiAreaHandler uiAreaHandler; -typedef struct uiAreaDrawParams uiAreaDrawParams; -typedef struct uiAreaMouseEvent uiAreaMouseEvent; -typedef struct uiAreaKeyEvent uiAreaKeyEvent; - -typedef struct uiDrawContext uiDrawContext; - -struct uiAreaHandler { - void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *); - // TODO document that resizes cause a full redraw for non-scrolling areas; implementation-defined for scrolling areas - void (*MouseEvent)(uiAreaHandler *, uiArea *, uiAreaMouseEvent *); - // TODO document that on first show if the mouse is already in the uiArea then one gets sent with left=0 - // TODO what about when the area is hidden and then shown again? - void (*MouseCrossed)(uiAreaHandler *, uiArea *, int left); - void (*DragBroken)(uiAreaHandler *, uiArea *); - int (*KeyEvent)(uiAreaHandler *, uiArea *, uiAreaKeyEvent *); -}; - -// TODO RTL layouts? -// TODO reconcile edge and corner naming -_UI_ENUM(uiWindowResizeEdge) { - uiWindowResizeEdgeLeft, - uiWindowResizeEdgeTop, - uiWindowResizeEdgeRight, - uiWindowResizeEdgeBottom, - uiWindowResizeEdgeTopLeft, - uiWindowResizeEdgeTopRight, - uiWindowResizeEdgeBottomLeft, - uiWindowResizeEdgeBottomRight, - // TODO have one for keyboard resizes? - // TODO GDK doesn't seem to have any others, including for keyboards... - // TODO way to bring up the system menu instead? -}; - -#define uiArea(this) ((uiArea *) (this)) -// TODO give a better name -// TODO document the types of width and height -_UI_EXTERN void uiAreaSetSize(uiArea *a, int width, int height); -// TODO uiAreaQueueRedraw() -_UI_EXTERN void uiAreaQueueRedrawAll(uiArea *a); -_UI_EXTERN void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height); -// TODO document these can only be called within Mouse() handlers -// TODO should these be allowed on scrolling areas? -// TODO decide which mouse events should be accepted; Down is the only one guaranteed to work right now -// TODO what happens to events after calling this up to and including the next mouse up? -// TODO release capture? -_UI_EXTERN void uiAreaBeginUserWindowMove(uiArea *a); -_UI_EXTERN void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge); -_UI_EXTERN uiArea *uiNewArea(uiAreaHandler *ah); -_UI_EXTERN uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height); - -struct uiAreaDrawParams { - uiDrawContext *Context; - - // TODO document that this is only defined for nonscrolling areas - double AreaWidth; - double AreaHeight; - - double ClipX; - double ClipY; - double ClipWidth; - double ClipHeight; -}; - -typedef struct uiDrawPath uiDrawPath; -typedef struct uiDrawBrush uiDrawBrush; -typedef struct uiDrawStrokeParams uiDrawStrokeParams; -typedef struct uiDrawMatrix uiDrawMatrix; - -typedef struct uiDrawBrushGradientStop uiDrawBrushGradientStop; - -_UI_ENUM(uiDrawBrushType) { - uiDrawBrushTypeSolid, - uiDrawBrushTypeLinearGradient, - uiDrawBrushTypeRadialGradient, - uiDrawBrushTypeImage, -}; - -_UI_ENUM(uiDrawLineCap) { - uiDrawLineCapFlat, - uiDrawLineCapRound, - uiDrawLineCapSquare, -}; - -_UI_ENUM(uiDrawLineJoin) { - uiDrawLineJoinMiter, - uiDrawLineJoinRound, - uiDrawLineJoinBevel, -}; - -// this is the default for botoh cairo and Direct2D (in the latter case, from the C++ helper functions) -// Core Graphics doesn't explicitly specify a default, but NSBezierPath allows you to choose one, and this is the initial value -// so we're good to use it too! -#define uiDrawDefaultMiterLimit 10.0 - -_UI_ENUM(uiDrawFillMode) { - uiDrawFillModeWinding, - uiDrawFillModeAlternate, -}; - -struct uiDrawMatrix { - double M11; - double M12; - double M21; - double M22; - double M31; - double M32; -}; - -struct uiDrawBrush { - uiDrawBrushType Type; - - // solid brushes - double R; - double G; - double B; - double A; - - // gradient brushes - double X0; // linear: start X, radial: start X - double Y0; // linear: start Y, radial: start Y - double X1; // linear: end X, radial: outer circle center X - double Y1; // linear: end Y, radial: outer circle center Y - double OuterRadius; // radial gradients only - uiDrawBrushGradientStop *Stops; - size_t NumStops; - // TODO extend mode - // cairo: none, repeat, reflect, pad; no individual control - // Direct2D: repeat, reflect, pad; no individual control - // Core Graphics: none, pad; before and after individually - // TODO cairo documentation is inconsistent about pad - - // TODO images - - // TODO transforms -}; - -struct uiDrawBrushGradientStop { - double Pos; - double R; - double G; - double B; - double A; -}; - -struct uiDrawStrokeParams { - uiDrawLineCap Cap; - uiDrawLineJoin Join; - // TODO what if this is 0? on windows there will be a crash with dashing - double Thickness; - double MiterLimit; - double *Dashes; - // TOOD what if this is 1 on Direct2D? - // TODO what if a dash is 0 on Cairo or Quartz? - size_t NumDashes; - double DashPhase; -}; - -_UI_EXTERN uiDrawPath *uiDrawNewPath(uiDrawFillMode fillMode); -_UI_EXTERN void uiDrawFreePath(uiDrawPath *p); - -_UI_EXTERN void uiDrawPathNewFigure(uiDrawPath *p, double x, double y); -_UI_EXTERN void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative); -_UI_EXTERN void uiDrawPathLineTo(uiDrawPath *p, double x, double y); -// notes: angles are both relative to 0 and go counterclockwise -// TODO is the initial line segment on cairo and OS X a proper join? -// TODO what if sweep < 0? -_UI_EXTERN void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative); -_UI_EXTERN void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY); -// TODO quadratic bezier -_UI_EXTERN void uiDrawPathCloseFigure(uiDrawPath *p); - -// TODO effect of these when a figure is already started -_UI_EXTERN void uiDrawPathAddRectangle(uiDrawPath *p, double x, double y, double width, double height); - -_UI_EXTERN void uiDrawPathEnd(uiDrawPath *p); - -_UI_EXTERN void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStrokeParams *p); -_UI_EXTERN void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b); - -// TODO primitives: -// - rounded rectangles -// - elliptical arcs -// - quadratic bezier curves - -_UI_EXTERN void uiDrawMatrixSetIdentity(uiDrawMatrix *m); -_UI_EXTERN void uiDrawMatrixTranslate(uiDrawMatrix *m, double x, double y); -_UI_EXTERN void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x, double y); -_UI_EXTERN void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount); -_UI_EXTERN void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount); -_UI_EXTERN void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src); -_UI_EXTERN int uiDrawMatrixInvertible(uiDrawMatrix *m); -_UI_EXTERN int uiDrawMatrixInvert(uiDrawMatrix *m); -_UI_EXTERN void uiDrawMatrixTransformPoint(uiDrawMatrix *m, double *x, double *y); -_UI_EXTERN void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y); - -_UI_EXTERN void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m); - -// TODO add a uiDrawPathStrokeToFill() or something like that -_UI_EXTERN void uiDrawClip(uiDrawContext *c, uiDrawPath *path); - -_UI_EXTERN void uiDrawSave(uiDrawContext *c); -_UI_EXTERN void uiDrawRestore(uiDrawContext *c); - -// uiAttribute stores information about an attribute in a -// uiAttributedString. -// -// You do not create uiAttributes directly; instead, you create a -// uiAttribute of a given type using the specialized constructor -// functions. For every Unicode codepoint in the uiAttributedString, -// at most one value of each attribute type can be applied. -// -// uiAttributes are immutable and the uiAttributedString takes -// ownership of the uiAttribute object once assigned, copying its -// contents as necessary. -typedef struct uiAttribute uiAttribute; - -// @role uiAttribute destructor -// uiFreeAttribute() frees a uiAttribute. You generally do not need to -// call this yourself, as uiAttributedString does this for you. In fact, -// it is an error to call this function on a uiAttribute that has been -// given to a uiAttributedString. You can call this, however, if you -// created a uiAttribute that you aren't going to use later. -_UI_EXTERN void uiFreeAttribute(uiAttribute *a); - -// uiAttributeType holds the possible uiAttribute types that may be -// returned by uiAttributeGetType(). Refer to the documentation for -// each type's constructor function for details on each type. -_UI_ENUM(uiAttributeType) { - uiAttributeTypeFamily, - uiAttributeTypeSize, - uiAttributeTypeWeight, - uiAttributeTypeItalic, - uiAttributeTypeStretch, - uiAttributeTypeColor, - uiAttributeTypeBackground, - uiAttributeTypeUnderline, - uiAttributeTypeUnderlineColor, - uiAttributeTypeFeatures, -}; - -// uiAttributeGetType() returns the type of a. -// TODO I don't like this name -_UI_EXTERN uiAttributeType uiAttributeGetType(const uiAttribute *a); - -// uiNewFamilyAttribute() creates a new uiAttribute that changes the -// font family of the text it is applied to. family is copied; you do not -// need to keep it alive after uiNewFamilyAttribute() returns. Font -// family names are case-insensitive. -_UI_EXTERN uiAttribute *uiNewFamilyAttribute(const char *family); - -// uiAttributeFamily() returns the font family stored in a. The -// returned string is owned by a. It is an error to call this on a -// uiAttribute that does not hold a font family. -_UI_EXTERN const char *uiAttributeFamily(const uiAttribute *a); - -// uiNewSizeAttribute() creates a new uiAttribute that changes the -// size of the text it is applied to, in typographical points. -_UI_EXTERN uiAttribute *uiNewSizeAttribute(double size); - -// uiAttributeSize() returns the font size stored in a. It is an error to -// call this on a uiAttribute that does not hold a font size. -_UI_EXTERN double uiAttributeSize(const uiAttribute *a); - -// uiTextWeight represents possible text weights. These roughly -// map to the OS/2 text weight field of TrueType and OpenType -// fonts, or to CSS weight numbers. The named constants are -// nominal values; the actual values may vary by font and by OS, -// though this isn't particularly likely. Any value between -// uiTextWeightMinimum and uiTextWeightMaximum, inclusive, -// is allowed. -// -// Note that due to restrictions in early versions of Windows, some -// fonts have "special" weights be exposed in many programs as -// separate font families. This is perhaps most notable with -// Arial Black. libui does not do this, even on Windows (because the -// DirectWrite API libui uses on Windows does not do this); to -// specify Arial Black, use family Arial and weight uiTextWeightBlack. -_UI_ENUM(uiTextWeight) { - uiTextWeightMinimum = 0, - uiTextWeightThin = 100, - uiTextWeightUltraLight = 200, - uiTextWeightLight = 300, - uiTextWeightBook = 350, - uiTextWeightNormal = 400, - uiTextWeightMedium = 500, - uiTextWeightSemiBold = 600, - uiTextWeightBold = 700, - uiTextWeightUltraBold = 800, - uiTextWeightHeavy = 900, - uiTextWeightUltraHeavy = 950, - uiTextWeightMaximum = 1000, -}; - -// uiNewWeightAttribute() creates a new uiAttribute that changes the -// weight of the text it is applied to. It is an error to specify a weight -// outside the range [uiTextWeightMinimum, -// uiTextWeightMaximum]. -_UI_EXTERN uiAttribute *uiNewWeightAttribute(uiTextWeight weight); - -// uiAttributeWeight() returns the font weight stored in a. It is an error -// to call this on a uiAttribute that does not hold a font weight. -_UI_EXTERN uiTextWeight uiAttributeWeight(const uiAttribute *a); - -// uiTextItalic represents possible italic modes for a font. Italic -// represents "true" italics where the slanted glyphs have custom -// shapes, whereas oblique represents italics that are merely slanted -// versions of the normal glyphs. Most fonts usually have one or the -// other. -_UI_ENUM(uiTextItalic) { - uiTextItalicNormal, - uiTextItalicOblique, - uiTextItalicItalic, -}; - -// uiNewItalicAttribute() creates a new uiAttribute that changes the -// italic mode of the text it is applied to. It is an error to specify an -// italic mode not specified in uiTextItalic. -_UI_EXTERN uiAttribute *uiNewItalicAttribute(uiTextItalic italic); - -// uiAttributeItalic() returns the font italic mode stored in a. It is an -// error to call this on a uiAttribute that does not hold a font italic -// mode. -_UI_EXTERN uiTextItalic uiAttributeItalic(const uiAttribute *a); - -// uiTextStretch represents possible stretches (also called "widths") -// of a font. -// -// Note that due to restrictions in early versions of Windows, some -// fonts have "special" stretches be exposed in many programs as -// separate font families. This is perhaps most notable with -// Arial Condensed. libui does not do this, even on Windows (because -// the DirectWrite API libui uses on Windows does not do this); to -// specify Arial Condensed, use family Arial and stretch -// uiTextStretchCondensed. -_UI_ENUM(uiTextStretch) { - uiTextStretchUltraCondensed, - uiTextStretchExtraCondensed, - uiTextStretchCondensed, - uiTextStretchSemiCondensed, - uiTextStretchNormal, - uiTextStretchSemiExpanded, - uiTextStretchExpanded, - uiTextStretchExtraExpanded, - uiTextStretchUltraExpanded, -}; - -// uiNewStretchAttribute() creates a new uiAttribute that changes the -// stretch of the text it is applied to. It is an error to specify a strech -// not specified in uiTextStretch. -_UI_EXTERN uiAttribute *uiNewStretchAttribute(uiTextStretch stretch); - -// uiAttributeStretch() returns the font stretch stored in a. It is an -// error to call this on a uiAttribute that does not hold a font stretch. -_UI_EXTERN uiTextStretch uiAttributeStretch(const uiAttribute *a); - -// uiNewColorAttribute() creates a new uiAttribute that changes the -// color of the text it is applied to. It is an error to specify an invalid -// color. -_UI_EXTERN uiAttribute *uiNewColorAttribute(double r, double g, double b, double a); - -// uiAttributeColor() returns the text color stored in a. It is an -// error to call this on a uiAttribute that does not hold a text color. -_UI_EXTERN void uiAttributeColor(const uiAttribute *a, double *r, double *g, double *b, double *alpha); - -// uiNewBackgroundAttribute() creates a new uiAttribute that -// changes the background color of the text it is applied to. It is an -// error to specify an invalid color. -_UI_EXTERN uiAttribute *uiNewBackgroundAttribute(double r, double g, double b, double a); - -// TODO reuse uiAttributeColor() for background colors, or make a new function... - -// uiUnderline specifies a type of underline to use on text. -_UI_ENUM(uiUnderline) { - uiUnderlineNone, - uiUnderlineSingle, - uiUnderlineDouble, - uiUnderlineSuggestion, // wavy or dotted underlines used for spelling/grammar checkers -}; - -// uiNewUnderlineAttribute() creates a new uiAttribute that changes -// the type of underline on the text it is applied to. It is an error to -// specify an underline type not specified in uiUnderline. -_UI_EXTERN uiAttribute *uiNewUnderlineAttribute(uiUnderline u); - -// uiAttributeUnderline() returns the underline type stored in a. It is -// an error to call this on a uiAttribute that does not hold an underline -// style. -_UI_EXTERN uiUnderline uiAttributeUnderline(const uiAttribute *a); - -// uiUnderlineColor specifies the color of any underline on the text it -// is applied to, regardless of the type of underline. In addition to -// being able to specify a custom color, you can explicitly specify -// platform-specific colors for suggestion underlines; to use them -// correctly, pair them with uiUnderlineSuggestion (though they can -// be used on other types of underline as well). -// -// If an underline type is applied but no underline color is -// specified, the text color is used instead. If an underline color -// is specified without an underline type, the underline color -// attribute is ignored, but not removed from the uiAttributedString. -_UI_ENUM(uiUnderlineColor) { - uiUnderlineColorCustom, - uiUnderlineColorSpelling, - uiUnderlineColorGrammar, - uiUnderlineColorAuxiliary, // for instance, the color used by smart replacements on macOS or in Microsoft Office -}; - -// uiNewUnderlineColorAttribute() creates a new uiAttribute that -// changes the color of the underline on the text it is applied to. -// It is an error to specify an underline color not specified in -// uiUnderlineColor. -// -// If the specified color type is uiUnderlineColorCustom, it is an -// error to specify an invalid color value. Otherwise, the color values -// are ignored and should be specified as zero. -_UI_EXTERN uiAttribute *uiNewUnderlineColorAttribute(uiUnderlineColor u, double r, double g, double b, double a); - -// uiAttributeUnderlineColor() returns the underline color stored in -// a. It is an error to call this on a uiAttribute that does not hold an -// underline color. -_UI_EXTERN void uiAttributeUnderlineColor(const uiAttribute *a, uiUnderlineColor *u, double *r, double *g, double *b, double *alpha); - -// uiOpenTypeFeatures represents a set of OpenType feature -// tag-value pairs, for applying OpenType features to text. -// OpenType feature tags are four-character codes defined by -// OpenType that cover things from design features like small -// caps and swashes to language-specific glyph shapes and -// beyond. Each tag may only appear once in any given -// uiOpenTypeFeatures instance. Each value is a 32-bit integer, -// often used as a Boolean flag, but sometimes as an index to choose -// a glyph shape to use. -// -// If a font does not support a certain feature, that feature will be -// ignored. (TODO verify this on all OSs) -// -// See the OpenType specification at -// https://www.microsoft.com/typography/otspec/featuretags.htm -// for the complete list of available features, information on specific -// features, and how to use them. -// TODO invalid features -typedef struct uiOpenTypeFeatures uiOpenTypeFeatures; - -// uiOpenTypeFeaturesForEachFunc is the type of the function -// invoked by uiOpenTypeFeaturesForEach() for every OpenType -// feature in otf. Refer to that function's documentation for more -// details. -typedef uiForEach (*uiOpenTypeFeaturesForEachFunc)(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data); - -// @role uiOpenTypeFeatures constructor -// uiNewOpenTypeFeatures() returns a new uiOpenTypeFeatures -// instance, with no tags yet added. -_UI_EXTERN uiOpenTypeFeatures *uiNewOpenTypeFeatures(void); - -// @role uiOpenTypeFeatures destructor -// uiFreeOpenTypeFeatures() frees otf. -_UI_EXTERN void uiFreeOpenTypeFeatures(uiOpenTypeFeatures *otf); - -// uiOpenTypeFeaturesClone() makes a copy of otf and returns it. -// Changing one will not affect the other. -_UI_EXTERN uiOpenTypeFeatures *uiOpenTypeFeaturesClone(const uiOpenTypeFeatures *otf); - -// uiOpenTypeFeaturesAdd() adds the given feature tag and value -// to otf. The feature tag is specified by a, b, c, and d. If there is -// already a value associated with the specified tag in otf, the old -// value is removed. -_UI_EXTERN void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value); - -// uiOpenTypeFeaturesRemove() removes the given feature tag -// and value from otf. If the tag is not present in otf, -// uiOpenTypeFeaturesRemove() does nothing. -_UI_EXTERN void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d); - -// uiOpenTypeFeaturesGet() determines whether the given feature -// tag is present in otf. If it is, *value is set to the tag's value and -// nonzero is returned. Otherwise, zero is returned. -// -// Note that if uiOpenTypeFeaturesGet() returns zero, value isn't -// changed. This is important: if a feature is not present in a -// uiOpenTypeFeatures, the feature is NOT treated as if its -// value was zero anyway. Script-specific font shaping rules and -// font-specific feature settings may use a different default value -// for a feature. You should likewise not treat a missing feature as -// having a value of zero either. Instead, a missing feature should -// be treated as having some unspecified default value. -_UI_EXTERN int uiOpenTypeFeaturesGet(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t *value); - -// uiOpenTypeFeaturesForEach() executes f for every tag-value -// pair in otf. The enumeration order is unspecified. You cannot -// modify otf while uiOpenTypeFeaturesForEach() is running. -_UI_EXTERN void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data); - -// uiNewFeaturesAttribute() creates a new uiAttribute that changes -// the font family of the text it is applied to. otf is copied; you may -// free it after uiNewFeaturesAttribute() returns. -_UI_EXTERN uiAttribute *uiNewFeaturesAttribute(const uiOpenTypeFeatures *otf); - -// uiAttributeFeatures() returns the OpenType features stored in a. -// The returned uiOpenTypeFeatures object is owned by a. It is an -// error to call this on a uiAttribute that does not hold OpenType -// features. -_UI_EXTERN const uiOpenTypeFeatures *uiAttributeFeatures(const uiAttribute *a); - -// uiAttributedString represents a string of UTF-8 text that can -// optionally be embellished with formatting attributes. libui -// provides the list of formatting attributes, which cover common -// formatting traits like boldface and color as well as advanced -// typographical features provided by OpenType like superscripts -// and small caps. These attributes can be combined in a variety of -// ways. -// -// Attributes are applied to runs of Unicode codepoints in the string. -// Zero-length runs are elided. Consecutive runs that have the same -// attribute type and value are merged. Each attribute is independent -// of each other attribute; overlapping attributes of different types -// do not split each other apart, but different values of the same -// attribute type do. -// -// The empty string can also be represented by uiAttributedString, -// but because of the no-zero-length-attribute rule, it will not have -// attributes. -// -// A uiAttributedString takes ownership of all attributes given to -// it, as it may need to duplicate or delete uiAttribute objects at -// any time. By extension, when you free a uiAttributedString, -// all uiAttributes within will also be freed. Each method will -// describe its own rules in more details. -// -// In addition, uiAttributedString provides facilities for moving -// between grapheme clusters, which represent a character -// from the point of view of the end user. The cursor of a text editor -// is always placed on a grapheme boundary, so you can use these -// features to move the cursor left or right by one "character". -// TODO does uiAttributedString itself need this -// -// uiAttributedString does not provide enough information to be able -// to draw itself onto a uiDrawContext or respond to user actions. -// In order to do that, you'll need to use a uiDrawTextLayout, which -// is built from the combination of a uiAttributedString and a set of -// layout-specific properties. -typedef struct uiAttributedString uiAttributedString; - -// uiAttributedStringForEachAttributeFunc is the type of the function -// invoked by uiAttributedStringForEachAttribute() for every -// attribute in s. Refer to that function's documentation for more -// details. -typedef uiForEach (*uiAttributedStringForEachAttributeFunc)(const uiAttributedString *s, const uiAttribute *a, size_t start, size_t end, void *data); - -// @role uiAttributedString constructor -// uiNewAttributedString() creates a new uiAttributedString from -// initialString. The string will be entirely unattributed. -_UI_EXTERN uiAttributedString *uiNewAttributedString(const char *initialString); - -// @role uiAttributedString destructor -// uiFreeAttributedString() destroys the uiAttributedString s. -// It will also free all uiAttributes within. -_UI_EXTERN void uiFreeAttributedString(uiAttributedString *s); - -// uiAttributedStringString() returns the textual content of s as a -// '\0'-terminated UTF-8 string. The returned pointer is valid until -// the next change to the textual content of s. -_UI_EXTERN const char *uiAttributedStringString(const uiAttributedString *s); - -// uiAttributedStringLength() returns the number of UTF-8 bytes in -// the textual content of s, excluding the terminating '\0'. -_UI_EXTERN size_t uiAttributedStringLen(const uiAttributedString *s); - -// uiAttributedStringAppendUnattributed() adds the '\0'-terminated -// UTF-8 string str to the end of s. The new substring will be -// unattributed. -_UI_EXTERN void uiAttributedStringAppendUnattributed(uiAttributedString *s, const char *str); - -// uiAttributedStringInsertAtUnattributed() adds the '\0'-terminated -// UTF-8 string str to s at the byte position specified by at. The new -// substring will be unattributed; existing attributes will be moved -// along with their text. -_UI_EXTERN void uiAttributedStringInsertAtUnattributed(uiAttributedString *s, const char *str, size_t at); - -// TODO add the Append and InsertAtExtendingAttributes functions -// TODO and add functions that take a string + length - -// uiAttributedStringDelete() deletes the characters and attributes of -// s in the byte range [start, end). -_UI_EXTERN void uiAttributedStringDelete(uiAttributedString *s, size_t start, size_t end); - -// TODO add a function to uiAttributedString to get an attribute's value at a specific index or in a specific range, so we can edit - -// uiAttributedStringSetAttribute() sets a in the byte range [start, end) -// of s. Any existing attributes in that byte range of the same type are -// removed. s takes ownership of a; you should not use it after -// uiAttributedStringSetAttribute() returns. -_UI_EXTERN void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttribute *a, size_t start, size_t end); - -// uiAttributedStringForEachAttribute() enumerates all the -// uiAttributes in s. It is an error to modify s in f. Within f, s still -// owns the attribute; you can neither free it nor save it for later -// use. -// TODO reword the above for consistency (TODO and find out what I meant by that) -// TODO define an enumeration order (or mark it as undefined); also define how consecutive runs of identical attributes are handled here and sync with the definition of uiAttributedString itself -_UI_EXTERN void uiAttributedStringForEachAttribute(const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data); - -// TODO const correct this somehow (the implementation needs to mutate the structure) -_UI_EXTERN size_t uiAttributedStringNumGraphemes(uiAttributedString *s); - -// TODO const correct this somehow (the implementation needs to mutate the structure) -_UI_EXTERN size_t uiAttributedStringByteIndexToGrapheme(uiAttributedString *s, size_t pos); - -// TODO const correct this somehow (the implementation needs to mutate the structure) -_UI_EXTERN size_t uiAttributedStringGraphemeToByteIndex(uiAttributedString *s, size_t pos); - -// uiFontDescriptor provides a complete description of a font where -// one is needed. Currently, this means as the default font of a -// uiDrawTextLayout and as the data returned by uiFontButton. -// All the members operate like the respective uiAttributes. -typedef struct uiFontDescriptor uiFontDescriptor; - -struct uiFontDescriptor { - // TODO const-correct this or figure out how to deal with this when getting a value - char *Family; - double Size; - uiTextWeight Weight; - uiTextItalic Italic; - uiTextStretch Stretch; -}; - -// uiDrawTextLayout is a concrete representation of a -// uiAttributedString that can be displayed in a uiDrawContext. -// It includes information important for the drawing of a block of -// text, including the bounding box to wrap the text within, the -// alignment of lines of text within that box, areas to mark as -// being selected, and other things. -// -// Unlike uiAttributedString, the content of a uiDrawTextLayout is -// immutable once it has been created. -// -// TODO talk about OS-specific differences with text drawing that libui can't account for... -typedef struct uiDrawTextLayout uiDrawTextLayout; - -// uiDrawTextAlign specifies the alignment of lines of text in a -// uiDrawTextLayout. -// TODO should this really have Draw in the name? -_UI_ENUM(uiDrawTextAlign) { - uiDrawTextAlignLeft, - uiDrawTextAlignCenter, - uiDrawTextAlignRight, -}; - -// uiDrawTextLayoutParams describes a uiDrawTextLayout. -// DefaultFont is used to render any text that is not attributed -// sufficiently in String. Width determines the width of the bounding -// box of the text; the height is determined automatically. -typedef struct uiDrawTextLayoutParams uiDrawTextLayoutParams; - -// TODO const-correct this somehow -struct uiDrawTextLayoutParams { - uiAttributedString *String; - uiFontDescriptor *DefaultFont; - double Width; - uiDrawTextAlign Align; -}; - -// @role uiDrawTextLayout constructor -// uiDrawNewTextLayout() creates a new uiDrawTextLayout from -// the given parameters. -// -// TODO -// - allow creating a layout out of a substring -// - allow marking compositon strings -// - allow marking selections, even after creation -// - add the following functions: -// - uiDrawTextLayoutHeightForWidth() (returns the height that a layout would need to be to display the entire string at a given width) -// - uiDrawTextLayoutRangeForSize() (returns what substring would fit in a given size) -// - uiDrawTextLayoutNewWithHeight() (limits amount of string used by the height) -// - some function to fix up a range (for text editing) -_UI_EXTERN uiDrawTextLayout *uiDrawNewTextLayout(uiDrawTextLayoutParams *params); - -// @role uiDrawFreeTextLayout destructor -// uiDrawFreeTextLayout() frees tl. The underlying -// uiAttributedString is not freed. -_UI_EXTERN void uiDrawFreeTextLayout(uiDrawTextLayout *tl); - -// uiDrawText() draws tl in c with the top-left point of tl at (x, y). -_UI_EXTERN void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, double y); - -// uiDrawTextLayoutExtents() returns the width and height of tl -// in width and height. The returned width may be smaller than -// the width passed into uiDrawNewTextLayout() depending on -// how the text in tl is wrapped. Therefore, you can use this -// function to get the actual size of the text layout. -_UI_EXTERN void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height); - -// TODO metrics functions - -// TODO number of lines visible for clipping rect, range visible for clipping rect? - -// uiFontButton is a button that allows users to choose a font when they click on it. -typedef struct uiFontButton uiFontButton; -#define uiFontButton(this) ((uiFontButton *) (this)) -// uiFontButtonFont() returns the font currently selected in the uiFontButton in desc. -// uiFontButtonFont() allocates resources in desc; when you are done with the font, call uiFreeFontButtonFont() to release them. -// uiFontButtonFont() does not allocate desc itself; you must do so. -// TODO have a function that sets an entire font descriptor to a range in a uiAttributedString at once, for SetFont? -_UI_EXTERN void uiFontButtonFont(uiFontButton *b, uiFontDescriptor *desc); -// TOOD SetFont, mechanics -// uiFontButtonOnChanged() sets the function that is called when the font in the uiFontButton is changed. -_UI_EXTERN void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data); -// uiNewFontButton() creates a new uiFontButton. The default font selected into the uiFontButton is OS-defined. -_UI_EXTERN uiFontButton *uiNewFontButton(void); -// uiFreeFontButtonFont() frees resources allocated in desc by uiFontButtonFont(). -// After calling uiFreeFontButtonFont(), the contents of desc should be assumed to be undefined (though since you allocate desc itself, you can safely reuse desc for other font descriptors). -// Calling uiFreeFontButtonFont() on a uiFontDescriptor not returned by uiFontButtonFont() results in undefined behavior. -_UI_EXTERN void uiFreeFontButtonFont(uiFontDescriptor *desc); - -_UI_ENUM(uiModifiers) { - uiModifierCtrl = 1 << 0, - uiModifierAlt = 1 << 1, - uiModifierShift = 1 << 2, - uiModifierSuper = 1 << 3, -}; - -// TODO document drag captures -struct uiAreaMouseEvent { - // TODO document what these mean for scrolling areas - double X; - double Y; - - // TODO see draw above - double AreaWidth; - double AreaHeight; - - int Down; - int Up; - - int Count; - - uiModifiers Modifiers; - - uint64_t Held1To64; -}; - -_UI_ENUM(uiExtKey) { - uiExtKeyEscape = 1, - uiExtKeyInsert, // equivalent to "Help" on Apple keyboards - uiExtKeyDelete, - uiExtKeyHome, - uiExtKeyEnd, - uiExtKeyPageUp, - uiExtKeyPageDown, - uiExtKeyUp, - uiExtKeyDown, - uiExtKeyLeft, - uiExtKeyRight, - uiExtKeyF1, // F1..F12 are guaranteed to be consecutive - uiExtKeyF2, - uiExtKeyF3, - uiExtKeyF4, - uiExtKeyF5, - uiExtKeyF6, - uiExtKeyF7, - uiExtKeyF8, - uiExtKeyF9, - uiExtKeyF10, - uiExtKeyF11, - uiExtKeyF12, - uiExtKeyN0, // numpad keys; independent of Num Lock state - uiExtKeyN1, // N0..N9 are guaranteed to be consecutive - uiExtKeyN2, - uiExtKeyN3, - uiExtKeyN4, - uiExtKeyN5, - uiExtKeyN6, - uiExtKeyN7, - uiExtKeyN8, - uiExtKeyN9, - uiExtKeyNDot, - uiExtKeyNEnter, - uiExtKeyNAdd, - uiExtKeyNSubtract, - uiExtKeyNMultiply, - uiExtKeyNDivide, -}; - -struct uiAreaKeyEvent { - char Key; - uiExtKey ExtKey; - uiModifiers Modifier; - - uiModifiers Modifiers; - - int Up; -}; - -typedef struct uiColorButton uiColorButton; -#define uiColorButton(this) ((uiColorButton *) (this)) -_UI_EXTERN void uiColorButtonColor(uiColorButton *b, double *r, double *g, double *bl, double *a); -_UI_EXTERN void uiColorButtonSetColor(uiColorButton *b, double r, double g, double bl, double a); -_UI_EXTERN void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data); -_UI_EXTERN uiColorButton *uiNewColorButton(void); - -typedef struct uiForm uiForm; -#define uiForm(this) ((uiForm *) (this)) -_UI_EXTERN void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy); -_UI_EXTERN void uiFormDelete(uiForm *f, int index); -_UI_EXTERN int uiFormPadded(uiForm *f); -_UI_EXTERN void uiFormSetPadded(uiForm *f, int padded); -_UI_EXTERN uiForm *uiNewForm(void); - -_UI_ENUM(uiAlign) { - uiAlignFill, - uiAlignStart, - uiAlignCenter, - uiAlignEnd, -}; - -_UI_ENUM(uiAt) { - uiAtLeading, - uiAtTop, - uiAtTrailing, - uiAtBottom, -}; - -typedef struct uiGrid uiGrid; -#define uiGrid(this) ((uiGrid *) (this)) -_UI_EXTERN void uiGridAppend(uiGrid *g, uiControl *c, int left, int top, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign); -_UI_EXTERN void uiGridInsertAt(uiGrid *g, uiControl *c, uiControl *existing, uiAt at, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign); -_UI_EXTERN int uiGridPadded(uiGrid *g); -_UI_EXTERN void uiGridSetPadded(uiGrid *g, int padded); -_UI_EXTERN uiGrid *uiNewGrid(void); - -// uiImage stores an image for display on screen. -// -// Images are built from one or more representations, each with the -// same aspect ratio but a different pixel size. libui automatically -// selects the most appropriate representation for drawing the image -// when it comes time to draw the image; what this means depends -// on the pixel density of the target context. Therefore, one can use -// uiImage to draw higher-detailed images on higher-density -// displays. The typical use cases are either: -// -// - have just a single representation, at which point all screens -// use the same image, and thus uiImage acts like a simple -// bitmap image, or -// - have two images, one at normal resolution and one at 2x -// resolution; this matches the current expectations of some -// desktop systems at the time of writing (mid-2018) -// -// uiImage is very simple: it only supports premultiplied 32-bit -// RGBA images, and libui does not provide any image file loading -// or image format conversion utilities on top of that. -typedef struct uiImage uiImage; - -// @role uiImage constructor -// uiNewImage creates a new uiImage with the given width and -// height. This width and height should be the size in points of the -// image in the device-independent case; typically this is the 1x size. -// TODO for all uiImage functions: use const void * for const correctness -_UI_EXTERN uiImage *uiNewImage(double width, double height); - -// @role uiImage destructor -// uiFreeImage frees the given image and all associated resources. -_UI_EXTERN void uiFreeImage(uiImage *i); - -// uiImageAppend adds a representation to the uiImage. -// pixels should point to a byte array of premultiplied pixels -// stored in [R G B A] order (so ((uint8_t *) pixels)[0] is the R of the -// first pixel and [3] is the A of the first pixel). pixelWidth and -// pixelHeight is the size *in pixels* of the image, and pixelStride is -// the number *of bytes* per row of the pixels array. Therefore, -// pixels itself must be at least byteStride * pixelHeight bytes long. -// TODO see if we either need the stride or can provide a way to get the OS-preferred stride (in cairo we do) -_UI_EXTERN void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int byteStride); - -// uiTableValue stores a value to be passed along uiTable and -// uiTableModel. -// -// You do not create uiTableValues directly; instead, you create a -// uiTableValue of a given type using the specialized constructor -// functions. -// -// uiTableValues are immutable and the uiTableModel and uiTable -// take ownership of the uiTableValue object once returned, copying -// its contents as necessary. -typedef struct uiTableValue uiTableValue; - -// @role uiTableValue destructor -// uiFreeTableValue() frees a uiTableValue. You generally do not -// need to call this yourself, as uiTable and uiTableModel do this -// for you. In fact, it is an error to call this function on a uiTableValue -// that has been given to a uiTable or uiTableModel. You can call this, -// however, if you created a uiTableValue that you aren't going to -// use later, or if you called a uiTableModelHandler method directly -// and thus never transferred ownership of the uiTableValue. -_UI_EXTERN void uiFreeTableValue(uiTableValue *v); - -// uiTableValueType holds the possible uiTableValue types that may -// be returned by uiTableValueGetType(). Refer to the documentation -// for each type's constructor function for details on each type. -// TODO actually validate these -_UI_ENUM(uiTableValueType) { - uiTableValueTypeString, - uiTableValueTypeImage, - uiTableValueTypeInt, - uiTableValueTypeColor, -}; - -// uiTableValueGetType() returns the type of v. -// TODO I don't like this name -_UI_EXTERN uiTableValueType uiTableValueGetType(const uiTableValue *v); - -// uiNewTableValueString() returns a new uiTableValue that contains -// str. str is copied; you do not need to keep it alive after -// uiNewTableValueString() returns. -_UI_EXTERN uiTableValue *uiNewTableValueString(const char *str); - -// uiTableValueString() returns the string stored in v. The returned -// string is owned by v. It is an error to call this on a uiTableValue -// that does not hold a string. -_UI_EXTERN const char *uiTableValueString(const uiTableValue *v); - -// uiNewTableValueImage() returns a new uiTableValue that contains -// the given uiImage. -// -// Unlike other similar constructors, uiNewTableValueImage() does -// NOT copy the image. This is because images are comparatively -// larger than the other objects in question. Therefore, you MUST -// keep the image alive as long as the returned uiTableValue is alive. -// As a general rule, if libui calls a uiTableModelHandler method, the -// uiImage is safe to free once any of your code is once again -// executed. -_UI_EXTERN uiTableValue *uiNewTableValueImage(uiImage *img); - -// uiTableValueImage() returns the uiImage stored in v. As these -// images are not owned by v, you should not assume anything -// about the lifetime of the image (unless you created the image, -// and thus control its lifetime). It is an error to call this on a -// uiTableValue that does not hold an image. -_UI_EXTERN uiImage *uiTableValueImage(const uiTableValue *v); - -// uiNewTableValueInt() returns a uiTableValue that stores the given -// int. This can be used both for boolean values (nonzero is true, as -// in C) or progresses (in which case the valid range is -1..100 -// inclusive). -_UI_EXTERN uiTableValue *uiNewTableValueInt(int i); - -// uiTableValueInt() returns the int stored in v. It is an error to call -// this on a uiTableValue that does not store an int. -_UI_EXTERN int uiTableValueInt(const uiTableValue *v); - -// uiNewTableValueColor() returns a uiTableValue that stores the -// given color. -_UI_EXTERN uiTableValue *uiNewTableValueColor(double r, double g, double b, double a); - -// uiTableValueColor() returns the color stored in v. It is an error to -// call this on a uiTableValue that does not store a color. -// TODO define whether all this, for both uiTableValue and uiAttribute, is undefined behavior or a caught error -_UI_EXTERN void uiTableValueColor(const uiTableValue *v, double *r, double *g, double *b, double *a); - -// uiTableModel is an object that provides the data for a uiTable. -// This data is returned via methods you provide in the -// uiTableModelHandler struct. -// -// uiTableModel represents data using a table, but this table does -// not map directly to uiTable itself. Instead, you can have data -// columns which provide instructions for how to render a given -// uiTable's column — for instance, one model column can be used -// to give certain rows of a uiTable a different background color. -// Row numbers DO match with uiTable row numbers. -// -// Once created, the number and data types of columns of a -// uiTableModel cannot change. -// -// Row and column numbers start at 0. A uiTableModel can be -// associated with more than one uiTable at a time. -typedef struct uiTableModel uiTableModel; - -// uiTableModelHandler defines the methods that uiTableModel -// calls when it needs data. Once a uiTableModel is created, these -// methods cannot change. -typedef struct uiTableModelHandler uiTableModelHandler; - -// TODO validate ranges; validate types on each getter/setter call (? table columns only?) -struct uiTableModelHandler { - // NumColumns returns the number of model columns in the - // uiTableModel. This value must remain constant through the - // lifetime of the uiTableModel. This method is not guaranteed - // to be called depending on the system. - // TODO strongly check column numbers and types on all platforms so these clauses can go away - int (*NumColumns)(uiTableModelHandler *, uiTableModel *); - // ColumnType returns the value type of the data stored in - // the given model column of the uiTableModel. The returned - // values must remain constant through the lifetime of the - // uiTableModel. This method is not guaranteed to be called - // depending on the system. - uiTableValueType (*ColumnType)(uiTableModelHandler *, uiTableModel *, int); - // NumRows returns the number or rows in the uiTableModel. - // This value must be non-negative. - int (*NumRows)(uiTableModelHandler *, uiTableModel *); - // CellValue returns a uiTableValue corresponding to the model - // cell at (row, column). The type of the returned uiTableValue - // must match column's value type. Under some circumstances, - // NULL may be returned; refer to the various methods that add - // columns to uiTable for details. Once returned, the uiTable - // that calls CellValue will free the uiTableValue returned. - uiTableValue *(*CellValue)(uiTableModelHandler *mh, uiTableModel *m, int row, int column); - // SetCellValue changes the model cell value at (row, column) - // in the uiTableModel. Within this function, either do nothing - // to keep the current cell value or save the new cell value as - // appropriate. After SetCellValue is called, the uiTable will - // itself reload the table cell. Under certain conditions, the - // uiTableValue passed in can be NULL; refer to the various - // methods that add columns to uiTable for details. Once - // returned, the uiTable that called SetCellValue will free the - // uiTableValue passed in. - void (*SetCellValue)(uiTableModelHandler *, uiTableModel *, int, int, const uiTableValue *); -}; - -// @role uiTableModel constructor -// uiNewTableModel() creates a new uiTableModel with the given -// handler methods. -_UI_EXTERN uiTableModel *uiNewTableModel(uiTableModelHandler *mh); - -// @role uiTableModel destructor -// uiFreeTableModel() frees the given table model. It is an error to -// free table models currently associated with a uiTable. -_UI_EXTERN void uiFreeTableModel(uiTableModel *m); - -// uiTableModelRowInserted() tells any uiTable associated with m -// that a new row has been added to m at index index. You call -// this function when the number of rows in your model has -// changed; after calling it, NumRows() should returm the new row -// count. -_UI_EXTERN void uiTableModelRowInserted(uiTableModel *m, int newIndex); - -// uiTableModelRowChanged() tells any uiTable associated with m -// that the data in the row at index has changed. You do not need to -// call this in your SetCellValue() handlers, but you do need to call -// this if your data changes at some other point. -_UI_EXTERN void uiTableModelRowChanged(uiTableModel *m, int index); - -// uiTableModelRowDeleted() tells any uiTable associated with m -// that the row at index index has been deleted. You call this -// function when the number of rows in your model has changed; -// after calling it, NumRows() should returm the new row -// count. -// TODO for this and Inserted: make sure the "after" part is right; clarify if it's after returning or after calling -_UI_EXTERN void uiTableModelRowDeleted(uiTableModel *m, int oldIndex); -// TODO reordering/moving - -// uiTableModelColumnNeverEditable and -// uiTableModelColumnAlwaysEditable are the value of an editable -// model column parameter to one of the uiTable create column -// functions; if used, that jparticular uiTable colum is not editable -// by the user and always editable by the user, respectively. -#define uiTableModelColumnNeverEditable (-1) -#define uiTableModelColumnAlwaysEditable (-2) - -// uiTableTextColumnOptionalParams are the optional parameters -// that control the appearance of the text column of a uiTable. -typedef struct uiTableTextColumnOptionalParams uiTableTextColumnOptionalParams; - -// uiTableParams defines the parameters passed to uiNewTable(). -typedef struct uiTableParams uiTableParams; - -struct uiTableTextColumnOptionalParams { - // ColorModelColumn is the model column containing the - // text color of this uiTable column's text, or -1 to use the - // default color. - // - // If CellValue() for this column for any cell returns NULL, that - // cell will also use the default text color. - int ColorModelColumn; -}; - -struct uiTableParams { - // Model is the uiTableModel to use for this uiTable. - // This parameter cannot be NULL. - uiTableModel *Model; - // RowBackgroundColorModelColumn is a model column - // number that defines the background color used for the - // entire row in the uiTable, or -1 to use the default color for - // all rows. - // - // If CellValue() for this column for any row returns NULL, that - // row will also use the default background color. - int RowBackgroundColorModelColumn; -}; - -// uiTable is a uiControl that shows tabular data, allowing users to -// manipulate rows of such data at a time. -typedef struct uiTable uiTable; -#define uiTable(this) ((uiTable *) (this)) - -// uiTableAppendTextColumn() appends a text column to t. -// name is displayed in the table header. -// textModelColumn is where the text comes from. -// If a row is editable according to textEditableModelColumn, -// SetCellValue() is called with textModelColumn as the column. -_UI_EXTERN void uiTableAppendTextColumn(uiTable *t, - const char *name, - int textModelColumn, - int textEditableModelColumn, - uiTableTextColumnOptionalParams *textParams); - -// uiTableAppendImageColumn() appends an image column to t. -// Images are drawn at icon size, appropriate to the pixel density -// of the screen showing the uiTable. -_UI_EXTERN void uiTableAppendImageColumn(uiTable *t, - const char *name, - int imageModelColumn); - -// uiTableAppendImageTextColumn() appends a column to t that -// shows both an image and text. -_UI_EXTERN void uiTableAppendImageTextColumn(uiTable *t, - const char *name, - int imageModelColumn, - int textModelColumn, - int textEditableModelColumn, - uiTableTextColumnOptionalParams *textParams); - -// uiTableAppendCheckboxColumn appends a column to t that -// contains a checkbox that the user can interact with (assuming the -// checkbox is editable). SetCellValue() will be called with -// checkboxModelColumn as the column in this case. -_UI_EXTERN void uiTableAppendCheckboxColumn(uiTable *t, - const char *name, - int checkboxModelColumn, - int checkboxEditableModelColumn); - -// uiTableAppendCheckboxTextColumn() appends a column to t -// that contains both a checkbox and text. -_UI_EXTERN void uiTableAppendCheckboxTextColumn(uiTable *t, - const char *name, - int checkboxModelColumn, - int checkboxEditableModelColumn, - int textModelColumn, - int textEditableModelColumn, - uiTableTextColumnOptionalParams *textParams); - -// uiTableAppendProgressBarColumn() appends a column to t -// that displays a progress bar. These columns work like -// uiProgressBar: a cell value of 0..100 displays that percentage, and -// a cell value of -1 displays an indeterminate progress bar. -_UI_EXTERN void uiTableAppendProgressBarColumn(uiTable *t, - const char *name, - int progressModelColumn); - -// uiTableAppendButtonColumn() appends a column to t -// that shows a button that the user can click on. When the user -// does click on the button, SetCellValue() is called with a NULL -// value and buttonModelColumn as the column. -// CellValue() on buttonModelColumn should return the text to show -// in the button. -_UI_EXTERN void uiTableAppendButtonColumn(uiTable *t, - const char *name, - int buttonModelColumn, - int buttonClickableModelColumn); - -// uiNewTable() creates a new uiTable with the specified parameters. -_UI_EXTERN uiTable *uiNewTable(uiTableParams *params); +#define uiprivEnum(s) typedef unsigned int s; enum #ifdef __cplusplus } diff --git a/ui_darwin.h b/ui_darwin.h index c9c6ad54..2a34ef44 100644 --- a/ui_darwin.h +++ b/ui_darwin.h @@ -4,219 +4,13 @@ This file assumes that you have imported and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Mac OS X. */ -#ifndef __LIBUI_UI_DARWIN_H__ -#define __LIBUI_UI_DARWIN_H__ +#ifndef uiprivIncludeGuard_ui_darwin_h +#define uiprivIncludeGuard_ui_darwin_h #ifdef __cplusplus extern "C" { #endif -typedef struct uiDarwinControl uiDarwinControl; -struct uiDarwinControl { - uiControl c; - uiControl *parent; - BOOL enabled; - BOOL visible; - void (*SyncEnableState)(uiDarwinControl *, int); - void (*SetSuperview)(uiDarwinControl *, NSView *); - BOOL (*HugsTrailingEdge)(uiDarwinControl *); - BOOL (*HugsBottom)(uiDarwinControl *); - void (*ChildEdgeHuggingChanged)(uiDarwinControl *); - NSLayoutPriority (*HuggingPriority)(uiDarwinControl *, NSLayoutConstraintOrientation); - void (*SetHuggingPriority)(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation); - void (*ChildVisibilityChanged)(uiDarwinControl *); -}; -#define uiDarwinControl(this) ((uiDarwinControl *) (this)) -// TODO document -_UI_EXTERN void uiDarwinControlSyncEnableState(uiDarwinControl *, int); -_UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *); -_UI_EXTERN BOOL uiDarwinControlHugsTrailingEdge(uiDarwinControl *); -_UI_EXTERN BOOL uiDarwinControlHugsBottom(uiDarwinControl *); -_UI_EXTERN void uiDarwinControlChildEdgeHuggingChanged(uiDarwinControl *); -_UI_EXTERN NSLayoutPriority uiDarwinControlHuggingPriority(uiDarwinControl *, NSLayoutConstraintOrientation); -_UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation); -_UI_EXTERN void uiDarwinControlChildVisibilityChanged(uiDarwinControl *); - -#define uiDarwinControlDefaultDestroy(type, handlefield) \ - static void type ## Destroy(uiControl *c) \ - { \ - [type(c)->handlefield release]; \ - uiFreeControl(c); \ - } -#define uiDarwinControlDefaultHandle(type, handlefield) \ - static uintptr_t type ## Handle(uiControl *c) \ - { \ - return (uintptr_t) (type(c)->handlefield); \ - } -#define uiDarwinControlDefaultParent(type, handlefield) \ - static uiControl *type ## Parent(uiControl *c) \ - { \ - return uiDarwinControl(c)->parent; \ - } -#define uiDarwinControlDefaultSetParent(type, handlefield) \ - static void type ## SetParent(uiControl *c, uiControl *parent) \ - { \ - uiControlVerifySetParent(c, parent); \ - uiDarwinControl(c)->parent = parent; \ - } -#define uiDarwinControlDefaultToplevel(type, handlefield) \ - static int type ## Toplevel(uiControl *c) \ - { \ - return 0; \ - } -#define uiDarwinControlDefaultVisible(type, handlefield) \ - static int type ## Visible(uiControl *c) \ - { \ - return uiDarwinControl(c)->visible; \ - } -#define uiDarwinControlDefaultShow(type, handlefield) \ - static void type ## Show(uiControl *c) \ - { \ - uiDarwinControl(c)->visible = YES; \ - [type(c)->handlefield setHidden:NO]; \ - uiDarwinNotifyVisibilityChanged(uiDarwinControl(c)); \ - } -#define uiDarwinControlDefaultHide(type, handlefield) \ - static void type ## Hide(uiControl *c) \ - { \ - uiDarwinControl(c)->visible = NO; \ - [type(c)->handlefield setHidden:YES]; \ - uiDarwinNotifyVisibilityChanged(uiDarwinControl(c)); \ - } -#define uiDarwinControlDefaultEnabled(type, handlefield) \ - static int type ## Enabled(uiControl *c) \ - { \ - return uiDarwinControl(c)->enabled; \ - } -#define uiDarwinControlDefaultEnable(type, handlefield) \ - static void type ## Enable(uiControl *c) \ - { \ - uiDarwinControl(c)->enabled = YES; \ - uiDarwinControlSyncEnableState(uiDarwinControl(c), uiControlEnabledToUser(c)); \ - } -#define uiDarwinControlDefaultDisable(type, handlefield) \ - static void type ## Disable(uiControl *c) \ - { \ - uiDarwinControl(c)->enabled = NO; \ - uiDarwinControlSyncEnableState(uiDarwinControl(c), uiControlEnabledToUser(c)); \ - } -#define uiDarwinControlDefaultSyncEnableState(type, handlefield) \ - static void type ## SyncEnableState(uiDarwinControl *c, int enabled) \ - { \ - if (uiDarwinShouldStopSyncEnableState(c, enabled)) \ - return; \ - if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \ - [((id) (type(c)->handlefield)) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \ - } -#define uiDarwinControlDefaultSetSuperview(type, handlefield) \ - static void type ## SetSuperview(uiDarwinControl *c, NSView *superview) \ - { \ - [type(c)->handlefield setTranslatesAutoresizingMaskIntoConstraints:NO]; \ - if (superview == nil) \ - [type(c)->handlefield removeFromSuperview]; \ - else \ - [superview addSubview:type(c)->handlefield]; \ - } -#define uiDarwinControlDefaultHugsTrailingEdge(type, handlefield) \ - static BOOL type ## HugsTrailingEdge(uiDarwinControl *c) \ - { \ - return YES; /* always hug by default */ \ - } -#define uiDarwinControlDefaultHugsBottom(type, handlefield) \ - static BOOL type ## HugsBottom(uiDarwinControl *c) \ - { \ - return YES; /* always hug by default */ \ - } -#define uiDarwinControlDefaultChildEdgeHuggingChanged(type, handlefield) \ - static void type ## ChildEdgeHuggingChanged(uiDarwinControl *c) \ - { \ - /* do nothing */ \ - } -#define uiDarwinControlDefaultHuggingPriority(type, handlefield) \ - static NSLayoutPriority type ## HuggingPriority(uiDarwinControl *c, NSLayoutConstraintOrientation orientation) \ - { \ - return [type(c)->handlefield contentHuggingPriorityForOrientation:orientation]; \ - } -#define uiDarwinControlDefaultSetHuggingPriority(type, handlefield) \ - static void type ## SetHuggingPriority(uiDarwinControl *c, NSLayoutPriority priority, NSLayoutConstraintOrientation orientation) \ - { \ - [type(c)->handlefield setContentHuggingPriority:priority forOrientation:orientation]; \ - } -#define uiDarwinControlDefaultChildVisibilityChanged(type, handlefield) \ - static void type ## ChildVisibilityChanged(uiDarwinControl *c) \ - { \ - /* do nothing */ \ - } - -#define uiDarwinControlAllDefaultsExceptDestroy(type, handlefield) \ - uiDarwinControlDefaultHandle(type, handlefield) \ - uiDarwinControlDefaultParent(type, handlefield) \ - uiDarwinControlDefaultSetParent(type, handlefield) \ - uiDarwinControlDefaultToplevel(type, handlefield) \ - uiDarwinControlDefaultVisible(type, handlefield) \ - uiDarwinControlDefaultShow(type, handlefield) \ - uiDarwinControlDefaultHide(type, handlefield) \ - uiDarwinControlDefaultEnabled(type, handlefield) \ - uiDarwinControlDefaultEnable(type, handlefield) \ - uiDarwinControlDefaultDisable(type, handlefield) \ - uiDarwinControlDefaultSyncEnableState(type, handlefield) \ - uiDarwinControlDefaultSetSuperview(type, handlefield) \ - uiDarwinControlDefaultHugsTrailingEdge(type, handlefield) \ - uiDarwinControlDefaultHugsBottom(type, handlefield) \ - uiDarwinControlDefaultChildEdgeHuggingChanged(type, handlefield) \ - uiDarwinControlDefaultHuggingPriority(type, handlefield) \ - uiDarwinControlDefaultSetHuggingPriority(type, handlefield) \ - uiDarwinControlDefaultChildVisibilityChanged(type, handlefield) - -#define uiDarwinControlAllDefaults(type, handlefield) \ - uiDarwinControlDefaultDestroy(type, handlefield) \ - uiDarwinControlAllDefaultsExceptDestroy(type, handlefield) - -// TODO document -#define uiDarwinNewControl(type, var) \ - var = type(uiDarwinAllocControl(sizeof (type), type ## Signature, #type)); \ - uiControl(var)->Destroy = type ## Destroy; \ - uiControl(var)->Handle = type ## Handle; \ - uiControl(var)->Parent = type ## Parent; \ - uiControl(var)->SetParent = type ## SetParent; \ - uiControl(var)->Toplevel = type ## Toplevel; \ - uiControl(var)->Visible = type ## Visible; \ - uiControl(var)->Show = type ## Show; \ - uiControl(var)->Hide = type ## Hide; \ - uiControl(var)->Enabled = type ## Enabled; \ - uiControl(var)->Enable = type ## Enable; \ - uiControl(var)->Disable = type ## Disable; \ - uiDarwinControl(var)->SyncEnableState = type ## SyncEnableState; \ - uiDarwinControl(var)->SetSuperview = type ## SetSuperview; \ - uiDarwinControl(var)->HugsTrailingEdge = type ## HugsTrailingEdge; \ - uiDarwinControl(var)->HugsBottom = type ## HugsBottom; \ - uiDarwinControl(var)->ChildEdgeHuggingChanged = type ## ChildEdgeHuggingChanged; \ - uiDarwinControl(var)->HuggingPriority = type ## HuggingPriority; \ - uiDarwinControl(var)->SetHuggingPriority = type ## SetHuggingPriority; \ - uiDarwinControl(var)->ChildVisibilityChanged = type ## ChildVisibilityChanged; \ - uiDarwinControl(var)->visible = YES; \ - uiDarwinControl(var)->enabled = YES; -// TODO document -_UI_EXTERN uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *typenamestr); - -// Use this function as a shorthand for setting control fonts. -_UI_EXTERN void uiDarwinSetControlFont(NSControl *c, NSControlSize size); - -// You can use this function from within your control implementations to return text strings that can be freed with uiFreeText(). -_UI_EXTERN char *uiDarwinNSStringToText(NSString *); - -// TODO document -_UI_EXTERN BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL); - -// TODO document -_UI_EXTERN void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *); -_UI_EXTERN void uiDarwinNotifyVisibilityChanged(uiDarwinControl *c); - -// TODO document -// TODO document that values should not be cached -_UI_EXTERN CGFloat uiDarwinMarginAmount(void *reserved); -_UI_EXTERN CGFloat uiDarwinPaddingAmount(void *reserved); - #ifdef __cplusplus } #endif diff --git a/ui_unix.h b/ui_unix.h index ed019260..8975c4cb 100644 --- a/ui_unix.h +++ b/ui_unix.h @@ -4,139 +4,13 @@ This file assumes that you have included and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Unix systems that use GTK+ to provide their UI (currently all except Mac OS X). */ -#ifndef __LIBUI_UI_UNIX_H__ -#define __LIBUI_UI_UNIX_H__ +#ifndef uiprivIncludeGuard_ui_unix_h +#define uiprivIncludeGuard_ui_unix_h #ifdef __cplusplus extern "C" { #endif -typedef struct uiUnixControl uiUnixControl; -struct uiUnixControl { - uiControl c; - uiControl *parent; - gboolean addedBefore; - gboolean explicitlyHidden; - void (*SetContainer)(uiUnixControl *, GtkContainer *, gboolean); -}; -#define uiUnixControl(this) ((uiUnixControl *) (this)) -// TODO document -_UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean); - -#define uiUnixControlDefaultDestroy(type) \ - static void type ## Destroy(uiControl *c) \ - { \ - /* TODO is this safe on floating refs? */ \ - g_object_unref(type(c)->widget); \ - uiFreeControl(c); \ - } -#define uiUnixControlDefaultHandle(type) \ - static uintptr_t type ## Handle(uiControl *c) \ - { \ - return (uintptr_t) (type(c)->widget); \ - } -#define uiUnixControlDefaultParent(type) \ - static uiControl *type ## Parent(uiControl *c) \ - { \ - return uiUnixControl(c)->parent; \ - } -#define uiUnixControlDefaultSetParent(type) \ - static void type ## SetParent(uiControl *c, uiControl *parent) \ - { \ - uiControlVerifySetParent(c, parent); \ - uiUnixControl(c)->parent = parent; \ - } -#define uiUnixControlDefaultToplevel(type) \ - static int type ## Toplevel(uiControl *c) \ - { \ - return 0; \ - } -#define uiUnixControlDefaultVisible(type) \ - static int type ## Visible(uiControl *c) \ - { \ - return gtk_widget_get_visible(type(c)->widget); \ - } -#define uiUnixControlDefaultShow(type) \ - static void type ## Show(uiControl *c) \ - { \ - /*TODO part of massive hack about hidden before*/uiUnixControl(c)->explicitlyHidden=FALSE; \ - gtk_widget_show(type(c)->widget); \ - } -#define uiUnixControlDefaultHide(type) \ - static void type ## Hide(uiControl *c) \ - { \ - /*TODO part of massive hack about hidden before*/uiUnixControl(c)->explicitlyHidden=TRUE; \ - gtk_widget_hide(type(c)->widget); \ - } -#define uiUnixControlDefaultEnabled(type) \ - static int type ## Enabled(uiControl *c) \ - { \ - return gtk_widget_get_sensitive(type(c)->widget); \ - } -#define uiUnixControlDefaultEnable(type) \ - static void type ## Enable(uiControl *c) \ - { \ - gtk_widget_set_sensitive(type(c)->widget, TRUE); \ - } -#define uiUnixControlDefaultDisable(type) \ - static void type ## Disable(uiControl *c) \ - { \ - gtk_widget_set_sensitive(type(c)->widget, FALSE); \ - } -// TODO this whole addedBefore stuff is a MASSIVE HACK. -#define uiUnixControlDefaultSetContainer(type) \ - static void type ## SetContainer(uiUnixControl *c, GtkContainer *container, gboolean remove) \ - { \ - if (!uiUnixControl(c)->addedBefore) { \ - g_object_ref_sink(type(c)->widget); /* our own reference, which we release in Destroy() */ \ - /* massive hack notes: without any of this, nothing gets shown when we show a window; without the if, all things get shown even if some were explicitly hidden (TODO why don't we just show everything except windows on create? */ \ - /*TODO*/if(!uiUnixControl(c)->explicitlyHidden) gtk_widget_show(type(c)->widget); \ - uiUnixControl(c)->addedBefore = TRUE; \ - } \ - if (remove) \ - gtk_container_remove(container, type(c)->widget); \ - else \ - gtk_container_add(container, type(c)->widget); \ - } - -#define uiUnixControlAllDefaultsExceptDestroy(type) \ - uiUnixControlDefaultHandle(type) \ - uiUnixControlDefaultParent(type) \ - uiUnixControlDefaultSetParent(type) \ - uiUnixControlDefaultToplevel(type) \ - uiUnixControlDefaultVisible(type) \ - uiUnixControlDefaultShow(type) \ - uiUnixControlDefaultHide(type) \ - uiUnixControlDefaultEnabled(type) \ - uiUnixControlDefaultEnable(type) \ - uiUnixControlDefaultDisable(type) \ - uiUnixControlDefaultSetContainer(type) - -#define uiUnixControlAllDefaults(type) \ - uiUnixControlDefaultDestroy(type) \ - uiUnixControlAllDefaultsExceptDestroy(type) - -// TODO document -#define uiUnixNewControl(type, var) \ - var = type(uiUnixAllocControl(sizeof (type), type ## Signature, #type)); \ - uiControl(var)->Destroy = type ## Destroy; \ - uiControl(var)->Handle = type ## Handle; \ - uiControl(var)->Parent = type ## Parent; \ - uiControl(var)->SetParent = type ## SetParent; \ - uiControl(var)->Toplevel = type ## Toplevel; \ - uiControl(var)->Visible = type ## Visible; \ - uiControl(var)->Show = type ## Show; \ - uiControl(var)->Hide = type ## Hide; \ - uiControl(var)->Enabled = type ## Enabled; \ - uiControl(var)->Enable = type ## Enable; \ - uiControl(var)->Disable = type ## Disable; \ - uiUnixControl(var)->SetContainer = type ## SetContainer; -// TODO document -_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr); - -// uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). -_UI_EXTERN char *uiUnixStrdupText(const char *); - #ifdef __cplusplus } #endif diff --git a/ui_windows.h b/ui_windows.h index 69dda366..cff24597 100644 --- a/ui_windows.h +++ b/ui_windows.h @@ -4,262 +4,13 @@ This file assumes that you have included and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls in Windows. */ -#ifndef __LIBUI_UI_WINDOWS_H__ -#define __LIBUI_UI_WINDOWS_H__ +#ifndef uiprivIncludeGuard_ui_windows_h +#define uiprivIncludeGuard_ui_windows_h #ifdef __cplusplus extern "C" { #endif -typedef struct uiWindowsSizing uiWindowsSizing; - -typedef struct uiWindowsControl uiWindowsControl; -struct uiWindowsControl { - uiControl c; - uiControl *parent; - // TODO this should be int on both os x and windows - BOOL enabled; - BOOL visible; - void (*SyncEnableState)(uiWindowsControl *, int); - void (*SetParentHWND)(uiWindowsControl *, HWND); - void (*MinimumSize)(uiWindowsControl *, int *, int *); - void (*MinimumSizeChanged)(uiWindowsControl *); - void (*LayoutRect)(uiWindowsControl *c, RECT *r); - void (*AssignControlIDZOrder)(uiWindowsControl *, LONG_PTR *, HWND *); - void (*ChildVisibilityChanged)(uiWindowsControl *); -}; -#define uiWindowsControl(this) ((uiWindowsControl *) (this)) -// TODO document -_UI_EXTERN void uiWindowsControlSyncEnableState(uiWindowsControl *, int); -_UI_EXTERN void uiWindowsControlSetParentHWND(uiWindowsControl *, HWND); -_UI_EXTERN void uiWindowsControlMinimumSize(uiWindowsControl *, int *, int *); -_UI_EXTERN void uiWindowsControlMinimumSizeChanged(uiWindowsControl *); -_UI_EXTERN void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *); -_UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *); -_UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *); - -// TODO document -#define uiWindowsControlDefaultDestroy(type) \ - static void type ## Destroy(uiControl *c) \ - { \ - uiWindowsEnsureDestroyWindow(type(c)->hwnd); \ - uiFreeControl(c); \ - } -#define uiWindowsControlDefaultHandle(type) \ - static uintptr_t type ## Handle(uiControl *c) \ - { \ - return (uintptr_t) (type(c)->hwnd); \ - } -#define uiWindowsControlDefaultParent(type) \ - static uiControl *type ## Parent(uiControl *c) \ - { \ - return uiWindowsControl(c)->parent; \ - } -#define uiWindowsControlDefaultSetParent(type) \ - static void type ## SetParent(uiControl *c, uiControl *parent) \ - { \ - uiControlVerifySetParent(c, parent); \ - uiWindowsControl(c)->parent = parent; \ - } -#define uiWindowsControlDefaultToplevel(type) \ - static int type ## Toplevel(uiControl *c) \ - { \ - return 0; \ - } -#define uiWindowsControlDefaultVisible(type) \ - static int type ## Visible(uiControl *c) \ - { \ - return uiWindowsControl(c)->visible; \ - } -#define uiWindowsControlDefaultShow(type) \ - static void type ## Show(uiControl *c) \ - { \ - uiWindowsControl(c)->visible = 1; \ - ShowWindow(type(c)->hwnd, SW_SHOW); \ - uiWindowsControlNotifyVisibilityChanged(uiWindowsControl(c)); \ - } -#define uiWindowsControlDefaultHide(type) \ - static void type ## Hide(uiControl *c) \ - { \ - uiWindowsControl(c)->visible = 0; \ - ShowWindow(type(c)->hwnd, SW_HIDE); \ - uiWindowsControlNotifyVisibilityChanged(uiWindowsControl(c)); \ - } -#define uiWindowsControlDefaultEnabled(type) \ - static int type ## Enabled(uiControl *c) \ - { \ - return uiWindowsControl(c)->enabled; \ - } -#define uiWindowsControlDefaultEnable(type) \ - static void type ## Enable(uiControl *c) \ - { \ - uiWindowsControl(c)->enabled = 1; \ - uiWindowsControlSyncEnableState(uiWindowsControl(c), uiControlEnabledToUser(c)); \ - } -#define uiWindowsControlDefaultDisable(type) \ - static void type ## Disable(uiControl *c) \ - { \ - uiWindowsControl(c)->enabled = 0; \ - uiWindowsControlSyncEnableState(uiWindowsControl(c), uiControlEnabledToUser(c)); \ - } -#define uiWindowsControlDefaultSyncEnableState(type) \ - static void type ## SyncEnableState(uiWindowsControl *c, int enabled) \ - { \ - if (uiWindowsShouldStopSyncEnableState(c, enabled)) \ - return; \ - EnableWindow(type(c)->hwnd, enabled); \ - } -#define uiWindowsControlDefaultSetParentHWND(type) \ - static void type ## SetParentHWND(uiWindowsControl *c, HWND parent) \ - { \ - uiWindowsEnsureSetParentHWND(type(c)->hwnd, parent); \ - } -// note that there is no uiWindowsControlDefaultMinimumSize(); you MUST define this yourself! -#define uiWindowsControlDefaultMinimumSizeChanged(type) \ - static void type ## MinimumSizeChanged(uiWindowsControl *c) \ - { \ - if (uiWindowsControlTooSmall(c)) { \ - uiWindowsControlContinueMinimumSizeChanged(c); \ - return; \ - } \ - /* otherwise do nothing; we have no children */ \ - } -#define uiWindowsControlDefaultLayoutRect(type) \ - static void type ## LayoutRect(uiWindowsControl *c, RECT *r) \ - { \ - /* use the window rect as we include the non-client area in the sizes */ \ - uiWindowsEnsureGetWindowRect(type(c)->hwnd, r); \ - } -#define uiWindowsControlDefaultAssignControlIDZOrder(type) \ - static void type ## AssignControlIDZOrder(uiWindowsControl *c, LONG_PTR *controlID, HWND *insertAfter) \ - { \ - uiWindowsEnsureAssignControlIDZOrder(type(c)->hwnd, controlID, insertAfter); \ - } -#define uiWindowsControlDefaultChildVisibilityChanged(type) \ - static void type ## ChildVisibilityChanged(uiWindowsControl *c) \ - { \ - /* do nothing */ \ - } - -#define uiWindowsControlAllDefaultsExceptDestroy(type) \ - uiWindowsControlDefaultHandle(type) \ - uiWindowsControlDefaultParent(type) \ - uiWindowsControlDefaultSetParent(type) \ - uiWindowsControlDefaultToplevel(type) \ - uiWindowsControlDefaultVisible(type) \ - uiWindowsControlDefaultShow(type) \ - uiWindowsControlDefaultHide(type) \ - uiWindowsControlDefaultEnabled(type) \ - uiWindowsControlDefaultEnable(type) \ - uiWindowsControlDefaultDisable(type) \ - uiWindowsControlDefaultSyncEnableState(type) \ - uiWindowsControlDefaultSetParentHWND(type) \ - uiWindowsControlDefaultMinimumSizeChanged(type) \ - uiWindowsControlDefaultLayoutRect(type) \ - uiWindowsControlDefaultAssignControlIDZOrder(type) \ - uiWindowsControlDefaultChildVisibilityChanged(type) - -#define uiWindowsControlAllDefaults(type) \ - uiWindowsControlDefaultDestroy(type) \ - uiWindowsControlAllDefaultsExceptDestroy(type) - -// TODO document -#define uiWindowsNewControl(type, var) \ - var = type(uiWindowsAllocControl(sizeof (type), type ## Signature, #type)); \ - uiControl(var)->Destroy = type ## Destroy; \ - uiControl(var)->Handle = type ## Handle; \ - uiControl(var)->Parent = type ## Parent; \ - uiControl(var)->SetParent = type ## SetParent; \ - uiControl(var)->Toplevel = type ## Toplevel; \ - uiControl(var)->Visible = type ## Visible; \ - uiControl(var)->Show = type ## Show; \ - uiControl(var)->Hide = type ## Hide; \ - uiControl(var)->Enabled = type ## Enabled; \ - uiControl(var)->Enable = type ## Enable; \ - uiControl(var)->Disable = type ## Disable; \ - uiWindowsControl(var)->SyncEnableState = type ## SyncEnableState; \ - uiWindowsControl(var)->SetParentHWND = type ## SetParentHWND; \ - uiWindowsControl(var)->MinimumSize = type ## MinimumSize; \ - uiWindowsControl(var)->MinimumSizeChanged = type ## MinimumSizeChanged; \ - uiWindowsControl(var)->LayoutRect = type ## LayoutRect; \ - uiWindowsControl(var)->AssignControlIDZOrder = type ## AssignControlIDZOrder; \ - uiWindowsControl(var)->ChildVisibilityChanged = type ## ChildVisibilityChanged; \ - uiWindowsControl(var)->visible = 1; \ - uiWindowsControl(var)->enabled = 1; -// TODO document -_UI_EXTERN uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr); - -// TODO document -_UI_EXTERN HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont); - -// TODO document -_UI_EXTERN void uiWindowsEnsureDestroyWindow(HWND hwnd); - -// TODO document -// TODO document that this should only be used in SetParentHWND() implementations -_UI_EXTERN void uiWindowsEnsureSetParentHWND(HWND hwnd, HWND parent); - -// TODO document -_UI_EXTERN void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR *controlID, HWND *insertAfter); - -// TODO document -_UI_EXTERN void uiWindowsEnsureGetClientRect(HWND hwnd, RECT *r); -_UI_EXTERN void uiWindowsEnsureGetWindowRect(HWND hwnd, RECT *r); - -// TODO document -_UI_EXTERN char *uiWindowsWindowText(HWND hwnd); -_UI_EXTERN void uiWindowsSetWindowText(HWND hwnd, const char *text); - -// TODO document -_UI_EXTERN int uiWindowsWindowTextWidth(HWND hwnd); - -// TODO document -// TODO point out this should only be used in a resize cycle -_UI_EXTERN void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, int x, int y, int width, int height); - -// TODO document -_UI_EXTERN void uiWindowsRegisterWM_COMMANDHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c); -_UI_EXTERN void uiWindowsUnregisterWM_COMMANDHandler(HWND hwnd); - -// TODO document -_UI_EXTERN void uiWindowsRegisterWM_NOTIFYHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *c); -_UI_EXTERN void uiWindowsUnregisterWM_NOTIFYHandler(HWND hwnd); - -// TODO document -_UI_EXTERN void uiWindowsRegisterWM_HSCROLLHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c); -_UI_EXTERN void uiWindowsUnregisterWM_HSCROLLHandler(HWND hwnd); - -// TODO document -_UI_EXTERN void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd); -_UI_EXTERN void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd); - -// TODO document -typedef struct uiWindowsSizing uiWindowsSizing; -struct uiWindowsSizing { - int BaseX; - int BaseY; - LONG InternalLeading; -}; -_UI_EXTERN void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing); -_UI_EXTERN void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y); -_UI_EXTERN void uiWindowsSizingStandardPadding(uiWindowsSizing *sizing, int *x, int *y); - -// TODO document -_UI_EXTERN HWND uiWindowsMakeContainer(uiWindowsControl *c, void (*onResize)(uiWindowsControl *)); - -// TODO document -_UI_EXTERN BOOL uiWindowsControlTooSmall(uiWindowsControl *c); -_UI_EXTERN void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c); - -// TODO document -_UI_EXTERN void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *); - -// TODO document -_UI_EXTERN BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled); - -// TODO document -_UI_EXTERN void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c); - #ifdef __cplusplus } #endif diff --git a/zOLD_ui.h b/zOLD_ui.h index 40aea949..e045bae5 100644 --- a/zOLD_ui.h +++ b/zOLD_ui.h @@ -1,5 +1,3 @@ -// 6 april 2015 - // TODO add a uiVerifyControlType() function that can be used by control implementations to verify controls // TODOs @@ -7,32 +5,6 @@ // - const-correct everything // - normalize documentation between typedefs and structs -#ifndef __LIBUI_UI_H__ -#define __LIBUI_UI_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// this macro is generated by cmake -#ifdef libui_EXPORTS -#ifdef _WIN32 -#define _UI_EXTERN __declspec(dllexport) extern -#else -#define _UI_EXTERN __attribute__((visibility("default"))) extern -#endif -#else -// TODO add __declspec(dllimport) on windows, but only if not static -#define _UI_EXTERN extern -#endif - -// C++ is really really really really really really dumb about enums, so screw that and just make them anonymous -// This has the advantage of being ABI-able should we ever need an ABI... -#define _UI_ENUM(s) typedef unsigned int s; enum - // This constant is provided because M_PI is nonstandard. // This comes from Go's math.Pi, which in turn comes from http://oeis.org/A000796. #define uiPi 3.14159265358979323846264338327950288419716939937510582097494459 @@ -40,7 +12,7 @@ extern "C" { // TODO uiBool? // uiForEach represents the return value from one of libui's various ForEach functions. -_UI_ENUM(uiForEach) { +uiprivEnum(uiForEach) { uiForEachContinue, uiForEachStop, }; @@ -51,16 +23,16 @@ struct uiInitOptions { size_t Size; }; -_UI_EXTERN const char *uiInit(uiInitOptions *options); -_UI_EXTERN void uiUninit(void); -_UI_EXTERN void uiFreeInitError(const char *err); +uiprivExtern const char *uiInit(uiInitOptions *options); +uiprivExtern void uiUninit(void); +uiprivExtern void uiFreeInitError(const char *err); -_UI_EXTERN void uiMain(void); -_UI_EXTERN void uiMainSteps(void); -_UI_EXTERN int uiMainStep(int wait); -_UI_EXTERN void uiQuit(void); +uiprivExtern void uiMain(void); +uiprivExtern void uiMainSteps(void); +uiprivExtern int uiMainStep(int wait); +uiprivExtern void uiQuit(void); -_UI_EXTERN void uiQueueMain(void (*f)(void *data), void *data); +uiprivExtern void uiQueueMain(void (*f)(void *data), void *data); // TODO standardize the looping behavior return type, either with some enum or something, and the test expressions throughout the code // TODO figure out what to do about looping and the exact point that the timer is rescheduled so we can document it; see https://github.com/andlabs/libui/pull/277 @@ -68,11 +40,11 @@ _UI_EXTERN void uiQueueMain(void (*f)(void *data), void *data); // TODO document that the minimum exact timing, either accuracy (timer burst, etc.) or granularity (15ms on Windows, etc.), is OS-defined // TODO also figure out how long until the initial tick is registered on all platforms to document // TODO also add a comment about how useful this could be in bindings, depending on the language being bound to -_UI_EXTERN void uiTimer(int milliseconds, int (*f)(void *data), void *data); +uiprivExtern void uiTimer(int milliseconds, int (*f)(void *data), void *data); -_UI_EXTERN void uiOnShouldQuit(int (*f)(void *data), void *data); +uiprivExtern void uiOnShouldQuit(int (*f)(void *data), void *data); -_UI_EXTERN void uiFreeText(char *text); +uiprivExtern void uiFreeText(char *text); typedef struct uiControl uiControl; @@ -94,104 +66,104 @@ struct uiControl { }; // TOOD add argument names to all arguments #define uiControl(this) ((uiControl *) (this)) -_UI_EXTERN void uiControlDestroy(uiControl *); -_UI_EXTERN uintptr_t uiControlHandle(uiControl *); -_UI_EXTERN uiControl *uiControlParent(uiControl *); -_UI_EXTERN void uiControlSetParent(uiControl *, uiControl *); -_UI_EXTERN int uiControlToplevel(uiControl *); -_UI_EXTERN int uiControlVisible(uiControl *); -_UI_EXTERN void uiControlShow(uiControl *); -_UI_EXTERN void uiControlHide(uiControl *); -_UI_EXTERN int uiControlEnabled(uiControl *); -_UI_EXTERN void uiControlEnable(uiControl *); -_UI_EXTERN void uiControlDisable(uiControl *); +uiprivExtern void uiControlDestroy(uiControl *); +uiprivExtern uintptr_t uiControlHandle(uiControl *); +uiprivExtern uiControl *uiControlParent(uiControl *); +uiprivExtern void uiControlSetParent(uiControl *, uiControl *); +uiprivExtern int uiControlToplevel(uiControl *); +uiprivExtern int uiControlVisible(uiControl *); +uiprivExtern void uiControlShow(uiControl *); +uiprivExtern void uiControlHide(uiControl *); +uiprivExtern int uiControlEnabled(uiControl *); +uiprivExtern void uiControlEnable(uiControl *); +uiprivExtern void uiControlDisable(uiControl *); -_UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr); -_UI_EXTERN void uiFreeControl(uiControl *); +uiprivExtern uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr); +uiprivExtern void uiFreeControl(uiControl *); // TODO make sure all controls have these -_UI_EXTERN void uiControlVerifySetParent(uiControl *, uiControl *); -_UI_EXTERN int uiControlEnabledToUser(uiControl *); +uiprivExtern void uiControlVerifySetParent(uiControl *, uiControl *); +uiprivExtern int uiControlEnabledToUser(uiControl *); -_UI_EXTERN void uiUserBugCannotSetParentOnToplevel(const char *type); +uiprivExtern void uiUserBugCannotSetParentOnToplevel(const char *type); typedef struct uiWindow uiWindow; #define uiWindow(this) ((uiWindow *) (this)) -_UI_EXTERN char *uiWindowTitle(uiWindow *w); -_UI_EXTERN void uiWindowSetTitle(uiWindow *w, const char *title); -_UI_EXTERN void uiWindowContentSize(uiWindow *w, int *width, int *height); -_UI_EXTERN void uiWindowSetContentSize(uiWindow *w, int width, int height); -_UI_EXTERN int uiWindowFullscreen(uiWindow *w); -_UI_EXTERN void uiWindowSetFullscreen(uiWindow *w, int fullscreen); -_UI_EXTERN void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data); -_UI_EXTERN void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data); -_UI_EXTERN int uiWindowBorderless(uiWindow *w); -_UI_EXTERN void uiWindowSetBorderless(uiWindow *w, int borderless); -_UI_EXTERN void uiWindowSetChild(uiWindow *w, uiControl *child); -_UI_EXTERN int uiWindowMargined(uiWindow *w); -_UI_EXTERN void uiWindowSetMargined(uiWindow *w, int margined); -_UI_EXTERN uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar); +uiprivExtern char *uiWindowTitle(uiWindow *w); +uiprivExtern void uiWindowSetTitle(uiWindow *w, const char *title); +uiprivExtern void uiWindowContentSize(uiWindow *w, int *width, int *height); +uiprivExtern void uiWindowSetContentSize(uiWindow *w, int width, int height); +uiprivExtern int uiWindowFullscreen(uiWindow *w); +uiprivExtern void uiWindowSetFullscreen(uiWindow *w, int fullscreen); +uiprivExtern void uiWindowOnContentSizeChanged(uiWindow *w, void (*f)(uiWindow *, void *), void *data); +uiprivExtern void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data); +uiprivExtern int uiWindowBorderless(uiWindow *w); +uiprivExtern void uiWindowSetBorderless(uiWindow *w, int borderless); +uiprivExtern void uiWindowSetChild(uiWindow *w, uiControl *child); +uiprivExtern int uiWindowMargined(uiWindow *w); +uiprivExtern void uiWindowSetMargined(uiWindow *w, int margined); +uiprivExtern uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar); typedef struct uiButton uiButton; #define uiButton(this) ((uiButton *) (this)) -_UI_EXTERN char *uiButtonText(uiButton *b); -_UI_EXTERN void uiButtonSetText(uiButton *b, const char *text); -_UI_EXTERN void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *b, void *data), void *data); -_UI_EXTERN uiButton *uiNewButton(const char *text); +uiprivExtern char *uiButtonText(uiButton *b); +uiprivExtern void uiButtonSetText(uiButton *b, const char *text); +uiprivExtern void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *b, void *data), void *data); +uiprivExtern uiButton *uiNewButton(const char *text); typedef struct uiBox uiBox; #define uiBox(this) ((uiBox *) (this)) -_UI_EXTERN void uiBoxAppend(uiBox *b, uiControl *child, int stretchy); -_UI_EXTERN void uiBoxDelete(uiBox *b, int index); -_UI_EXTERN int uiBoxPadded(uiBox *b); -_UI_EXTERN void uiBoxSetPadded(uiBox *b, int padded); -_UI_EXTERN uiBox *uiNewHorizontalBox(void); -_UI_EXTERN uiBox *uiNewVerticalBox(void); +uiprivExtern void uiBoxAppend(uiBox *b, uiControl *child, int stretchy); +uiprivExtern void uiBoxDelete(uiBox *b, int index); +uiprivExtern int uiBoxPadded(uiBox *b); +uiprivExtern void uiBoxSetPadded(uiBox *b, int padded); +uiprivExtern uiBox *uiNewHorizontalBox(void); +uiprivExtern uiBox *uiNewVerticalBox(void); typedef struct uiCheckbox uiCheckbox; #define uiCheckbox(this) ((uiCheckbox *) (this)) -_UI_EXTERN char *uiCheckboxText(uiCheckbox *c); -_UI_EXTERN void uiCheckboxSetText(uiCheckbox *c, const char *text); -_UI_EXTERN void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *c, void *data), void *data); -_UI_EXTERN int uiCheckboxChecked(uiCheckbox *c); -_UI_EXTERN void uiCheckboxSetChecked(uiCheckbox *c, int checked); -_UI_EXTERN uiCheckbox *uiNewCheckbox(const char *text); +uiprivExtern char *uiCheckboxText(uiCheckbox *c); +uiprivExtern void uiCheckboxSetText(uiCheckbox *c, const char *text); +uiprivExtern void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *c, void *data), void *data); +uiprivExtern int uiCheckboxChecked(uiCheckbox *c); +uiprivExtern void uiCheckboxSetChecked(uiCheckbox *c, int checked); +uiprivExtern uiCheckbox *uiNewCheckbox(const char *text); typedef struct uiEntry uiEntry; #define uiEntry(this) ((uiEntry *) (this)) -_UI_EXTERN char *uiEntryText(uiEntry *e); -_UI_EXTERN void uiEntrySetText(uiEntry *e, const char *text); -_UI_EXTERN void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *e, void *data), void *data); -_UI_EXTERN int uiEntryReadOnly(uiEntry *e); -_UI_EXTERN void uiEntrySetReadOnly(uiEntry *e, int readonly); -_UI_EXTERN uiEntry *uiNewEntry(void); -_UI_EXTERN uiEntry *uiNewPasswordEntry(void); -_UI_EXTERN uiEntry *uiNewSearchEntry(void); +uiprivExtern char *uiEntryText(uiEntry *e); +uiprivExtern void uiEntrySetText(uiEntry *e, const char *text); +uiprivExtern void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *e, void *data), void *data); +uiprivExtern int uiEntryReadOnly(uiEntry *e); +uiprivExtern void uiEntrySetReadOnly(uiEntry *e, int readonly); +uiprivExtern uiEntry *uiNewEntry(void); +uiprivExtern uiEntry *uiNewPasswordEntry(void); +uiprivExtern uiEntry *uiNewSearchEntry(void); typedef struct uiLabel uiLabel; #define uiLabel(this) ((uiLabel *) (this)) -_UI_EXTERN char *uiLabelText(uiLabel *l); -_UI_EXTERN void uiLabelSetText(uiLabel *l, const char *text); -_UI_EXTERN uiLabel *uiNewLabel(const char *text); +uiprivExtern char *uiLabelText(uiLabel *l); +uiprivExtern void uiLabelSetText(uiLabel *l, const char *text); +uiprivExtern uiLabel *uiNewLabel(const char *text); typedef struct uiTab uiTab; #define uiTab(this) ((uiTab *) (this)) -_UI_EXTERN void uiTabAppend(uiTab *t, const char *name, uiControl *c); -_UI_EXTERN void uiTabInsertAt(uiTab *t, const char *name, int before, uiControl *c); -_UI_EXTERN void uiTabDelete(uiTab *t, int index); -_UI_EXTERN int uiTabNumPages(uiTab *t); -_UI_EXTERN int uiTabMargined(uiTab *t, int page); -_UI_EXTERN void uiTabSetMargined(uiTab *t, int page, int margined); -_UI_EXTERN uiTab *uiNewTab(void); +uiprivExtern void uiTabAppend(uiTab *t, const char *name, uiControl *c); +uiprivExtern void uiTabInsertAt(uiTab *t, const char *name, int before, uiControl *c); +uiprivExtern void uiTabDelete(uiTab *t, int index); +uiprivExtern int uiTabNumPages(uiTab *t); +uiprivExtern int uiTabMargined(uiTab *t, int page); +uiprivExtern void uiTabSetMargined(uiTab *t, int page, int margined); +uiprivExtern uiTab *uiNewTab(void); typedef struct uiGroup uiGroup; #define uiGroup(this) ((uiGroup *) (this)) -_UI_EXTERN char *uiGroupTitle(uiGroup *g); -_UI_EXTERN void uiGroupSetTitle(uiGroup *g, const char *title); -_UI_EXTERN void uiGroupSetChild(uiGroup *g, uiControl *c); -_UI_EXTERN int uiGroupMargined(uiGroup *g); -_UI_EXTERN void uiGroupSetMargined(uiGroup *g, int margined); -_UI_EXTERN uiGroup *uiNewGroup(const char *title); +uiprivExtern char *uiGroupTitle(uiGroup *g); +uiprivExtern void uiGroupSetTitle(uiGroup *g, const char *title); +uiprivExtern void uiGroupSetChild(uiGroup *g, uiControl *c); +uiprivExtern int uiGroupMargined(uiGroup *g); +uiprivExtern void uiGroupSetMargined(uiGroup *g, int margined); +uiprivExtern uiGroup *uiNewGroup(const char *title); // spinbox/slider rules: // setting value outside of range will automatically clamp @@ -200,53 +172,53 @@ _UI_EXTERN uiGroup *uiNewGroup(const char *title); typedef struct uiSpinbox uiSpinbox; #define uiSpinbox(this) ((uiSpinbox *) (this)) -_UI_EXTERN int uiSpinboxValue(uiSpinbox *s); -_UI_EXTERN void uiSpinboxSetValue(uiSpinbox *s, int value); -_UI_EXTERN void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data); -_UI_EXTERN uiSpinbox *uiNewSpinbox(int min, int max); +uiprivExtern int uiSpinboxValue(uiSpinbox *s); +uiprivExtern void uiSpinboxSetValue(uiSpinbox *s, int value); +uiprivExtern void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data); +uiprivExtern uiSpinbox *uiNewSpinbox(int min, int max); typedef struct uiSlider uiSlider; #define uiSlider(this) ((uiSlider *) (this)) -_UI_EXTERN int uiSliderValue(uiSlider *s); -_UI_EXTERN void uiSliderSetValue(uiSlider *s, int value); -_UI_EXTERN void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data); -_UI_EXTERN uiSlider *uiNewSlider(int min, int max); +uiprivExtern int uiSliderValue(uiSlider *s); +uiprivExtern void uiSliderSetValue(uiSlider *s, int value); +uiprivExtern void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data); +uiprivExtern uiSlider *uiNewSlider(int min, int max); typedef struct uiProgressBar uiProgressBar; #define uiProgressBar(this) ((uiProgressBar *) (this)) -_UI_EXTERN int uiProgressBarValue(uiProgressBar *p); -_UI_EXTERN void uiProgressBarSetValue(uiProgressBar *p, int n); -_UI_EXTERN uiProgressBar *uiNewProgressBar(void); +uiprivExtern int uiProgressBarValue(uiProgressBar *p); +uiprivExtern void uiProgressBarSetValue(uiProgressBar *p, int n); +uiprivExtern uiProgressBar *uiNewProgressBar(void); typedef struct uiSeparator uiSeparator; #define uiSeparator(this) ((uiSeparator *) (this)) -_UI_EXTERN uiSeparator *uiNewHorizontalSeparator(void); -_UI_EXTERN uiSeparator *uiNewVerticalSeparator(void); +uiprivExtern uiSeparator *uiNewHorizontalSeparator(void); +uiprivExtern uiSeparator *uiNewVerticalSeparator(void); typedef struct uiCombobox uiCombobox; #define uiCombobox(this) ((uiCombobox *) (this)) -_UI_EXTERN void uiComboboxAppend(uiCombobox *c, const char *text); -_UI_EXTERN int uiComboboxSelected(uiCombobox *c); -_UI_EXTERN void uiComboboxSetSelected(uiCombobox *c, int n); -_UI_EXTERN void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data); -_UI_EXTERN uiCombobox *uiNewCombobox(void); +uiprivExtern void uiComboboxAppend(uiCombobox *c, const char *text); +uiprivExtern int uiComboboxSelected(uiCombobox *c); +uiprivExtern void uiComboboxSetSelected(uiCombobox *c, int n); +uiprivExtern void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data); +uiprivExtern uiCombobox *uiNewCombobox(void); typedef struct uiEditableCombobox uiEditableCombobox; #define uiEditableCombobox(this) ((uiEditableCombobox *) (this)) -_UI_EXTERN void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text); -_UI_EXTERN char *uiEditableComboboxText(uiEditableCombobox *c); -_UI_EXTERN void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text); +uiprivExtern void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text); +uiprivExtern char *uiEditableComboboxText(uiEditableCombobox *c); +uiprivExtern void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text); // TODO what do we call a function that sets the currently selected item and fills the text field with it? editable comboboxes have no consistent concept of selected item -_UI_EXTERN void uiEditableComboboxOnChanged(uiEditableCombobox *c, void (*f)(uiEditableCombobox *c, void *data), void *data); -_UI_EXTERN uiEditableCombobox *uiNewEditableCombobox(void); +uiprivExtern void uiEditableComboboxOnChanged(uiEditableCombobox *c, void (*f)(uiEditableCombobox *c, void *data), void *data); +uiprivExtern uiEditableCombobox *uiNewEditableCombobox(void); typedef struct uiRadioButtons uiRadioButtons; #define uiRadioButtons(this) ((uiRadioButtons *) (this)) -_UI_EXTERN void uiRadioButtonsAppend(uiRadioButtons *r, const char *text); -_UI_EXTERN int uiRadioButtonsSelected(uiRadioButtons *r); -_UI_EXTERN void uiRadioButtonsSetSelected(uiRadioButtons *r, int n); -_UI_EXTERN void uiRadioButtonsOnSelected(uiRadioButtons *r, void (*f)(uiRadioButtons *, void *), void *data); -_UI_EXTERN uiRadioButtons *uiNewRadioButtons(void); +uiprivExtern void uiRadioButtonsAppend(uiRadioButtons *r, const char *text); +uiprivExtern int uiRadioButtonsSelected(uiRadioButtons *r); +uiprivExtern void uiRadioButtonsSetSelected(uiRadioButtons *r, int n); +uiprivExtern void uiRadioButtonsOnSelected(uiRadioButtons *r, void (*f)(uiRadioButtons *, void *), void *data); +uiprivExtern uiRadioButtons *uiNewRadioButtons(void); struct tm; typedef struct uiDateTimePicker uiDateTimePicker; @@ -255,47 +227,47 @@ typedef struct uiDateTimePicker uiDateTimePicker; // TODO document that for both sides // TODO document time zone conversions or lack thereof // TODO for Time: define what values are returned when a part is missing -_UI_EXTERN void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time); -_UI_EXTERN void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time); -_UI_EXTERN void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data); -_UI_EXTERN uiDateTimePicker *uiNewDateTimePicker(void); -_UI_EXTERN uiDateTimePicker *uiNewDatePicker(void); -_UI_EXTERN uiDateTimePicker *uiNewTimePicker(void); +uiprivExtern void uiDateTimePickerTime(uiDateTimePicker *d, struct tm *time); +uiprivExtern void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time); +uiprivExtern void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data); +uiprivExtern uiDateTimePicker *uiNewDateTimePicker(void); +uiprivExtern uiDateTimePicker *uiNewDatePicker(void); +uiprivExtern uiDateTimePicker *uiNewTimePicker(void); // TODO provide a facility for entering tab stops? typedef struct uiMultilineEntry uiMultilineEntry; #define uiMultilineEntry(this) ((uiMultilineEntry *) (this)) -_UI_EXTERN char *uiMultilineEntryText(uiMultilineEntry *e); -_UI_EXTERN void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text); -_UI_EXTERN void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text); -_UI_EXTERN void uiMultilineEntryOnChanged(uiMultilineEntry *e, void (*f)(uiMultilineEntry *e, void *data), void *data); -_UI_EXTERN int uiMultilineEntryReadOnly(uiMultilineEntry *e); -_UI_EXTERN void uiMultilineEntrySetReadOnly(uiMultilineEntry *e, int readonly); -_UI_EXTERN uiMultilineEntry *uiNewMultilineEntry(void); -_UI_EXTERN uiMultilineEntry *uiNewNonWrappingMultilineEntry(void); +uiprivExtern char *uiMultilineEntryText(uiMultilineEntry *e); +uiprivExtern void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text); +uiprivExtern void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text); +uiprivExtern void uiMultilineEntryOnChanged(uiMultilineEntry *e, void (*f)(uiMultilineEntry *e, void *data), void *data); +uiprivExtern int uiMultilineEntryReadOnly(uiMultilineEntry *e); +uiprivExtern void uiMultilineEntrySetReadOnly(uiMultilineEntry *e, int readonly); +uiprivExtern uiMultilineEntry *uiNewMultilineEntry(void); +uiprivExtern uiMultilineEntry *uiNewNonWrappingMultilineEntry(void); typedef struct uiMenuItem uiMenuItem; #define uiMenuItem(this) ((uiMenuItem *) (this)) -_UI_EXTERN void uiMenuItemEnable(uiMenuItem *m); -_UI_EXTERN void uiMenuItemDisable(uiMenuItem *m); -_UI_EXTERN void uiMenuItemOnClicked(uiMenuItem *m, void (*f)(uiMenuItem *sender, uiWindow *window, void *data), void *data); -_UI_EXTERN int uiMenuItemChecked(uiMenuItem *m); -_UI_EXTERN void uiMenuItemSetChecked(uiMenuItem *m, int checked); +uiprivExtern void uiMenuItemEnable(uiMenuItem *m); +uiprivExtern void uiMenuItemDisable(uiMenuItem *m); +uiprivExtern void uiMenuItemOnClicked(uiMenuItem *m, void (*f)(uiMenuItem *sender, uiWindow *window, void *data), void *data); +uiprivExtern int uiMenuItemChecked(uiMenuItem *m); +uiprivExtern void uiMenuItemSetChecked(uiMenuItem *m, int checked); typedef struct uiMenu uiMenu; #define uiMenu(this) ((uiMenu *) (this)) -_UI_EXTERN uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name); -_UI_EXTERN uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name); -_UI_EXTERN uiMenuItem *uiMenuAppendQuitItem(uiMenu *m); -_UI_EXTERN uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m); -_UI_EXTERN uiMenuItem *uiMenuAppendAboutItem(uiMenu *m); -_UI_EXTERN void uiMenuAppendSeparator(uiMenu *m); -_UI_EXTERN uiMenu *uiNewMenu(const char *name); +uiprivExtern uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name); +uiprivExtern uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name); +uiprivExtern uiMenuItem *uiMenuAppendQuitItem(uiMenu *m); +uiprivExtern uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m); +uiprivExtern uiMenuItem *uiMenuAppendAboutItem(uiMenu *m); +uiprivExtern void uiMenuAppendSeparator(uiMenu *m); +uiprivExtern uiMenu *uiNewMenu(const char *name); -_UI_EXTERN char *uiOpenFile(uiWindow *parent); -_UI_EXTERN char *uiSaveFile(uiWindow *parent); -_UI_EXTERN void uiMsgBox(uiWindow *parent, const char *title, const char *description); -_UI_EXTERN void uiMsgBoxError(uiWindow *parent, const char *title, const char *description); +uiprivExtern char *uiOpenFile(uiWindow *parent); +uiprivExtern char *uiSaveFile(uiWindow *parent); +uiprivExtern void uiMsgBox(uiWindow *parent, const char *title, const char *description); +uiprivExtern void uiMsgBoxError(uiWindow *parent, const char *title, const char *description); typedef struct uiArea uiArea; typedef struct uiAreaHandler uiAreaHandler; @@ -318,7 +290,7 @@ struct uiAreaHandler { // TODO RTL layouts? // TODO reconcile edge and corner naming -_UI_ENUM(uiWindowResizeEdge) { +uiprivEnum(uiWindowResizeEdge) { uiWindowResizeEdgeLeft, uiWindowResizeEdgeTop, uiWindowResizeEdgeRight, @@ -335,19 +307,19 @@ _UI_ENUM(uiWindowResizeEdge) { #define uiArea(this) ((uiArea *) (this)) // TODO give a better name // TODO document the types of width and height -_UI_EXTERN void uiAreaSetSize(uiArea *a, int width, int height); +uiprivExtern void uiAreaSetSize(uiArea *a, int width, int height); // TODO uiAreaQueueRedraw() -_UI_EXTERN void uiAreaQueueRedrawAll(uiArea *a); -_UI_EXTERN void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height); +uiprivExtern void uiAreaQueueRedrawAll(uiArea *a); +uiprivExtern void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height); // TODO document these can only be called within Mouse() handlers // TODO should these be allowed on scrolling areas? // TODO decide which mouse events should be accepted; Down is the only one guaranteed to work right now // TODO what happens to events after calling this up to and including the next mouse up? // TODO release capture? -_UI_EXTERN void uiAreaBeginUserWindowMove(uiArea *a); -_UI_EXTERN void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge); -_UI_EXTERN uiArea *uiNewArea(uiAreaHandler *ah); -_UI_EXTERN uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height); +uiprivExtern void uiAreaBeginUserWindowMove(uiArea *a); +uiprivExtern void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge); +uiprivExtern uiArea *uiNewArea(uiAreaHandler *ah); +uiprivExtern uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height); struct uiAreaDrawParams { uiDrawContext *Context; @@ -369,20 +341,20 @@ typedef struct uiDrawMatrix uiDrawMatrix; typedef struct uiDrawBrushGradientStop uiDrawBrushGradientStop; -_UI_ENUM(uiDrawBrushType) { +uiprivEnum(uiDrawBrushType) { uiDrawBrushTypeSolid, uiDrawBrushTypeLinearGradient, uiDrawBrushTypeRadialGradient, uiDrawBrushTypeImage, }; -_UI_ENUM(uiDrawLineCap) { +uiprivEnum(uiDrawLineCap) { uiDrawLineCapFlat, uiDrawLineCapRound, uiDrawLineCapSquare, }; -_UI_ENUM(uiDrawLineJoin) { +uiprivEnum(uiDrawLineJoin) { uiDrawLineJoinMiter, uiDrawLineJoinRound, uiDrawLineJoinBevel, @@ -393,7 +365,7 @@ _UI_ENUM(uiDrawLineJoin) { // so we're good to use it too! #define uiDrawDefaultMiterLimit 10.0 -_UI_ENUM(uiDrawFillMode) { +uiprivEnum(uiDrawFillMode) { uiDrawFillModeWinding, uiDrawFillModeAlternate, }; @@ -456,51 +428,51 @@ struct uiDrawStrokeParams { double DashPhase; }; -_UI_EXTERN uiDrawPath *uiDrawNewPath(uiDrawFillMode fillMode); -_UI_EXTERN void uiDrawFreePath(uiDrawPath *p); +uiprivExtern uiDrawPath *uiDrawNewPath(uiDrawFillMode fillMode); +uiprivExtern void uiDrawFreePath(uiDrawPath *p); -_UI_EXTERN void uiDrawPathNewFigure(uiDrawPath *p, double x, double y); -_UI_EXTERN void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative); -_UI_EXTERN void uiDrawPathLineTo(uiDrawPath *p, double x, double y); +uiprivExtern void uiDrawPathNewFigure(uiDrawPath *p, double x, double y); +uiprivExtern void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative); +uiprivExtern void uiDrawPathLineTo(uiDrawPath *p, double x, double y); // notes: angles are both relative to 0 and go counterclockwise // TODO is the initial line segment on cairo and OS X a proper join? // TODO what if sweep < 0? -_UI_EXTERN void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative); -_UI_EXTERN void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY); +uiprivExtern void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative); +uiprivExtern void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY); // TODO quadratic bezier -_UI_EXTERN void uiDrawPathCloseFigure(uiDrawPath *p); +uiprivExtern void uiDrawPathCloseFigure(uiDrawPath *p); // TODO effect of these when a figure is already started -_UI_EXTERN void uiDrawPathAddRectangle(uiDrawPath *p, double x, double y, double width, double height); +uiprivExtern void uiDrawPathAddRectangle(uiDrawPath *p, double x, double y, double width, double height); -_UI_EXTERN void uiDrawPathEnd(uiDrawPath *p); +uiprivExtern void uiDrawPathEnd(uiDrawPath *p); -_UI_EXTERN void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStrokeParams *p); -_UI_EXTERN void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b); +uiprivExtern void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStrokeParams *p); +uiprivExtern void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b); // TODO primitives: // - rounded rectangles // - elliptical arcs // - quadratic bezier curves -_UI_EXTERN void uiDrawMatrixSetIdentity(uiDrawMatrix *m); -_UI_EXTERN void uiDrawMatrixTranslate(uiDrawMatrix *m, double x, double y); -_UI_EXTERN void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x, double y); -_UI_EXTERN void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount); -_UI_EXTERN void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount); -_UI_EXTERN void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src); -_UI_EXTERN int uiDrawMatrixInvertible(uiDrawMatrix *m); -_UI_EXTERN int uiDrawMatrixInvert(uiDrawMatrix *m); -_UI_EXTERN void uiDrawMatrixTransformPoint(uiDrawMatrix *m, double *x, double *y); -_UI_EXTERN void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y); +uiprivExtern void uiDrawMatrixSetIdentity(uiDrawMatrix *m); +uiprivExtern void uiDrawMatrixTranslate(uiDrawMatrix *m, double x, double y); +uiprivExtern void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x, double y); +uiprivExtern void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount); +uiprivExtern void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount); +uiprivExtern void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src); +uiprivExtern int uiDrawMatrixInvertible(uiDrawMatrix *m); +uiprivExtern int uiDrawMatrixInvert(uiDrawMatrix *m); +uiprivExtern void uiDrawMatrixTransformPoint(uiDrawMatrix *m, double *x, double *y); +uiprivExtern void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y); -_UI_EXTERN void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m); +uiprivExtern void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m); // TODO add a uiDrawPathStrokeToFill() or something like that -_UI_EXTERN void uiDrawClip(uiDrawContext *c, uiDrawPath *path); +uiprivExtern void uiDrawClip(uiDrawContext *c, uiDrawPath *path); -_UI_EXTERN void uiDrawSave(uiDrawContext *c); -_UI_EXTERN void uiDrawRestore(uiDrawContext *c); +uiprivExtern void uiDrawSave(uiDrawContext *c); +uiprivExtern void uiDrawRestore(uiDrawContext *c); // uiAttribute stores information about an attribute in a // uiAttributedString. @@ -521,12 +493,12 @@ typedef struct uiAttribute uiAttribute; // it is an error to call this function on a uiAttribute that has been // given to a uiAttributedString. You can call this, however, if you // created a uiAttribute that you aren't going to use later. -_UI_EXTERN void uiFreeAttribute(uiAttribute *a); +uiprivExtern void uiFreeAttribute(uiAttribute *a); // uiAttributeType holds the possible uiAttribute types that may be // returned by uiAttributeGetType(). Refer to the documentation for // each type's constructor function for details on each type. -_UI_ENUM(uiAttributeType) { +uiprivEnum(uiAttributeType) { uiAttributeTypeFamily, uiAttributeTypeSize, uiAttributeTypeWeight, @@ -541,26 +513,26 @@ _UI_ENUM(uiAttributeType) { // uiAttributeGetType() returns the type of a. // TODO I don't like this name -_UI_EXTERN uiAttributeType uiAttributeGetType(const uiAttribute *a); +uiprivExtern uiAttributeType uiAttributeGetType(const uiAttribute *a); // uiNewFamilyAttribute() creates a new uiAttribute that changes the // font family of the text it is applied to. family is copied; you do not // need to keep it alive after uiNewFamilyAttribute() returns. Font // family names are case-insensitive. -_UI_EXTERN uiAttribute *uiNewFamilyAttribute(const char *family); +uiprivExtern uiAttribute *uiNewFamilyAttribute(const char *family); // uiAttributeFamily() returns the font family stored in a. The // returned string is owned by a. It is an error to call this on a // uiAttribute that does not hold a font family. -_UI_EXTERN const char *uiAttributeFamily(const uiAttribute *a); +uiprivExtern const char *uiAttributeFamily(const uiAttribute *a); // uiNewSizeAttribute() creates a new uiAttribute that changes the // size of the text it is applied to, in typographical points. -_UI_EXTERN uiAttribute *uiNewSizeAttribute(double size); +uiprivExtern uiAttribute *uiNewSizeAttribute(double size); // uiAttributeSize() returns the font size stored in a. It is an error to // call this on a uiAttribute that does not hold a font size. -_UI_EXTERN double uiAttributeSize(const uiAttribute *a); +uiprivExtern double uiAttributeSize(const uiAttribute *a); // uiTextWeight represents possible text weights. These roughly // map to the OS/2 text weight field of TrueType and OpenType @@ -576,7 +548,7 @@ _UI_EXTERN double uiAttributeSize(const uiAttribute *a); // Arial Black. libui does not do this, even on Windows (because the // DirectWrite API libui uses on Windows does not do this); to // specify Arial Black, use family Arial and weight uiTextWeightBlack. -_UI_ENUM(uiTextWeight) { +uiprivEnum(uiTextWeight) { uiTextWeightMinimum = 0, uiTextWeightThin = 100, uiTextWeightUltraLight = 200, @@ -596,18 +568,18 @@ _UI_ENUM(uiTextWeight) { // weight of the text it is applied to. It is an error to specify a weight // outside the range [uiTextWeightMinimum, // uiTextWeightMaximum]. -_UI_EXTERN uiAttribute *uiNewWeightAttribute(uiTextWeight weight); +uiprivExtern uiAttribute *uiNewWeightAttribute(uiTextWeight weight); // uiAttributeWeight() returns the font weight stored in a. It is an error // to call this on a uiAttribute that does not hold a font weight. -_UI_EXTERN uiTextWeight uiAttributeWeight(const uiAttribute *a); +uiprivExtern uiTextWeight uiAttributeWeight(const uiAttribute *a); // uiTextItalic represents possible italic modes for a font. Italic // represents "true" italics where the slanted glyphs have custom // shapes, whereas oblique represents italics that are merely slanted // versions of the normal glyphs. Most fonts usually have one or the // other. -_UI_ENUM(uiTextItalic) { +uiprivEnum(uiTextItalic) { uiTextItalicNormal, uiTextItalicOblique, uiTextItalicItalic, @@ -616,12 +588,12 @@ _UI_ENUM(uiTextItalic) { // uiNewItalicAttribute() creates a new uiAttribute that changes the // italic mode of the text it is applied to. It is an error to specify an // italic mode not specified in uiTextItalic. -_UI_EXTERN uiAttribute *uiNewItalicAttribute(uiTextItalic italic); +uiprivExtern uiAttribute *uiNewItalicAttribute(uiTextItalic italic); // uiAttributeItalic() returns the font italic mode stored in a. It is an // error to call this on a uiAttribute that does not hold a font italic // mode. -_UI_EXTERN uiTextItalic uiAttributeItalic(const uiAttribute *a); +uiprivExtern uiTextItalic uiAttributeItalic(const uiAttribute *a); // uiTextStretch represents possible stretches (also called "widths") // of a font. @@ -633,7 +605,7 @@ _UI_EXTERN uiTextItalic uiAttributeItalic(const uiAttribute *a); // the DirectWrite API libui uses on Windows does not do this); to // specify Arial Condensed, use family Arial and stretch // uiTextStretchCondensed. -_UI_ENUM(uiTextStretch) { +uiprivEnum(uiTextStretch) { uiTextStretchUltraCondensed, uiTextStretchExtraCondensed, uiTextStretchCondensed, @@ -648,30 +620,30 @@ _UI_ENUM(uiTextStretch) { // uiNewStretchAttribute() creates a new uiAttribute that changes the // stretch of the text it is applied to. It is an error to specify a strech // not specified in uiTextStretch. -_UI_EXTERN uiAttribute *uiNewStretchAttribute(uiTextStretch stretch); +uiprivExtern uiAttribute *uiNewStretchAttribute(uiTextStretch stretch); // uiAttributeStretch() returns the font stretch stored in a. It is an // error to call this on a uiAttribute that does not hold a font stretch. -_UI_EXTERN uiTextStretch uiAttributeStretch(const uiAttribute *a); +uiprivExtern uiTextStretch uiAttributeStretch(const uiAttribute *a); // uiNewColorAttribute() creates a new uiAttribute that changes the // color of the text it is applied to. It is an error to specify an invalid // color. -_UI_EXTERN uiAttribute *uiNewColorAttribute(double r, double g, double b, double a); +uiprivExtern uiAttribute *uiNewColorAttribute(double r, double g, double b, double a); // uiAttributeColor() returns the text color stored in a. It is an // error to call this on a uiAttribute that does not hold a text color. -_UI_EXTERN void uiAttributeColor(const uiAttribute *a, double *r, double *g, double *b, double *alpha); +uiprivExtern void uiAttributeColor(const uiAttribute *a, double *r, double *g, double *b, double *alpha); // uiNewBackgroundAttribute() creates a new uiAttribute that // changes the background color of the text it is applied to. It is an // error to specify an invalid color. -_UI_EXTERN uiAttribute *uiNewBackgroundAttribute(double r, double g, double b, double a); +uiprivExtern uiAttribute *uiNewBackgroundAttribute(double r, double g, double b, double a); // TODO reuse uiAttributeColor() for background colors, or make a new function... // uiUnderline specifies a type of underline to use on text. -_UI_ENUM(uiUnderline) { +uiprivEnum(uiUnderline) { uiUnderlineNone, uiUnderlineSingle, uiUnderlineDouble, @@ -681,12 +653,12 @@ _UI_ENUM(uiUnderline) { // uiNewUnderlineAttribute() creates a new uiAttribute that changes // the type of underline on the text it is applied to. It is an error to // specify an underline type not specified in uiUnderline. -_UI_EXTERN uiAttribute *uiNewUnderlineAttribute(uiUnderline u); +uiprivExtern uiAttribute *uiNewUnderlineAttribute(uiUnderline u); // uiAttributeUnderline() returns the underline type stored in a. It is // an error to call this on a uiAttribute that does not hold an underline // style. -_UI_EXTERN uiUnderline uiAttributeUnderline(const uiAttribute *a); +uiprivExtern uiUnderline uiAttributeUnderline(const uiAttribute *a); // uiUnderlineColor specifies the color of any underline on the text it // is applied to, regardless of the type of underline. In addition to @@ -699,7 +671,7 @@ _UI_EXTERN uiUnderline uiAttributeUnderline(const uiAttribute *a); // specified, the text color is used instead. If an underline color // is specified without an underline type, the underline color // attribute is ignored, but not removed from the uiAttributedString. -_UI_ENUM(uiUnderlineColor) { +uiprivEnum(uiUnderlineColor) { uiUnderlineColorCustom, uiUnderlineColorSpelling, uiUnderlineColorGrammar, @@ -714,12 +686,12 @@ _UI_ENUM(uiUnderlineColor) { // If the specified color type is uiUnderlineColorCustom, it is an // error to specify an invalid color value. Otherwise, the color values // are ignored and should be specified as zero. -_UI_EXTERN uiAttribute *uiNewUnderlineColorAttribute(uiUnderlineColor u, double r, double g, double b, double a); +uiprivExtern uiAttribute *uiNewUnderlineColorAttribute(uiUnderlineColor u, double r, double g, double b, double a); // uiAttributeUnderlineColor() returns the underline color stored in // a. It is an error to call this on a uiAttribute that does not hold an // underline color. -_UI_EXTERN void uiAttributeUnderlineColor(const uiAttribute *a, uiUnderlineColor *u, double *r, double *g, double *b, double *alpha); +uiprivExtern void uiAttributeUnderlineColor(const uiAttribute *a, uiUnderlineColor *u, double *r, double *g, double *b, double *alpha); // uiOpenTypeFeatures represents a set of OpenType feature // tag-value pairs, for applying OpenType features to text. @@ -750,26 +722,26 @@ typedef uiForEach (*uiOpenTypeFeaturesForEachFunc)(const uiOpenTypeFeatures *otf // @role uiOpenTypeFeatures constructor // uiNewOpenTypeFeatures() returns a new uiOpenTypeFeatures // instance, with no tags yet added. -_UI_EXTERN uiOpenTypeFeatures *uiNewOpenTypeFeatures(void); +uiprivExtern uiOpenTypeFeatures *uiNewOpenTypeFeatures(void); // @role uiOpenTypeFeatures destructor // uiFreeOpenTypeFeatures() frees otf. -_UI_EXTERN void uiFreeOpenTypeFeatures(uiOpenTypeFeatures *otf); +uiprivExtern void uiFreeOpenTypeFeatures(uiOpenTypeFeatures *otf); // uiOpenTypeFeaturesClone() makes a copy of otf and returns it. // Changing one will not affect the other. -_UI_EXTERN uiOpenTypeFeatures *uiOpenTypeFeaturesClone(const uiOpenTypeFeatures *otf); +uiprivExtern uiOpenTypeFeatures *uiOpenTypeFeaturesClone(const uiOpenTypeFeatures *otf); // uiOpenTypeFeaturesAdd() adds the given feature tag and value // to otf. The feature tag is specified by a, b, c, and d. If there is // already a value associated with the specified tag in otf, the old // value is removed. -_UI_EXTERN void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value); +uiprivExtern void uiOpenTypeFeaturesAdd(uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value); // uiOpenTypeFeaturesRemove() removes the given feature tag // and value from otf. If the tag is not present in otf, // uiOpenTypeFeaturesRemove() does nothing. -_UI_EXTERN void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d); +uiprivExtern void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b, char c, char d); // uiOpenTypeFeaturesGet() determines whether the given feature // tag is present in otf. If it is, *value is set to the tag's value and @@ -783,23 +755,23 @@ _UI_EXTERN void uiOpenTypeFeaturesRemove(uiOpenTypeFeatures *otf, char a, char b // for a feature. You should likewise not treat a missing feature as // having a value of zero either. Instead, a missing feature should // be treated as having some unspecified default value. -_UI_EXTERN int uiOpenTypeFeaturesGet(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t *value); +uiprivExtern int uiOpenTypeFeaturesGet(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t *value); // uiOpenTypeFeaturesForEach() executes f for every tag-value // pair in otf. The enumeration order is unspecified. You cannot // modify otf while uiOpenTypeFeaturesForEach() is running. -_UI_EXTERN void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data); +uiprivExtern void uiOpenTypeFeaturesForEach(const uiOpenTypeFeatures *otf, uiOpenTypeFeaturesForEachFunc f, void *data); // uiNewFeaturesAttribute() creates a new uiAttribute that changes // the font family of the text it is applied to. otf is copied; you may // free it after uiNewFeaturesAttribute() returns. -_UI_EXTERN uiAttribute *uiNewFeaturesAttribute(const uiOpenTypeFeatures *otf); +uiprivExtern uiAttribute *uiNewFeaturesAttribute(const uiOpenTypeFeatures *otf); // uiAttributeFeatures() returns the OpenType features stored in a. // The returned uiOpenTypeFeatures object is owned by a. It is an // error to call this on a uiAttribute that does not hold OpenType // features. -_UI_EXTERN const uiOpenTypeFeatures *uiAttributeFeatures(const uiAttribute *a); +uiprivExtern const uiOpenTypeFeatures *uiAttributeFeatures(const uiAttribute *a); // uiAttributedString represents a string of UTF-8 text that can // optionally be embellished with formatting attributes. libui @@ -849,39 +821,39 @@ typedef uiForEach (*uiAttributedStringForEachAttributeFunc)(const uiAttributedSt // @role uiAttributedString constructor // uiNewAttributedString() creates a new uiAttributedString from // initialString. The string will be entirely unattributed. -_UI_EXTERN uiAttributedString *uiNewAttributedString(const char *initialString); +uiprivExtern uiAttributedString *uiNewAttributedString(const char *initialString); // @role uiAttributedString destructor // uiFreeAttributedString() destroys the uiAttributedString s. // It will also free all uiAttributes within. -_UI_EXTERN void uiFreeAttributedString(uiAttributedString *s); +uiprivExtern void uiFreeAttributedString(uiAttributedString *s); // uiAttributedStringString() returns the textual content of s as a // '\0'-terminated UTF-8 string. The returned pointer is valid until // the next change to the textual content of s. -_UI_EXTERN const char *uiAttributedStringString(const uiAttributedString *s); +uiprivExtern const char *uiAttributedStringString(const uiAttributedString *s); // uiAttributedStringLength() returns the number of UTF-8 bytes in // the textual content of s, excluding the terminating '\0'. -_UI_EXTERN size_t uiAttributedStringLen(const uiAttributedString *s); +uiprivExtern size_t uiAttributedStringLen(const uiAttributedString *s); // uiAttributedStringAppendUnattributed() adds the '\0'-terminated // UTF-8 string str to the end of s. The new substring will be // unattributed. -_UI_EXTERN void uiAttributedStringAppendUnattributed(uiAttributedString *s, const char *str); +uiprivExtern void uiAttributedStringAppendUnattributed(uiAttributedString *s, const char *str); // uiAttributedStringInsertAtUnattributed() adds the '\0'-terminated // UTF-8 string str to s at the byte position specified by at. The new // substring will be unattributed; existing attributes will be moved // along with their text. -_UI_EXTERN void uiAttributedStringInsertAtUnattributed(uiAttributedString *s, const char *str, size_t at); +uiprivExtern void uiAttributedStringInsertAtUnattributed(uiAttributedString *s, const char *str, size_t at); // TODO add the Append and InsertAtExtendingAttributes functions // TODO and add functions that take a string + length // uiAttributedStringDelete() deletes the characters and attributes of // s in the byte range [start, end). -_UI_EXTERN void uiAttributedStringDelete(uiAttributedString *s, size_t start, size_t end); +uiprivExtern void uiAttributedStringDelete(uiAttributedString *s, size_t start, size_t end); // TODO add a function to uiAttributedString to get an attribute's value at a specific index or in a specific range, so we can edit @@ -889,7 +861,7 @@ _UI_EXTERN void uiAttributedStringDelete(uiAttributedString *s, size_t start, si // of s. Any existing attributes in that byte range of the same type are // removed. s takes ownership of a; you should not use it after // uiAttributedStringSetAttribute() returns. -_UI_EXTERN void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttribute *a, size_t start, size_t end); +uiprivExtern void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttribute *a, size_t start, size_t end); // uiAttributedStringForEachAttribute() enumerates all the // uiAttributes in s. It is an error to modify s in f. Within f, s still @@ -897,16 +869,16 @@ _UI_EXTERN void uiAttributedStringSetAttribute(uiAttributedString *s, uiAttribut // use. // TODO reword the above for consistency (TODO and find out what I meant by that) // TODO define an enumeration order (or mark it as undefined); also define how consecutive runs of identical attributes are handled here and sync with the definition of uiAttributedString itself -_UI_EXTERN void uiAttributedStringForEachAttribute(const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data); +uiprivExtern void uiAttributedStringForEachAttribute(const uiAttributedString *s, uiAttributedStringForEachAttributeFunc f, void *data); // TODO const correct this somehow (the implementation needs to mutate the structure) -_UI_EXTERN size_t uiAttributedStringNumGraphemes(uiAttributedString *s); +uiprivExtern size_t uiAttributedStringNumGraphemes(uiAttributedString *s); // TODO const correct this somehow (the implementation needs to mutate the structure) -_UI_EXTERN size_t uiAttributedStringByteIndexToGrapheme(uiAttributedString *s, size_t pos); +uiprivExtern size_t uiAttributedStringByteIndexToGrapheme(uiAttributedString *s, size_t pos); // TODO const correct this somehow (the implementation needs to mutate the structure) -_UI_EXTERN size_t uiAttributedStringGraphemeToByteIndex(uiAttributedString *s, size_t pos); +uiprivExtern size_t uiAttributedStringGraphemeToByteIndex(uiAttributedString *s, size_t pos); // uiFontDescriptor provides a complete description of a font where // one is needed. Currently, this means as the default font of a @@ -939,7 +911,7 @@ typedef struct uiDrawTextLayout uiDrawTextLayout; // uiDrawTextAlign specifies the alignment of lines of text in a // uiDrawTextLayout. // TODO should this really have Draw in the name? -_UI_ENUM(uiDrawTextAlign) { +uiprivEnum(uiDrawTextAlign) { uiDrawTextAlignLeft, uiDrawTextAlignCenter, uiDrawTextAlignRight, @@ -972,22 +944,22 @@ struct uiDrawTextLayoutParams { // - uiDrawTextLayoutRangeForSize() (returns what substring would fit in a given size) // - uiDrawTextLayoutNewWithHeight() (limits amount of string used by the height) // - some function to fix up a range (for text editing) -_UI_EXTERN uiDrawTextLayout *uiDrawNewTextLayout(uiDrawTextLayoutParams *params); +uiprivExtern uiDrawTextLayout *uiDrawNewTextLayout(uiDrawTextLayoutParams *params); // @role uiDrawFreeTextLayout destructor // uiDrawFreeTextLayout() frees tl. The underlying // uiAttributedString is not freed. -_UI_EXTERN void uiDrawFreeTextLayout(uiDrawTextLayout *tl); +uiprivExtern void uiDrawFreeTextLayout(uiDrawTextLayout *tl); // uiDrawText() draws tl in c with the top-left point of tl at (x, y). -_UI_EXTERN void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, double y); +uiprivExtern void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, double y); // uiDrawTextLayoutExtents() returns the width and height of tl // in width and height. The returned width may be smaller than // the width passed into uiDrawNewTextLayout() depending on // how the text in tl is wrapped. Therefore, you can use this // function to get the actual size of the text layout. -_UI_EXTERN void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height); +uiprivExtern void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height); // TODO metrics functions @@ -1000,18 +972,18 @@ typedef struct uiFontButton uiFontButton; // uiFontButtonFont() allocates resources in desc; when you are done with the font, call uiFreeFontButtonFont() to release them. // uiFontButtonFont() does not allocate desc itself; you must do so. // TODO have a function that sets an entire font descriptor to a range in a uiAttributedString at once, for SetFont? -_UI_EXTERN void uiFontButtonFont(uiFontButton *b, uiFontDescriptor *desc); +uiprivExtern void uiFontButtonFont(uiFontButton *b, uiFontDescriptor *desc); // TOOD SetFont, mechanics // uiFontButtonOnChanged() sets the function that is called when the font in the uiFontButton is changed. -_UI_EXTERN void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data); +uiprivExtern void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data); // uiNewFontButton() creates a new uiFontButton. The default font selected into the uiFontButton is OS-defined. -_UI_EXTERN uiFontButton *uiNewFontButton(void); +uiprivExtern uiFontButton *uiNewFontButton(void); // uiFreeFontButtonFont() frees resources allocated in desc by uiFontButtonFont(). // After calling uiFreeFontButtonFont(), the contents of desc should be assumed to be undefined (though since you allocate desc itself, you can safely reuse desc for other font descriptors). // Calling uiFreeFontButtonFont() on a uiFontDescriptor not returned by uiFontButtonFont() results in undefined behavior. -_UI_EXTERN void uiFreeFontButtonFont(uiFontDescriptor *desc); +uiprivExtern void uiFreeFontButtonFont(uiFontDescriptor *desc); -_UI_ENUM(uiModifiers) { +uiprivEnum(uiModifiers) { uiModifierCtrl = 1 << 0, uiModifierAlt = 1 << 1, uiModifierShift = 1 << 2, @@ -1038,7 +1010,7 @@ struct uiAreaMouseEvent { uint64_t Held1To64; }; -_UI_ENUM(uiExtKey) { +uiprivEnum(uiExtKey) { uiExtKeyEscape = 1, uiExtKeyInsert, // equivalent to "Help" on Apple keyboards uiExtKeyDelete, @@ -1092,27 +1064,27 @@ struct uiAreaKeyEvent { typedef struct uiColorButton uiColorButton; #define uiColorButton(this) ((uiColorButton *) (this)) -_UI_EXTERN void uiColorButtonColor(uiColorButton *b, double *r, double *g, double *bl, double *a); -_UI_EXTERN void uiColorButtonSetColor(uiColorButton *b, double r, double g, double bl, double a); -_UI_EXTERN void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data); -_UI_EXTERN uiColorButton *uiNewColorButton(void); +uiprivExtern void uiColorButtonColor(uiColorButton *b, double *r, double *g, double *bl, double *a); +uiprivExtern void uiColorButtonSetColor(uiColorButton *b, double r, double g, double bl, double a); +uiprivExtern void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data); +uiprivExtern uiColorButton *uiNewColorButton(void); typedef struct uiForm uiForm; #define uiForm(this) ((uiForm *) (this)) -_UI_EXTERN void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy); -_UI_EXTERN void uiFormDelete(uiForm *f, int index); -_UI_EXTERN int uiFormPadded(uiForm *f); -_UI_EXTERN void uiFormSetPadded(uiForm *f, int padded); -_UI_EXTERN uiForm *uiNewForm(void); +uiprivExtern void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy); +uiprivExtern void uiFormDelete(uiForm *f, int index); +uiprivExtern int uiFormPadded(uiForm *f); +uiprivExtern void uiFormSetPadded(uiForm *f, int padded); +uiprivExtern uiForm *uiNewForm(void); -_UI_ENUM(uiAlign) { +uiprivEnum(uiAlign) { uiAlignFill, uiAlignStart, uiAlignCenter, uiAlignEnd, }; -_UI_ENUM(uiAt) { +uiprivEnum(uiAt) { uiAtLeading, uiAtTop, uiAtTrailing, @@ -1121,11 +1093,11 @@ _UI_ENUM(uiAt) { typedef struct uiGrid uiGrid; #define uiGrid(this) ((uiGrid *) (this)) -_UI_EXTERN void uiGridAppend(uiGrid *g, uiControl *c, int left, int top, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign); -_UI_EXTERN void uiGridInsertAt(uiGrid *g, uiControl *c, uiControl *existing, uiAt at, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign); -_UI_EXTERN int uiGridPadded(uiGrid *g); -_UI_EXTERN void uiGridSetPadded(uiGrid *g, int padded); -_UI_EXTERN uiGrid *uiNewGrid(void); +uiprivExtern void uiGridAppend(uiGrid *g, uiControl *c, int left, int top, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign); +uiprivExtern void uiGridInsertAt(uiGrid *g, uiControl *c, uiControl *existing, uiAt at, int xspan, int yspan, int hexpand, uiAlign halign, int vexpand, uiAlign valign); +uiprivExtern int uiGridPadded(uiGrid *g); +uiprivExtern void uiGridSetPadded(uiGrid *g, int padded); +uiprivExtern uiGrid *uiNewGrid(void); // uiImage stores an image for display on screen. // @@ -1154,11 +1126,11 @@ typedef struct uiImage uiImage; // height. This width and height should be the size in points of the // image in the device-independent case; typically this is the 1x size. // TODO for all uiImage functions: use const void * for const correctness -_UI_EXTERN uiImage *uiNewImage(double width, double height); +uiprivExtern uiImage *uiNewImage(double width, double height); // @role uiImage destructor // uiFreeImage frees the given image and all associated resources. -_UI_EXTERN void uiFreeImage(uiImage *i); +uiprivExtern void uiFreeImage(uiImage *i); // uiImageAppend adds a representation to the uiImage. // pixels should point to a byte array of premultiplied pixels @@ -1168,7 +1140,7 @@ _UI_EXTERN void uiFreeImage(uiImage *i); // the number *of bytes* per row of the pixels array. Therefore, // pixels itself must be at least byteStride * pixelHeight bytes long. // TODO see if we either need the stride or can provide a way to get the OS-preferred stride (in cairo we do) -_UI_EXTERN void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int byteStride); +uiprivExtern void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int byteStride); // uiTableValue stores a value to be passed along uiTable and // uiTableModel. @@ -1190,13 +1162,13 @@ typedef struct uiTableValue uiTableValue; // however, if you created a uiTableValue that you aren't going to // use later, or if you called a uiTableModelHandler method directly // and thus never transferred ownership of the uiTableValue. -_UI_EXTERN void uiFreeTableValue(uiTableValue *v); +uiprivExtern void uiFreeTableValue(uiTableValue *v); // uiTableValueType holds the possible uiTableValue types that may // be returned by uiTableValueGetType(). Refer to the documentation // for each type's constructor function for details on each type. // TODO actually validate these -_UI_ENUM(uiTableValueType) { +uiprivEnum(uiTableValueType) { uiTableValueTypeString, uiTableValueTypeImage, uiTableValueTypeInt, @@ -1205,17 +1177,17 @@ _UI_ENUM(uiTableValueType) { // uiTableValueGetType() returns the type of v. // TODO I don't like this name -_UI_EXTERN uiTableValueType uiTableValueGetType(const uiTableValue *v); +uiprivExtern uiTableValueType uiTableValueGetType(const uiTableValue *v); // uiNewTableValueString() returns a new uiTableValue that contains // str. str is copied; you do not need to keep it alive after // uiNewTableValueString() returns. -_UI_EXTERN uiTableValue *uiNewTableValueString(const char *str); +uiprivExtern uiTableValue *uiNewTableValueString(const char *str); // uiTableValueString() returns the string stored in v. The returned // string is owned by v. It is an error to call this on a uiTableValue // that does not hold a string. -_UI_EXTERN const char *uiTableValueString(const uiTableValue *v); +uiprivExtern const char *uiTableValueString(const uiTableValue *v); // uiNewTableValueImage() returns a new uiTableValue that contains // the given uiImage. @@ -1227,33 +1199,33 @@ _UI_EXTERN const char *uiTableValueString(const uiTableValue *v); // As a general rule, if libui calls a uiTableModelHandler method, the // uiImage is safe to free once any of your code is once again // executed. -_UI_EXTERN uiTableValue *uiNewTableValueImage(uiImage *img); +uiprivExtern uiTableValue *uiNewTableValueImage(uiImage *img); // uiTableValueImage() returns the uiImage stored in v. As these // images are not owned by v, you should not assume anything // about the lifetime of the image (unless you created the image, // and thus control its lifetime). It is an error to call this on a // uiTableValue that does not hold an image. -_UI_EXTERN uiImage *uiTableValueImage(const uiTableValue *v); +uiprivExtern uiImage *uiTableValueImage(const uiTableValue *v); // uiNewTableValueInt() returns a uiTableValue that stores the given // int. This can be used both for boolean values (nonzero is true, as // in C) or progresses (in which case the valid range is -1..100 // inclusive). -_UI_EXTERN uiTableValue *uiNewTableValueInt(int i); +uiprivExtern uiTableValue *uiNewTableValueInt(int i); // uiTableValueInt() returns the int stored in v. It is an error to call // this on a uiTableValue that does not store an int. -_UI_EXTERN int uiTableValueInt(const uiTableValue *v); +uiprivExtern int uiTableValueInt(const uiTableValue *v); // uiNewTableValueColor() returns a uiTableValue that stores the // given color. -_UI_EXTERN uiTableValue *uiNewTableValueColor(double r, double g, double b, double a); +uiprivExtern uiTableValue *uiNewTableValueColor(double r, double g, double b, double a); // uiTableValueColor() returns the color stored in v. It is an error to // call this on a uiTableValue that does not store a color. // TODO define whether all this, for both uiTableValue and uiAttribute, is undefined behavior or a caught error -_UI_EXTERN void uiTableValueColor(const uiTableValue *v, double *r, double *g, double *b, double *a); +uiprivExtern void uiTableValueColor(const uiTableValue *v, double *r, double *g, double *b, double *a); // uiTableModel is an object that provides the data for a uiTable. // This data is returned via methods you provide in the @@ -1317,25 +1289,25 @@ struct uiTableModelHandler { // @role uiTableModel constructor // uiNewTableModel() creates a new uiTableModel with the given // handler methods. -_UI_EXTERN uiTableModel *uiNewTableModel(uiTableModelHandler *mh); +uiprivExtern uiTableModel *uiNewTableModel(uiTableModelHandler *mh); // @role uiTableModel destructor // uiFreeTableModel() frees the given table model. It is an error to // free table models currently associated with a uiTable. -_UI_EXTERN void uiFreeTableModel(uiTableModel *m); +uiprivExtern void uiFreeTableModel(uiTableModel *m); // uiTableModelRowInserted() tells any uiTable associated with m // that a new row has been added to m at index index. You call // this function when the number of rows in your model has // changed; after calling it, NumRows() should returm the new row // count. -_UI_EXTERN void uiTableModelRowInserted(uiTableModel *m, int newIndex); +uiprivExtern void uiTableModelRowInserted(uiTableModel *m, int newIndex); // uiTableModelRowChanged() tells any uiTable associated with m // that the data in the row at index has changed. You do not need to // call this in your SetCellValue() handlers, but you do need to call // this if your data changes at some other point. -_UI_EXTERN void uiTableModelRowChanged(uiTableModel *m, int index); +uiprivExtern void uiTableModelRowChanged(uiTableModel *m, int index); // uiTableModelRowDeleted() tells any uiTable associated with m // that the row at index index has been deleted. You call this @@ -1343,7 +1315,7 @@ _UI_EXTERN void uiTableModelRowChanged(uiTableModel *m, int index); // after calling it, NumRows() should returm the new row // count. // TODO for this and Inserted: make sure the "after" part is right; clarify if it's after returning or after calling -_UI_EXTERN void uiTableModelRowDeleted(uiTableModel *m, int oldIndex); +uiprivExtern void uiTableModelRowDeleted(uiTableModel *m, int oldIndex); // TODO reordering/moving // uiTableModelColumnNeverEditable and @@ -1395,7 +1367,7 @@ typedef struct uiTable uiTable; // textModelColumn is where the text comes from. // If a row is editable according to textEditableModelColumn, // SetCellValue() is called with textModelColumn as the column. -_UI_EXTERN void uiTableAppendTextColumn(uiTable *t, +uiprivExtern void uiTableAppendTextColumn(uiTable *t, const char *name, int textModelColumn, int textEditableModelColumn, @@ -1404,13 +1376,13 @@ _UI_EXTERN void uiTableAppendTextColumn(uiTable *t, // uiTableAppendImageColumn() appends an image column to t. // Images are drawn at icon size, appropriate to the pixel density // of the screen showing the uiTable. -_UI_EXTERN void uiTableAppendImageColumn(uiTable *t, +uiprivExtern void uiTableAppendImageColumn(uiTable *t, const char *name, int imageModelColumn); // uiTableAppendImageTextColumn() appends a column to t that // shows both an image and text. -_UI_EXTERN void uiTableAppendImageTextColumn(uiTable *t, +uiprivExtern void uiTableAppendImageTextColumn(uiTable *t, const char *name, int imageModelColumn, int textModelColumn, @@ -1421,14 +1393,14 @@ _UI_EXTERN void uiTableAppendImageTextColumn(uiTable *t, // contains a checkbox that the user can interact with (assuming the // checkbox is editable). SetCellValue() will be called with // checkboxModelColumn as the column in this case. -_UI_EXTERN void uiTableAppendCheckboxColumn(uiTable *t, +uiprivExtern void uiTableAppendCheckboxColumn(uiTable *t, const char *name, int checkboxModelColumn, int checkboxEditableModelColumn); // uiTableAppendCheckboxTextColumn() appends a column to t // that contains both a checkbox and text. -_UI_EXTERN void uiTableAppendCheckboxTextColumn(uiTable *t, +uiprivExtern void uiTableAppendCheckboxTextColumn(uiTable *t, const char *name, int checkboxModelColumn, int checkboxEditableModelColumn, @@ -1440,7 +1412,7 @@ _UI_EXTERN void uiTableAppendCheckboxTextColumn(uiTable *t, // that displays a progress bar. These columns work like // uiProgressBar: a cell value of 0..100 displays that percentage, and // a cell value of -1 displays an indeterminate progress bar. -_UI_EXTERN void uiTableAppendProgressBarColumn(uiTable *t, +uiprivExtern void uiTableAppendProgressBarColumn(uiTable *t, const char *name, int progressModelColumn); @@ -1450,16 +1422,10 @@ _UI_EXTERN void uiTableAppendProgressBarColumn(uiTable *t, // value and buttonModelColumn as the column. // CellValue() on buttonModelColumn should return the text to show // in the button. -_UI_EXTERN void uiTableAppendButtonColumn(uiTable *t, +uiprivExtern void uiTableAppendButtonColumn(uiTable *t, const char *name, int buttonModelColumn, int buttonClickableModelColumn); // uiNewTable() creates a new uiTable with the specified parameters. -_UI_EXTERN uiTable *uiNewTable(uiTableParams *params); - -#ifdef __cplusplus -} -#endif - -#endif +uiprivExtern uiTable *uiNewTable(uiTableParams *params); diff --git a/zOLD_ui_darwin.h b/zOLD_ui_darwin.h index c9c6ad54..9bfa849c 100644 --- a/zOLD_ui_darwin.h +++ b/zOLD_ui_darwin.h @@ -1,16 +1,3 @@ -// 7 april 2015 - -/* -This file assumes that you have imported and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Mac OS X. -*/ - -#ifndef __LIBUI_UI_DARWIN_H__ -#define __LIBUI_UI_DARWIN_H__ - -#ifdef __cplusplus -extern "C" { -#endif - typedef struct uiDarwinControl uiDarwinControl; struct uiDarwinControl { uiControl c; @@ -28,14 +15,14 @@ struct uiDarwinControl { }; #define uiDarwinControl(this) ((uiDarwinControl *) (this)) // TODO document -_UI_EXTERN void uiDarwinControlSyncEnableState(uiDarwinControl *, int); -_UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *); -_UI_EXTERN BOOL uiDarwinControlHugsTrailingEdge(uiDarwinControl *); -_UI_EXTERN BOOL uiDarwinControlHugsBottom(uiDarwinControl *); -_UI_EXTERN void uiDarwinControlChildEdgeHuggingChanged(uiDarwinControl *); -_UI_EXTERN NSLayoutPriority uiDarwinControlHuggingPriority(uiDarwinControl *, NSLayoutConstraintOrientation); -_UI_EXTERN void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation); -_UI_EXTERN void uiDarwinControlChildVisibilityChanged(uiDarwinControl *); +uiprivExtern void uiDarwinControlSyncEnableState(uiDarwinControl *, int); +uiprivExtern void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *); +uiprivExtern BOOL uiDarwinControlHugsTrailingEdge(uiDarwinControl *); +uiprivExtern BOOL uiDarwinControlHugsBottom(uiDarwinControl *); +uiprivExtern void uiDarwinControlChildEdgeHuggingChanged(uiDarwinControl *); +uiprivExtern NSLayoutPriority uiDarwinControlHuggingPriority(uiDarwinControl *, NSLayoutConstraintOrientation); +uiprivExtern void uiDarwinControlSetHuggingPriority(uiDarwinControl *, NSLayoutPriority, NSLayoutConstraintOrientation); +uiprivExtern void uiDarwinControlChildVisibilityChanged(uiDarwinControl *); #define uiDarwinControlDefaultDestroy(type, handlefield) \ static void type ## Destroy(uiControl *c) \ @@ -197,28 +184,22 @@ _UI_EXTERN void uiDarwinControlChildVisibilityChanged(uiDarwinControl *); uiDarwinControl(var)->visible = YES; \ uiDarwinControl(var)->enabled = YES; // TODO document -_UI_EXTERN uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *typenamestr); +uiprivExtern uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *typenamestr); // Use this function as a shorthand for setting control fonts. -_UI_EXTERN void uiDarwinSetControlFont(NSControl *c, NSControlSize size); +uiprivExtern void uiDarwinSetControlFont(NSControl *c, NSControlSize size); // You can use this function from within your control implementations to return text strings that can be freed with uiFreeText(). -_UI_EXTERN char *uiDarwinNSStringToText(NSString *); +uiprivExtern char *uiDarwinNSStringToText(NSString *); // TODO document -_UI_EXTERN BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL); +uiprivExtern BOOL uiDarwinShouldStopSyncEnableState(uiDarwinControl *, BOOL); // TODO document -_UI_EXTERN void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *); -_UI_EXTERN void uiDarwinNotifyVisibilityChanged(uiDarwinControl *c); +uiprivExtern void uiDarwinNotifyEdgeHuggingChanged(uiDarwinControl *); +uiprivExtern void uiDarwinNotifyVisibilityChanged(uiDarwinControl *c); // TODO document // TODO document that values should not be cached -_UI_EXTERN CGFloat uiDarwinMarginAmount(void *reserved); -_UI_EXTERN CGFloat uiDarwinPaddingAmount(void *reserved); - -#ifdef __cplusplus -} -#endif - -#endif +uiprivExtern CGFloat uiDarwinMarginAmount(void *reserved); +uiprivExtern CGFloat uiDarwinPaddingAmount(void *reserved); diff --git a/zOLD_ui_unix.h b/zOLD_ui_unix.h index ed019260..ca0a204c 100644 --- a/zOLD_ui_unix.h +++ b/zOLD_ui_unix.h @@ -1,16 +1,3 @@ -// 7 april 2015 - -/* -This file assumes that you have included and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls on Unix systems that use GTK+ to provide their UI (currently all except Mac OS X). -*/ - -#ifndef __LIBUI_UI_UNIX_H__ -#define __LIBUI_UI_UNIX_H__ - -#ifdef __cplusplus -extern "C" { -#endif - typedef struct uiUnixControl uiUnixControl; struct uiUnixControl { uiControl c; @@ -21,7 +8,7 @@ struct uiUnixControl { }; #define uiUnixControl(this) ((uiUnixControl *) (this)) // TODO document -_UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean); +uiprivExtern void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gboolean); #define uiUnixControlDefaultDestroy(type) \ static void type ## Destroy(uiControl *c) \ @@ -132,13 +119,7 @@ _UI_EXTERN void uiUnixControlSetContainer(uiUnixControl *, GtkContainer *, gbool uiControl(var)->Disable = type ## Disable; \ uiUnixControl(var)->SetContainer = type ## SetContainer; // TODO document -_UI_EXTERN uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr); +uiprivExtern uiUnixControl *uiUnixAllocControl(size_t n, uint32_t typesig, const char *typenamestr); // uiUnixStrdupText() takes the given string and produces a copy of it suitable for being freed by uiFreeText(). -_UI_EXTERN char *uiUnixStrdupText(const char *); - -#ifdef __cplusplus -} -#endif - -#endif +uiprivExtern char *uiUnixStrdupText(const char *); diff --git a/zOLD_ui_windows.h b/zOLD_ui_windows.h index 69dda366..89815a1d 100644 --- a/zOLD_ui_windows.h +++ b/zOLD_ui_windows.h @@ -1,16 +1,3 @@ -// 21 april 2016 - -/* -This file assumes that you have included and "ui.h" beforehand. It provides API-specific functions for interfacing with foreign controls in Windows. -*/ - -#ifndef __LIBUI_UI_WINDOWS_H__ -#define __LIBUI_UI_WINDOWS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - typedef struct uiWindowsSizing uiWindowsSizing; typedef struct uiWindowsControl uiWindowsControl; @@ -30,13 +17,13 @@ struct uiWindowsControl { }; #define uiWindowsControl(this) ((uiWindowsControl *) (this)) // TODO document -_UI_EXTERN void uiWindowsControlSyncEnableState(uiWindowsControl *, int); -_UI_EXTERN void uiWindowsControlSetParentHWND(uiWindowsControl *, HWND); -_UI_EXTERN void uiWindowsControlMinimumSize(uiWindowsControl *, int *, int *); -_UI_EXTERN void uiWindowsControlMinimumSizeChanged(uiWindowsControl *); -_UI_EXTERN void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *); -_UI_EXTERN void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *); -_UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *); +uiprivExtern void uiWindowsControlSyncEnableState(uiWindowsControl *, int); +uiprivExtern void uiWindowsControlSetParentHWND(uiWindowsControl *, HWND); +uiprivExtern void uiWindowsControlMinimumSize(uiWindowsControl *, int *, int *); +uiprivExtern void uiWindowsControlMinimumSizeChanged(uiWindowsControl *); +uiprivExtern void uiWindowsControlLayoutRect(uiWindowsControl *, RECT *); +uiprivExtern void uiWindowsControlAssignControlIDZOrder(uiWindowsControl *, LONG_PTR *, HWND *); +uiprivExtern void uiWindowsControlChildVisibilityChanged(uiWindowsControl *); // TODO document #define uiWindowsControlDefaultDestroy(type) \ @@ -187,51 +174,51 @@ _UI_EXTERN void uiWindowsControlChildVisibilityChanged(uiWindowsControl *); uiWindowsControl(var)->visible = 1; \ uiWindowsControl(var)->enabled = 1; // TODO document -_UI_EXTERN uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr); +uiprivExtern uiWindowsControl *uiWindowsAllocControl(size_t n, uint32_t typesig, const char *typenamestr); // TODO document -_UI_EXTERN HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont); +uiprivExtern HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont); // TODO document -_UI_EXTERN void uiWindowsEnsureDestroyWindow(HWND hwnd); +uiprivExtern void uiWindowsEnsureDestroyWindow(HWND hwnd); // TODO document // TODO document that this should only be used in SetParentHWND() implementations -_UI_EXTERN void uiWindowsEnsureSetParentHWND(HWND hwnd, HWND parent); +uiprivExtern void uiWindowsEnsureSetParentHWND(HWND hwnd, HWND parent); // TODO document -_UI_EXTERN void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR *controlID, HWND *insertAfter); +uiprivExtern void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR *controlID, HWND *insertAfter); // TODO document -_UI_EXTERN void uiWindowsEnsureGetClientRect(HWND hwnd, RECT *r); -_UI_EXTERN void uiWindowsEnsureGetWindowRect(HWND hwnd, RECT *r); +uiprivExtern void uiWindowsEnsureGetClientRect(HWND hwnd, RECT *r); +uiprivExtern void uiWindowsEnsureGetWindowRect(HWND hwnd, RECT *r); // TODO document -_UI_EXTERN char *uiWindowsWindowText(HWND hwnd); -_UI_EXTERN void uiWindowsSetWindowText(HWND hwnd, const char *text); +uiprivExtern char *uiWindowsWindowText(HWND hwnd); +uiprivExtern void uiWindowsSetWindowText(HWND hwnd, const char *text); // TODO document -_UI_EXTERN int uiWindowsWindowTextWidth(HWND hwnd); +uiprivExtern int uiWindowsWindowTextWidth(HWND hwnd); // TODO document // TODO point out this should only be used in a resize cycle -_UI_EXTERN void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, int x, int y, int width, int height); +uiprivExtern void uiWindowsEnsureMoveWindowDuringResize(HWND hwnd, int x, int y, int width, int height); // TODO document -_UI_EXTERN void uiWindowsRegisterWM_COMMANDHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c); -_UI_EXTERN void uiWindowsUnregisterWM_COMMANDHandler(HWND hwnd); +uiprivExtern void uiWindowsRegisterWM_COMMANDHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c); +uiprivExtern void uiWindowsUnregisterWM_COMMANDHandler(HWND hwnd); // TODO document -_UI_EXTERN void uiWindowsRegisterWM_NOTIFYHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *c); -_UI_EXTERN void uiWindowsUnregisterWM_NOTIFYHandler(HWND hwnd); +uiprivExtern void uiWindowsRegisterWM_NOTIFYHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, NMHDR *, LRESULT *), uiControl *c); +uiprivExtern void uiWindowsUnregisterWM_NOTIFYHandler(HWND hwnd); // TODO document -_UI_EXTERN void uiWindowsRegisterWM_HSCROLLHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c); -_UI_EXTERN void uiWindowsUnregisterWM_HSCROLLHandler(HWND hwnd); +uiprivExtern void uiWindowsRegisterWM_HSCROLLHandler(HWND hwnd, BOOL (*handler)(uiControl *, HWND, WORD, LRESULT *), uiControl *c); +uiprivExtern void uiWindowsUnregisterWM_HSCROLLHandler(HWND hwnd); // TODO document -_UI_EXTERN void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd); -_UI_EXTERN void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd); +uiprivExtern void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd); +uiprivExtern void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd); // TODO document typedef struct uiWindowsSizing uiWindowsSizing; @@ -240,28 +227,22 @@ struct uiWindowsSizing { int BaseY; LONG InternalLeading; }; -_UI_EXTERN void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing); -_UI_EXTERN void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y); -_UI_EXTERN void uiWindowsSizingStandardPadding(uiWindowsSizing *sizing, int *x, int *y); +uiprivExtern void uiWindowsGetSizing(HWND hwnd, uiWindowsSizing *sizing); +uiprivExtern void uiWindowsSizingDlgUnitsToPixels(uiWindowsSizing *sizing, int *x, int *y); +uiprivExtern void uiWindowsSizingStandardPadding(uiWindowsSizing *sizing, int *x, int *y); // TODO document -_UI_EXTERN HWND uiWindowsMakeContainer(uiWindowsControl *c, void (*onResize)(uiWindowsControl *)); +uiprivExtern HWND uiWindowsMakeContainer(uiWindowsControl *c, void (*onResize)(uiWindowsControl *)); // TODO document -_UI_EXTERN BOOL uiWindowsControlTooSmall(uiWindowsControl *c); -_UI_EXTERN void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c); +uiprivExtern BOOL uiWindowsControlTooSmall(uiWindowsControl *c); +uiprivExtern void uiWindowsControlContinueMinimumSizeChanged(uiWindowsControl *c); // TODO document -_UI_EXTERN void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *); +uiprivExtern void uiWindowsControlAssignSoleControlIDZOrder(uiWindowsControl *); // TODO document -_UI_EXTERN BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled); +uiprivExtern BOOL uiWindowsShouldStopSyncEnableState(uiWindowsControl *c, int enabled); // TODO document -_UI_EXTERN void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c); - -#ifdef __cplusplus -} -#endif - -#endif +uiprivExtern void uiWindowsControlNotifyVisibilityChanged(uiWindowsControl *c);