Use proper namespace for iostream classes
[AXE.git] / demos / doodle3.cpp
1 /**************************************************************************
2 **  (c) Copyright 2002, Andromeda Technology & Automation
3 ***************************************************************************
4 ** MODULE INFORMATION *
5 ***********************
6 **      FILE NAME      : doodle2.cpp
7 **      SYSTEM NAME    : AXE - Andromeda X-windows Encapsulation
8 **      VERSION NUMBER : $Revision: 1.2 $
9 **
10 **  DESCRIPTION      :  Doodle is an exmaple application to demonstrate
11 **                      the functions in AXE as a tutorial.
12 **                      The second phase shows how to draw graphics in a
13 **                      window and the event handling mechanism.
14 **
15 **  EXPORTED OBJECTS : 
16 **  LOCAL    OBJECTS : 
17 **  MODULES  USED    :
18 ***************************************************************************
19 **  ADMINISTRATIVE INFORMATION *
20 ********************************
21 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
22 **      CREATION DATE   : Mar 01, 2002
23 **************************************************************************/
24
25 /*****************************
26    $Log: doodle3.cpp,v $
27    Revision 1.2  2002-11-04 07:44:45  arjen
28    Use proper namespace for iostream classes
29    Use local header files and not the installed ones.
30
31    Revision 1.1  2002/07/25 08:01:18  arjen
32    First checkin, AXE release 0.2
33
34 *****************************/
35
36 static const char *RCSID = "$Id: doodle3.cpp,v 1.2 2002-11-04 07:44:45 arjen Exp $";
37
38 #include "xappl.h"
39
40 class doodle_view : public window
41 {
42 public:
43
44    doodle_view(window *parent) : window (*parent, 10, 30, 300, 220)
45    {
46       SelectInput(ExposureMask, 1);
47       SelectInput(KeyPressMask, 1);
48       Background(color("lightyellow"));
49    }
50
51    virtual int EV_Expose(XExposeEvent);
52    virtual int EV_KeyPress(XKeyEvent ev);
53 };
54
55 class doodle: public xapplication
56 {
57    managed_window *main_frame;
58    doodle_view    *draw_frame;
59
60    virtual void SetupResources(void);
61 };
62
63 doodle DoodleApp;
64
65 void doodle::SetupResources()
66 {
67    main_frame = new managed_window("Doodling with AXE");
68    main_frame->Map();
69
70    draw_frame = new doodle_view(main_frame);
71    draw_frame->Map();
72 }
73
74 int doodle_view::EV_Expose(XExposeEvent ev)
75 {
76    gc    graphic("black");
77
78    DrawRectangle(graphic, 50, 70, 200, 100);
79
80    return 1;
81 }
82
83 int doodle_view::EV_KeyPress(XKeyEvent ev)
84 {
85    KeySym   key;
86
87    key = XLookupKeysym(&ev, ev.state & 1);
88
89    if (key == 'q')
90    {
91       return 0;
92    }
93    else
94    {
95       return 1;
96    }
97 }