Subversion Repositories Filer-Free

Rev

Rev 58 | 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
 
59 gdshaw@RISCPKG.ORG 54
        /** Destroy application. */
55
        virtual ~application();
56
 
6 gdshaw@RISCPKG.ORG 57
        /** Run application
58
         * @param pollword a pointer to an optional pollword
59
         */
60
        void run(int* pollword=0);
61
 
62
        /** Get task handle.
63
         * @return the task handle of the application
64
         */
65
        wimp_t handle()
66
                { return _handle; }
67
 
13 gdshaw@RISCPKG.ORG 68
        /** Find window associated with given handle.
69
         * @param handle the window handle to be found
70
         * @return the associated window, or 0 if not found
71
         */
72
        window* find_window(wimp_w handle);
73
 
6 gdshaw@RISCPKG.ORG 74
        /** Get wimp poll flags.
75
         * By default all flags are zero (no events masked).
76
         * @return the required wimp poll flags
77
         */
78
        virtual wimp_poll_flags poll_flags();
79
 
80
        /** Handle an event from the window manager.
81
         * @param event the window manager event number
82
         * @param the window manager event block
83
         */
84
        virtual void handle_event(wimp_event_no event,wimp_block& block);
13 gdshaw@RISCPKG.ORG 85
 
86
        /** Handle mouse click.
87
         * @param block the mouse click event block
88
         */
89
        virtual void handle_mouse_click(wimp_pointer& block);
90
 
58 gdshaw@RISCPKG.ORG 91
        /** Handle key press.
92
         * @param block the key press notification
93
         */
94
        virtual void handle_key_pressed(wimp_key& block);
95
 
26 gdshaw@RISCPKG.ORG 96
        /** Handle user message.
97
         * @param event the window manager event number
98
         * @param the window manager event block
99
         */
100
        virtual void handle_user_message(wimp_event_no event,
101
                wimp_message& message);
102
 
13 gdshaw@RISCPKG.ORG 103
        /** Register window.
104
         * A window object should be registered when the underlying
105
         * RISC OS window is created and remain registered until that
106
         * window is destroyed.
107
         * @param w the window to be registered
108
         */
58 gdshaw@RISCPKG.ORG 109
        virtual void register_window(window& w);
13 gdshaw@RISCPKG.ORG 110
 
111
        /** Deregister window.
112
         * @param w the window to be deregistered
113
         */
58 gdshaw@RISCPKG.ORG 114
        virtual void deregister_window(window& w);
16 gdshaw@RISCPKG.ORG 115
 
116
        /** Register menu.
117
         * The menu will be automatically de-registered when it is closed.
118
         * @param m the menu to be registered
119
         */
120
        void register_menu(menu& m);
37 gdshaw@RISCPKG.ORG 121
 
122
        /** Register drag.
123
         * The drag will be automatically de-registered when it is closed.
124
         * The specified window becomes the owner of the current drag operation,
125
         * and will therefore receive any events associated with the drag.
126
         */
127
        void register_drag(window& w);
6 gdshaw@RISCPKG.ORG 128
};
129
 
130
#endif