|
1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
3 * |
|
4 * Copyright 2017 Olaf Wintermann. All rights reserved. |
|
5 * |
|
6 * Redistribution and use in source and binary forms, with or without |
|
7 * modification, are permitted provided that the following conditions are met: |
|
8 * |
|
9 * 1. Redistributions of source code must retain the above copyright |
|
10 * notice, this list of conditions and the following disclaimer. |
|
11 * |
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
|
13 * notice, this list of conditions and the following disclaimer in the |
|
14 * documentation and/or other materials provided with the distribution. |
|
15 * |
|
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
26 * POSSIBILITY OF SUCH DAMAGE. |
|
27 */ |
|
28 |
|
29 #ifndef UI_TEXT_H |
|
30 #define UI_TEXT_H |
|
31 |
|
32 #include "toolkit.h" |
|
33 |
|
34 #ifdef __cplusplus |
|
35 extern "C" { |
|
36 #endif |
|
37 |
|
38 typedef struct UiTextFieldArgs { |
|
39 UiTri fill; |
|
40 UiBool hexpand; |
|
41 UiBool vexpand; |
|
42 int colspan; |
|
43 int rowspan; |
|
44 int width; |
|
45 |
|
46 UiString* value; |
|
47 const char* varname; |
|
48 ui_callback onchange; |
|
49 void* onchangedata; |
|
50 } UiTextFieldArgs; |
|
51 |
|
52 typedef struct UiPathElmRet { |
|
53 char* name; |
|
54 size_t name_len; |
|
55 char* path; |
|
56 size_t path_len; |
|
57 } UiPathElm; |
|
58 |
|
59 typedef UiPathElm*(*ui_pathelm_func)(const char *full_path, size_t len, size_t *ret_nelm, void* data); |
|
60 |
|
61 |
|
62 |
|
63 typedef struct UiPathTextFieldArgs { |
|
64 UiTri fill; |
|
65 UiBool hexpand; |
|
66 UiBool vexpand; |
|
67 int colspan; |
|
68 int rowspan; |
|
69 |
|
70 UiString *value; |
|
71 const char* varname; |
|
72 |
|
73 ui_pathelm_func getpathelm; |
|
74 void* getpathelmdata; |
|
75 |
|
76 ui_callback onactivate; |
|
77 void* onactivatedata; |
|
78 |
|
79 ui_callback ondragstart; |
|
80 void* ondragstartdata; |
|
81 ui_callback ondragcomplete; |
|
82 void* ondragcompletedata; |
|
83 ui_callback ondrop; |
|
84 void* ondropsdata; |
|
85 } UiPathTextFieldArgs; |
|
86 |
|
87 UIWIDGET ui_textarea(UiObject *obj, UiText *value); |
|
88 UIWIDGET ui_textarea_nv(UiObject *obj, char *varname); |
|
89 |
|
90 UIWIDGET ui_textarea_gettextwidget(UIWIDGET textarea); |
|
91 |
|
92 void ui_text_undo(UiText *value); |
|
93 void ui_text_redo(UiText *value); |
|
94 |
|
95 #define ui_textfield(obj, ...) ui_textfield_create(obj, (UiTextFieldArgs) { __VA_ARGS__ }) |
|
96 #define ui_frameless_textfield(obj, ...) ui_frameless_field_create(obj, (UiTextFieldArgs) { __VA_ARGS__ }) |
|
97 #define ui_passwordfield(obj, ...) ui_passwordfield_create(obj, (UiTextFieldArgs) { __VA_ARGS__ }) |
|
98 #define ui_path_textfield(obj, ...) ui_path_textfield_create(obj, (UiPathTextFieldArgs) { __VA_ARGS__ } ) |
|
99 |
|
100 UIEXPORT UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args); |
|
101 UIEXPORT UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args); |
|
102 UIEXPORT UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args); |
|
103 |
|
104 UIEXPORT UIWIDGET ui_path_textfield_create(UiObject* obj, UiPathTextFieldArgs args); |
|
105 |
|
106 #ifdef __cplusplus |
|
107 } |
|
108 #endif |
|
109 |
|
110 #endif /* UI_TEXT_H */ |
|
111 |