ui/ui/text.h

Tue, 29 Oct 2024 10:43:59 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 29 Oct 2024 10:43:59 +0100
branch
newapi
changeset 366
799c8f60b9f1
parent 356
eae98e4f3f1f
permissions
-rw-r--r--

fix replace close_request signal on gtk3

5
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 121
diff changeset
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
5
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19d37cb9c96c added textarea
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
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #ifndef UI_TEXT_H
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #define UI_TEXT_H
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "toolkit.h"
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #ifdef __cplusplus
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 extern "C" {
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #endif
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
38 typedef struct UiTextAreaArgs {
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
39 UiTri fill;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
40 UiBool hexpand;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
41 UiBool vexpand;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
42 int colspan;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
43 int rowspan;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
44 int width;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
45 const char *name;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
46 const char *style_class;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
47
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
48 UiText *value;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
49 const char *varname;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
50 ui_callback onchange;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
51 void *onchangedata;
356
eae98e4f3f1f add support for groups/states to text, list widgets (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
52
eae98e4f3f1f add support for groups/states to text, list widgets (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
53 const int *groups;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
54 } UiTextAreaArgs;
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
55
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
56 typedef struct UiTextFieldArgs {
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
57 UiTri fill;
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
58 UiBool hexpand;
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
59 UiBool vexpand;
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
60 int colspan;
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
61 int rowspan;
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
62 int width;
313
b679cc6059ab add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
63 const char *name;
b679cc6059ab add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
64 const char *style_class;
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
65
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
66 UiString* value;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
67 const char *varname;
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
68 ui_callback onchange;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
69 void *onchangedata;
356
eae98e4f3f1f add support for groups/states to text, list widgets (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
70
eae98e4f3f1f add support for groups/states to text, list widgets (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 335
diff changeset
71 const int *groups;
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
72 } UiTextFieldArgs;
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
73
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
74 typedef struct UiPathElmRet {
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
75 char *name;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
76 size_t name_len;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
77 char *path;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
78 size_t path_len;
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
79 } UiPathElm;
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
80
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
81 typedef UiPathElm*(*ui_pathelm_func)(const char *full_path, size_t len, size_t *ret_nelm, void *data);
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
82
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
83
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
84
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
85 typedef struct UiPathTextFieldArgs {
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
86 UiTri fill;
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
87 UiBool hexpand;
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
88 UiBool vexpand;
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
89 int colspan;
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
90 int rowspan;
313
b679cc6059ab add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
91 const char *name;
b679cc6059ab add option to name widgets and add css classes (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 267
diff changeset
92 const char *style_class;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
93
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
94 UiString *value;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
95 const char *varname;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
96
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
97 ui_pathelm_func getpathelm;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
98 void *getpathelmdata;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
99
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
100 ui_callback onactivate;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
101 void *onactivatedata;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
102
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
103 ui_callback ondragstart;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
104 void *ondragstartdata;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
105 ui_callback ondragcomplete;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
106 void *ondragcompletedata;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
107 ui_callback ondrop;
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
108 void *ondropsdata;
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
109 } UiPathTextFieldArgs;
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
110
335
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
111 #define ui_textarea(obj, ...) ui_textarea_create(obj, (UiTextAreaArgs) { __VA_ARGS__ })
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
112
91d4f0391282 add new textarea (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 313
diff changeset
113 UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs args);
5
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114
168
1b99acacc5bb refactor widget groups
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
115 UIWIDGET ui_textarea_gettextwidget(UIWIDGET textarea);
1b99acacc5bb refactor widget groups
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
116
6
05a18c56d9ca added undo for text
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
117 void ui_text_undo(UiText *value);
05a18c56d9ca added undo for text
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 5
diff changeset
118 void ui_text_redo(UiText *value);
5
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119
192
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
120 #define ui_textfield(obj, ...) ui_textfield_create(obj, (UiTextFieldArgs) { __VA_ARGS__ })
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
121 #define ui_frameless_textfield(obj, ...) ui_frameless_field_create(obj, (UiTextFieldArgs) { __VA_ARGS__ })
bcacd00ea955 implement textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 168
diff changeset
122 #define ui_passwordfield(obj, ...) ui_passwordfield_create(obj, (UiTextFieldArgs) { __VA_ARGS__ })
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
123 #define ui_path_textfield(obj, ...) ui_path_textfield_create(obj, (UiPathTextFieldArgs) { __VA_ARGS__ } )
107
9aff1dc3990d improved box container and added radio button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 94
diff changeset
124
201
7f67ebbb0c1c add UIEXPORT macro to create a dll
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 192
diff changeset
125 UIEXPORT UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args);
7f67ebbb0c1c add UIEXPORT macro to create a dll
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 192
diff changeset
126 UIEXPORT UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args);
7f67ebbb0c1c add UIEXPORT macro to create a dll
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 192
diff changeset
127 UIEXPORT UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args);
225
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
128
097f45f9c1fa add new path textfield (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 201
diff changeset
129 UIEXPORT UIWIDGET ui_path_textfield_create(UiObject* obj, UiPathTextFieldArgs args);
121
1cc365c34125 added some special textfields (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 107
diff changeset
130
5
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 #ifdef __cplusplus
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 }
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 #endif
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 #endif /* UI_TEXT_H */
19d37cb9c96c added textarea
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136

mercurial