Subversion Repositories Filer-Free

Rev

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

Rev Author Line No. Line
21 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_FILER_WINDOW
7
#define FILER_FILER_WINDOW
8
 
9
#include "directory.h"
35 gdshaw@RISCPKG.ORG 10
#include "auto_pos.h"
21 gdshaw@RISCPKG.ORG 11
#include "window.h"
25 gdshaw@RISCPKG.ORG 12
#include "filer_options.h"
21 gdshaw@RISCPKG.ORG 13
 
31 gdshaw@RISCPKG.ORG 14
class filer_menu;
21 gdshaw@RISCPKG.ORG 15
class filer_application;
16
 
17
/** A class to represent a filer window. */
18
class filer_window:
19
        public window
20
{
21
private:
22
        /** The pathname of the directory to be viewed by the filer window. */
23
        char* _pathname;
24
 
25 gdshaw@RISCPKG.ORG 25
        /** The options applicable to this window. */
26
        filer_options _options;
27
 
21 gdshaw@RISCPKG.ORG 28
        /** The content of the directory. */
29
        directory _directory;
25 gdshaw@RISCPKG.ORG 30
 
31
        /** The width of one cell. */
32
        int _xcsize;
33
 
34
        /** The height of one cell. */
35
        int _ycsize;
36
 
37
        /** The number of columns. */
38
        int _xccount;
39
 
40
        /** The number of rows. */
41
        int _yccount;
31 gdshaw@RISCPKG.ORG 42
 
43
        /** The index of the cell temporarily selected while a menu is open,
44
         * or directory::npos if none. */
45
        directory::size_type _temp_selection;
35 gdshaw@RISCPKG.ORG 46
 
47
        /** The position at which a filer window for a subdirectory will be
48
         * opened. */
49
        auto_pos _auto_pos;
21 gdshaw@RISCPKG.ORG 50
public:
51
        /** Construct filer window.
52
         * @param app the application to which this filer window belongs
53
         * @param pathname the pathname of the directory to be viewed
54
         * @param box the initial bounding box of the window
25 gdshaw@RISCPKG.ORG 55
         * @param options the initial options for the filer window
21 gdshaw@RISCPKG.ORG 56
         */
57
        filer_window(filer_application* app,const char* pathname,
25 gdshaw@RISCPKG.ORG 58
                const os_box& box,const filer_options& options);
21 gdshaw@RISCPKG.ORG 59
 
60
        /** Destroy filer window. */
61
        ~filer_window();
62
 
29 gdshaw@RISCPKG.ORG 63
        virtual void handle_redraw_request(wimp_draw& block);
28 gdshaw@RISCPKG.ORG 64
        virtual void handle_open_request(wimp_open& block);
29 gdshaw@RISCPKG.ORG 65
        virtual void handle_close_request(wimp_close& block);
30 gdshaw@RISCPKG.ORG 66
        virtual void handle_mouse_click(wimp_pointer& block);
55 gdshaw@RISCPKG.ORG 67
        virtual void handle_user_drag_box(wimp_dragged& block);
21 gdshaw@RISCPKG.ORG 68
 
31 gdshaw@RISCPKG.ORG 69
        /** Handle menus deleted event.
70
         * The event should already have been handled by the menu itself.
71
         */
72
        void handle_menus_deleted();
73
 
21 gdshaw@RISCPKG.ORG 74
        /** Get pathname.
75
         * @return the pathname of the directory viewed by this filer window
76
         */
77
        const char* pathname() const
78
                { return _pathname; }
25 gdshaw@RISCPKG.ORG 79
 
80
        /** Get filer options.
81
         * @return the filer options applicable to this window
82
         */
83
        const filer_options& options() const
84
                { return _options; }
85
 
86
        /** Set filer options.
87
         * @param options the required filer options
88
         */
89
        void options(const filer_options& options);
31 gdshaw@RISCPKG.ORG 90
 
91
        /** Get selection.
92
         * @return the content of this directory, with selected objected marked
93
         */
94
        directory& selection()
95
                { return _directory; }
96
 
97
        /** Get temporary selection.
98
         * An object is temporarily selected if the user clicks menu above it
99
         * when no other objects are selected.  It is automatically deselected
100
         * when that menu is closed.
101
         * @return the index of the object temporarily selected,
102
         *  or directory::npos if none
103
         */
104
        int temp_selection() const
105
                { return _temp_selection; }
21 gdshaw@RISCPKG.ORG 106
private:
31 gdshaw@RISCPKG.ORG 107
        /** Get shared menu.
108
         * One copy of the menu is shared between all filer windows.
109
         * @return a reference to the shared menu
110
         */
111
        filer_menu& shared_menu() const;
112
 
21 gdshaw@RISCPKG.ORG 113
        /** Reload directory listing. */
114
        void reload();
25 gdshaw@RISCPKG.ORG 115
 
116
        /** Reformat content of window. */
117
        void reformat();
118
 
119
        /** Reformat content of window to given width.
120
         * @param xsize the required width
121
         */
122
        void reformat(int xsize);
29 gdshaw@RISCPKG.ORG 123
 
53 gdshaw@RISCPKG.ORG 124
        /** Set extent of work area.
125
         * If the extent of the visible area matches the extent of the work
126
         * area (in one or both directions) then the visible area is resized
127
         * automatically to match the work area (in the directions that match).
128
         * @param extent the required extent
129
         */
130
        void set_extent(const os_box& extent);
131
 
30 gdshaw@RISCPKG.ORG 132
        /** Find the cell which contains a given point.
133
         * @param p the point to be found
134
         * @return the cell index if found, otherwise npos
135
         */
136
        unsigned int find_cell(const os_coord& p);
137
 
138
        /** Force a redraw of a given cell.
139
         * @param index the index of the cell to be redrawn
140
         */
141
        void force_redraw_cell(unsigned int index);
32 gdshaw@RISCPKG.ORG 142
public:
34 gdshaw@RISCPKG.ORG 143
        /** Refresh window.
144
         * The directory is re-read from disc.  The current selection is
145
         * preserved so far as is possible.
146
         */
147
        void refresh();
148
 
30 gdshaw@RISCPKG.ORG 149
        /** Select or deselect all objects
150
         * @param selected the required selection state
151
         */
152
        void select_all(int selected);
33 gdshaw@RISCPKG.ORG 153
 
29 gdshaw@RISCPKG.ORG 154
        /** Open filer window for parent directory.
155
         * @param offset the position at which to open the top left-hand
156
         *  corner of the new filer window, with respect to the top left-hand
157
         *  corner of this one
158
         */
159
        void open_parent(const os_coord& offset) const;
35 gdshaw@RISCPKG.ORG 160
 
42 gdshaw@RISCPKG.ORG 161
        /** Set the current work directory to this directory. */
162
        void set_work_directory() const;
163
 
45 gdshaw@RISCPKG.ORG 164
        /** Begin an operation on the current selection using the
165
         * FilerAction module.
166
         * This function performs the first three steps of the procedure
167
         * for starting an operation using this module:
168
         * - it executes the command Filer_Action;
169
         * - it calls FilerAction_SendSelectedDirectory;
170
         * - it calls FilerAction_SendSelectedFile for each member of the
171
         *   current selection.
172
         *
173
         * The final step, sending a Message_FilerAction (either directly
174
         * or via FilerAction_SendStartOperation), must be done separately.
175
         * @return the task handle to which the Message_FilerAction must
176
         *  be sent
177
         */
178
        wimp_t begin_filer_action();
179
 
35 gdshaw@RISCPKG.ORG 180
        /** Run object
181
         * Note that setting the close parameter does not actually cause
182
         * the parent window to be closed, however the information is
183
         * needed because it affected the location at which a child
184
         * directory is opened.
185
         * @param info the directory entry for the object to be run
186
         * @param close true if the parent window is to be closed, otherwise false
187
         * @param shift true if shift was pressed, otherwise false
188
         */
189
        void run(osgbpb_info& info,int close,int shift);
21 gdshaw@RISCPKG.ORG 190
};
191
 
192
#endif