X11 Work Bench 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-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 _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 __WB_SCROLLINFO__
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 
193 void WBSetVScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax);
194 
207 void WBSetHScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax);
208 
220 void WBSetVScrollPos(WB_SCROLLINFO *pSI, int iPos);
221 
233 void WBSetHScrollPos(WB_SCROLLINFO *pSI, int iPos);
234 
246 int WBCalcVScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iY); // 'iY' is the 'y' value for the mouse position relative to window orig
247 
259 int WBCalcHScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iX); // 'iX' is the 'x' value for the mouse position relative to window orig
260 
261 // internal SCROLLINFO utilities for list-based dialog controls
276 void WBCalcVScrollBar(WB_SCROLLINFO *pScrollInfo, WB_GEOM *pgeomClient, int iVScrollWidth,
277  int iHScrollHeight, int nListItems, int nPos); // calculates V scroll geometry for paint
278 
293 void WBCalcHScrollBar(WB_SCROLLINFO *pScrollInfo, WB_GEOM *pgeomClient, int iVScrollWidth,
294  int iHScrollHeight, int nListItems, int nPos); // calculates H scroll geometry for paint
295 
309 void WBUpdateScrollBarGeometry(WB_SCROLLINFO *pSI, XFontSet fontSetRef,
310  WB_GEOM *pgeomClient, WB_GEOM *pgeomUsable);
311 
328 int WBScrollBarEvent(Window wID, XEvent *pEvent, WB_SCROLLINFO *pScrollInfo);
329 
343 void WBPaintVScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID,
344  GC gc, WB_GEOM *pgeomClient);
345 
359 void WBPaintHScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID,
360  GC gc, WB_GEOM *pgeomClient);
361 
362 // borders and '3D' rectangle art
363 
377 void WBDrawBorderRect(Display *pDisplay, Drawable wID, GC gc,
378  WB_GEOM *pgeomBorder, unsigned long lBorderColor);
379 
394 void WBDraw3DBorderRect(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomBorder,
395  unsigned long lBorderColor1, unsigned long lBorderColor2);
396 
410 void WBDrawDashedRect(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
411 
412 
426 void WBDrawLeftArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
427 
441 void WBDrawRightArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
442 
456 void WBDrawUpArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
457 
471 void WBDrawDownArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
472 
473 
505 void WBDraw3DBorderTab(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomOutline,
506  int fFocus, unsigned long lFGColor, unsigned long lBGColor,
507  unsigned long lBorderColor1, unsigned long lBorderColor2,
508  unsigned long lHighlightColor,
509  XFontSet fontSet, XFontSet fontSetBold,
510  Atom aGraphic, const char *szText);
511 
512 
513 
514 #ifdef __cplusplus
515 };
516 #endif // __cplusplus
517 
518 
519 #endif // _WINDOW_DRESSING_H_INCLUDED_
520 
521 
522 
WB_GEOM geomVKnob
geometry for the vertical scroll bar 'knob' (empty if not visible)
int iVBarHeight
calculated height of vertical scroll bar (re-calculate on window size change)
'window helper' main header file for the X11workbench Toolkit API
int iHMin
minimum horizontal range (0 if no bar)
right button in 'drag' state on horizontal scroll bar
WBScrollState_ENUM
int iVKnob
calculated relative Y pixel position of vertical scroll 'knob'
int WBScrollBarEvent(Window wID, XEvent *pEvent, WB_SCROLLINFO *pScrollInfo)
Event handler for scroll bars.
WB_GEOM geomVBar
geometry for the vertical scroll bar excluding border (empty if not visible)
void WBDraw3DBorderRect(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor1, unsigned long lBorderColor2)
Draw a 3D 'border' rectangle.
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.
void WBSetVScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax)
Set the scroll range for a vertical scrollbar in the WB_SCROLLINFO structure.
WB_GEOM geomVUp
geometry for the vertical scroll bar 'up' button (empty if not visible)
int iVPos
current vertical scroll position (N/A if outside of min/max range)
int iScrollState
scroll state flags - see enumeration WBScrollState_ENUM
void WBDrawBorderRect(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor)
Draw a 'border' rectangle.
int iHScrollHeight
calculated height of horizontal scroll bar (in pixels); 0 if not known
Structure that defines scroll bar info for both horizontal and vertical scroll bars.
int iHPos
current horozontal scroll position (N/A if outside of min/max range)
struct __WB_SCROLLINFO__ 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)
middle button in 'drag' state on horizontal scroll bar
int iHMax
maximum horizontal range (0 if no bar)
int iHBarWidth
calculated width of horizontal scroll bar (re-calculate on window size change)
void WBSetHScrollPos(WB_SCROLLINFO *pSI, int iPos)
Set the scroll range for a horizontal scrollbar in the WB_SCROLLINFO structure.
void WBDraw3DBorderTab(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomOutline, int fFocus, unsigned long lFGColor, unsigned long lBGColor, unsigned long lBorderColor1, unsigned long lBorderColor2, unsigned long lHighlightColor, XFontSet fontSet, XFontSet fontSetBold, Atom aGraphic, const char *szText)
Draw a 'tab' within a specified 'outline' rectangle.
middle button in 'drag' state on vertical scroll bar
WB_GEOM geomHLeft
geometry for the horizontal scroll bar 'left' button (empty if not visible)
void WBDrawDownArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a down arrow in a window within a specified geometry.
int WBCalcVScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iY)
Calculate and assign the correct vertical scroll bar position from mouse coordinates.
WB_GEOM geomHBar
geometry for the horizontal scroll bar excluding border (empty if not visible)
int iVKnobSize
calculated pixel height of vertical scroll 'knob'
void WBSetVScrollPos(WB_SCROLLINFO *pSI, int iPos)
Set the scroll range for a vertical scrollbar in the WB_SCROLLINFO structure.
void WBDrawLeftArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a left arrow in a window within a specified geometry.
int iHKnobSize
calculated pixel width of horizontal scroll 'knob'
void WBSetHScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax)
Set the scroll range for a horizontal scrollbar in the WB_SCROLLINFO structure.
void WBPaintVScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomClient)
Paint the vertical scroll bar within a window based on WB_SCROLLINFO.
int iVMax
maximum vertical range (0 if no bar)
WB_GEOM geomHKnob
geometry for the horizontal scroll bar 'knob' (empty if not visible)
int iVMin
minimum vertical range (0 if no bar)
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.
WB_GEOM geomHRight
geometry for the horizontal scroll bar 'right' button (empty if not visible)
void WBDrawUpArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw an up arrow in a window within a specified geometry.
int iHKnob
calculated relative X pixel position of horizontal scroll 'knob'
WB_GEOM geomVDown
geometry for the vertical scroll bar 'down' button (empty if not visible)
void WBDrawRightArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a right arrow in a window within a specified geometry.
internal wrapper struct for X11 'geometry' definition
left button in 'drag' state on horizontal scroll bar (relies on drag cancel)
right button in 'drag' state on vertical scroll bar
int iVScrollWidth
calculated width of vertical scroll bar (in pixels); 0 if not known
void WBUpdateScrollBarGeometry(WB_SCROLLINFO *pSI, XFontSet fontSetRef, WB_GEOM *pgeomClient, WB_GEOM *pgeomUsable)
Update the scroll bar geometry within the WB_SCROLLINFO structure.
void WBPaintHScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomClient)
Paint the horizontal scroll bar within a window based on WB_SCROLLINFO.
void WBDrawDashedRect(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a 'dashed' rectangle.