Subversion Repositories Filer-Free

Rev

Rev 37 | Rev 59 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 gdshaw@RISCPKG.ORG 1
// This file is part of the free Filer module for RISC OS.
2
// Copyright  2007 Graham Shaw.
3
// Redistribution and modification are permitted under the terms of the
4
// GNU General Public License (version 2 or any later version).
5
 
6
#ifndef FILER_APPLICATION
7
#define FILER_APPLICATION
8
 
9
#include "oslib/wimp.h"
10
 
13 gdshaw@RISCPKG.ORG 11
#include "window_table.h"
12
 
13
class window;
16 gdshaw@RISCPKG.ORG 14
class menu;
13 gdshaw@RISCPKG.ORG 15
 
6 gdshaw@RISCPKG.ORG 16
/** A class to represent a RISC OS application. */
17
class application
18
{
19
private:
20
        /** The application name.
21
         * This is a copy of the pointer passed into the constructor.
22
         * The data itself is the original, not a copy.
23
         */
24
        const char* _appname;
25
 
26
        /** The task handle. */
27
        wimp_t _handle;
28
 
29
        /** The quit flag.
30
         * True to terminate the application at the end of the current iteration
31
         * of the poll loop, otherwise false.
32
         */
33
        bool _quit;
13 gdshaw@RISCPKG.ORG 34
 
35
        /** A table of windows indexed by handle. */
36
        window_table _windows;
16 gdshaw@RISCPKG.ORG 37
 
38
        /** The current menu, or 0 if none. */
39
        menu* _current_menu;
37 gdshaw@RISCPKG.ORG 40
 
41
        /** The window that owns the current drag operation, or 0 if none. */
42
        window* _current_drag;
6 gdshaw@RISCPKG.ORG 43
public:
44
        /** Construct application.
45
         * The character string containing the application name must remain
46
         * in existance for the lifetime of the application object.
47
         * (This saves memory in the most common use case.)
48
         * @param appname the name of the application
49
         * @param messages a list of message numbers which the application
50
         *  should receive
51
         */
52
        application(const char* appname,wimp_message_list* messages);
53
 
54
        /** Run application
55
         * @param pollword a pointer to an optional pollword
56
         */
57
        void run(int* pollword=0);
58
 
59
        /** Get task handle.
60
         * @return the task handle of the application
61
         */
62
        wimp_t handle()
63
                { return _handle; }
64
 
13 gdshaw@RISCPKG.ORG 65
        /** Find window associated with given handle.
66
         * @param handle the window handle to be found
67
         * @return the associated window, or 0 if not found
68
         */
69
        window* find_window(wimp_w handle);
70
 
6 gdshaw@RISCPKG.ORG 71
        /** Get wimp poll flags.
72
         * By default all flags are zero (no events masked).
73
         * @return the required wimp poll flags
74
         */
75
        virtual wimp_poll_flags poll_flags();
76
 
77
        /** Handle an event from the window manager.
78
         * @param event the window manager event number
79
         * @param the window manager event block
80
         */
81
        virtual void handle_event(wimp_event_no event,wimp_block& block);
13 gdshaw@RISCPKG.ORG 82
 
83
        /** Handle mouse click.
84
         * @param block the mouse click event block
85
         */
86
        virtual void handle_mouse_click(wimp_pointer& block);
87
 
58 gdshaw@RISCPKG.ORG 88
        /** Handle key press.
89
         * @param block the key press notification
90
         */
91
        virtual void handle_key_pressed(wimp_key& block);
92
 
26 gdshaw@RISCPKG.ORG 93
        /** Handle user message.
94
         * @param event the window manager event number
95
         * @param the window manager event block
96
         */
97
        virtual void handle_user_message(wimp_event_no event,
98
                wimp_message& message);
99
 
13 gdshaw@RISCPKG.ORG 100
        /** Register window.
101
         * A window object should be registered when the underlying
102
         * RISC OS window is created and remain registered until that
103
         * window is destroyed.
104
         * @param w the window to be registered
105
         */
58 gdshaw@RISCPKG.ORG 106
        virtual void register_window(window& w);
13 gdshaw@RISCPKG.ORG 107
 
108
        /** Deregister window.
109
         * @param w the window to be deregistered
110
         */
58 gdshaw@RISCPKG.ORG 111
        virtual void deregister_window(window& w);
16 gdshaw@RISCPKG.ORG 112
 
113
        /** Register menu.
114
         * The menu will be automatically de-registered when it is closed.
115
         * @param m the menu to be registered
116
         */
117
        void register_menu(menu& m);
37 gdshaw@RISCPKG.ORG 118
 
119
        /** Register drag.
120
         * The drag will be automatically de-registered when it is closed.
121
         * The specified window becomes the owner of the current drag operation,
122
         * and will therefore receive any events associated with the drag.
123
         */
124
        void register_drag(window& w);
6 gdshaw@RISCPKG.ORG 125
};
126
 
127
#endif