wmi

git clone git://oldgit.suckless.org/wmi/
Log | Files | Refs | LICENSE

thing.h (2307B)


      1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us>
      2 // See LICENSE for license details.
      3 
      4 #ifndef __THING_H
      5 #define __THING_H
      6 
      7 extern "C" {
      8 #include <X11/Xlib.h>
      9 #include <X11/Xutil.h>
     10 }
     11 
     12 #include <string>
     13 
     14 #include "rectangle.h"
     15 #include "wmi.h"
     16 
     17 class Label;
     18 class Monitor;
     19 class Frame;
     20 class Group;
     21 class Theme;
     22 class Workspace;
     23 
     24 /**
     25  * Base class of frames and clients which provides the base
     26  * functionality for both.
     27  */
     28 class Thing : public Rectangle {
     29 
     30 public:
     31 
     32     ////////////////////////////////////////////////////////////
     33     // model
     34 
     35     enum Type {CLIENT, FRAME};
     36 
     37     Thing(Monitor *monitor, Rectangle *rect, Type type_);
     38 
     39     virtual ~Thing();
     40 
     41     void initFrameWindow();
     42 
     43     Type type() const;
     44 
     45     Monitor *monitor() const;
     46 
     47     bool isVisible() const;
     48 
     49     ////////////////////////////////////////////////////////////
     50     // view
     51 
     52     enum InvertButton {NONE, MINCLIENT, DEMAX, CLOSE};
     53 
     54     void setTitleBarHeight(unsigned int titleBarHeight);
     55 
     56     unsigned int titleBarHeight() const;
     57 
     58     void setBorderWidth(unsigned int borderWidth);
     59 
     60     unsigned int borderWidth() const;
     61 
     62     Rectangle *prevRectangle() const;
     63 
     64     InvertButton buttonState() const;
     65 
     66     void setButtonState(InvertButton state);
     67 
     68     void handleMotionNotify(XMotionEvent *event);
     69 
     70     virtual Window window() = 0;
     71     virtual void illuminate() = 0;
     72     virtual void resize() = 0;
     73     virtual bool isFocused() = 0;
     74     virtual void handleButtonPress(XButtonEvent *event) = 0;
     75     virtual void handleButtonRelease(XButtonEvent *event) = 0;
     76     virtual Cursor cursorForXY(int pointerX, int pointerY) = 0;
     77 
     78     virtual void show();
     79     virtual void hide();
     80 
     81     void setName(string name);
     82     string name() const;
     83     bool hasDecoration() const;
     84 
     85 protected:
     86 
     87     void fitClientArea();
     88 
     89     // model
     90     bool isVisible_;
     91     string name_;
     92 
     93     // view
     94     void illuminateBorder();
     95 
     96     Rectangle clientAreaRect_;
     97     Theme *theme_;
     98     Label *label_;
     99     GC gc_;
    100     unsigned int titleBarHeight_;
    101     unsigned int borderWidth_;
    102     bool areButtonsVisible_;
    103 
    104     Cursor cursor_;
    105 
    106     InvertButton buttonState_;
    107 
    108     // model
    109     Window frameWindow_;
    110     bool hasDecoration_;
    111 
    112 private:
    113 
    114     // view
    115     void initGC();
    116 
    117     Monitor *monitor_;
    118     Type type_;
    119 
    120     Rectangle *prevRect_;
    121 };
    122 
    123 #endif // __THING_H