home *** CD-ROM | disk | FTP | other *** search
- // **************************************************************************
- // Copyright 1996 David Allison
- //
- // VV VV IIIIII SSSSS TTTTTT AA
- // VV VV II SS TT AA AA
- // VV VV II SSSS TT AA AA
- // VV VV II SS TT AAAAAAAA
- // VV IIIIII SSSS TT AA AA
- //
- // MULTI-THREADED C++ WIMP CLASS LIBRARY
- // for RISC OS
- // **************************************************************************
- //
- // P U B L I C D O M A I N L I C E N C E
- // -------------------------------------------
- //
- // This library is copyright. You may not sell the library for
- // profit, but you may sell products which use it providing
- // those products are presented as executable code and are not
- // libraries themselves. The library is supplied without any
- // warranty and the copyright owner cannot be held responsible for
- // damage resulting from failure of any part of this library.
- //
- // See the User Manual for details of the licence.
- //
- // *************************************************************************
-
-
-
- #ifndef __myapps_h
- #define __myapps_h
-
- #include "Vista:vista.h"
- #include <stdio.h>
-
- class MyApps ;
-
- //
- // abstract class for object within window. An instance of this class is
- // held with each icon in a window. The user_ref of the icon points
- // to the instance
- //
-
- class AppObject
- {
- public:
- AppObject (Task *task, char *name) ;
- AppObject (Task *task, char *name, char *sprite) ;
- ~AppObject() ;
- char *name ; // name in the directory
- char *sprite ; // name of the sprite
- virtual void rename(char *newname) ; // give a new name
- virtual void run() = 0 ; // pure virtual run function (depends on derived class)
- protected:
- Task *task ;
- } ;
-
-
- class AppGrid : public IconGrid
- {
- enum menu_items
- {
- APP,
- NEW,
- SELECT_ALL,
- CLEAR_SEL,
- SET_NAME
- } ;
- enum app_menu_items
- {
- RENAME,
- REMOVE
- } ;
- public:
- AppGrid (MyApps *myapps, bool ismain = false) ;
- ~AppGrid() ;
- void double_click (int mx, int my, int buttons, Icon *icon) ; // double click on an icon
- void pre_menu(Menu *m, int x, int y, int button, int icon) ; // modify menu before display
- void menu(MenuItem items[]) ; // menu hit
- void add_object (char *path) ; // add a new object
- void add_object (AppGrid *, char *) ;
- AppGrid *next ;
- AppGrid *prev ;
- private:
- AppObject *current_object ;
- Icon *current_icon ;
- int num_selected ;
- MyApps *myapps ;
- bool ismain ;
- } ;
-
- //
- // This application object represents a file with a path on disk
- //
-
- class PathAppObject : public AppObject
- {
- public:
- PathAppObject (Task *task, char *name, char *path) ;
- ~PathAppObject() ;
- protected:
- char path[256] ; // real path of object
- } ;
-
- //
- // This represents an application on disk
- //
-
-
- class ApplicationAppObject : public PathAppObject
- {
- public:
- ApplicationAppObject (Task *task, char *name, char *path) ;
- ~ApplicationAppObject() ;
- void run() ;
- } ;
-
- // a directory
-
- class DirAppObject : public PathAppObject
- {
- public:
- DirAppObject (Task *task, char *name, char *path) ;
- ~DirAppObject() ;
- void run() ;
- } ;
-
- // a normal file
-
- class FileAppObject : public PathAppObject
- {
- public:
- FileAppObject (Task *task, char *name, char *path, int type) ;
- ~FileAppObject() ;
- void run() ;
- } ;
-
- //
- // This is one of my own windows
- //
-
- class GridAppObject : public AppObject
- {
- public:
- GridAppObject (Task *task, char *name, AppGrid *grid) ;
- ~GridAppObject() ;
- void run() ;
- void rename (char *) ;
- protected:
- AppGrid *grid ;
- } ;
-
-
- //
- // this class loads files into the icon grid
- //
-
- class Loader: public DataSave
- {
- public:
- Loader(MyApps *myapps) ;
- ~Loader() ;
- void receive (int action, int task, int my_ref, int your_ref, int data_length, void *data) ; // receive a message
- private:
- MyApps *myapps ;
- } ;
-
- //
- // This class is the task itself. The icon bar has a menu with 2 items. The task responds
- // to clicks on the icon bar (click() function) and menu hits (menu() function). Private
- // data includes the main window object.
- //
-
-
- class MyApps : public Task
- {
- enum menu_items
- {
- INFO, // program info
- QUIT // quit application
- } ;
- public:
- MyApps() ;
- ~MyApps() ;
- void save() ;
- void click(int x, int y, int buttons, int icon) ; // icon bar click
- void menu (MenuItem items[]) ; // iconbar menu hit
- AppGrid *find_grid (int window_handle) ;
- void add_grid (AppGrid *) ;
- void remove_grid (AppGrid*) ;
- private:
- Loader *loader ;
- AppGrid *main_grid ;
- AppGrid *grids, *last_grid ;
- int num_grids ;
- } ;
-
- #endif
-