summaryrefslogtreecommitdiff
path: root/src/user/include/cxx/raleigh/widget.h
blob: 54b92874a872e521812644830fbac142987cde92 (plain) (blame)
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
#ifndef RALEIGH_WIDGET_H
#define RALEIGH_WIDGET_H

namespace raleigh {
  class widget;
}

#include <raleigh/window.h>
#include <pland/syscall.h>
#include <raleigh/util.h>

namespace raleigh {
  class widget {
  public:
    coord size;

    //set by window class (or parent widget)
    window *w;
    coord window_offset;

    //fewest steps up that a widget can be redrawn without needing its parents
    //if a widget is opaque, it will set this to a pointer to itself, and then call
    //  notify_has_opaque_parent on any children, passing itself as an argument.
    //in notify_has_opaque_parent's handler, it should set this if it isn't already set,
    //  and then call notify_has_opaque_parent on any children (with the opaque parent).
    widget *closest_opaque;

    //called by window class (or parent widget)
    virtual void notify_window_change() = 0;
    virtual void paint(_pixel_t *pixbuf, uint32_t pitch) = 0;
    virtual void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) = 0;
    virtual void notify_has_opaque_parent(widget *parent) = 0;
    virtual void handle_key(struct key_packet kp) = 0;
    virtual void on_focus() = 0;
    virtual void on_unfocus() = 0;
  };
}

#endif