summaryrefslogtreecommitdiff
path: root/src/iwindow.h
blob: c2cf75e60a59d1ccb68aadfafa7d149e2d957ced (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/**************************************************************************\
 ibtk (Insomnia's Basic ToolKit)

  By Insomnia (Steaphan Greene)
  (insomnia@core.binghamton.edu)

  Copyright (C) 1999 Steaphan Greene

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.

\**************************************************************************/

#ifndef IWINDOW_H
#define IWINDOW_H

#define IBTK_DEFAULT     0
#define IBTK_STEP        1

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>

#include <sys/time.h>

#include "idodad.h"
#include "pclaim.h"

class IWindow  {
private:
  Display *Disp;
  Window Win, Root, Icon;
  Pixmap WinBuf;
  GC gc, cgc;
  Atom closeatom;
  XFontStruct *fs;
  unsigned int wbgcol, bgcol, lbgcol, dbgcol, fgcol, pcol, scol;
  int mapped;
  PositionClaim *claim, *lclaim;
  IDoDad *pdd, *fdd;
  int quit;
  int DispFD;
  struct timeval *DispatchTime;
  void (*DispatchHook)(void);
  void RevRedraw(PositionClaim *it);
  void RevRedraw(PositionClaim *it, int x, int y, int xs, int ys);
  void Dispatch(XEvent ev);
  void Init(char *name, int xs, int ys, int xpos, int ypos, char *bg,
            Window* iwin, int xsi, int ysi);
  void LoadConfig();
  IWindow *parent;
  void (*activitycallback)(IWindow *);
  void (*exposecallback)(IWindow *);
  void (*resizecallback)(IWindow *, int, int);
  void (*repositioncallback)(IWindow *, int, int);
  void (*unhandledcallback)(IWindow *, XEvent *);
  void (*clickcallback)(IWindow *, int, int, int);
  void (*dblclickcallback)(IWindow *, int, int, int);
  void (*dragcallback)(IWindow *, int, int, int);
  void (*releasecallback)(IWindow *, int, int, int);
  void (*keymappingcallback)(IWindow *, XEvent *);
  int xsize, ysize, xpos, ypos, depth;
  int bufxs, bufys;
  int useicon, appearance;
  int xsizei, ysizei, xposi, yposi;
  Time clicktime;
  unsigned int doubleclicktime;

public:
  ~IWindow();
  unsigned int greencol, yellowcol, redcol;
  IWindow(char *bg = NULL);
  IWindow(int xs, int ys, char *bg = NULL);
  IWindow(int xs, int ys, int xpos, int ypos, char *bg = NULL);
  IWindow(char *name, char *bg = NULL,
          Window *iwin = NULL, int xsi = 96, int ysi = 72);
  IWindow(char *name, int xs, int ys, char *bg = NULL);
  IWindow(char *name, int xs, int ys, int xpos, int ypos, char *bg = NULL);
  void SetTitle(char *tit);
  Window GetWindow()  { return Win; };
  Window GetWindowBuffer()  { return WinBuf; };
  Window GetRootWindow()  { return Root; };
  Display *GetDisplay()  { return Disp; };
  GC GetGC()  { return gc; };
  GC GetClipGC()  { return cgc; };
  void RebuildClip();
  XFontStruct *GetFontStruct() { return fs; };
  Font GetFont() { return fs->fid; };
  void RegisterHook(void (*hookfn)(), struct timeval *waittime);
  void DispatchEvents();
  void DispatchCurrentEvents();
  void DispatchAutomaticEvents();
  int HasQuit() { return quit; };
  unsigned int GetSelectColor()  { return scol; };
  unsigned int GetPaperColor()  { return pcol; };
  unsigned int GetFGColor()  { return fgcol; };
  unsigned int GetWinBGColor()  { return wbgcol; };
  unsigned int GetBGColor()  { return bgcol; };
  unsigned int GetLBGColor()  { return lbgcol; };
  unsigned int GetDBGColor()  { return dbgcol; };
  void AddClaim(IDoDad *it, int x1, int y1, int x2, int y2);
  void RemoveClaim(IDoDad *it);
  void TakeFocus(IDoDad *it);
  IDoDad *GetFocus() { return fdd; };
  IDoDad *GetClaim(int x, int y);
  void Close();
  unsigned int GetRGBColor(int r, int g, int b);
  void Redraw();
  void Redraw(int, int, int, int);
  void Rebuild();
  void Rebuild(int, int, int, int);
  void SetParent(IWindow *p) { parent = p; };
  void SetActivityCallback(void (*cb)(IWindow *));
  void SetExposeCallback(void (*cb)(IWindow *));
  void SetResizeCallback(void (*cb)(IWindow *, int, int));
  void SetRepositionCallback(void (*cb)(IWindow *, int, int));
  void SetUnhandledCallback(void (*cb)(IWindow *, XEvent *));
  void SetClickCallback(void (*cb)(IWindow *, int, int, int));
  void SetDblClickCallback(void (*cb)(IWindow *, int, int, int));
  void SetDragCallback(void (*cb)(IWindow *, int, int, int));
  void SetReleaseCallback(void (*cb)(IWindow *, int, int, int));
  void SetKeyMappingCallback(void (*cb)(IWindow *, XEvent *));
  void Resize(int, int);
  void SetBufSize(int, int);
  void Map(int, int);
  void Map();
  void Clear();
  void Activity() { if(activitycallback) (*activitycallback)(this); };
  int XPos() { return (mapped) ? xpos : xposi; };
  int YPos() { return (mapped) ? ypos : yposi; };
  int XSize() { return (mapped) ? xsize : xsizei; };
  int YSize() { return (mapped) ? ysize : ysizei; };
  int XDeskSize();
  int YDeskSize();
  int Depth() { return depth; };
  void EnableIcon() { if(Icon) useicon=1; };
  void DisableIcon() { useicon=0; };
  int Appearance() { return appearance; };
  };

#endif