Subversion Repositories Filer-Free

Rev

Rev 16 | Rev 37 | 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;
6 gdshaw@RISCPKG.ORG 40
public:
41
        /** Construct application.
42
         * The character string containing the application name must remain
43
         * in existance for the lifetime of the application object.
44
         * (This saves memory in the most common use case.)
45
         * @param appname the name of the application
46
         * @param messages a list of message numbers which the application
47
         *  should receive
48
         */
49
        application(const char* appname,wimp_message_list* messages);
50
 
51
        /** Run application
52
         * @param pollword a pointer to an optional pollword
53
         */
54
        void run(int* pollword=0);
55
 
56
        /** Get task handle.
57
         * @return the task handle of the application
58
         */
59
        wimp_t handle()
60
                { return _handle; }
61
 
13 gdshaw@RISCPKG.ORG 62
        /** Find window associated with given handle.
63
         * @param handle the window handle to be found
64
         * @return the associated window, or 0 if not found
65
         */
66
        window* find_window(wimp_w handle);
67
 
6 gdshaw@RISCPKG.ORG 68
        /** Get wimp poll flags.
69
         * By default all flags are zero (no events masked).
70
         * @return the required wimp poll flags
71
         */
72
        virtual wimp_poll_flags poll_flags();
73
 
74
        /** Handle an event from the window manager.
75
         * @param event the window manager event number
76
         * @param the window manager event block
77
         */
78
        virtual void handle_event(wimp_event_no event,wimp_block& block);
13 gdshaw@RISCPKG.ORG 79
 
80
        /** Handle mouse click.
81
         * @param block the mouse click event block
82
         */
83
        virtual void handle_mouse_click(wimp_pointer& block);
84
 
26 gdshaw@RISCPKG.ORG 85
        /** Handle user message.
86
         * @param event the window manager event number
87
         * @param the window manager event block
88
         */
89
        virtual void handle_user_message(wimp_event_no event,
90
                wimp_message& message);
91
 
13 gdshaw@RISCPKG.ORG 92
        /** Register window.
93
         * A window object should be registered when the underlying
94
         * RISC OS window is created and remain registered until that
95
         * window is destroyed.
96
         * @param w the window to be registered
97
         */
98
        void register_window(window& w);
99
 
100
        /** Deregister window.
101
         * @param w the window to be deregistered
102
         */
103
        void deregister_window(window& w);
16 gdshaw@RISCPKG.ORG 104
 
105
        /** Register menu.
106
         * The menu will be automatically de-registered when it is closed.
107
         * @param m the menu to be registered
108
         */
109
        void register_menu(menu& m);
6 gdshaw@RISCPKG.ORG 110
};
111
 
112
#endif