1 /* |
1 /* |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 * |
3 * |
4 * Copyright 2014 Olaf Wintermann. All rights reserved. |
4 * Copyright 2017 Olaf Wintermann. All rights reserved. |
5 * |
5 * |
6 * Redistribution and use in source and binary forms, with or without |
6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are met: |
7 * modification, are permitted provided that the following conditions are met: |
8 * |
8 * |
9 * 1. Redistributions of source code must retain the above copyright |
9 * 1. Redistributions of source code must retain the above copyright |
41 typedef struct UiVar UiVar; |
41 typedef struct UiVar UiVar; |
42 typedef struct UiListPtr UiListPtr; |
42 typedef struct UiListPtr UiListPtr; |
43 typedef struct UiListVar UiListVar; |
43 typedef struct UiListVar UiListVar; |
44 typedef struct UiGroupWidget UiGroupWidget; |
44 typedef struct UiGroupWidget UiGroupWidget; |
45 |
45 |
|
46 typedef enum UiVarType UiVarType; |
|
47 |
|
48 enum UiVarType { |
|
49 UI_VAR_SPECIAL = 0, |
|
50 UI_VAR_INTEGER, |
|
51 UI_VAR_STRING, |
|
52 UI_VAR_TEXT, |
|
53 UI_VAR_LIST, |
|
54 UI_VAR_RANGE |
|
55 }; |
|
56 |
46 struct UiContext { |
57 struct UiContext { |
47 UiContext *parent; |
58 UiContext *parent; |
48 UiObject *obj; |
59 UiObject *obj; |
49 UcxMempool *mempool; |
60 UcxMempool *mempool; |
|
61 UcxMap *bound; // key: char* value: UiVar* |
50 UcxMap *vars; // key: char* value: UiVar* |
62 UcxMap *vars; // key: char* value: UiVar* |
51 void *document; |
63 void *document; |
52 UcxList *groups; // int list |
64 UcxList *groups; // int list |
53 UcxList *group_widgets; // UiGroupWidget* list |
65 UcxList *group_widgets; // UiGroupWidget* list |
54 |
66 |
55 void (*set_document)(UiContext *ctx, void *document); |
67 void (*set_document)(UiContext *ctx, void *document); |
56 void (*detach_document)(UiContext *ctx, void *document); |
68 void (*detach_document)(UiContext *ctx); |
57 |
69 |
58 char *title; |
70 char *title; |
59 |
71 |
60 #ifdef UI_GTK |
72 #ifdef UI_GTK |
61 GtkAccelGroup *accel_group; |
73 GtkAccelGroup *accel_group; |
64 ui_callback close_callback; |
76 ui_callback close_callback; |
65 void *close_data; |
77 void *close_data; |
66 }; |
78 }; |
67 |
79 |
68 struct UiVar { |
80 struct UiVar { |
69 void *value; |
81 void *value; |
70 int type; |
82 void *orig_val; |
71 int isextern; |
83 UiVarType type; |
72 UcxMap *from; |
84 UiVar *from; |
73 }; |
|
74 |
|
75 struct UiListPtr { |
|
76 UiList *list; |
|
77 }; |
|
78 |
|
79 struct UiListVar { |
|
80 UiListPtr *listptr; |
|
81 }; |
85 }; |
82 |
86 |
83 struct UiGroupWidget { |
87 struct UiGroupWidget { |
84 UIWIDGET widget; |
88 UIWIDGET widget; |
85 int *groups; |
89 int *groups; |
86 int numgroups; |
90 int numgroups; |
87 }; |
91 }; |
88 |
92 |
89 enum UiVarType { |
|
90 UI_VAR_INTEGER = 0, |
|
91 UI_VAR_STRING, |
|
92 UI_VAR_TEXT, |
|
93 UI_VAR_LIST |
|
94 }; |
|
95 |
93 |
96 UiContext* uic_context(UiObject *toplevel, UcxMempool *mp); |
94 UiContext* uic_context(UiObject *toplevel, UcxMempool *mp); |
97 UiContext* uic_root_context(UiContext *ctx); |
95 UiContext* uic_root_context(UiContext *ctx); |
98 void uic_context_set_document(UiContext *ctx, void *document); |
96 void uic_context_set_document(UiContext *ctx, void *document); |
99 void uic_context_detach_document(UiContext *ctx, void *document); |
97 void uic_context_detach_document(UiContext *ctx); |
100 |
98 |
101 UiVar* uic_get_var(UiContext *ctx, char *name); |
99 //UiVar* uic_get_var(UiContext *ctx, char *name); |
102 UiVar* uic_connect_var(UiContext *ctx, char *name, int type); |
100 UiVar* uic_create_var(UiContext *ctx, char *name, UiVarType type); |
103 void uic_move_var(UiVar *from, UiVar *to, UiBool set); |
101 void* uic_create_value(UiContext *ctx, UiVarType type); |
104 void uic_reg_var(UiContext *ctx, char *name, int type, size_t vs, void *value); |
|
105 void uic_add_var( |
|
106 UiContext *ctx, |
|
107 char *name, |
|
108 UiVar *newvar, |
|
109 int type, |
|
110 size_t vs); |
|
111 |
102 |
112 void* uic_create_value(UcxAllocator *a, int type); |
103 void uic_copy_binding(UiVar *from, UiVar *to, UiBool copytodoc); |
|
104 void uic_unbind_var(UiVar *var); |
|
105 |
|
106 void uic_reg_var(UiContext *ctx, char *name, UiVarType type, void *value); |
|
107 |
|
108 void uic_remove_bound_var(UiContext *ctx, UiVar *var); |
113 |
109 |
114 void uic_check_group_widgets(UiContext *ctx); |
110 void uic_check_group_widgets(UiContext *ctx); |
115 void uic_add_group_widget(UiContext *ctx, void *widget, UcxList *groups); |
111 void uic_add_group_widget(UiContext *ctx, void *widget, UcxList *groups); |
116 |
112 |
117 |
113 |