1 /* XDigger Copyright (C) 1988-99 Alexander Lang.
2
3 XDigger is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 XDigger is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
16
17 #include <stdio.h>
18 #include <X11/keysym.h>
19 #include <X11/Xlib.h>
20 #include <X11/Xutil.h>
21
22 #include "drawpixmaps.h"
23 #include "drawtext.h"
24 #include "icon.h"
25 #include "xdigger.h"
26
Init_Title()27 void Init_Title()
28 {
29 int i;
30
31 /* for (i=0; i<32; i++) */
32 /* WriteTextStr(" ", */
33 /* 0, i, kcf_weiss, kcb_blau); */
34 WriteTextStr("\234\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\236", 0, 0, kcf_weiss, kcb_blau);
35 WriteTextStr("\237\240\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\242\237", 0, 1, kcf_weiss, kcb_blau);
36 WriteTextStr("\237\243\234\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\236\251\237", 0, 2, kcf_weiss, kcb_blau);
37
38 for (i=3; i<27+2*vertvar; i++)
39 {
40 WriteTextStr("\237\243\237", 0, i, kcf_weiss, kcb_blau);
41 WriteTextStr("\237\251\237", 37, i, kcf_weiss, kcb_blau);
42 }
43
44 WriteTextStr("\200\201\202\203 \210 \211\212\213\214 \211\212\213\214 \200\201\215\215 \133\215\221\222", 7, 6, kcf_weiss, kcb_blau);
45 WriteTextStr("\133 \206\207 \133 \133 \215 \133 \215 \133 \133 \223\224", 7, 7, kcf_weiss, kcb_blau);
46 WriteTextStr("\133 \133 \133 \133 \244\216 \133 \244\216 \133\217\220 \133\225\226\227", 7, 8, kcf_weiss, kcb_blau);
47 WriteTextStr("\133 \260\261 \133 \133 \316\133 \133 \316\133 \133 \133 \230\231", 7, 9, kcf_weiss, kcb_blau);
48 WriteTextStr("\252\253\254\255 \262 \263\264\265\266 \263\264\265\266 \252\253\267\267 \133 \232\233", 7, 10, kcf_weiss, kcb_blau);
49
50 WriteTextStr("WRITTEN BY ALEXANDER LANG", 7, 13, kcf_weiss, kcb_blau);
51 /* WriteTextStr("GRAPHIX BY MARTIN GUTH", 7, 15, kcf_weiss, kcb_blau); */
52 WriteTextStr("GRAPHIX BY STEFAN DAHLKE", 7, 15, kcf_weiss, kcb_blau);
53 WriteTextStr("HUMBOLDT-UNIVERSITY \245\246", 7, 17, kcf_weiss, kcb_blau);
54 WriteTextStr(" BERLIN \247\250", 7, 18, kcf_weiss, kcb_blau);
55 WriteTextStr("P: PLAY", 11, 20, kcf_weiss, kcb_blau);
56 WriteTextStr("L: A LOOK AT THE ROOMS", 9, 22, kcf_weiss, kcb_blau);
57 WriteTextStr("\140 1988", 26, 25, kcf_weiss, kcb_blau);
58 WriteTextStr("BERLIN", 26, 26, kcf_weiss, kcb_blau);
59
60 WriteTextStr("\237\243\306\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\310\251\237", 0, 27+2*vertvar, kcf_weiss, kcb_blau);
61 WriteTextStr("\237\312\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\313\314\237", 0, 28+2*vertvar, kcf_weiss, kcb_blau);
62 WriteTextStr("\306\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\235\310", 0, 29+2*vertvar, kcf_weiss, kcb_blau);
63 } /* Init_Title() */
64
65 /*void ClearExposeEvents()
66 {
67 XEvent event;
68
69 while (XCheckWindowEvent(display, mainwindow, ExposureMask, &event));
70 }*/
71
Title()72 char Title()
73 {
74 XSetWindowAttributes setwindowattributes;
75 XWindowAttributes windowattributes;
76 unsigned long valuemask;
77 XEvent event;
78 Bool Done = False;
79 KeySym keysym;
80
81 strcpy(LastArgv, " (Title)");
82 setwindowattributes.background_pixel = kcb_blau;
83 valuemask = CWBackPixel;
84 XChangeWindowAttributes(display, mainwindow, valuemask, &setwindowattributes);
85
86 ClearCharField(kcb_blau, True);
87 Init_Title();
88 DrawTextField();
89
90 while (!Done)
91 {
92 if (!XEventsQueued(display, QueuedAfterReading))
93 {
94 XDigger_Idle();
95 XFlush(display);
96 } /* if (!XEventsQueued()) */
97 else
98 {
99 XNextEvent(display, &event);
100 if (event.xany.window == iconwindow)
101 Handle_IconWindow_Event(&event); else
102 switch(event.type)
103 {
104 case Expose:
105 /*fprintf(stderr, "%d %d %d %d \n", event.xexpose.x, event.xexpose.y,
106 event.xexpose.width, event.xexpose.height);
107 fflush(stderr);*/
108 /* Resize ? */
109 XGetWindowAttributes(display, mainwindow, &windowattributes);
110 if (xpmmag != windowattributes.width / 320)
111 ResizeXPixmaps(windowattributes.width / 320);
112 Mark_CharField(&event.xexpose, 29+2*vertvar);
113 if (event.xexpose.count == 0)
114 DrawTextField();
115 break;
116 /*case ResizeRequest:*/
117 case MappingNotify:
118 XRefreshKeyboardMapping(&event.xmapping);
119 break;
120 case ButtonPress:
121 if (event.xbutton.button == Button1) return('p');
122 break;
123 case KeyPress:
124 keysym = XKeycodeToKeysym(display, event.xkey.keycode, 0);
125 switch (keysym)
126 {
127 case XK_e: return('e');
128 case XK_l: return('l');
129 case XK_p: return('p');
130 case XK_q:
131 quit = True;
132 return('q');
133 case XK_plus:
134 case XK_KP_Add:
135 XResizeWindow(display, mainwindow, 320*(xpmmag+1),
136 (240 + vertvar*16)*(xpmmag+1));
137 break;
138 case XK_minus:
139 case XK_KP_Subtract:
140 if (xpmmag > 1)
141 XResizeWindow(display, mainwindow, 320*(xpmmag-1),
142 (240 + vertvar*16)*(xpmmag-1));
143 break;
144 }
145 break;
146 case ClientMessage:
147 if (event.xclient.data.l[0] == protocol[0])
148 {
149 /*exit(0);*/
150 quit = True;
151 return('q');
152 }
153 break;
154 /*case NoExpose:
155 break;
156 default:
157 fprintf(stderr, "default: %d\n", event.type);
158 fflush(stderr);*/
159 } /* switch(event.type) */
160 } /* if (!XEventsQueued()) else */
161 } /* while (!Done) */
162 strcpy(LastArgv, "");
163 return(0);
164 } /* char Title() */
165