X11workbench 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-2018 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 <inttypes.h> // needed for intptr_t, uintptr_t among other things
55 
56 //#include "window_helper.h"
57 #include "window_dressing.h"
58 #include "menu_bar.h"
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif // __cplusplus
63 
64 
65 
182 #define FRAME_WINDOW_TAG (*((const unsigned int *)"FWFW"))
183 
184 
218 {
219  uintptr_t lMenuID;
220 
221  int (* callback)(XClientMessageEvent *);
222 
228  int (* UIcallback)(WBMenu *, WBMenuItem *);
230 
231 
232 
274 typedef struct __WB_FRAME_WINDOW__
275 {
276  unsigned int ulTag;
277  Window wID;
278  int iFlags;
279 
280  int iClientX;
281  int iClientY;
284 
285 } WBFrameWindow;
286 
287 
288 
296 {
297 
302 
303  WBFrameWindow_MAX = 0x80000000L
304 };
305 
312 {
313  WBStatusTabInfo_MASK = 0x0fffffff,
314  WBStatusTabInfo_BREAK = 0x10000000,
321 };
322 
323 
324 // NOTE: WBChildFrame and WBChildFrameUI are defined HERE to avoid circular header file dependencies
325 // (also defining supporting structs for same reason)
326 
327 struct __WBChildFrameUI__; // forward declaration
328 
426 typedef struct __WBChildFrame__
427 {
428  unsigned int ulTag;
429  Window wID;
431  XFontSet rFontSet;
432 
437 
439  int iColWidth;
440 
442 
443  int iSplit;
444 
446 
447  int fFlags;
448 
450  Atom aImageAtom;
451 
452  char *szStatusText;
453 
457 
459  void (*destructor)(struct __WBChildFrame__ *);
461 
463 } WBChildFrame;
464 
465 
677 typedef struct __WBChildFrameUI__
678 {
679  unsigned int ulTag;
680  void (*do_char)(WBChildFrame *, XClientMessageEvent *);
681  void (*scancode)(WBChildFrame *, XClientMessageEvent *);
682  void (*bkspace)(WBChildFrame *, int iACS);
683  void (*del)(WBChildFrame *, int iACS);
684  void (*tab)(WBChildFrame *, int iACS);
685  void (*enter)(WBChildFrame *, int iACS);
686  void (*properties)(WBChildFrame *);
687  void (*uparrow)(WBChildFrame *, int iACS);
688  void (*downarrow)(WBChildFrame *, int iACS);
689  void (*leftarrow)(WBChildFrame *, int iACS);
690  void (*rightarrow)(WBChildFrame *, int iACS);
691  void (*home)(WBChildFrame *, int iACS);
692  void (*end)(WBChildFrame *, int iACS);
693  void (*pgup)(WBChildFrame *, int iACS);
694  void (*pgdown)(WBChildFrame *, int iACS);
695  void (*pgleft)(WBChildFrame *, int iACS);
696  void (*pgright)(WBChildFrame *, int iACS);
697  void (*help)(WBChildFrame *, int iACS);
698  void (*hover_notify)(WBChildFrame *, int x, int y);
699  void (*hover_cancel)(WBChildFrame *);
700  int (*is_ins_mode)(WBChildFrame *);
701  void (*toggle_ins_mode)(WBChildFrame *);
702  void (*copy_to_cb)(WBChildFrame *);
703  void (*paste_from_cb)(WBChildFrame *);
704  void (*cut_to_cb)(WBChildFrame *);
705  void (*delete_sel)(WBChildFrame *);
706  void (*select_all)(WBChildFrame *);
707  void (*select_none)(WBChildFrame *);
708  void (*save)(WBChildFrame *, const char *szFileName);
709 
710  WB_PCSTR (* get_file_name)(WBChildFrame *);
711 
712  void (*mouse_click)(WBChildFrame *, int iX, int iY,
713  int iButtonMask, int iACS);
714  void (*mouse_dblclick)(WBChildFrame *, int iX, int iY,
715  int iButtonMask, int iACS);
716  void (*mouse_drag)(WBChildFrame *, int iX, int iY,
717  int iButtonMask, int iACS);
718  void (*mouse_drop)(WBChildFrame *, int iX, int iY,
719  int iButtonMask, int iACS);
720  void (*mouse_move)(WBChildFrame *, int iX, int iY);
721 
722  void (*scroll_vert)(WBChildFrame *, int iMode, int iValue);
723  void (*scroll_horiz)(WBChildFrame *, int iMode, int iValue);
724 
725  void (*mouse_cancel)(WBChildFrame *);
726  void (*get_row_col)(WBChildFrame *, int *piR, int *piC);
727  int (*has_selection)(WBChildFrame *);
728  void (*undo)(WBChildFrame *);
729  void (*redo)(WBChildFrame *);
730  int (*can_undo)(WBChildFrame *);
731  int (*can_redo)(WBChildFrame *);
732  int (*is_empty)(WBChildFrame *);
733 
735 
736 
737 
738 
745 {
752 };
753 
754 
755 // FRAME WINDOW ATOMS
756 
757 #if !defined(_FRAME_WINDOW_C_) && !defined(_CLIPBOARD_HELPER_C)
758  /* this declares the atoms 'const' outside of frame_window.c, and does NOT declare them in clipboard_helper.c */
759  /* These atoms are GLOBAL variables, assigned by the DEFAULT Display, and may not work for other threads. */
760 
761 extern const Atom aTAB_MESSAGE; // command sent by Client Message related to tabs
762 
763 #endif // !defined(_FRAME_WINDOW_C_) && !defined(_CLIPBOARD_HELPER_C)
764 
765 
766 
767 
768 
794 WBFrameWindow *FWCreateFrameWindow(const char *szTitle, int idIcon, const char *szMenuResource,
795  int iX, int iY, int iWidth, int iHeight,
796  WBWinEvent pUserCallback, int iFlags);
797 
808 void FWRecalcLayout(Window wID); // recalculate layout information (propagates to contained windows)
809 
810 
822 void FWSetUserCallback(WBFrameWindow *pFW, WBWinEvent pCallBack);
823 
824 
835 static __inline__ WBFrameWindow *FWGetFrameWindowStruct(Window wID) // for frame windows, returns the frame window struct
836 {
837  WBFrameWindow *pRval = (WBFrameWindow *)WBGetWindowData(wID, 0); // offset 0 for window-specific structs
838 
839  if(pRval && pRval->ulTag == FRAME_WINDOW_TAG)
840  {
841  return(pRval);
842  }
843 
844  return(NULL);
845 }
846 
857 void FWDestroyFrameWindow(Window wID); // destroys frame window using the Window ID (frees the struct also)
858 
869 void FWDestroyFrameWindow2(WBFrameWindow *pFrameWindow); // destroys it using the struct pointer
870 
885 void FWSetMenuHandlers(WBFrameWindow *pFrameWindow, const WBFWMenuHandler *pHandlerArray);
886 
893 #define FW_MENU_HANDLER_BEGIN(X) static const WBFWMenuHandler X[] = {
894 
902 #define FW_MENU_HANDLER_ENTRY(X,Y,Z) { (unsigned long)X, Y, Z },
903 
907 #define FW_MENU_HANDLER_END {0, 0, 0} };
908 
909 
910 // frame window 'contents' functions
911 
920 int FWGetNumContWindows(const WBFrameWindow *pFrameWindow);
921 
934 WBChildFrame * FWGetContainedWindowByIndex(const WBFrameWindow *pFrameWindow, int iIndex);
935 
942 #define FWGetFocusWindow(pFW) FWGetContainedWindowByIndex(pFW, -1)
943 
953 int FWAddContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pNew);
954 
964 void FWRemoveContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
965 
993 void FWReplaceContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, WBChildFrame *pContNew);
994 
1004 void FWSetFocusWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
1005 
1015 void FWSetFocusWindowIndex(WBFrameWindow *pFrameWindow, int iIndex);
1016 
1026 int FWGetChildFrameIndex(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
1027 
1038 void FWMoveChildFrameTabIndex(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, int iIndex);
1039 
1044 #define MOVE_CHILD_FRAME_TAB_INDEX_BEGINNING 0
1045 
1049 #define MOVE_CHILD_FRAME_TAB_INDEX_RIGHT -2
1050 
1054 #define MOVE_CHILD_FRAME_TAB_INDEX_LEFT -1
1055 
1071 void FWSetStatusText(WBFrameWindow *pFrameWindow, const char *szText);
1072 
1094 void FWSetStatusTabInfo(WBFrameWindow *pFrameWindow, int nTabs, const int *pTabs);
1095 
1096 // DEFAULT COLORS
1097 
1105 XColor FWGetDefaultFG(void);
1106 
1114 XColor FWGetDefaultBG(void);
1115 
1123 XColor FWGetDefaultBD(void);
1124 
1125 
1126 #if 0
1127 
1142 int FWDoSelectionEvents(WBFrameWindow *pFrameWindow, Window wID, Window wIDMenu, XEvent *pEvent);
1143 #endif // 0
1144 
1145 
1146 #ifdef __cplusplus
1147 };
1148 #endif // __cplusplus
1149 
1150 
1151 #endif // FRAME_WINDOW_H_INCLUDED
1152 
RESERVED - &#39;splitter&#39; window with horizontal sizeable &#39;split&#39;.
Definition: frame_window.h:749
void FWReplaceContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, WBChildFrame *pContNew)
Replace a &#39;contained&#39; window from a frame window.
internal wrapper struct for &#39;extent&#39; definition
struct __WBChildFrameUI__ * pUI
pointer to &#39;WBChildFrameUI&#39; function pointer table (assigned by &#39;superclass&#39;)
Definition: frame_window.h:460
structure for managing menu items
Definition: menu.h:185
set this to disable tabs (single child frame only)
Definition: frame_window.h:300
int iClientX
The current X position of the frame window&#39;s client area (relative to the window) ...
Definition: frame_window.h:280
void FWRemoveContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont)
Removes a &#39;contained&#39; window from a frame window. Does not destroy the &#39;contained&#39; 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:303
set this flag for application top-level window and whenever it is destroyed the application will exit...
Definition: frame_window.h:298
void FWDestroyFrameWindow2(WBFrameWindow *pFrameWindow)
Function to destroy a frame window based on the WBFrameWindow structure.
Definition: frame_window.c:722
unsigned int ulTag
tag indicating I&#39;m a frame window
Definition: frame_window.h:276
WBStatusTabInfo_FLAGS
enumeration for bit flags that are &#39;or&#39;d with the tab stop index
Definition: frame_window.h:311
Window wID
Window id for the frame window.
Definition: frame_window.h:277
void FWDestroyFrameWindow(Window wID)
Function to destroy a frame window based on the Window id.
Definition: frame_window.c:717
char * szDisplayName
display name shown in tab and title bar. You should not alter this member directly.
Definition: frame_window.h:449
int fFlags
various bitflags defining features. See WBChildFrame_FLAGS enum.
Definition: frame_window.h:447
WBFrameWindow * pOwner
a pointer to the WBFrameWindow owner
Definition: frame_window.h:430
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:746
#define FRAME_WINDOW_TAG
TAG for the WBFrameWindow structure.
Definition: frame_window.h:182
mask for the &#39;justification&#39; value
Definition: frame_window.h:315
static __inline__ WBFrameWindow * FWGetFrameWindowStruct(Window wID)
Obtain the associated WBFrameWindow structure pointer for a frame window&#39;s Window ID...
Definition: frame_window.h:835
Structure that defines a Child Frame within a Frame Window.
Definition: frame_window.h:426
structure for managing menu items
Definition: menu.h:127
left-justify text within the column (default)
Definition: frame_window.h:316
WBFrameWindow_FLAGS
Frame Window type and status flags.
Definition: frame_window.h:295
right justify text within the column
Definition: frame_window.h:318
void FWSetMenuHandlers(WBFrameWindow *pFrameWindow, const WBFWMenuHandler *pHandlerArray)
Function to assign the default menu handler to a frame window.
Definition: frame_window.c:794
WB_SCROLLINFO scrollSplit
reserved - &#39;scroll info&#39; for &#39;split&#39; area (implementation-defined)
Definition: frame_window.h:445
set this to make window immediately visible
Definition: frame_window.h:299
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:427
WB_POINT origin
viewport &#39;origin&#39; in &#39;client units&#39; (such as chars and lines) - determines scroll behavior ...
Definition: frame_window.h:435
struct __WBChildFrame__ * pNext
&#39;Next Object&#39; pointer in an internally stored linked list (do not alter or use this) ...
Definition: frame_window.h:462
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:441
Structure that defines scroll bar info for both horizontal and vertical scroll bars.
const Atom aTAB_MESSAGE
command sent by Client Message related to &#39;tab&#39; operations
Definition: frame_window.c:192
char * szStatusText
Status text (&#39;WBAlloc&#39;d) to display when this child frame window has the input focus. Updated by &#39;superclass&#39;. can be NULL.
Definition: frame_window.h:452
RESERVED - bit mask for &#39;splitter&#39; flags.
Definition: frame_window.h:750
int FWAddContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pNew)
Adds a &#39;contained&#39; window and returns the tab order index.
RESERVED - &#39;splitter&#39; window with vertical sizeable &#39;split&#39;.
Definition: frame_window.h:748
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 &#39;contained&#39; windows.
void FWSetUserCallback(WBFrameWindow *pFW, WBWinEvent pCallBack)
assign a new WBWinEvent callback function for a frame window
Definition: frame_window.c:772
use PIXELS instead of characters and lines to define the viewport
Definition: frame_window.h:747
unsigned int ulTag
tag indicating I&#39;m a &#39;Child Frame&#39; window
Definition: frame_window.h:428
XFontSet rFontSet
default font for the window
Definition: frame_window.h:431
represents a &#39;break&#39; (marks end of a column)
Definition: frame_window.h:314
structure for managing menu callbacks
Definition: frame_window.h:217
mask for the actual tab value
Definition: frame_window.h:313
struct __WB_FRAME_WINDOW__ WBFrameWindow
main controlling structure for frame windows
Definition: X11workbench.h:111
void FWSetStatusTabInfo(WBFrameWindow *pFrameWindow, int nTabs, const int *pTabs)
Sets the &#39;status&#39; tab info for a Frame Window with a status bar.
int iClientWidth
The current width of the frame window&#39;s client area.
Definition: frame_window.h:282
Structure that defines a Child Frame&#39;s UI, mainly for a &#39;superclass&#39;.
Definition: frame_window.h:677
uintptr_t lMenuID
menu ID (< 0x10000L) or const pointer to string
Definition: frame_window.h:219
int iClientHeight
The current height of the frame window&#39;s client area.
Definition: frame_window.h:283
int(* WBWinEvent)(Window wID, XEvent *pEvent)
event callback function type for window events
Atom aImageAtom
&#39;image&#39; atom for display in tabs. default is &#39;None&#39;. You should not alter this member directly...
Definition: frame_window.h:450
XColor FWGetDefaultBG(void)
Get the default background color.
Definition: frame_window.c:434
bit flag to &#39;right justify&#39; the column location
Definition: frame_window.h:320
int iRowHeight
cached &#39;row height&#39; (height of line including interline spacing)
Definition: frame_window.h:438
Window wID
window identifier for the &#39;Child Frame&#39; window. may contain &#39;None&#39; while being destroyed ...
Definition: frame_window.h:429
WBChildFrame * FWGetContainedWindowByIndex(const WBFrameWindow *pFrameWindow, int iIndex)
Returns the Window ID for the specified &#39;contained&#39; window. The index follows the tab order...
WB_EXTENT extent
viewport &#39;extent&#39; in &#39;client units&#39; (such as chars and lines) - determines scroll behavior ...
Definition: frame_window.h:436
RESERVED - bit set if split cannot be sized with the mouse.
Definition: frame_window.h:751
char * pszMenuResource
resource string for this child frame&#39;s menu (NULL = &#39;use default&#39;)
Definition: frame_window.h:454
internal wrapper struct for &#39;point&#39; definition
int iColWidth
cached &#39;column width&#39; (width of 1 character)
Definition: frame_window.h:439
WB_SCROLLINFO scroll
&#39;scroll info&#39; (horizontal and vertical min/max/pos and other details)
Definition: frame_window.h:441
main controlling structure for frame windows
Definition: frame_window.h:274
struct __WBChildFrameUI__ WBChildFrameUI
Structure that defines a Child Frame&#39;s UI, mainly for a &#39;superclass&#39;.
center text within the column
Definition: frame_window.h:317
WBChildFrame_FLAGS
enumeration for &#39;fFlags&#39; member of WBChildFrame
Definition: frame_window.h:744
struct __WB_FW_MENU_HANDLER__ WBFWMenuHandler
structure for managing menu callbacks
WBFWMenuHandler * pMenuHandler
menu handler for this child frame&#39;s menu (NULL = &#39;use default&#39;)
Definition: frame_window.h:455
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:477
WB_GEOM geomEntire
client-area geometry (excludes scroll bars)
Definition: frame_window.h:434
struct __WBChildFrame__ WBChildFrame
Structure that defines a Child Frame within a Frame Window.
set this to enable a &#39;status bar&#39; at the bottom
Definition: frame_window.h:301
int(* callback)(XClientMessageEvent *)
menu callback (gets pointer to the &#39;XClientMessageEvent&#39;).
Definition: frame_window.h:221
int iContextMenuID
menu ID (from pszMenuResource or owning frame&#39;s menu) for context popup, -1 if none ...
Definition: frame_window.h:456
void FWSetStatusText(WBFrameWindow *pFrameWindow, const char *szText)
Sets the &#39;status&#39; text for a Frame Window with a status bar, forcing a re-paint.
unsigned int ulTag
tag indicating I&#39;m a &#39;Child Frame UI&#39; structure
Definition: frame_window.h:679
WBWinEvent pUserCallback
message callback function pointer (can be NULL)
Definition: frame_window.h:458
reserved: unspecified new justification method
Definition: frame_window.h:319
int iFlags
bitmask of attribute flags (see WBFrameWindow_FLAGS enumeration)
Definition: frame_window.h:278
const char * WB_PCSTR
pointer to const char string - a convenience typedef
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:443
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:228
WB_GEOM geom
total client-area geometry (excludes scroll bars) in &#39;pixels&#39;
Definition: frame_window.h:433
int iClientY
The current Y position of the frame window&#39;s client area (relative to the window) ...
Definition: frame_window.h:281