X11 Work Bench Toolkit  1.0
frame_window.h
Go to the documentation of this file.
1 // __ _ _ _ //
3 // / _| _ __ __ _ _ __ ___ ___ __ __(_) _ __ __| | ___ __ __| |__ //
4 // | |_ | '__|/ _` || '_ ` _ \ / _ \ \ \ /\ / /| || '_ \ / _` | / _ \\ \ /\ / /| '_ \ //
5 // | _|| | | (_| || | | | | || __/ \ V V / | || | | || (_| || (_) |\ V V /_| | | | //
6 // |_| |_| \__,_||_| |_| |_| \___|_____\_/\_/ |_||_| |_| \__,_| \___/ \_/\_/(_)_| |_| //
7 // |_____| //
8 // //
9 // a top-level window that can have menus, toolbars, a status bar, and a client area //
10 // (multiple-document versions have tabs and child frames) //
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 
51 #ifndef FRAME_WINDOW_H_INCLUDED
52 #define FRAME_WINDOW_H_INCLUDED
53 
54 //#include "window_helper.h"
55 #include "window_dressing.h"
56 #include "menu_bar.h"
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif // __cplusplus
61 
62 
63 
180 #define FRAME_WINDOW_TAG (*((const unsigned int *)"FWFW"))
181 
182 
216 {
217  unsigned long lMenuID;
218 
219  int (* callback)(XClientMessageEvent *);
220 
226  int (* UIcallback)(WBMenu *, WBMenuItem *);
228 
229 
230 
264 typedef struct __WB_FRAME_WINDOW__
265 {
266  unsigned int ulTag;
267  Window wID;
268  int iFlags;
269 
270  int iClientX;
271  int iClientY;
274 
275 } WBFrameWindow;
276 
277 
278 
286 {
287 
292 
293  WBFrameWindow_MAX = 0x80000000L
294 };
295 
302 {
303  WBStatusTabInfo_MASK = 0x0fffffff,
304  WBStatusTabInfo_BREAK = 0x10000000,
311 };
312 
313 
314 struct __WBChildFrameUI__; // forward declaration
315 
409 typedef struct __WBChildFrame__
410 {
411  unsigned int ulTag;
412  Window wID;
414  XFontSet rFontSet;
415 
420 
422  int iColWidth;
423 
425 
426  int iSplit;
427 
429 
430  int fFlags;
431 
433  Atom aImageAtom;
434 
435  char *szStatusText;
436 
440 
442  void (*destructor)(struct __WBChildFrame__ *);
444 
446 } WBChildFrame;
447 
448 
449 // WBChildFrame is defined HERE to avoid circular header file dependencies
450 // (also defining supporting structs for same reason)
451 
662 typedef struct __WBChildFrameUI__
663 {
664  unsigned int ulTag;
665  void (*do_char)(WBChildFrame *, XClientMessageEvent *);
666  void (*scancode)(WBChildFrame *, XClientMessageEvent *);
667  void (*bkspace)(WBChildFrame *, int iACS);
668  void (*del)(WBChildFrame *, int iACS);
669  void (*tab)(WBChildFrame *, int iACS);
670  void (*enter)(WBChildFrame *, int iACS);
671  void (*uparrow)(WBChildFrame *, int iACS);
672  void (*downarrow)(WBChildFrame *, int iACS);
673  void (*leftarrow)(WBChildFrame *, int iACS);
674  void (*rightarrow)(WBChildFrame *, int iACS);
675  void (*home)(WBChildFrame *, int iACS);
676  void (*end)(WBChildFrame *, int iACS);
677  void (*pgup)(WBChildFrame *, int iACS);
678  void (*pgdown)(WBChildFrame *, int iACS);
679  void (*pgleft)(WBChildFrame *, int iACS);
680  void (*pgright)(WBChildFrame *, int iACS);
681  void (*help)(WBChildFrame *, int iACS);
682  void (*hover_notify)(WBChildFrame *, int x, int y);
683  void (*hover_cancel)(WBChildFrame *);
684  int (*is_ins_mode)(WBChildFrame *);
685  void (*toggle_ins_mode)(WBChildFrame *);
686  void (*copy_to_cb)(WBChildFrame *);
687  void (*paste_from_cb)(WBChildFrame *);
688  void (*cut_to_cb)(WBChildFrame *);
689  void (*delete_sel)(WBChildFrame *);
690  void (*select_all)(WBChildFrame *);
691  void (*select_none)(WBChildFrame *);
692  void (*save)(WBChildFrame *, const char *szFileName);
693 
694  WB_PCSTR (* get_file_name)(WBChildFrame *);
695 
696  void (*mouse_click)(WBChildFrame *, int iX, int iY,
697  int iButtonMask, int iACS);
698  void (*mouse_dblclick)(WBChildFrame *, int iX, int iY,
699  int iButtonMask, int iACS);
700  void (*mouse_drag)(WBChildFrame *, int iX, int iY,
701  int iButtonMask, int iACS);
702  void (*mouse_drop)(WBChildFrame *, int iX, int iY,
703  int iButtonMask, int iACS);
704  void (*mouse_move)(WBChildFrame *, int iX, int iY);
705  void (*mouse_scrollup)(WBChildFrame *, int iX, int iY,
706  int iButtonMask, int iACS);
707  void (*mouse_scrolldown)(WBChildFrame *, int iX, int iY,
708  int iButtonMask, int iACS);
709  void (*mouse_cancel)(WBChildFrame *);
710  void (*get_row_col)(WBChildFrame *, int *piR, int *piC);
711  int (*has_selection)(WBChildFrame *);
712  void (*undo)(WBChildFrame *);
713  void (*redo)(WBChildFrame *);
714  int (*can_undo)(WBChildFrame *);
715  int (*can_redo)(WBChildFrame *);
716  int (*is_empty)(WBChildFrame *);
717 
719 
720 
721 
722 
729 {
736 };
737 
738 
739 // FRAME WINDOW ATOMS
740 
741 #if !defined(_FRAME_WINDOW_C_) && !defined(_CLIPBOARD_HELPER_C)
742  /* this declares the atoms 'const' outside of frame_window.c, and does NOT declare them in clipboard_helper.c */
743  /* These atoms are GLOBAL variables, assigned by the DEFAULT Display, and may not work for other threads. */
744 
745 extern const Atom aTAB_MESSAGE; // command sent by Client Message related to tabs
746 
747 #endif // !defined(_FRAME_WINDOW_C_) && !defined(_CLIPBOARD_HELPER_C)
748 
749 
750 
751 
752 
778 WBFrameWindow *FWCreateFrameWindow(const char *szTitle, int idIcon, const char *szMenuResource,
779  int iX, int iY, int iWidth, int iHeight,
780  WBWinEvent pUserCallback, int iFlags);
781 
792 void FWRecalcLayout(Window wID); // recalculate layout information (propagates to contained windows)
793 
794 
806 void FWSetUserCallback(WBFrameWindow *pFW, WBWinEvent pCallBack);
807 
808 
819 static __inline__ WBFrameWindow *FWGetFrameWindowStruct(Window wID) // for frame windows, returns the frame window struct
820 {
821  WBFrameWindow *pRval = (WBFrameWindow *)WBGetWindowData(wID, 0); // offset 0 for window-specific structs
822 
823  if(pRval && pRval->ulTag == FRAME_WINDOW_TAG)
824  {
825  return(pRval);
826  }
827 
828  return(NULL);
829 }
830 
841 void FWDestroyFrameWindow(Window wID); // destroys frame window using the Window ID (frees the struct also)
842 
853 void FWDestroyFrameWindow2(WBFrameWindow *pFrameWindow); // destroys it using the struct pointer
854 
869 void FWSetMenuHandlers(WBFrameWindow *pFrameWindow, const WBFWMenuHandler *pHandlerArray);
870 
877 #define FW_MENU_HANDLER_BEGIN(X) static const WBFWMenuHandler X[] = {
878 
886 #define FW_MENU_HANDLER_ENTRY(X,Y,Z) { (unsigned long)X, Y, Z },
887 
891 #define FW_MENU_HANDLER_END {0, 0, 0} };
892 
893 
894 // frame window 'contents' functions
895 
904 int FWGetNumContWindows(const WBFrameWindow *pFrameWindow);
905 
918 WBChildFrame * FWGetContainedWindowByIndex(const WBFrameWindow *pFrameWindow, int iIndex);
919 
926 #define FWGetFocusWindow(pFW) FWGetContainedWindowByIndex(pFW, -1)
927 
937 int FWAddContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pNew);
938 
948 void FWRemoveContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
949 
977 void FWReplaceContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, WBChildFrame *pContNew);
978 
988 void FWSetFocusWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
989 
999 void FWSetFocusWindowIndex(WBFrameWindow *pFrameWindow, int iIndex);
1000 
1010 int FWGetChildFrameIndex(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
1011 
1022 void FWMoveChildFrameTabIndex(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, int iIndex);
1023 
1039 void FWSetStatusText(WBFrameWindow *pFrameWindow, const char *szText);
1040 
1062 void FWSetStatusTabInfo(WBFrameWindow *pFrameWindow, int nTabs, const int *pTabs);
1063 
1064 // DEFAULT COLORS
1065 
1073 XColor FWGetDefaultFG(void);
1074 
1082 XColor FWGetDefaultBG(void);
1083 
1091 XColor FWGetDefaultBD(void);
1092 
1093 
1094 #if 0
1095 
1110 int FWDoSelectionEvents(WBFrameWindow *pFrameWindow, Window wID, Window wIDMenu, XEvent *pEvent);
1111 #endif // 0
1112 
1113 
1114 #ifdef __cplusplus
1115 };
1116 #endif // __cplusplus
1117 
1118 
1119 #endif // FRAME_WINDOW_H_INCLUDED
1120 
RESERVED - 'splitter' window with horizontal sizeable 'split'.
Definition: frame_window.h:733
void FWReplaceContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, WBChildFrame *pContNew)
Replace a 'contained' window from a frame window.
const char * WB_PCSTR
pointer to const char string - a convenience typedef
internal wrapper struct for 'extent' definition
struct __WBChildFrameUI__ * pUI
pointer to 'WBChildFrameUI' function pointer table (assigned by 'superclass')
Definition: frame_window.h:443
structure for managing menu items
Definition: menu.h:185
set this to disable tabs (single child frame only)
Definition: frame_window.h:290
int iClientX
The current X position of the frame window's client area (relative to the window) ...
Definition: frame_window.h:270
void FWRemoveContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont)
Removes a 'contained' window from a frame window. Does not destroy the 'contained' window...
void * WBGetWindowData(Window wID, int iIndex)
Gets the data associated with this window and the specified index.
maximum flag value (for reference only)
Definition: frame_window.h:293
set this flag for application top-level window and whenever it is destroyed the application will exit...
Definition: frame_window.h:288
void FWDestroyFrameWindow2(WBFrameWindow *pFrameWindow)
Function to destroy a frame window based on the WBFrameWindow structure.
Definition: frame_window.c:689
unsigned int ulTag
tag indicating I'm a frame window
Definition: frame_window.h:266
WBStatusTabInfo_FLAGS
enumeration for bit flags that are 'or'd with the tab stop index
Definition: frame_window.h:301
Window wID
Window id for the frame window.
Definition: frame_window.h:267
void FWDestroyFrameWindow(Window wID)
Function to destroy a frame window based on the Window id.
Definition: frame_window.c:684
char * szDisplayName
display name shown in tab and title bar. You should not alter this member directly.
Definition: frame_window.h:432
int fFlags
various bitflags defining features. See WBChildFrame_FLAGS enum.
Definition: frame_window.h:430
WBFrameWindow * pOwner
a pointer to the WBFrameWindow owner
Definition: frame_window.h:413
int FWGetChildFrameIndex(WBFrameWindow *pFrameWindow, WBChildFrame *pCont)
Sets the focus to a specific contained window using its tab order index.
does not use MDI tabs [intended for SDI interface]
Definition: frame_window.h:730
#define FRAME_WINDOW_TAG
TAG for the WBFrameWindow structure.
Definition: frame_window.h:180
mask for the 'justification' value
Definition: frame_window.h:305
static __inline__ WBFrameWindow * FWGetFrameWindowStruct(Window wID)
Obtain the associated WBFrameWindow structure pointer for a frame window's Window ID...
Definition: frame_window.h:819
Structure that defines a Child Frame within a Frame Window.
Definition: frame_window.h:409
structure for managing menu items
Definition: menu.h:127
left-justify text within the column (default)
Definition: frame_window.h:306
WBFrameWindow_FLAGS
Frame Window type and status flags.
Definition: frame_window.h:285
right justify text within the column
Definition: frame_window.h:308
void FWSetMenuHandlers(WBFrameWindow *pFrameWindow, const WBFWMenuHandler *pHandlerArray)
Function to assign the default menu handler to a frame window.
Definition: frame_window.c:761
WB_SCROLLINFO scrollSplit
reserved - 'scroll info' for 'split' area (implementation-defined)
Definition: frame_window.h:428
set this to make window immediately visible
Definition: frame_window.h:289
void FWRecalcLayout(Window wID)
Force a frame window to recalculate its layout, which may involve resizing multiple contained windows...
XColor FWGetDefaultFG(void)
Get the default foreground color.
Definition: frame_window.c:394
WB_POINT origin
viewport 'origin' in 'client units' (such as chars and lines) - determines scroll behavior ...
Definition: frame_window.h:418
struct __WBChildFrame__ * pNext
'Next Object' pointer in an internally stored linked list (do not alter or use this) ...
Definition: frame_window.h:445
void FWSetFocusWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont)
Sets the focus to a specific contained window using the Window ID.
XColor FWGetDefaultBD(void)
Get the default border color.
Definition: frame_window.c:408
Structure that defines scroll bar info for both horizontal and vertical scroll bars.
const Atom aTAB_MESSAGE
command sent by Client Message related to 'tab' operations
Definition: frame_window.c:192
char * szStatusText
Status text ('WBAlloc'd) to display when this child frame window has the input focus. Updated by 'superclass'. can be NULL.
Definition: frame_window.h:435
RESERVED - bit mask for 'splitter' flags.
Definition: frame_window.h:734
int FWAddContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pNew)
Adds a 'contained' window and returns the tab order index.
RESERVED - 'splitter' window with vertical sizeable 'split'.
Definition: frame_window.h:732
void FWSetFocusWindowIndex(WBFrameWindow *pFrameWindow, int iIndex)
Sets the focus to a specific contained window using its tab order index.
int FWGetNumContWindows(const WBFrameWindow *pFrameWindow)
Returns the total number of 'contained' windows.
void FWSetUserCallback(WBFrameWindow *pFW, WBWinEvent pCallBack)
assign a new WBWinEvent callback function for a frame window
Definition: frame_window.c:739
use PIXELS instead of characters and lines to define the viewport
Definition: frame_window.h:731
unsigned int ulTag
tag indicating I'm a 'Child Frame' window
Definition: frame_window.h:411
XFontSet rFontSet
default font for the window
Definition: frame_window.h:414
represents a 'break' (marks end of a column)
Definition: frame_window.h:304
structure for managing menu callbacks
Definition: frame_window.h:215
mask for the actual tab value
Definition: frame_window.h:303
struct __WB_FRAME_WINDOW__ WBFrameWindow
main controlling structure for frame windows
void FWSetStatusTabInfo(WBFrameWindow *pFrameWindow, int nTabs, const int *pTabs)
Sets the 'status' tab info for a Frame Window with a status bar.
int iClientWidth
The current width of the frame window's client area.
Definition: frame_window.h:272
Structure that defines a Child Frame's UI, mainly for a 'superclass'.
Definition: frame_window.h:662
int iClientHeight
The current height of the frame window's client area.
Definition: frame_window.h:273
int(* WBWinEvent)(Window wID, XEvent *pEvent)
event callback function type for window events
Atom aImageAtom
'image' atom for display in tabs. default is 'None'. You should not alter this member directly...
Definition: frame_window.h:433
XColor FWGetDefaultBG(void)
Get the default background color.
Definition: frame_window.c:401
bit flag to 'right justify' the column location
Definition: frame_window.h:310
int iRowHeight
cached 'row height' (height of line including interline spacing)
Definition: frame_window.h:421
Window wID
window identifier for the 'Child Frame' window. may contain 'None' while being destroyed ...
Definition: frame_window.h:412
WBChildFrame * FWGetContainedWindowByIndex(const WBFrameWindow *pFrameWindow, int iIndex)
Returns the Window ID for the specified 'contained' window. The index follows the tab order...
WB_EXTENT extent
viewport 'extent' in 'client units' (such as chars and lines) - determines scroll behavior ...
Definition: frame_window.h:419
RESERVED - bit set if split cannot be sized with the mouse.
Definition: frame_window.h:735
char * pszMenuResource
resource string for this child frame's menu (NULL = 'use default')
Definition: frame_window.h:437
internal wrapper struct for 'point' definition
int iColWidth
cached 'column width' (width of 1 character)
Definition: frame_window.h:422
WB_SCROLLINFO scroll
'scroll info' (horizontal and vertical min/max/pos and other details)
Definition: frame_window.h:424
main controlling structure for frame windows
Definition: frame_window.h:264
struct __WBChildFrameUI__ WBChildFrameUI
Structure that defines a Child Frame's UI, mainly for a 'superclass'.
center text within the column
Definition: frame_window.h:307
WBChildFrame_FLAGS
enumeration for 'fFlags' member of WBChildFrame
Definition: frame_window.h:728
struct __WB_FW_MENU_HANDLER__ WBFWMenuHandler
structure for managing menu callbacks
WBFWMenuHandler * pMenuHandler
menu handler for this child frame's menu (NULL = 'use default')
Definition: frame_window.h:438
WBFrameWindow * FWCreateFrameWindow(const char *szTitle, int idIcon, const char *szMenuResource, int iX, int iY, int iWidth, int iHeight, WBWinEvent pUserCallback, int iFlags)
Create a frame window.
Definition: frame_window.c:444
WB_GEOM geomEntire
client-area geometry (excludes scroll bars)
Definition: frame_window.h:417
struct __WBChildFrame__ WBChildFrame
Structure that defines a Child Frame within a Frame Window.
set this to enable a 'status bar' at the bottom
Definition: frame_window.h:291
int(* callback)(XClientMessageEvent *)
menu callback (gets pointer to the 'XClientMessageEvent').
Definition: frame_window.h:219
int iContextMenuID
menu ID (from pszMenuResource or owning frame's menu) for context popup, -1 if none ...
Definition: frame_window.h:439
void FWSetStatusText(WBFrameWindow *pFrameWindow, const char *szText)
Sets the 'status' text for a Frame Window with a status bar, forcing a re-paint.
unsigned int ulTag
tag indicating I'm a 'Child Frame UI' structure
Definition: frame_window.h:664
WBWinEvent pUserCallback
message callback function pointer (can be NULL)
Definition: frame_window.h:441
reserved: unspecified new justification method
Definition: frame_window.h:309
int iFlags
bitmask of attribute flags (see WBFrameWindow_FLAGS enumeration)
Definition: frame_window.h:268
unsigned long lMenuID
menu ID (< 0x10000L) or const pointer to string
Definition: frame_window.h:217
internal wrapper struct for X11 &#39;geometry&#39; definition
int iSplit
reserved - position for &#39;split&#39; (-1 for &#39;no split&#39;)
Definition: frame_window.h:426
void FWMoveChildFrameTabIndex(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, int iIndex)
Sets the specific contained window to a particular index in the tab order.
int(* UIcallback)(WBMenu *, WBMenuItem *)
menu &#39;UI&#39; callback to handle displaying menu states.
Definition: frame_window.h:226
WB_GEOM geom
total client-area geometry (excludes scroll bars) in &#39;pixels&#39;
Definition: frame_window.h:416
int iClientY
The current Y position of the frame window&#39;s client area (relative to the window) ...
Definition: frame_window.h:271