X11 Work Bench Toolkit  1.0
edit_window.h
Go to the documentation of this file.
1 
2 // _ _ _ _ _ _ //
3 // ___ __| |(_)| |_ __ __(_) _ __ __| | ___ __ __| |__ //
4 // / _ \ / _` || || __| \ \ /\ / /| || '_ \ / _` | / _ \\ \ /\ / /| '_ \ //
5 // | __/| (_| || || |_ \ V V / | || | | || (_| || (_) |\ V V /_| | | | //
6 // \___| \__,_||_| \__|_____\_/\_/ |_||_| |_| \__,_| \___/ \_/\_/(_)_| |_| //
7 // |_____| //
8 // //
9 // a window into which you can type (and edit) text //
10 // //
12 
13 /*****************************************************************************
14 
15  X11workbench - X11 programmer's 'work bench' application and toolkit
16  Copyright (c) 2010-2016 by Bob Frazier (aka 'Big Bad Bombastic Bob')
17  all rights reserved
18 
19  DISCLAIMER: The X11workbench application and toolkit software are supplied
20  'as-is', with no warranties, either implied or explicit.
21  Any claims to alleged functionality or features should be
22  considered 'preliminary', and might not function as advertised.
23 
24  BSD-like license:
25 
26  There is no restriction as to what you can do with this software, so long
27  as you include the above copyright notice and DISCLAIMER for any distributed
28  work that is equal to or derived from this one, along with this paragraph
29  that explains the terms of the license if the source is also being made
30  available. A "derived work" describes a work that uses a significant portion
31  of the source files or algorithms that are included with this one.
32  Specifically excluded from this are files that were generated by the software,
33  or anything that is included with the software that is part of another package
34  (such as files that were created or added during the 'configure' process).
35  Specifically included is the use of part or all of any of the X11 workbench
36  toolkit source or header files in your distributed application. If you do not
37  ship the source, the above copyright statement is still required to be placed
38  in a reasonably prominent place, such as documentation, splash screens, and/or
39  'about the application' dialog boxes.
40 
41  Use and distribution are in accordance with GPL, LGPL, and/or the above
42  BSD-like license. See COPYING and README files for more information.
43 
44 
45  Additional information at http://sourceforge.net/projects/X11workbench
46 
47 ******************************************************************************/
48 
49 
50 #ifndef _EDIT_WINDOW_H_INCLUDED_
51 #define _EDIT_WINDOW_H_INCLUDED_
52 
53 #include "text_object.h"
54 #include "frame_window.h"
55 #include "child_frame.h"
56 
57 
73 #define EDIT_WINDOW_TAG (*((const unsigned int * const)"FWEW"))
74 
75 
76 #ifdef __cplusplus
77 extern "C" {
78 #endif // __cplusplus
79 
80 // OBSOLETE 'IDEA' CODE, LEFT FOR REFERENCE
81 //
82 //typedef struct __WBLineBuffer
83 //{
84 // int iLength; // length of buffer (not including the structure size)
85 // int iMaxPos; // maximum position into which any text has been entered (usually end of line)
86 // int iEndOfLine; // the actual end of line (not counting trailing white space)
87 // struct __WBLineBuffer *pPrev, *pNext; // linked list of buffers
88 // char data[4]; // the actual data for the line (typically ASCII)
89 // // variable length following this
90 //} WBLineBuffer;
91 //
92 //typedef struct
93 //{
94 // Window wSelf, wOwner; // window identifiers for self, owner
95 // XFontStruct *pFont; // default font for the window
96 // WBLineBuffer *pStart, *pEnd; // pointers to start and end of linked buffer list
97 // WBLineBuffer *pBufArray; // array of buffers for visible lines
98 // int nBufArray; // maximum size of buffer array
99 // int iTop, iHeight, iLeft, iWidth; // line/char position and size of client area
100 // // iTop corresponds to pBufArray[0]
101 // int iMaxWidth, iMaxHeight; // size of document in lines and chars
102 // int iFlags; // various flags associated with the window
103 // char *pszFileName; // file name associated with edit window
104 //
105 //} WBEditWindow;
106 //
107 //enum
108 //{
109 // WBEditWindowFlags_EncodingMask = 0x7,
110 // WBEditWindowFlags_EncodingASCII = 0x0,
111 // WBEditWindowFlags_EncodingUTF8 = 0x1,
112 // WBEditWindowFlags_EncodingUTF16 = 0x2,
113 // WBEditWindowFlags_EncodingOther = 0x3, // 'other' implies locales, etc. (reserved)
114 //
115 //};
116 
117 
156 typedef struct __WBEditWindow__
157 {
159 
160  unsigned int ulTag;
161 
162  char *szFileName;
163 
165 
167 
168 } WBEditWindow;
169 
170 
171 // external atoms associated with edit windows, documented elsewhere
172 
173 #ifndef _EDIT_WINDOW_C_IMPLEMENTED_
174 extern Atom aEW_HOVER_NOTIFY;
175 extern Atom aEW_EDIT_CHANGE;
176 #endif // _EDIT_WINDOW_C_IMPLEMENTED_
177 
194 WBEditWindow *WBCreateEditWindow(WBFrameWindow *pOwner, XFontStruct *pFont,
195  const char *szFocusMenu, const WBFWMenuHandler *pHandlerArray,
196  int fFlags);
197 
198 
209 void WBDestroyEditWindow(WBEditWindow *pEditWindow);
210 
211 
223 
224 
236 int WBEditWindowLoadFile(WBEditWindow *pEditWindow, const char *pszFileName);
237 
238 
250 int WBEditWindowSaveFile(WBEditWindow *pEditWindow, const char *pszFileName);
251 
252 
262 void WBEditWindowClear(WBEditWindow *pEditWindow);
263 
264 
273 static __inline int WBIsValidEditWindow(WBEditWindow *pEditWindow)
274 {
275  if(!pEditWindow || // invalid pointer (TODO: check range?)
276  pEditWindow->childframe.ulTag != CHILD_FRAME_TAG || // child frame tag not valid
277  pEditWindow->ulTag != EDIT_WINDOW_TAG) // edit window tag not valid
278  {
279  return 0; // NOT valid.
280  }
281 
282  return 1;
283 }
284 
285 
286 // CALLBACK REGISTRATION
287 
288 
305 void WBEditWindowRegisterCallback(WBEditWindow *pEditWindow, WBWinEvent pUserCallback);
306 
307 
308 
309 
310 #ifdef __cplusplus
311 };
312 #endif // __cplusplus
313 
314 #endif // _EDIT_WINDOW_H_INCLUDED_
315