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-2018 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 
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 
311 void WBUpdateScrollBarGeometry(WB_SCROLLINFO *pSI, XFontSet fontSetRef,
312  WB_GEOM *pgeomClient, WB_GEOM *pgeomUsable);
313 
330 int WBScrollBarEvent(Window wID, XEvent *pEvent, WB_SCROLLINFO *pScrollInfo);
331 
345 void WBPaintVScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID,
346  GC gc, WB_GEOM *pgeomClient);
347 
361 void WBPaintHScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID,
362  GC gc, WB_GEOM *pgeomClient);
363 
364 // borders and '3D' rectangle/polygon art
365 
379 void WBDrawBorderRect(Display *pDisplay, Drawable wID, GC gc,
380  WB_GEOM *pgeomBorder, unsigned long lBorderColor);
381 
396 void WBDraw3DBorderRect(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomBorder,
397  unsigned long lBorderColor1, unsigned long lBorderColor2);
398 
412 void WBDrawBorderElipse(Display *pDisplay, Drawable wID, GC gc,
413  WB_GEOM *pgeomBorder, unsigned long lBorderColor);
414 
429 void WBDraw3DBorderElipse(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomBorder,
430  unsigned long lBorderColor1, unsigned long lBorderColor2);
431 
445 void WBDrawDashedRect(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
446 
447 
461 void WBDrawLeftArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
462 
476 void WBDrawRightArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
477 
491 void WBDrawUpArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
492 
506 void WBDrawDownArrow(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomRect, unsigned long lColor);
507 
508 
540 void WBDraw3DBorderTab(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomOutline,
541  int fFocus, unsigned long lFGColor, unsigned long lBGColor,
542  unsigned long lBorderColor1, unsigned long lBorderColor2,
543  unsigned long lHighlightColor,
544  XFontSet fontSet, XFontSet fontSetBold,
545  Atom aGraphic, const char *szText);
546 
547 
548 
549 #ifdef __cplusplus
550 };
551 #endif // __cplusplus
552 
553 
554 #endif // _WINDOW_DRESSING_H_INCLUDED_
555 
556 
557 
WB_GEOM geomVKnob
geometry for the vertical scroll bar 'knob' (empty if not visible)
void WBDrawBorderElipse(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor)
Draw a 'border' elipse within a bounding geometry.
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 WBDraw3DBorderElipse(Display *pDisplay, Drawable wID, GC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor1, unsigned long lBorderColor2)
Draw a 3D 'border' elipse within a bounding geometry.
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 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.
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 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)
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.
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.