add UIEXPORT macro to create a dll newapi

Tue, 03 Oct 2023 16:30:42 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 03 Oct 2023 16:30:42 +0200
branch
newapi
changeset 201
7f67ebbb0c1c
parent 200
f40dadf3498f
child 202
9f309d1914a2

add UIEXPORT macro to create a dll

ui/ui/button.h file | annotate | diff | comparison | revisions
ui/ui/container.h file | annotate | diff | comparison | revisions
ui/ui/menu.h file | annotate | diff | comparison | revisions
ui/ui/text.h file | annotate | diff | comparison | revisions
ui/ui/toolkit.h file | annotate | diff | comparison | revisions
ui/ui/tree.h file | annotate | diff | comparison | revisions
ui/ui/window.h file | annotate | diff | comparison | revisions
ui/winui/toolkit.h file | annotate | diff | comparison | revisions
ui/winui/winui.vcxproj file | annotate | diff | comparison | revisions
--- a/ui/ui/button.h	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/ui/button.h	Tue Oct 03 16:30:42 2023 +0200
@@ -69,11 +69,11 @@
 #define ui_switch(obj, ...) ui_switch_create(obj, (UiToggleArgs){ __VA_ARGS__ } )
 #define ui_radiobutton(obj, ...) ui_radiobutton_create(obj, (UiToggleArgs){ __VA_ARGS__ } )
 
-UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs args);
-UIWIDGET ui_togglebutton_create(UiObject* obj, UiToggleArgs args);
-UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs args);
-UIWIDGET ui_switch_create(UiObject* obj, UiToggleArgs args);
-UIWIDGET ui_radiobutton_create(UiObject* obj, UiToggleArgs args);
+UIEXPORT UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs args);
+UIEXPORT UIWIDGET ui_togglebutton_create(UiObject* obj, UiToggleArgs args);
+UIEXPORT UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs args);
+UIEXPORT UIWIDGET ui_switch_create(UiObject* obj, UiToggleArgs args);
+UIEXPORT UIWIDGET ui_radiobutton_create(UiObject* obj, UiToggleArgs args);
 
 
 
--- a/ui/ui/container.h	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/ui/container.h	Tue Oct 03 16:30:42 2023 +0200
@@ -123,49 +123,49 @@
 
 #define ui_tab(obj, label) for(ui_tab_create(obj, label);ui_container_finish(obj);ui_container_begin_close(obj))
 
-void ui_end(UiObject *obj);
+UIEXPORT void ui_end(UiObject *obj);
     
-UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs args);
-UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args);
-UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args);
-UIWIDGET ui_frame_create(UiObject* obj, UiFrameArgs args);
-UIWIDGET ui_expander_create(UiObject* obj, UiFrameArgs args);
-UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args);
-UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args);
+UIEXPORT UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs args);
+UIEXPORT UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args);
+UIEXPORT UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args);
+UIEXPORT UIWIDGET ui_frame_create(UiObject* obj, UiFrameArgs args);
+UIEXPORT UIWIDGET ui_expander_create(UiObject* obj, UiFrameArgs args);
+UIEXPORT UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args);
+UIEXPORT UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args);
 
-void ui_tab_create(UiObject* obj, const char* title);
+UIEXPORT void ui_tab_create(UiObject* obj, const char* title);
 
-UIWIDGET ui_scrolledwindow_deprecated(UiObject *obj);
+UIEXPORT UIWIDGET ui_scrolledwindow_deprecated(UiObject *obj);
 
-UIWIDGET ui_sidebar(UiObject *obj);
+UIEXPORT UIWIDGET ui_sidebar(UiObject *obj);
 
-UIWIDGET ui_hsplitpane(UiObject *obj, int max);
-UIWIDGET ui_vsplitpane(UiObject *obj, int max);
+UIEXPORT UIWIDGET ui_hsplitpane(UiObject *obj, int max);
+UIEXPORT UIWIDGET ui_vsplitpane(UiObject *obj, int max);
 
-UIWIDGET ui_tabview_deprecated(UiObject *obj);
+UIEXPORT UIWIDGET ui_tabview_deprecated(UiObject *obj);
 
-void ui_select_tab(UIWIDGET tabview, int tab);
+UIEXPORT void ui_select_tab(UIWIDGET tabview, int tab);
 
 // box container layout functions
-void ui_layout_fill(UiObject *obj, UiBool fill);
+UIEXPORT void ui_layout_fill(UiObject *obj, UiBool fill);
 // grid container layout functions
-void ui_layout_hexpand(UiObject *obj, UiBool expand);
-void ui_layout_vexpand(UiObject *obj, UiBool expand);
-void ui_layout_width(UiObject *obj, int width);
-void ui_layout_height(UiObject* obj, int width);
-void ui_layout_colspan(UiObject *obj, int cols);
-void ui_layout_rowspan(UiObject* obj, int rows);
-void ui_newline(UiObject *obj);
+UIEXPORT void ui_layout_hexpand(UiObject *obj, UiBool expand);
+UIEXPORT void ui_layout_vexpand(UiObject *obj, UiBool expand);
+UIEXPORT void ui_layout_width(UiObject *obj, int width);
+UIEXPORT void ui_layout_height(UiObject* obj, int width);
+UIEXPORT void ui_layout_colspan(UiObject *obj, int cols);
+UIEXPORT void ui_layout_rowspan(UiObject* obj, int rows);
+UIEXPORT void ui_newline(UiObject *obj);
 
 
-UiTabbedPane* ui_tabbed_document_view(UiObject *obj);
+UIEXPORT UiTabbedPane* ui_tabbed_document_view(UiObject *obj);
 
-UiObject* ui_document_tab(UiTabbedPane *view);
+UIEXPORT UiObject* ui_document_tab(UiTabbedPane *view);
 
 
 /* used for macro */
-void ui_container_begin_close(UiObject *obj);
-int ui_container_finish(UiObject *obj);
+UIEXPORT void ui_container_begin_close(UiObject *obj);
+UIEXPORT int ui_container_finish(UiObject *obj);
 
 #define UI_APPLY_LAYOUT1(obj, args) \
     if(args.fill != UI_DEFAULT) ui_layout_fill(obj, args.fill == UI_ON ? 1 : 0 ); \
--- a/ui/ui/menu.h	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/ui/menu.h	Tue Oct 03 16:30:42 2023 +0200
@@ -38,33 +38,33 @@
 /*
  * application menu functions
  */
-void ui_menu(char *label);
-void ui_submenu(char *label);
-void ui_submenu_end();
+UIEXPORT void ui_menu(char *label);
+UIEXPORT void ui_submenu(char *label);
+UIEXPORT void ui_submenu_end();
 
-void ui_menuitem(char *label, ui_callback f, void *userdata);
-void ui_menuitem_st(char *stockid, ui_callback f, void *userdata);
-void ui_menuitem_gr(char *label, ui_callback f, void *userdata, ...);
-void ui_menuitem_stgr(char *stockid, ui_callback f, void *userdata, ...);
+UIEXPORT void ui_menuitem(char *label, ui_callback f, void *userdata);
+UIEXPORT void ui_menuitem_st(char *stockid, ui_callback f, void *userdata);
+UIEXPORT void ui_menuitem_gr(char *label, ui_callback f, void *userdata, ...);
+UIEXPORT void ui_menuitem_stgr(char *stockid, ui_callback f, void *userdata, ...);
 
-void ui_menuseparator();
+UIEXPORT void ui_menuseparator();
 
-void ui_checkitem(char *label, ui_callback f, void *userdata);
-void ui_checkitem_nv(char *label, char *vname);
+UIEXPORT void ui_checkitem(char *label, ui_callback f, void *userdata);
+UIEXPORT void ui_checkitem_nv(char *label, char *vname);
 
-void ui_menuitem_list(UiList *items, ui_callback f, void *userdata);
+UIEXPORT void ui_menuitem_list(UiList *items, ui_callback f, void *userdata);
 
 /*
  * widget menu functions
  */
-UIMENU ui_contextmenu(UiObject *obj);
-UIMENU ui_contextmenu_w(UiObject *obj, UIWIDGET widget);
-void ui_contextmenu_popup(UIMENU menu);
+UIEXPORT UIMENU ui_contextmenu(UiObject *obj);
+UIEXPORT UIMENU ui_contextmenu_w(UiObject *obj, UIWIDGET widget);
+UIEXPORT void ui_contextmenu_popup(UIMENU menu);
 
-void ui_widget_menuitem(UiObject *obj, char *label, ui_callback f, void *userdata);
-void ui_widget_menuitem_st(UiObject *obj, char *stockid, ui_callback f, void *userdata);
-void ui_widget_menuitem_gr(UiObject *obj, char *label, ui_callback f, void *userdata, ...);
-void ui_widget_menuitem_stgr(UiObject *obj, char *stockid, ui_callback f, void *userdata, ...);
+UIEXPORT void ui_widget_menuitem(UiObject *obj, char *label, ui_callback f, void *userdata);
+UIEXPORT void ui_widget_menuitem_st(UiObject *obj, char *stockid, ui_callback f, void *userdata);
+UIEXPORT void ui_widget_menuitem_gr(UiObject *obj, char *label, ui_callback f, void *userdata, ...);
+UIEXPORT void ui_widget_menuitem_stgr(UiObject *obj, char *stockid, ui_callback f, void *userdata, ...);
 
 #ifdef	__cplusplus
 }
--- a/ui/ui/text.h	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/ui/text.h	Tue Oct 03 16:30:42 2023 +0200
@@ -61,9 +61,9 @@
 #define ui_frameless_textfield(obj, ...) ui_frameless_field_create(obj, (UiTextFieldArgs) { __VA_ARGS__ })
 #define ui_passwordfield(obj, ...) ui_passwordfield_create(obj, (UiTextFieldArgs) { __VA_ARGS__ })
 
-UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args);
-UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args);
-UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args);
+UIEXPORT UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args);
+UIEXPORT UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args);
+UIEXPORT UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args);
         
 #ifdef	__cplusplus
 }
--- a/ui/ui/toolkit.h	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/ui/toolkit.h	Tue Oct 03 16:30:42 2023 +0200
@@ -69,6 +69,8 @@
 
 #elif UI_WINUI
 
+#define UIEXPORT __declspec(dllexport) 
+
 #ifdef __cplusplus
 
 #include <Windows.h>
@@ -346,85 +348,85 @@
 };
 
 
-void ui_init(const char *appname, int argc, char **argv);
-const char* ui_appname();
+UIEXPORT void ui_init(const char *appname, int argc, char **argv);
+UIEXPORT const char* ui_appname();
 
-UiContext* ui_global_context(void);
+UIEXPORT UiContext* ui_global_context(void);
 
-void ui_context_closefunc(UiContext *ctx, ui_callback fnc, void *udata);
+UIEXPORT void ui_context_closefunc(UiContext *ctx, ui_callback fnc, void *udata);
 
-void ui_onstartup(ui_callback f, void *userdata);
-void ui_onopen(ui_callback f, void *userdata);
-void ui_onexit(ui_callback f, void *userdata);
+UIEXPORT void ui_onstartup(ui_callback f, void *userdata);
+UIEXPORT void ui_onopen(ui_callback f, void *userdata);
+UIEXPORT void ui_onexit(ui_callback f, void *userdata);
 
-void ui_main();
-void ui_show(UiObject *obj);
-void ui_close(UiObject *obj);
+UIEXPORT void ui_main();
+UIEXPORT void ui_show(UiObject *obj);
+UIEXPORT void ui_close(UiObject *obj);
 
-void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd);
+UIEXPORT void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd);
 
-void* ui_document_new(size_t size);
-void  ui_document_destroy(void *doc);
+UIEXPORT void* ui_document_new(size_t size);
+UIEXPORT void  ui_document_destroy(void *doc);
 
-void ui_set_document(UiObject *obj, void *document);    // deprecated
-void ui_detach_document(UiObject *obj);                 // deprecated
-void* ui_get_document(UiObject *obj);                   // deprecated
-void ui_set_subdocument(void *document, void *sub);     // deprecated
-void ui_detach_subdocument(void *document, void *sub);  // deprecated
-void* ui_get_subdocument(void *document);               // deprecated
+UIEXPORT void ui_set_document(UiObject *obj, void *document);    // deprecated
+UIEXPORT void ui_detach_document(UiObject *obj);                 // deprecated
+UIEXPORT void* ui_get_document(UiObject *obj);                   // deprecated
+UIEXPORT void ui_set_subdocument(void *document, void *sub);     // deprecated
+UIEXPORT void ui_detach_subdocument(void *document, void *sub);  // deprecated
+UIEXPORT void* ui_get_subdocument(void *document);               // deprecated
 
-UiContext* ui_document_context(void *doc);
+UIEXPORT UiContext* ui_document_context(void *doc);
 
-void ui_attach_document(UiContext *ctx, void *document);
-void ui_detach_document2(UiContext *ctx, void *document);
+UIEXPORT void ui_attach_document(UiContext *ctx, void *document);
+UIEXPORT void ui_detach_document2(UiContext *ctx, void *document);
 
-void ui_widget_set_groups(UiContext *ctx, UIWIDGET widget, ui_enablefunc enable, ...);
+UIEXPORT void ui_widget_set_groups(UiContext *ctx, UIWIDGET widget, ui_enablefunc enable, ...);
 
-void ui_set_group(UiContext *ctx, int group);
-void ui_unset_group(UiContext *ctx, int group);
-int* ui_active_groups(UiContext *ctx, int *ngroups);
+UIEXPORT void ui_set_group(UiContext *ctx, int group);
+UIEXPORT void ui_unset_group(UiContext *ctx, int group);
+UIEXPORT int* ui_active_groups(UiContext *ctx, int *ngroups);
     
-void* ui_malloc(UiContext *ctx, size_t size);
-void* ui_calloc(UiContext *ctx, size_t nelem, size_t elsize);
-void  ui_free(UiContext *ctx, void *ptr);
-void* ui_realloc(UiContext *ctx, void *ptr, size_t size);
+UIEXPORT void* ui_malloc(UiContext *ctx, size_t size);
+UIEXPORT void* ui_calloc(UiContext *ctx, size_t nelem, size_t elsize);
+UIEXPORT void  ui_free(UiContext *ctx, void *ptr);
+UIEXPORT void* ui_realloc(UiContext *ctx, void *ptr, size_t size);
 
 // types
 
-UiInteger* ui_int_new(UiContext *ctx, char *name);
-UiDouble* ui_double_new(UiContext *ctx, char *name);
-UiString* ui_string_new(UiContext *ctx, char *name);
-UiText* ui_text_new(UiContext *ctx, char *name);
-UiRange* ui_range_new(UiContext *ctx, char *name);
+UIEXPORT UiInteger* ui_int_new(UiContext *ctx, char *name);
+UIEXPORT UiDouble* ui_double_new(UiContext *ctx, char *name);
+UIEXPORT UiString* ui_string_new(UiContext *ctx, char *name);
+UIEXPORT UiText* ui_text_new(UiContext *ctx, char *name);
+UIEXPORT UiRange* ui_range_new(UiContext *ctx, char *name);
 
-UiObserver* ui_observer_new(ui_callback f, void *data);
-UiObserver* ui_obsvlist_add(UiObserver *list, UiObserver *observer);
-UiObserver* ui_add_observer(UiObserver *list, ui_callback f, void *data);
-void ui_notify(UiObserver *observer, void *data);
-void ui_notify_except(UiObserver *observer, UiObserver *exc, void *data);
-void ui_notify_evt(UiObserver *observer, UiEvent *event);
+UIEXPORT UiObserver* ui_observer_new(ui_callback f, void *data);
+UIEXPORT UiObserver* ui_obsvlist_add(UiObserver *list, UiObserver *observer);
+UIEXPORT UiObserver* ui_add_observer(UiObserver *list, ui_callback f, void *data);
+UIEXPORT void ui_notify(UiObserver *observer, void *data);
+UIEXPORT void ui_notify_except(UiObserver *observer, UiObserver *exc, void *data);
+UIEXPORT void ui_notify_evt(UiObserver *observer, UiEvent *event);
 
 
-UiList* ui_list_new(UiContext *ctx, char *name);
-void* ui_list_first(UiList *list);
-void* ui_list_next(UiList *list);
-void* ui_list_get(UiList *list, int i);
-int   ui_list_count(UiList *list);
-void  ui_list_append(UiList *list, void *data);
-void  ui_list_prepend(UiList *list, void *data);
-void ui_list_clear(UiList *list);
-void  ui_list_addobsv(UiList *list, ui_callback f, void *data);
-void  ui_list_notify(UiList *list);
+UIEXPORT UiList* ui_list_new(UiContext *ctx, char *name);
+UIEXPORT void* ui_list_first(UiList *list);
+UIEXPORT void* ui_list_next(UiList *list);
+UIEXPORT void* ui_list_get(UiList *list, int i);
+UIEXPORT int   ui_list_count(UiList *list);
+UIEXPORT void  ui_list_append(UiList *list, void *data);
+UIEXPORT void  ui_list_prepend(UiList *list, void *data);
+UIEXPORT void ui_list_clear(UiList *list);
+UIEXPORT void  ui_list_addobsv(UiList *list, ui_callback f, void *data);
+UIEXPORT void  ui_list_notify(UiList *list);
 
-void ui_clipboard_set(char *str);
-char* ui_clipboard_get();
+UIEXPORT void ui_clipboard_set(char *str);
+UIEXPORT char* ui_clipboard_get();
 
-void ui_add_image(char *imgname, char *filename); // TODO: remove?
+UIEXPORT void ui_add_image(char *imgname, char *filename); // TODO: remove?
 
 // general widget functions
-void ui_set_enabled(UIWIDGET widget, int enabled);
-void ui_set_show_all(UIWIDGET widget, int value);
-void ui_set_visible(UIWIDGET widget, int visible);
+UIEXPORT void ui_set_enabled(UIWIDGET widget, int enabled);
+UIEXPORT void ui_set_show_all(UIWIDGET widget, int value);
+UIEXPORT void ui_set_visible(UIWIDGET widget, int visible);
 
 
 #ifdef	__cplusplus
--- a/ui/ui/tree.h	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/ui/tree.h	Tue Oct 03 16:30:42 2023 +0200
@@ -128,16 +128,16 @@
     UiBool multiselection;
 };
 
-UiModel* ui_model(UiContext *ctx, ...);
-void ui_model_free(UiContext *ctx, UiModel *mi);
+UIEXPORT UiModel* ui_model(UiContext *ctx, ...);
+UIEXPORT void ui_model_free(UiContext *ctx, UiModel *mi);
 
 #define ui_listview(obj, ...) ui_listview_create(obj, (UiListArgs) { __VA_ARGS__ } )
 #define ui_table(obj, ...) ui_table_create(obj, (UiListArgs) { __VA_ARGS__ } )
 #define ui_combobox(obj, ...) ui_combobox_create(obj, (UiListArgs) { __VA_ARGS__ } )
 
-UIWIDGET ui_listview_create(UiObject* obj, UiListArgs args);
-UIWIDGET ui_table_create(UiObject* obj, UiListArgs args);
-UIWIDGET ui_combobox_create(UiObject* obj, UiListArgs);
+UIEXPORT UIWIDGET ui_listview_create(UiObject* obj, UiListArgs args);
+UIEXPORT UIWIDGET ui_table_create(UiObject* obj, UiListArgs args);
+UIEXPORT UIWIDGET ui_combobox_create(UiObject* obj, UiListArgs);
 
 UIWIDGET ui_listview_deprecated(UiObject *obj, UiList *list, ui_getvaluefunc getvalue, ui_callback f, void *udata);
 UIWIDGET ui_listview_str_deprecated(UiObject *obj, UiList *list, ui_callback f, void *udata);
--- a/ui/ui/window.h	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/ui/window.h	Tue Oct 03 16:30:42 2023 +0200
@@ -35,8 +35,8 @@
 extern "C" {
 #endif
 
-UiObject* ui_window(const char *title, void *window_data);
-UiObject* ui_simplewindow(char *title, void *window_data);
+UIEXPORT UiObject* ui_window(const char *title, void *window_data);
+UIEXPORT UiObject* ui_simplewindow(char *title, void *window_data);
 
 char* ui_openfiledialog(UiObject *obj);
 char* ui_savefiledialog(UiObject *obj);
--- a/ui/winui/toolkit.h	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/winui/toolkit.h	Tue Oct 03 16:30:42 2023 +0200
@@ -28,7 +28,6 @@
 
 #pragma once
 
-#define UIEXPORT extern "C" __declspec(dllexport) 
 #include "../ui/toolkit.h"
 
 typedef void(*ui_eventfunc)(void*, void*);
--- a/ui/winui/winui.vcxproj	Tue Oct 03 15:32:46 2023 +0200
+++ b/ui/winui/winui.vcxproj	Tue Oct 03 16:30:42 2023 +0200
@@ -46,7 +46,7 @@
     <CharacterSet>Unicode</CharacterSet>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
-    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <PlatformToolset>v143</PlatformToolset>
     <CharacterSet>Unicode</CharacterSet>

mercurial