Subversion Repositories Filer-Free

Rev

Rev 28 | Rev 30 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

// This file is part of the free Filer module for RISC OS.
// Copyright © 2007 Graham Shaw.
// Redistribution and modification are permitted under the terms of the
// GNU General Public License (version 2 or any later version).

#ifndef FILER_FILER_WINDOW
#define FILER_FILER_WINDOW

#include "directory.h"
#include "window.h"
#include "filer_options.h"

class filer_application;

/** A class to represent a filer window. */
class filer_window:
        public window
{
private:
        /** The pathname of the directory to be viewed by the filer window. */
        char* _pathname;

        /** The options applicable to this window. */
        filer_options _options;

        /** The content of the directory. */
        directory _directory;

        /** The width of one cell. */
        int _xcsize;

        /** The height of one cell. */
        int _ycsize;

        /** The number of columns. */
        int _xccount;

        /** The number of rows. */
        int _yccount;
public:
        /** Construct filer window.
         * @param app the application to which this filer window belongs
         * @param pathname the pathname of the directory to be viewed
         * @param box the initial bounding box of the window
         * @param options the initial options for the filer window
         */

        filer_window(filer_application* app,const char* pathname,
                const os_box& box,const filer_options& options);

        /** Destroy filer window. */
        ~filer_window();

        virtual void handle_redraw_request(wimp_draw& block);
        virtual void handle_open_request(wimp_open& block);
        virtual void handle_close_request(wimp_close& block);

        /** Get pathname.
         * @return the pathname of the directory viewed by this filer window
         */

        const char* pathname() const
                { return _pathname; }

        /** Get filer options.
         * @return the filer options applicable to this window
         */

        const filer_options& options() const
                { return _options; }

        /** Set filer options.
         * @param options the required filer options
         */

        void options(const filer_options& options);
private:
        /** Reload directory listing. */
        void reload();

        /** Reformat content of window. */
        void reformat();

        /** Reformat content of window to given width.
         * @param xsize the required width
         */

        void reformat(int xsize);

        /** Open filer window for parent directory.
         * @param offset the position at which to open the top left-hand
         *  corner of the new filer window, with respect to the top left-hand
         *  corner of this one
         */

        void open_parent(const os_coord& offset) const;
};

#endif