1 /**
2  *
3  * $Id: TextP.h,v 1.1 2004/08/28 19:23:26 dannybackx Exp $
4  *
5  * Copyright (C) 1995 Free Software Foundation, Inc.
6  * Copyright (C) 1995-2001 LessTif Development Team
7  *
8  * This file is part of the GNU LessTif Library.
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the Free
22  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  **/
25 
26 #ifndef _XM_TEXTP_H
27 #define _XM_TEXTP_H
28 
29 #include <Xm/PrimitiveP.h>
30 #include <Xm/Text.h>
31 #include <Xm/TextOutP.h>
32 #include <Xm/TextInP.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct _InputRec *Input;
39 typedef struct _OutputRec *Output;
40 
41 #define MAXINT	INT_MAX
42 #define NODELTA	MAXINT
43 #define TEXTWIDGETCLASS	"Text"
44 
45 #define GetSrc(widget)	(((XmTextWidget)(widget))->text.source)
46 
47 typedef struct {
48     XmTextPosition start;
49     Boolean changed;
50     XmTextPosition changed_position;
51     Boolean past_end;
52     LineTableExtra extra;
53 } LineRec, *Line;
54 
55 typedef struct _XmTextLineTableRec {
56     unsigned int start_pos : 31,
57 		 virt_line : 1;
58 } XmTextLineTableRec, *XmTextLineTable;
59 
60 typedef struct {
61     XmTextPosition from, to;
62 } RangeRec;
63 
64 typedef struct {
65     Cardinal number;
66     Cardinal maximum;
67     RangeRec *range;
68 } Ranges;
69 
70 typedef struct {
71     XmTextSource source;
72     XtCallbackList activate_callback;
73     XtCallbackList focus_callback;
74     XtCallbackList losing_focus_callback;
75     XtCallbackList value_changed_callback;
76     XtCallbackList modify_verify_callback;
77     XtCallbackList wcs_modify_verify_callback;
78     XtCallbackList motion_verify_callback;
79     XtCallbackList gain_primary_callback;
80     XtCallbackList lose_primary_callback;
81 
82     char *value;
83     wchar_t *wc_value;
84     Dimension margin_height;
85     Dimension margin_width;
86     Dimension cursor_position_x;
87 
88     OutputCreateProc output_create;
89     InputCreateProc input_create;
90 
91     XmTextPosition top_character;
92     XmTextPosition bottom_position;
93     XmTextPosition cursor_position;
94     int max_length;
95     int edit_mode;
96 
97     Boolean auto_show_cursor_position;
98     Boolean editable;
99     Boolean verify_bell;
100     Boolean add_mode;
101     Boolean traversed;
102     Boolean in_redisplay;
103     Boolean needs_redisplay;
104     Boolean in_refigure_lines;
105     Boolean needs_refigure_lines;
106     Boolean in_setvalues;
107     Boolean in_resize;
108     Boolean in_expose;
109     Boolean highlight_changed;
110     Boolean pendingoff;
111 
112     char char_size;
113     OnOrOff on_or_off;
114 
115     Output output;
116     Input input;
117 
118     XmTextPosition first_position;
119     XmTextPosition last_position;
120     XmTextPosition forget_past;
121     XmTextPosition force_display;
122     XmTextPosition new_top;
123     XmTextPosition last_top_char;
124     XmTextPosition dest_position;
125 
126     int disable_depth;
127     int pending_scroll;
128     int total_lines;
129     int top_line;
130     int vsbar_scrolling;
131 
132     Cardinal number_lines;
133     Cardinal maximum_lines;
134     Line line;
135 
136     Ranges repaint;
137     _XmHighlightData highlight;
138     _XmHighlightData old_highlight;
139     Widget inner_widget;
140 
141     XmTextLineTable line_table;
142     unsigned int table_size;
143     unsigned int table_index;
144 } XmTextPart;
145 
146 /* Define the full instance record */
147 typedef struct _XmTextRec {
148     CorePart core;
149     XmPrimitivePart primitive;
150     XmTextPart text;
151 } XmTextRec;
152 
153 /* Define class part structure */
154 typedef struct {
155     XtPointer extension;
156 } XmTextClassPart;
157 
158 /* Define the full class record */
159 typedef struct _XmTextClassRec {
160     CoreClassPart core_class;
161     XmPrimitiveClassPart primitive_class;
162     XmTextClassPart text_class;
163 } XmTextClassRec;
164 
165 /* External definition for class record */
166 
167 XMLIBEXPORT extern XmTextClassRec xmTextClassRec;
168 
169 
170 /* Inner Widget: base object for the Output and Input "subparts".  This really
171  * is only to hold the values for resource specification.  An Output and an
172  * input object will be created later that will copy the information from
173  * these records into their own.
174  */
175 
176 typedef struct {
177     OutputDataRec out;
178     InputDataRec in;
179 } XmTextInnerPart;
180 
181 /* Define the full instance record */
182 typedef struct _XmTextInnerRec {
183     ObjectPart object;
184     XmTextInnerPart inner;
185 } XmTextInnerRec;
186 
187 /* Define the full class record */
188 typedef struct _XmTextInnerClassRec {
189     ObjectClassPart object_class;
190     XmTextClassPart text_src_class; /* just a dummy */
191 } XmTextInnerClassRec;
192 
193 /* External definition for class record */
194 
195 XMLIBEXPORT extern XmTextInnerClassRec xmTextInnerClassRec;
196 typedef struct _XmTextInnerRec *XmTextInnerWidget;
197 
198 
199 XMLIBEXPORT extern int _XmTextGetTotalLines(Widget widget);
200 XMLIBEXPORT extern XmTextLineTable _XmTextGetLineTable(Widget widget,
201 					   int *total_lines);
202 XMLIBEXPORT extern void _XmTextRealignLineTable(XmTextWidget widget,
203 				    XmTextLineTable *temp_table,
204 				    int *temp_table_size,
205 				    register unsigned int cur_index,
206 				    register XmTextPosition cur_start,
207 				    register XmTextPosition cur_end);
208 XMLIBEXPORT extern unsigned int _XmTextGetTableIndex(XmTextWidget widget,
209 					 XmTextPosition pos);
210 XMLIBEXPORT extern void _XmTextUpdateLineTable(Widget widget,
211 				   XmTextPosition start,
212 				   XmTextPosition end,
213 				   XmTextBlock block,
214 				   Boolean update);
215 XMLIBEXPORT extern void _XmTextSetCursorPosition(Widget w,
216 				     XmTextPosition pos);
217 XMLIBEXPORT extern void _XmTextLineInfo(XmTextWidget widget,
218 			    LineNum line,
219 			    XmTextPosition *startpos,
220 			    LineTableExtra *extra);
221 XMLIBEXPORT extern LineNum _XmTextPosToLine(XmTextWidget widget,
222 				XmTextPosition position);
223 XMLIBEXPORT extern void _XmTextMarkRedraw(XmTextWidget widget,
224 			      XmTextPosition left,
225 			      XmTextPosition right);
226 XMLIBEXPORT extern void _XmTextDisableRedisplay(XmTextWidget widget,
227 				    Boolean losesbackingstore);
228 XMLIBEXPORT extern void _XmTextEnableRedisplay(XmTextWidget widget) ;
229 XMLIBEXPORT extern void _XmTextDelete(XmTextWidget w, XEvent *ev,
230 		XmTextPosition start, XmTextPosition end);
231 XMLIBEXPORT extern void _XmTextSetTopCharacter ( Widget w, XmTextPosition position);
232 XMLIBEXPORT extern LineNum _XmTextNumLines( XmTextWidget widget);
233 void _XmTextInvalidate(XmTextWidget w, XmTextPosition position,
234 		       XmTextPosition topos, long delta);
235 
236 #define Text_Source(w) (((XmTextWidget)(w))->text.source)
237 #define Text_ActivateCallback(w) (((XmTextWidget)(w))->text.activate_callback)
238 #define Text_FocusCallback(w) (((XmTextWidget)(w))->text.focus_callback)
239 #define Text_LosingFocusCallback(w) (((XmTextWidget)(w))->text.losing_focus_callback)
240 #define Text_ValueChangedCallback(w) (((XmTextWidget)(w))->text.value_changed_callback)
241 #define Text_ModifyVerifyCallback(w) (((XmTextWidget)(w))->text.modify_verify_callback)
242 #define Text_WcsModifyVerifyCallback(w) (((XmTextWidget)(w))->text.wcs_modify_verify_callback)
243 #define Text_MotionVerifyCallback(w) (((XmTextWidget)(w))->text.motion_verify_callback)
244 #define Text_GainPrimaryCallback(w) (((XmTextWidget)(w))->text.gain_primary_callback)
245 #define Text_LosePrimaryCallback(w) (((XmTextWidget)(w))->text.lose_primary_callback)
246 #define Text_Value(w) (((XmTextWidget)(w))->text.value)
247 #define Text_WcsValue(w) (((XmTextWidget)(w))->text.wc_value)
248 #define Text_MarginWidth(w) (((XmTextWidget)(w))->text.margin_width)
249 #define Text_MarginHeight(w) (((XmTextWidget)(w))->text.margin_height)
250 #define Text_CursorPositionX(w) (((XmTextWidget)(w))->text.cursor_position_x)
251 #define Text_OutputCreate(w) (((XmTextWidget)(w))->text.output_create)
252 #define Text_InputCreate(w) (((XmTextWidget)(w))->text.input_create)
253 #define Text_TopPos(w) (((XmTextWidget)(w))->text.top_character)
254 #define Text_BottomPos(w) (((XmTextWidget)(w))->text.bottom_position)
255 #define Text_CursorPos(w) (((XmTextWidget)(w))->text.cursor_position)
256 #define Text_FirstPos(w) (((XmTextWidget)(w))->text.first_position)
257 #define Text_LastPos(w) (((XmTextWidget)(w))->text.last_position)
258 #define Text_MaxLength(w) (((XmTextWidget)(w))->text.max_length)
259 #define Text_EditMode(w) (((XmTextWidget)(w))->text.edit_mode)
260 #define Text_AutoShowCursorPosition(w) (((XmTextWidget)(w))->text.auto_show_cursor_position)
261 #define Text_Editable(w) (((XmTextWidget)(w))->text.editable)
262 #define Text_VerifyBell(w) (((XmTextWidget)(w))->text.verify_bell)
263 #define Text_AddMode(w) (((XmTextWidget)(w))->text.add_mode)
264 #define Text_Traversed(w) (((XmTextWidget)(w))->text.traversed)
265 #define Text_InRedisplay(w) (((XmTextWidget)(w))->text.in_redisplay)
266 #define Text_NeedsRedisplay(w) (((XmTextWidget)(w))->text.needs_redisplay)
267 #define Text_InRefigureLines(w) (((XmTextWidget)(w))->text.in_refigure_lines)
268 #define Text_NeedsRefigureLines(w) (((XmTextWidget)(w))->text.needs_refigure_lines)
269 #define Text_InSetValues(w) (((XmTextWidget)(w))->text.in_setvalues)
270 #define Text_InResize(w) (((XmTextWidget)(w))->text.in_resize)
271 #define Text_InExpose(w) (((XmTextWidget)(w))->text.in_expose)
272 #define Text_HighlightChanged(w) (((XmTextWidget)(w))->text.highlight_changed)
273 #define Text_PendingOff(w) (((XmTextWidget)(w))->text.pendingoff)
274 #define Text_CharSize(w) (((XmTextWidget)(w))->text.char_size)
275 #define Text_OnOrOff(w) (((XmTextWidget)(w))->text.on_or_off)
276 #define Text_Output(w) (((XmTextWidget)(w))->text.output)
277 #define Text_OutputData(w) (Text_Output(w)->data)
278 #define Text_Input(w) (((XmTextWidget)(w))->text.input)
279 #define Text_InputData(w) (Text_Input(w)->data)
280 #define Text_ForgetPast(w) (((XmTextWidget)(w))->text.forget_past)
281 #define Text_ForceDisplay(w) (((XmTextWidget)(w))->text.force_display)
282 #define Text_NewTop(w) (((XmTextWidget)(w))->text.new_top)
283 #define Text_LastTopChar(w) (((XmTextWidget)(w))->text.last_top_char)
284 #define Text_DestPosition(w) (((XmTextWidget)(w))->text.dest_position)
285 #define Text_DisableDepth(w) (((XmTextWidget)(w))->text.disable_depth)
286 #define Text_PendingScroll(w) (((XmTextWidget)(w))->text.pending_scroll)
287 #define Text_TotalLines(w) (((XmTextWidget)(w))->text.total_lines)
288 #define Text_TopLine(w) (((XmTextWidget)(w))->text.top_line)
289 #define Text_VSBarScrolling(w) (((XmTextWidget)(w))->text.vsbar_scrolling)
290 #define Text_Line(w) (((XmTextWidget)(w))->text.line)
291 #define Text_LineCount(w) (((XmTextWidget)(w))->text.number_lines)
292 #define Text_LineMax(w) (((XmTextWidget)(w))->text.maximum_lines)
293 #define Text_Repaint(w) (((XmTextWidget)(w))->text.repaint)
294 #define Text_Highlight(w) (((XmTextWidget)(w))->text.highlight)
295 #define Text_OldHighlight(w) (((XmTextWidget)(w))->text.old_highlight)
296 #define Text_InnerWidget(w) (XmTextInnerWidget)(((XmTextWidget)(w))->text.inner_widget)
297 #define Text_LineTable(w) (((XmTextWidget)(w))->text.line_table)
298 #define Text_TableSize(w) (((XmTextWidget)(w))->text.table_size)
299 #define Text_TableIndex(w) (((XmTextWidget)(w))->text.table_index)
300 
301 #ifdef __cplusplus
302 };
303 #endif
304 
305 #endif /* _XM_TEXTP_H */
306