Tue, 29 Oct 2024 11:52:01 +0100
improve window close handling
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
4 | * Copyright 2017 Olaf Wintermann. All rights reserved. |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #ifndef UI_BUTTON_H |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #define UI_BUTTON_H |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #include "toolkit.h" |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #ifdef __cplusplus |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | extern "C" { |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #endif |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
37 | |
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
38 | typedef struct UiButtonArgs { |
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
39 | UiTri fill; |
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
40 | UiBool hexpand; |
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
41 | UiBool vexpand; |
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
42 | int colspan; |
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
43 | int rowspan; |
313
b679cc6059ab
add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
230
diff
changeset
|
44 | const char *name; |
b679cc6059ab
add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
230
diff
changeset
|
45 | const char *style_class; |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
46 | |
187
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
47 | const char* label; |
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
48 | const char* stockid; |
230
4f5b32a2a60f
add icon parameter for buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
201
diff
changeset
|
49 | const char* icon; |
4f5b32a2a60f
add icon parameter for buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
201
diff
changeset
|
50 | UiLabelType labeltype; |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
51 | ui_callback onclick; |
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
52 | void* onclickdata; |
343
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
53 | |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
54 | const int* groups; |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
55 | } UiButtonArgs; |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
57 | typedef struct UiToggleArgs { |
187
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
58 | UiTri fill; |
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
59 | UiBool hexpand; |
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
60 | UiBool vexpand; |
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
61 | int colspan; |
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
62 | int rowspan; |
313
b679cc6059ab
add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
230
diff
changeset
|
63 | const char *name; |
b679cc6059ab
add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
230
diff
changeset
|
64 | const char *style_class; |
b679cc6059ab
add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
230
diff
changeset
|
65 | |
187
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
66 | const char* label; |
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
67 | const char* stockid; |
230
4f5b32a2a60f
add icon parameter for buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
201
diff
changeset
|
68 | const char* icon; |
4f5b32a2a60f
add icon parameter for buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
201
diff
changeset
|
69 | UiLabelType labeltype; |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
70 | UiInteger* value; |
187
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
71 | const char* varname; |
189
4daddc326877
add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
188
diff
changeset
|
72 | ui_callback onchange; |
4daddc326877
add onchange event for toggle buttons (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
188
diff
changeset
|
73 | void* onchangedata; |
359
c51e58359db8
add option to automatically enable states with toggle buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
343
diff
changeset
|
74 | int enable_group; |
343
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
75 | |
54f5d7eb1335
implement widget groups for buttons (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
313
diff
changeset
|
76 | const int* groups; |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
77 | } UiToggleArgs; |
313
b679cc6059ab
add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
230
diff
changeset
|
78 | |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
79 | #define ui_button(obj, ...) ui_button_create(obj, (UiButtonArgs){ __VA_ARGS__ } ) |
187
24ce2c326d85
implement toggle button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
186
diff
changeset
|
80 | #define ui_togglebutton(obj, ...) ui_togglebutton_create(obj, (UiToggleArgs){ __VA_ARGS__ } ) |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
81 | #define ui_checkbox(obj, ...) ui_checkbox_create(obj, (UiToggleArgs){ __VA_ARGS__ } ) |
191
6113ed66d258
add toggle switch (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
189
diff
changeset
|
82 | #define ui_switch(obj, ...) ui_switch_create(obj, (UiToggleArgs){ __VA_ARGS__ } ) |
188
fbbae6738252
implement radio button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
187
diff
changeset
|
83 | #define ui_radiobutton(obj, ...) ui_radiobutton_create(obj, (UiToggleArgs){ __VA_ARGS__ } ) |
94
d51e334c1439
added checkbox and labels with alignment (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
4
diff
changeset
|
84 | |
201
7f67ebbb0c1c
add UIEXPORT macro to create a dll
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
191
diff
changeset
|
85 | UIEXPORT UIWIDGET ui_button_create(UiObject* obj, UiButtonArgs args); |
7f67ebbb0c1c
add UIEXPORT macro to create a dll
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
191
diff
changeset
|
86 | UIEXPORT UIWIDGET ui_togglebutton_create(UiObject* obj, UiToggleArgs args); |
7f67ebbb0c1c
add UIEXPORT macro to create a dll
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
191
diff
changeset
|
87 | UIEXPORT UIWIDGET ui_checkbox_create(UiObject* obj, UiToggleArgs args); |
7f67ebbb0c1c
add UIEXPORT macro to create a dll
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
191
diff
changeset
|
88 | UIEXPORT UIWIDGET ui_switch_create(UiObject* obj, UiToggleArgs args); |
7f67ebbb0c1c
add UIEXPORT macro to create a dll
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
191
diff
changeset
|
89 | UIEXPORT UIWIDGET ui_radiobutton_create(UiObject* obj, UiToggleArgs args); |
186
5db4979bf482
implement new api style for ui_button (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
142
diff
changeset
|
90 | |
107
9aff1dc3990d
improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
94
diff
changeset
|
91 | |
4
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | #ifdef __cplusplus |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | } |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | #endif |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | #endif /* UI_BUTTON_H */ |
39b9b86ec452
added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 |