3 * Copyright (c) 2000 Makoto Sugano
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include <libdockapp/dockapp.h>
28 #include "XPM/back.xpm"
29 #include "XPM/button_pressed.xpm"
31 #include "XPM/daikichi.xpm"
32 #include "XPM/chukichi.xpm"
33 #include "XPM/shoukichi.xpm"
34 #include "XPM/suekichi.xpm"
35 #include "XPM/kyou.xpm"
36 #include "XPM/daikyou.xpm"
42 char *displayName
= "";
44 Pixmap back_pixmap
, back_mask
;
45 Pixmap button_pressed_pixmap
;
48 int i
, j
, animation
= ON
;
51 buttonReleaseCallback (int button
, int state
, int x
, int y
)
53 if (button
== 1 && 0 < x
&& x
< 64 && 44 < y
&& y
< 64){
54 srand(time(0L) * (getpid()));
56 j
= rand() / (RAND_MAX
/ 6 + 1) + 18;
59 XCopyArea(DADisplay
, back_pixmap
, pixmap
, gc
, 0, 44, 64, 64, 0, 44);
64 buttonPressCallback (int button
, int state
, int x
, int y
)
66 if (button
== 1 && 0 < x
&& x
< 64 && 44 < y
&& y
< 64){
67 XCopyArea(DADisplay
, button_pressed_pixmap
, pixmap
, gc
, 0, 44, 64, 64, 0, 44);
72 static DAProgramOption options
[] = {
73 {"-d", "--displayname", "display to use.", DOString
, False
, {&displayName
}},
76 int main(int argc
, char **argv
)
78 Pixmap daikichi_pixmap
;
79 Pixmap chukichi_pixmap
;
80 Pixmap shoukichi_pixmap
;
81 Pixmap suekichi_pixmap
;
83 Pixmap daikyou_pixmap
;
85 short unsigned int w
= 64, h
= 64;
87 DACallbacks callbacks
= {NULL
,buttonPressCallback
88 ,buttonReleaseCallback
,NULL
,NULL
,NULL
,NULL
};
90 DAParseArguments(argc
, argv
, options
,
91 sizeof(options
)/sizeof(DAProgramOption
),
92 "dockapp that predict your luck", "wmomikuzi 0.122");
94 DAInitialize(displayName
, "wmomikuzi", 64, 64, argc
, argv
);
95 pixmap
= DAMakePixmap();
97 /* making pixmaps for the panel */
98 DAMakePixmapFromData(back_xpm
, &back_pixmap
, &back_mask
, &w
, &h
);
99 DAMakePixmapFromData(button_pressed_xpm
, &button_pressed_pixmap
, NULL
, &w
, &h
);
101 DAMakePixmapFromData(daikichi_xpm
, &daikichi_pixmap
, NULL
, &w
, &h
);
102 DAMakePixmapFromData(chukichi_xpm
, &chukichi_pixmap
, NULL
, &w
, &h
);
103 DAMakePixmapFromData(shoukichi_xpm
, &shoukichi_pixmap
, NULL
, &w
, &h
);
104 DAMakePixmapFromData(suekichi_xpm
, &suekichi_pixmap
, NULL
, &w
, &h
);
105 DAMakePixmapFromData(kyou_xpm
, &kyou_pixmap
, NULL
, &w
, &h
);
106 DAMakePixmapFromData(daikyou_xpm
, &daikyou_pixmap
, NULL
, &w
, &h
);
108 /* setting up the mask for the panel */
109 DASetShape(back_mask
);
110 DASetPixmap(back_pixmap
);
112 /* setting up the graphic context */
113 gc
= DefaultGC(DADisplay
, DefaultScreen(DADisplay
));
115 DASetCallbacks(&callbacks
);
118 srand(time(0L) * (getpid()));
120 j
= rand() / (RAND_MAX
/ 6 + 1) + 18;
122 /* draws the button part */
123 XCopyArea(DADisplay
, back_pixmap
, pixmap
, gc
, 0, 44, 64, 64, 0, 44);
128 /* draws the display part */
129 XCopyArea(DADisplay
, back_pixmap
, pixmap
, gc
, 0, 0, 64, 44, 0, 0);
132 XCopyArea(DADisplay
, daikichi_pixmap
, pixmap
, gc
, 0, 0, 64, 39, 5, 5);
133 } else if ((i
% 6) == 2){
134 XCopyArea(DADisplay
, chukichi_pixmap
, pixmap
, gc
, 0, 0, 64, 39, 5, 5);
135 } else if ((i
% 6) == 3){
136 XCopyArea(DADisplay
, shoukichi_pixmap
, pixmap
, gc
, 0, 0, 64, 39, 5, 5);
137 } else if ((i
% 6) == 4){
138 XCopyArea(DADisplay
, suekichi_pixmap
, pixmap
, gc
, 0, 0, 64, 39, 5, 5);
139 } else if ((i
% 6) == 5){
140 XCopyArea(DADisplay
, kyou_pixmap
, pixmap
, gc
, 0, 0, 64, 39, 5, 5);
141 } else if ((i
% 6) == 0){
142 XCopyArea(DADisplay
, daikyou_pixmap
, pixmap
, gc
, 0, 0, 64, 39, 5, 5);
148 /* j is the destination number */
155 while (animation
== OFF
) {
157 /* handle all pending X events */
158 while (XPending(DADisplay
)) {
159 XNextEvent(DADisplay
, &ev
);