X11 Work Bench Toolkit  1.0
draw_text.h
Go to the documentation of this file.
1 
2 // _ _ _ _ //
3 // __| | _ __ __ _ __ __ | |_ ___ __ __| |_ | |__ //
4 // / _` || '__|/ _` |\ \ /\ / / | __|/ _ \\ \/ /| __| | '_ \ //
5 // | (_| || | | (_| | \ V V / | |_| __/ > < | |_ _ | | | | //
6 // \__,_||_| \__,_| \_/\_/_____\__|\___|/_/\_\ \__|(_)|_| |_| //
7 // |_____| //
8 // //
9 // text draw, multi-line and tabbed text //
10 // Also, additional text-related utilities //
11 // //
13 
14 /*****************************************************************************
15 
16  X11workbench - X11 programmer's 'work bench' application and toolkit
17  Copyright (c) 2010-2016 by Bob Frazier (aka 'Big Bad Bombastic Bob')
18  all rights reserved
19 
20  DISCLAIMER: The X11workbench application and toolkit software are supplied
21  'as-is', with no warranties, either implied or explicit.
22  Any claims to alleged functionality or features should be
23  considered 'preliminary', and might not function as advertised.
24 
25  BSD-like license:
26 
27  There is no restriction as to what you can do with this software, so long
28  as you include the above copyright notice and DISCLAIMER for any distributed
29  work that is equal to or derived from this one, along with this paragraph
30  that explains the terms of the license if the source is also being made
31  available. A "derived work" describes a work that uses a significant portion
32  of the source files or algorithms that are included with this one.
33  Specifically excluded from this are files that were generated by the software,
34  or anything that is included with the software that is part of another package
35  (such as files that were created or added during the 'configure' process).
36  Specifically included is the use of part or all of any of the X11 workbench
37  toolkit source or header files in your distributed application. If you do not
38  ship the source, the above copyright statement is still required to be placed
39  in a reasonably prominent place, such as documentation, splash screens, and/or
40  'about the application' dialog boxes.
41 
42  Use and distribution are in accordance with GPL, LGPL, and/or the above
43  BSD-like license. See COPYING and README files for more information.
44 
45 
46  Additional information at http://sourceforge.net/projects/X11workbench
47 
48 ******************************************************************************/
49 
50 
58 #ifndef _DRAW_TEXT_H_INCLUDED_
59 #define _DRAW_TEXT_H_INCLUDED_
60 
61 #ifndef WINDOW_HELPER_H_INCLUDED
62 #include "window_helper.h"
63 #endif // WINDOW_HELPER_H_INCLUDED
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif // __cplusplus
68 
69 
76 {
81 
83 
91  DTAlignment_VMASK = 0xf0,
92 
93  // these next flags are primarily for DTCalcIdealBounds, and some for DTCalcIdealFont
94 
96 
97 
98 
99 
103 
104 
105 
106 
108 
109 
111 
113 
114 
116 
117 
118 
119  DTAlignment_SINGLELINE = 0x20000000,
120  DTAlignment_UNDERSCORE = 0x40000000,
121  DTAlignment_PRINTING = 0x80000000
122 
123 };
124 
125 
160 typedef struct __DT_WORD__
161 {
162  const char *pText;
163 
164 
165  int nLength;
166  int iWidth;
167  int iHeight;
168  int iIsTab;
171  int iX;
172  int iY;
173 } DT_WORD;
174 
175 
205 typedef struct __DT_WORDS__
206 {
207  struct __DT_WORDS__ *pPrev;
208  struct __DT_WORDS__ *pNext;
209  int nCount;
210  int nMax;
211  int iMaxWidth;
213  const char *szText;
215 } DT_WORDS;
216 
217 
218 
231 int DTGetTextWidth(XFontSet fontSet, const char *szUTF8, int nLength);
232 
233 
246 XFontStruct *DTCalcIdealFont(XFontStruct *pRefFont, const char *szText, WB_GEOM *geomBounds);
247 
248 
262 XFontSet DTCalcIdealFontSet(Display *pDisplay, XFontSet fontSet, const char *szText, WB_GEOM *geomBounds);
263 
264 
290 int DTCalcIdealBounds0(XFontStruct *pFont, const char *szText, int iTabWidth, unsigned int iTabOrigin,
291  const WB_RECT *prcSource, WB_RECT *prcDest, int iAlignment);
292 
319 int DTCalcIdealBounds(Display *pDisplay, XFontSet fontSet, const char *szText, int iTabWidth, unsigned int iTabOrigin,
320  const WB_RECT *prcSource, WB_RECT *prcDest, int iAlignment);
321 
344 void DTDrawSingleLineText0(XFontStruct *pFont, const char *szText, Display *pDisplay, GC gc, Drawable dw,
345  int iTabWidth, int iTabOrigin, const WB_RECT *prcBounds, int iAlignment);
346 
369 void DTDrawSingleLineText(XFontSet fontSet, const char *szText, Display *pDisplay, GC gc, Drawable dw,
370  int iTabWidth, int iTabOrigin, const WB_RECT *prcBounds, int iAlignment);
371 
392 void DTDrawMultiLineText0(XFontStruct *pFont, const char *szText, Display *pDisplay, GC gc, Drawable dw,
393  int iTabWidth, int iTabOrigin, const WB_RECT *prcBounds, int iAlignment);
394 
415 void DTDrawMultiLineText(XFontSet fontSet, const char *szText, Display *pDisplay, GC gc, Drawable dw,
416  int iTabWidth, int iTabOrigin, const WB_RECT *prcBounds, int iAlignment);
417 
418 
435 DT_WORDS * DTGetWordsFromText0(XFontStruct *pFont, const char *szText, int iAlignment);
436 
454 DT_WORDS * DTGetWordsFromText(Display *pDisplay, XFontSet fontSet, const char *szText, int iAlignment);
455 
481 void DTPreRender(Display *pDisplay, XFontSet fontSet, DT_WORDS *pWords, int iTabWidth, int iTabOrigin,
482  WB_RECT *prcBounds, int iAlignment, int iStartLine, int iEndLine);
483 
503 void DTRender(Display *pDisplay, XFontSet fontSet, const DT_WORDS *pWords, GC gc, Drawable dw,
504  int iHScrollBy, int iVScrollBy, const WB_RECT *prcBounds, const WB_RECT *prcViewport, int iAlignment);
505 
506 #ifdef __cplusplus
507 };
508 #endif // __cplusplus
509 
510 
511 #endif // _DRAW_TEXT_H_INCLUDED_
512