Subversion Repositories Filer-Free

Rev

Rev 38 | 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_WINDOW
#define FILER_WINDOW

#include "oslib/wimp.h"

#include "component.h"

class application;
class filer_window;

/** A base class to represent a RISC OS window. */
class window:
        public component
{
private:
        /** The window handle. */
        wimp_w _handle;
public:
        /** Construct window.
         * @note This constructor does not create the underlying RISC OS
         *  window.  To do that, call create_window(wimp_window&).
         * @param app the application to which this window will belong
         */

        window(application* app);

        /** Destroy window. */
        virtual ~window();

        /** Get window handle.
         * @return the window handle
         */

        wimp_w handle() const
                { return _handle; }

        /** Handle window redraw request.
         * @param block the redraw request
         */

        virtual void handle_redraw_request(wimp_draw& block);

        /** Handle window open request.
         * @param block the window open request
         */

        virtual void handle_open_request(wimp_open& block);

        /** Handle window close request.
         * @param block the window close request
         */

        virtual void handle_close_request(wimp_close& block);

        /** Handle mouse click.
         * @param block the mouse click notification
         */

        virtual void handle_mouse_click(wimp_pointer& block);

        /** Handle user drag event.
         * @param block the user drag notification
         */

        virtual void handle_user_drag_box(wimp_dragged& block);

        /** Handle key press.
         * @param block the key press notification
         */

        virtual void handle_key_pressed(wimp_key& block);

        /** Create window.
         * @param block a wimp_window block to be used when creating the
         *  window
         */

        void create_window(wimp_window& block);

        /** Open window.
         * @param open the window open block
         */

        void open_window(wimp_open& block);

        /** Close window. */
        void close_window();

        /** Get window state.
         * The window handle is automatically inserted into the supplied block.
         * @param block the window state block
         */

        void get_window_state(wimp_window_state& block) const;

        /** Get window information.
         * The window handle is automatically inserted into the supplied block.
         * @param block the window information block
         */

        void get_window_info_header(wimp_window_info& block) const;

        /** Set extent.
         * @param box the required extent
         */

        void set_extent(const os_box& box);

        /** Get icon state.
         * The window handle is automatically inserted into the supplied block.
         * @param block the icon state block
         */

        void get_icon_state(wimp_icon_state& block) const;

        /** Set icon state.
         * @param i the icon handle
         * @param xor_mask flags to be toggled
         * @param bic_mask flags to be cleared
         */

        void set_icon_state(wimp_i i,
                wimp_icon_flags xor_mask,wimp_icon_flags bic_mask);

        /** Force redraw of visible area. */
        void force_redraw();

        /** Force redraw of given area.
         * @param box the area to redraw with respect to the work area
         */

        void force_redraw(const os_box& box);

        /** Begin a drag operation.
         * @param block the state of the pointer at the start of the drag
         * @param sprite_name the name of the sprite to be dragged
         */

        void begin_drag(wimp_pointer& block,const char* sprite_name);
};

#endif