00001 #ifndef WORKER_CLASS 00002 #define WORKER_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : worker * 00007 * Author : Chris Koeritz * 00008 * * 00009 * Purpose: * 00010 * * 00011 * A worker object can be displayed on a manager object. * 00012 * * 00013 ******************************************************************************* 00014 * Copyright (c) 1991-$now By Author. This program is free software; you can * 00015 * redistribute it and/or modify it under the terms of the GNU General Public * 00016 * License as published by the Free Software Foundation; either version 2 of * 00017 * the License or (at your option) any later version. This is online at: * 00018 * http://www.fsf.org/copyleft/gpl.html * 00019 * Please send any updates to: fred@gruntose.com * 00020 \*****************************************************************************/ 00021 00022 // Description: 00023 // 00024 // Each worker has an origin. An origin serves as both: (a) an internal 00025 // reference point that each part of the worker is located in relation 00026 // to, and (b) the point on the parent where the worker starts. The 00027 // value held in "origin()" is (b), while that origin's location on the 00028 // parent is considered as the (0, 0) for the internal origin (a). 00029 00030 #include "argument_list.h" 00031 #include "drawable.h" 00032 #include "manager.h" 00033 00034 class WP_PASSIVE_CLASS_STYLE worker : public nub, public drawable 00035 { 00036 public: 00037 worker(manager &root, const c_rectangle &dimensions, window_handle self = NIL, 00038 const color &foreground = colors::WHITE, const color &background = colors::BLACK); 00039 // The "self" is used when the worker's underlying window object can be 00040 // constructed along with the worker, and "self" should contain the handle 00041 // of that object. The "dimensions" are used to set the size of the 00042 // worker, if that is possible. if the vertices of dimensions are 00043 // identical, then the underlying windowing system must determine the size 00044 // of the worker. 00045 00046 virtual ~worker(); 00047 00048 IMPLEMENT_CLASS_NAME("worker"); 00049 00050 virtual void draw(); 00051 // This function places the worker on the screen. The default function 00052 // makes the window_handle visible on the screen and then calls 00053 // set_visible(). The worker::draw() function should at least be called 00054 // by virtual draw functions for these actions. 00055 virtual void erase(); 00056 // This function removes the worker from the screen. The default 00057 // function checks to make sure the object is "visible()", then it 00058 // unmaps the window_handle and calls "set_invisible()". If the object 00059 // was not visible (i.e., the set_visible function was not called), then 00060 // the object is not erased. If a virtual "erase" function is provided 00061 // in a derived class, it should also call the worker erase function or 00062 // at least mimic the functionality (by calling "set_invisible"). 00063 00064 virtual c_rectangle dimensions() const; 00065 virtual void dimensions(const c_rectangle &new_location); 00066 // Observes or modifies the worker's size (in universal coordinates). 00067 00068 palette &colormap() const; 00069 // Accesses this worker's manager's palette. 00070 manager &root() const; 00071 // Accesses the parent of this worker. 00072 00073 color foreground() const; 00074 virtual void foreground(const color &new_foreground); 00075 // Observes or modifies the foreground color of the worker. The color 00076 // is returned by the modifier after being added to the colormap. 00077 00078 color background() const; 00079 virtual void background(const color &new_background); 00080 00081 virtual void set_origin(const c_point &new_origin); 00082 // sets a new origin for the worker. this is virtual to allow more 00083 // complicated objects to adapt themselves to the new origin. 00084 00085 private: 00086 manager &_root; 00087 color _background; 00088 c_rectangle _dimensions; 00089 00090 c_rectangle ask_for_dimensions(); 00091 worker(const worker &to_copy); 00092 worker &operator =(const worker &to_copy); 00093 00094 void attach(); 00095 void detach(); 00096 }; 00097 00098 #endif 00099
1.5.1