Subversion Repositories Filer-Free

Rev

Rev 34 | Rev 42 | 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);
21 gdshaw@RISCPKG.ORG 67
 
31 gdshaw@RISCPKG.ORG 68
        /** Handle menus deleted event.
69
         * The event should already have been handled by the menu itself.
70
         */
71
        void handle_menus_deleted();
72
 
21 gdshaw@RISCPKG.ORG 73
        /** Get pathname.
74
         * @return the pathname of the directory viewed by this filer window
75
         */
76
        const char* pathname() const
77
                { return _pathname; }
25 gdshaw@RISCPKG.ORG 78
 
79
        /** Get filer options.
80
         * @return the filer options applicable to this window
81
         */
82
        const filer_options& options() const
83
                { return _options; }
84
 
85
        /** Set filer options.
86
         * @param options the required filer options
87
         */
88
        void options(const filer_options& options);
31 gdshaw@RISCPKG.ORG 89
 
90
        /** Get selection.
91
         * @return the content of this directory, with selected objected marked
92
         */
93
        directory& selection()
94
                { return _directory; }
95
 
96
        /** Get temporary selection.
97
         * An object is temporarily selected if the user clicks menu above it
98
         * when no other objects are selected.  It is automatically deselected
99
         * when that menu is closed.
100
         * @return the index of the object temporarily selected,
101
         *  or directory::npos if none
102
         */
103
        int temp_selection() const
104
                { return _temp_selection; }
21 gdshaw@RISCPKG.ORG 105
private:
31 gdshaw@RISCPKG.ORG 106
        /** Get shared menu.
107
         * One copy of the menu is shared between all filer windows.
108
         * @return a reference to the shared menu
109
         */
110
        filer_menu& shared_menu() const;
111
 
21 gdshaw@RISCPKG.ORG 112
        /** Reload directory listing. */
113
        void reload();
25 gdshaw@RISCPKG.ORG 114
 
115
        /** Reformat content of window. */
116
        void reformat();
117
 
118
        /** Reformat content of window to given width.
119
         * @param xsize the required width
120
         */
121
        void reformat(int xsize);
29 gdshaw@RISCPKG.ORG 122
 
30 gdshaw@RISCPKG.ORG 123
        /** Find the cell which contains a given point.
124
         * @param p the point to be found
125
         * @return the cell index if found, otherwise npos
126
         */
127
        unsigned int find_cell(const os_coord& p);
128
 
129
        /** Force a redraw of a given cell.
130
         * @param index the index of the cell to be redrawn
131
         */
132
        void force_redraw_cell(unsigned int index);
32 gdshaw@RISCPKG.ORG 133
public:
34 gdshaw@RISCPKG.ORG 134
        /** Refresh window.
135
         * The directory is re-read from disc.  The current selection is
136
         * preserved so far as is possible.
137
         */
138
        void refresh();
139
 
30 gdshaw@RISCPKG.ORG 140
        /** Select or deselect all objects
141
         * @param selected the required selection state
142
         */
143
        void select_all(int selected);
33 gdshaw@RISCPKG.ORG 144
 
29 gdshaw@RISCPKG.ORG 145
        /** Open filer window for parent directory.
146
         * @param offset the position at which to open the top left-hand
147
         *  corner of the new filer window, with respect to the top left-hand
148
         *  corner of this one
149
         */
150
        void open_parent(const os_coord& offset) const;
35 gdshaw@RISCPKG.ORG 151
 
152
        /** Run object
153
         * Note that setting the close parameter does not actually cause
154
         * the parent window to be closed, however the information is
155
         * needed because it affected the location at which a child
156
         * directory is opened.
157
         * @param info the directory entry for the object to be run
158
         * @param close true if the parent window is to be closed, otherwise false
159
         * @param shift true if shift was pressed, otherwise false
160
         */
161
        void run(osgbpb_info& info,int close,int shift);
21 gdshaw@RISCPKG.ORG 162
};
163
 
164
#endif