Subversion Repositories Filer-Free

Rev

Rev 30 | Rev 32 | 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"
10
#include "window.h"
25 gdshaw@RISCPKG.ORG 11
#include "filer_options.h"
21 gdshaw@RISCPKG.ORG 12
 
31 gdshaw@RISCPKG.ORG 13
class filer_menu;
21 gdshaw@RISCPKG.ORG 14
class filer_application;
15
 
16
/** A class to represent a filer window. */
17
class filer_window:
18
        public window
19
{
20
private:
21
        /** The pathname of the directory to be viewed by the filer window. */
22
        char* _pathname;
23
 
25 gdshaw@RISCPKG.ORG 24
        /** The options applicable to this window. */
25
        filer_options _options;
26
 
21 gdshaw@RISCPKG.ORG 27
        /** The content of the directory. */
28
        directory _directory;
25 gdshaw@RISCPKG.ORG 29
 
30
        /** The width of one cell. */
31
        int _xcsize;
32
 
33
        /** The height of one cell. */
34
        int _ycsize;
35
 
36
        /** The number of columns. */
37
        int _xccount;
38
 
39
        /** The number of rows. */
40
        int _yccount;
31 gdshaw@RISCPKG.ORG 41
 
42
        /** The index of the cell temporarily selected while a menu is open,
43
         * or directory::npos if none. */
44
        directory::size_type _temp_selection;
21 gdshaw@RISCPKG.ORG 45
public:
46
        /** Construct filer window.
47
         * @param app the application to which this filer window belongs
48
         * @param pathname the pathname of the directory to be viewed
49
         * @param box the initial bounding box of the window
25 gdshaw@RISCPKG.ORG 50
         * @param options the initial options for the filer window
21 gdshaw@RISCPKG.ORG 51
         */
52
        filer_window(filer_application* app,const char* pathname,
25 gdshaw@RISCPKG.ORG 53
                const os_box& box,const filer_options& options);
21 gdshaw@RISCPKG.ORG 54
 
55
        /** Destroy filer window. */
56
        ~filer_window();
57
 
29 gdshaw@RISCPKG.ORG 58
        virtual void handle_redraw_request(wimp_draw& block);
28 gdshaw@RISCPKG.ORG 59
        virtual void handle_open_request(wimp_open& block);
29 gdshaw@RISCPKG.ORG 60
        virtual void handle_close_request(wimp_close& block);
30 gdshaw@RISCPKG.ORG 61
        virtual void handle_mouse_click(wimp_pointer& block);
21 gdshaw@RISCPKG.ORG 62
 
31 gdshaw@RISCPKG.ORG 63
        /** Handle menus deleted event.
64
         * The event should already have been handled by the menu itself.
65
         */
66
        void handle_menus_deleted();
67
 
21 gdshaw@RISCPKG.ORG 68
        /** Get pathname.
69
         * @return the pathname of the directory viewed by this filer window
70
         */
71
        const char* pathname() const
72
                { return _pathname; }
25 gdshaw@RISCPKG.ORG 73
 
74
        /** Get filer options.
75
         * @return the filer options applicable to this window
76
         */
77
        const filer_options& options() const
78
                { return _options; }
79
 
80
        /** Set filer options.
81
         * @param options the required filer options
82
         */
83
        void options(const filer_options& options);
31 gdshaw@RISCPKG.ORG 84
 
85
        /** Get selection.
86
         * @return the content of this directory, with selected objected marked
87
         */
88
        directory& selection()
89
                { return _directory; }
90
 
91
        /** Get temporary selection.
92
         * An object is temporarily selected if the user clicks menu above it
93
         * when no other objects are selected.  It is automatically deselected
94
         * when that menu is closed.
95
         * @return the index of the object temporarily selected,
96
         *  or directory::npos if none
97
         */
98
        int temp_selection() const
99
                { return _temp_selection; }
21 gdshaw@RISCPKG.ORG 100
private:
31 gdshaw@RISCPKG.ORG 101
        /** Get shared menu.
102
         * One copy of the menu is shared between all filer windows.
103
         * @return a reference to the shared menu
104
         */
105
        filer_menu& shared_menu() const;
106
 
21 gdshaw@RISCPKG.ORG 107
        /** Reload directory listing. */
108
        void reload();
25 gdshaw@RISCPKG.ORG 109
 
110
        /** Reformat content of window. */
111
        void reformat();
112
 
113
        /** Reformat content of window to given width.
114
         * @param xsize the required width
115
         */
116
        void reformat(int xsize);
29 gdshaw@RISCPKG.ORG 117
 
30 gdshaw@RISCPKG.ORG 118
        /** Find the cell which contains a given point.
119
         * @param p the point to be found
120
         * @return the cell index if found, otherwise npos
121
         */
122
        unsigned int find_cell(const os_coord& p);
123
 
124
        /** Force a redraw of a given cell.
125
         * @param index the index of the cell to be redrawn
126
         */
127
        void force_redraw_cell(unsigned int index);
128
 
129
        /** Select or deselect all objects
130
         * @param selected the required selection state
131
         */
132
        void select_all(int selected);
133
 
29 gdshaw@RISCPKG.ORG 134
        /** Open filer window for parent directory.
135
         * @param offset the position at which to open the top left-hand
136
         *  corner of the new filer window, with respect to the top left-hand
137
         *  corner of this one
138
         */
139
        void open_parent(const os_coord& offset) const;
21 gdshaw@RISCPKG.ORG 140
};
141
 
142
#endif