2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published
4 * by the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
12 * You should have received a copy of the GNU General Public
13 * License along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 #include "testwindow.h"
19 // c++ -g -I../guicast testwindow.C ../guicast/x86_64/libguicast.a \
20 // -DHAVE_GL -DHAVE_XFT -I/usr/include/freetype2 -lGL -lX11 -lXext \
21 // -lXinerama -lXv -lpng -lfontconfig -lfreetype -lXft -pthread
25 : BC_Window("test", xS(100),yS(100), xS(100),yS(100), xS(100),yS(100))
27 in_motion = 0; last_x = last_y = -1;
29 clear_box(0,0,get_w(),get_h());
31 tx = get_text_ascent(MEDIUMFONT);
32 ty = tx + get_text_height(MEDIUMFONT);
40 int TestWindowGUI::button_press_event()
42 if( !is_event_win() ) return 0;
43 if( !cursor_inside() ) return 0;
44 if( get_buttonpress() != 1 ) return 0;
46 last_x = get_abs_cursor_x(0);
47 last_y = get_abs_cursor_y(0);
51 int TestWindowGUI::button_release_event()
57 int TestWindowGUI::cursor_motion_event()
59 if( !in_motion ) return 1;
60 char position[BCSTRLEN];
61 int cx = get_abs_cursor_x(0), dx = cx-last_x; last_x = cx;
62 int cy = get_abs_cursor_y(0), dy = cy-last_y; last_y = cy;
63 reposition_window_relative(dx, dy);
64 snprintf(position,sizeof(position),"%d,%d",get_x(),get_y());
65 clear_box(0,0,get_w(),get_h());
67 draw_text(tx,ty, position);
76 int main(int ac, char **av)
80 TestWindow test_window;