1 
2 #include <fx.h>
3 #include <iostream>
4 #include <iomanip>
5 #include <fxkeys.h>
6 using namespace std;
7 
8 class Window : public FX::FXMainWindow {
9 
10     FXDECLARE(Window)
11 protected:
Window()12     Window() {
13         ;
14     }
15 public:
16 
17     Window(FXApp* a);
18     long onKeyPress(FXObject*, FXSelector, void* ptr);
19 
~Window()20     virtual ~Window() {
21         ;
22     }
23 
create()24     virtual void create() {
25         FXMainWindow::create();
26         show(PLACEMENT_SCREEN);
27     }
28 };
29 
30 FXDEFMAP(Window) WindowMap[] = {
31     FXMAPFUNC(SEL_KEYPRESS, 0, Window::onKeyPress)
32 
33 };
34 
FXIMPLEMENT(Window,FX::FXMainWindow,WindowMap,ARRAYNUMBER (WindowMap))35 FXIMPLEMENT(Window, FX::FXMainWindow, WindowMap, ARRAYNUMBER(WindowMap))
36 
37 long Window::onKeyPress(FXObject*, FXSelector, void* ptr) {
38     FXEvent *ev = (FXEvent *)ptr;
39     const char *t = ev->text.text();
40     if (*t == 0) return 1;
41     cout << "ONKEYPRESS" << "  " << t << ": " << std::hex;
42     while (*t != 0) cout << " " << std::setw(2) << ((int)*t++ & 0xff);
43     cout << endl;
44     return 1;
45 }
46 
Window(FXApp * a)47 Window::Window(FXApp* a) : FXMainWindow(a, "example", NULL, NULL,
48 DECOR_TITLE | DECOR_MINIMIZE | DECOR_CLOSE | LAYOUT_FILL_X |
49 LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH, 0, 0, 640, 480) {
50 
51 }
52 
53 Window *g_window;
54 
main(int argc,char * argv[])55 int main(int argc, char *argv[]) {
56     FXApp application("example", "example");
57     application.init(argc, argv);
58     g_window = new Window(&application);
59     application.create();
60     return application.run();
61 }
62 
63 
64