X11 Work Bench Toolkit  1.0
frame_window.h
Go to the documentation of this file.
1 
2 // __ _ _ _ //
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 
407 typedef struct __WBChildFrame__
408 {
409  unsigned int ulTag;
410  Window wID;
412  XFontSet rFontSet;
413 
415 
416  int iTop;
417  int iHeight;
418  int iLeft;
419  int iWidth;
420 
421  int iXExtent;
422  int iYExtent;
423 
425 
426  int iSplit;
427 
429 
430  int fFlags;
431 
433  Atom aImageAtom;
434 
435  char *szStatusText;
436 
439 
441  void (*destructor)(struct __WBChildFrame__ *);
443 
445 } WBChildFrame;
446 
447 
448 // WBChildFrame is defined HERE to avoid circular header file dependencies
449 // (also defining supporting structs for same reason)
450 
661 typedef struct __WBChildFrameUI__
662 {
663  unsigned int ulTag;
664  void (*do_char)(WBChildFrame *, XClientMessageEvent *);
665  void (*scancode)(WBChildFrame *, XClientMessageEvent *);
666  void (*bkspace)(WBChildFrame *, int iACS);
667  void (*del)(WBChildFrame *, int iACS);
668  void (*tab)(WBChildFrame *, int iACS);
669  void (*enter)(WBChildFrame *, int iACS);
670  void (*uparrow)(WBChildFrame *, int iACS);
671  void (*downarrow)(WBChildFrame *, int iACS);
672  void (*leftarrow)(WBChildFrame *, int iACS);
673  void (*rightarrow)(WBChildFrame *, int iACS);
674  void (*home)(WBChildFrame *, int iACS);
675  void (*end)(WBChildFrame *, int iACS);
676  void (*pgup)(WBChildFrame *, int iACS);
677  void (*pgdown)(WBChildFrame *, int iACS);
678  void (*pgleft)(WBChildFrame *, int iACS);
679  void (*pgright)(WBChildFrame *, int iACS);
680  void (*help)(WBChildFrame *, int iACS);
681  void (*hover_notify)(WBChildFrame *, int x, int y);
687  void (*cut_to_cb)(WBChildFrame *);
691  void (*save)(WBChildFrame *, const char *szFileName);
692 
694 
695  void (*mouse_click)(WBChildFrame *, int iX, int iY,
696  int iButtonMask, int iACS);
697  void (*mouse_dblclick)(WBChildFrame *, int iX, int iY,
698  int iButtonMask, int iACS);
699  void (*mouse_drag)(WBChildFrame *, int iX, int iY,
700  int iButtonMask, int iACS);
701  void (*mouse_drop)(WBChildFrame *, int iX, int iY,
702  int iButtonMask, int iACS);
703  void (*mouse_move)(WBChildFrame *, int iX, int iY);
704  void (*mouse_scrollup)(WBChildFrame *, int iX, int iY,
705  int iButtonMask, int iACS);
706  void (*mouse_scrolldown)(WBChildFrame *, int iX, int iY,
707  int iButtonMask, int iACS);
709  void (*get_row_col)(WBChildFrame *, int *piR, int *piC);
711  void (*undo)(WBChildFrame *);
712  void (*redo)(WBChildFrame *);
713  int (*can_undo)(WBChildFrame *);
714  int (*can_redo)(WBChildFrame *);
715  int (*is_empty)(WBChildFrame *);
716 
718 
719 
720 
721 
728 {
735 };
736 
737 
738 // FRAME WINDOW ATOMS
739 
740 #if !defined(_FRAME_WINDOW_C_) && !defined(_CLIPBOARD_HELPER_C)
741  /* this declares the atoms 'const' outside of frame_window.c, and does NOT declare them in clipboard_helper.c */
742  /* These atoms are GLOBAL variables, assigned by the DEFAULT Display, and may not work for other threads. */
743 
744 extern const Atom aTAB_MESSAGE; // command sent by Client Message related to tabs
745 
746 #endif // !defined(_FRAME_WINDOW_C_) && !defined(_CLIPBOARD_HELPER_C)
747 
748 
749 
750 
751 
777 WBFrameWindow *FWCreateFrameWindow(const char *szTitle, int idIcon, const char *szMenuResource,
778  int iX, int iY, int iWidth, int iHeight,
779  WBWinEvent pUserCallback, int iFlags);
780 
791 void FWRecalcLayout(Window wID); // recalculate layout information (propagates to contained windows)
792 
793 
805 void FWSetUserCallback(WBFrameWindow *pFW, WBWinEvent pCallBack);
806 
807 
818 static __inline__ WBFrameWindow *FWGetFrameWindowStruct(Window wID) // for frame windows, returns the frame window struct
819 {
820  WBFrameWindow *pRval = (WBFrameWindow *)WBGetWindowData(wID, 0); // offset 0 for window-specific structs
821 
822  if(pRval && pRval->ulTag == FRAME_WINDOW_TAG)
823  {
824  return(pRval);
825  }
826 
827  return(NULL);
828 }
829 
840 void FWDestroyFrameWindow(Window wID); // destroys frame window using the Window ID (frees the struct also)
841 
852 void FWDestroyFrameWindow2(WBFrameWindow *pFrameWindow); // destroys it using the struct pointer
853 
868 void FWSetMenuHandlers(WBFrameWindow *pFrameWindow, const WBFWMenuHandler *pHandlerArray);
869 
876 #define FW_MENU_HANDLER_BEGIN(X) static const WBFWMenuHandler X[] = {
877 
885 #define FW_MENU_HANDLER_ENTRY(X,Y,Z) { (unsigned long)X, Y, Z },
886 
890 #define FW_MENU_HANDLER_END {0, 0, 0} };
891 
892 
893 // frame window 'contents' functions
894 
903 int FWGetNumContWindows(const WBFrameWindow *pFrameWindow);
904 
917 WBChildFrame * FWGetContainedWindowByIndex(const WBFrameWindow *pFrameWindow, int iIndex);
918 
925 #define FWGetFocusWindow(pFW) FWGetContainedWindowByIndex(pFW, -1)
926 
936 int FWAddContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pNew);
937 
947 void FWRemoveContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
948 
976 void FWReplaceContainedWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, WBChildFrame *pContNew);
977 
987 void FWSetFocusWindow(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
988 
998 void FWSetFocusWindowIndex(WBFrameWindow *pFrameWindow, int iIndex);
999 
1009 int FWGetChildFrameIndex(WBFrameWindow *pFrameWindow, WBChildFrame *pCont);
1010 
1021 void FWMoveChildFrameTabIndex(WBFrameWindow *pFrameWindow, WBChildFrame *pCont, int iIndex);
1022 
1038 void FWSetStatusText(WBFrameWindow *pFrameWindow, const char *szText);
1039 
1061 void FWSetStatusTabInfo(WBFrameWindow *pFrameWindow, int nTabs, const int *pTabs);
1062 
1063 // DEFAULT COLORS
1064 
1072 XColor FWGetDefaultFG(void);
1073 
1081 XColor FWGetDefaultBG(void);
1082 
1090 XColor FWGetDefaultBD(void);
1091 
1092 
1093 #if 0
1094 
1109 int FWDoSelectionEvents(WBFrameWindow *pFrameWindow, Window wID, Window wIDMenu, XEvent *pEvent);
1110 #endif // 0
1111 
1112 
1113 #ifdef __cplusplus
1114 };
1115 #endif // __cplusplus
1116 
1117 
1118 #endif // FRAME_WINDOW_H_INCLUDED
1119