X11workbench Toolkit  1.0
window_dressing.h
Go to the documentation of this file.
1 // _ _ _ _ _ //
3 // __ __(_) _ __ __| | ___ __ __ __| | _ __ ___ ___ ___ (_) _ __ __ _ | |__ //
4 // \ \ /\ / /| || '_ \ / _` | / _ \\ \ /\ / / / _` || '__|/ _ \/ __|/ __|| || '_ \ / _` | | '_ \ //
5 // \ V V / | || | | || (_| || (_) |\ V V / | (_| || | | __/\__ \\__ \| || | | || (_| | _ | | | | //
6 // \_/\_/ |_||_| |_| \__,_| \___/ \_/\_/_____\__,_||_| \___||___/|___/|_||_| |_| \__, |(_)|_| |_| //
7 // |_____| |___/ //
8 // //
9 // Utilities for painting and handling standard components of windows //
10 // //
12 
13 /*****************************************************************************
14 
15  X11workbench - X11 programmer's 'work bench' application and toolkit
16  Copyright (c) 2010-2019 by Bob Frazier (aka 'Big Bad Bombastic Bob')
17 
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  MIT-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  MIT-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 _WINDOW_DRESSING_H_INCLUDED_
51 #define _WINDOW_DRESSING_H_INCLUDED_
52 
53 #include "window_helper.h" // make sure
54 #include "font_helper.h" // make sure
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif // __cplusplus
59 
60 
64 // SCROLL BARS
65 
117 typedef struct tagWB_SCROLL_INFO
118 {
120 
121  // fixed dimension sizes - 0 if not known, else based on owner client width/height
126 
127  int iHKnob;
128  int iVKnob;
131 
132  int iHMin;
133  int iHMax;
134  int iVMin;
135  int iVMax;
136 
137  int iHPos;
138  int iVPos;
139 
148 } WB_SCROLLINFO;
149 
150 
160 {
167 };
168 
169 
179 static __inline__ void WBInitScrollInfo(WB_SCROLLINFO *pSI) { bzero(pSI, sizeof(*pSI)); pSI->iHPos = pSI->iVPos = -1; }
180 
194 int WBSetVScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax);
195 
209 int WBSetHScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax);
210 
222 void WBSetVScrollPos(WB_SCROLLINFO *pSI, int iPos);
223 
235 void WBSetHScrollPos(WB_SCROLLINFO *pSI, int iPos);
236 
248 int WBCalcVScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iY); // 'iY' is the 'y' value for the mouse position relative to window orig
249 
261 int WBCalcHScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iX); // 'iX' is the 'x' value for the mouse position relative to window orig
262 
263 // internal SCROLLINFO utilities for list-based dialog controls
278 void WBCalcVScrollBar(WB_SCROLLINFO *pScrollInfo, WB_GEOM *pgeomClient, int iVScrollWidth,
279  int iHScrollHeight, int nListItems, int nPos); // calculates V scroll geometry for paint
280 
295 void WBCalcHScrollBar(WB_SCROLLINFO *pScrollInfo, WB_GEOM *pgeomClient, int iVScrollWidth,
296  int iHScrollHeight, int nListItems, int nPos); // calculates H scroll geometry for paint
297 
312  WB_GEOM *pgeomClient, WB_GEOM *pgeomUsable);
313 
324 void WBInvalidateVScrollGeom(Window wID, WB_SCROLLINFO *pScrollInfo, int bAll, int bUpdate);
325 
336 void WBInvalidateHScrollGeom(Window wID, WB_SCROLLINFO *pScrollInfo, int bAll, int bUpdate);
337 
354 int WBScrollBarEvent(Window wID, XEvent *pEvent, WB_SCROLLINFO *pScrollInfo);
355 
369 void WBPaintVScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID,
370  WBGC gc, WB_GEOM *pgeomClient);
371 
385 void WBPaintHScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID,
386  WBGC gc, WB_GEOM *pgeomClient);
387 
388 // borders and '3D' rectangle/polygon art
389 
403 void WBDrawBorderRect(Display *pDisplay, Drawable wID, WBGC gc,
404  WB_GEOM *pgeomBorder, unsigned long lBorderColor);
405 
420 void WBDraw3DBorderRect(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder,
421  unsigned long lBorderColor1, unsigned long lBorderColor2);
422 
436 void WBDrawBorderElipse(Display *pDisplay, Drawable wID, WBGC gc,
437  WB_GEOM *pgeomBorder, unsigned long lBorderColor);
438 
453 void WBDraw3DBorderElipse(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder,
454  unsigned long lBorderColor1, unsigned long lBorderColor2);
455 
469 void WBDrawDashedRect(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor);
470 
471 
485 void WBDrawLeftArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor);
486 
500 void WBDrawRightArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor);
501 
515 void WBDrawUpArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor);
516 
530 void WBDrawDownArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor);
531 
532 
564 void WBDraw3DBorderTab(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomOutline,
565  int fFocus, unsigned long lFGColor, unsigned long lBGColor,
566  unsigned long lBorderColor1, unsigned long lBorderColor2,
567  unsigned long lHighlightColor,
568  WB_FONTC pFont, WB_FONTC pFontBold,
569  Atom aGraphic, const char *szText);
570 
571 
572 
573 #ifdef __cplusplus
574 };
575 #endif // __cplusplus
576 
577 
578 #endif // _WINDOW_DRESSING_H_INCLUDED_
579 
580 
581 
void WBDraw3DBorderElipse(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor1, unsigned long lBorderColor2)
Draw a 3D 'border' elipse within a bounding geometry.
'window helper' main header file for the X11workbench Toolkit API
right button in 'drag' state on horizontal scroll bar
WBScrollState_ENUM
void WBPaintHScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomClient)
Paint the horizontal scroll bar within a window based on WB_SCROLLINFO.
int iHPos
current horozontal scroll position (N/A if outside of min/max range)
WB_GEOM geomVDown
geometry for the vertical scroll bar 'down' button (empty if not visible)
WB_GEOM geomHRight
geometry for the horizontal scroll bar 'right' button (empty if not visible)
int WBScrollBarEvent(Window wID, XEvent *pEvent, WB_SCROLLINFO *pScrollInfo)
Event handler for scroll bars.
Definition file for font helper functions and structures.
int WBCalcHScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iX)
Calculate and assign the correct horizontal scroll bar position from mouse coordinates.
int iHBarWidth
calculated width of horizontal scroll bar (re-calculate on window size change)
WB_GEOM geomVBar
geometry for the vertical scroll bar excluding border (empty if not visible)
void WBDrawLeftArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a left arrow in a window within a specified geometry.
internal wrapper struct for X11 'geometry' definition
int iVScrollWidth
calculated width of vertical scroll bar (in pixels); 0 if not known
void WBInvalidateHScrollGeom(Window wID, WB_SCROLLINFO *pScrollInfo, int bAll, int bUpdate)
Utility function to invalidate the geometry for the horizontal scroll bar.
void WBDrawRightArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a right arrow in a window within a specified geometry.
int iScrollState
scroll state flags - see enumeration WBScrollState_ENUM
struct tagWB_SCROLL_INFO WB_SCROLLINFO
Structure that defines scroll bar info for both horizontal and vertical scroll bars.
left button in 'drag' state on vertical scroll bar (relies on drag cancel)
int iVMax
maximum vertical range (0 if no bar)
WB_GEOM geomVKnob
geometry for the vertical scroll bar 'knob' (empty if not visible)
middle button in 'drag' state on horizontal scroll bar
int iVBarHeight
calculated height of vertical scroll bar (re-calculate on window size change)
int iVPos
current vertical scroll position (N/A if outside of min/max range)
int iHMin
minimum horizontal range (0 if no bar)
void WBSetHScrollPos(WB_SCROLLINFO *pSI, int iPos)
Set the scroll range for a horizontal scrollbar in the WB_SCROLLINFO structure.
WB_GEOM geomHKnob
geometry for the horizontal scroll bar 'knob' (empty if not visible)
WB_GEOM geomHBar
geometry for the horizontal scroll bar excluding border (empty if not visible)
middle button in 'drag' state on vertical scroll bar
int iHScrollHeight
calculated height of horizontal scroll bar (in pixels); 0 if not known
int WBSetHScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax)
Set the scroll range for a horizontal scrollbar in the WB_SCROLLINFO structure.
int WBCalcVScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iY)
Calculate and assign the correct vertical scroll bar position from mouse coordinates.
void WBDrawDashedRect(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a 'dashed' rectangle.
void WBSetVScrollPos(WB_SCROLLINFO *pSI, int iPos)
Set the scroll range for a vertical scrollbar in the WB_SCROLLINFO structure.
int iVKnob
calculated relative Y pixel position of vertical scroll 'knob'
int iHMax
maximum horizontal range (0 if no bar)
void WBDrawUpArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw an up arrow in a window within a specified geometry.
void WBInvalidateVScrollGeom(Window wID, WB_SCROLLINFO *pScrollInfo, int bAll, int bUpdate)
Utility function to invalidate the geometry for the vertical scroll bar.
int iHKnob
calculated relative X pixel position of horizontal scroll 'knob'
int iHKnobSize
calculated pixel width of horizontal scroll 'knob'
void WBDraw3DBorderRect(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor1, unsigned long lBorderColor2)
Draw a 3D 'border' rectangle.
int iVMin
minimum vertical range (0 if no bar)
An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified...
Definition: font_helper.h:152
int WBSetVScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax)
Set the scroll range for a vertical scrollbar in the WB_SCROLLINFO structure.
static __inline__ void WBInitScrollInfo(WB_SCROLLINFO *pSI)
Initialization function for a 'WB_SCROLLINFO' structure.
void WBCalcHScrollBar(WB_SCROLLINFO *pScrollInfo, WB_GEOM *pgeomClient, int iVScrollWidth, int iHScrollHeight, int nListItems, int nPos)
Calculate the parameters for a horizontal scroll bar.
void WBCalcVScrollBar(WB_SCROLLINFO *pScrollInfo, WB_GEOM *pgeomClient, int iVScrollWidth, int iHScrollHeight, int nListItems, int nPos)
Calculate the parameters for a vertical scroll bar.
int iVKnobSize
calculated pixel height of vertical scroll 'knob'
WB_GEOM geomVUp
geometry for the vertical scroll bar 'up' button (empty if not visible)
internal wrapper struct for GC with local cache
void WBDrawBorderRect(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor)
Draw a 'border' rectangle.
Structure that defines scroll bar info for both horizontal and vertical scroll bars.
void WBDrawBorderElipse(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor)
Draw a 'border' elipse within a bounding geometry.
WB_GEOM geomHLeft
geometry for the horizontal scroll bar 'left' button (empty if not visible)
void WBPaintVScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomClient)
Paint the vertical scroll bar within a window based on WB_SCROLLINFO.
left button in 'drag' state on horizontal scroll bar (relies on drag cancel)
right button in 'drag' state on vertical scroll bar
void WBDraw3DBorderTab(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomOutline, int fFocus, unsigned long lFGColor, unsigned long lBGColor, unsigned long lBorderColor1, unsigned long lBorderColor2, unsigned long lHighlightColor, WB_FONTC pFont, WB_FONTC pFontBold, Atom aGraphic, const char *szText)
Draw a 'tab' within a specified 'outline' rectangle.
void WBUpdateScrollBarGeometry(WB_SCROLLINFO *pSI, WB_FONTC pFontRef, WB_GEOM *pgeomClient, WB_GEOM *pgeomUsable)
Update the scroll bar geometry within the WB_SCROLLINFO structure.
void WBDrawDownArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a down arrow in a window within a specified geometry.