summaryrefslogtreecommitdiff
path: root/otk/widget.hh
blob: 5c008e18ed31ea834dc8119b90c4de3d248cf556 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __widget_hh
#define __widget_hh

#include "basewidget.hh"
#include "eventdispatcher.hh"

extern "C" {
#include <assert.h>
}

namespace otk {

class OtkWidget : public OtkBaseWidget, public OtkEventHandler {

public:

  enum Direction { Horizontal, Vertical };

  OtkWidget(OtkWidget *parent, Direction = Horizontal);
  OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
            Direction direction = Horizontal, Cursor cursor = 0,
            int bevel_width = 1);

  virtual ~OtkWidget();

  virtual void update(void);

  void exposeHandler(const XExposeEvent &e);
  void configureHandler(const XConfigureEvent &e);

  inline bool isStretchableHorz(void) const { return _stretchable_horz; }
  void setStretchableHorz(bool s_horz = true) { _stretchable_horz = s_horz; }

  inline bool isStretchableVert(void) const { return _stretchable_vert; }
  void setStretchableVert(bool s_vert = true)  { _stretchable_vert = s_vert; }

  inline Direction getDirection(void) const { return _direction; }
  void setDirection(Direction dir) { _direction = dir; }

  inline OtkEventDispatcher *getEventDispatcher(void)
  { return _event_dispatcher; }
  void setEventDispatcher(OtkEventDispatcher *disp);

private:

  void adjust(void);
  void adjustHorz(void);
  void adjustVert(void);
  void internalResize(int width, int height);

  Direction _direction;

  bool _stretchable_vert;
  bool _stretchable_horz;

  OtkEventDispatcher *_event_dispatcher;
};

}

#endif // __widget_hh