summaryrefslogtreecommitdiff
path: root/src/user/raleigh/w
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/raleigh/w')
-rw-r--r--src/user/raleigh/w/button.cpp6
-rw-r--r--src/user/raleigh/w/colorpicker.cpp6
-rw-r--r--src/user/raleigh/w/entry.cpp33
-rw-r--r--src/user/raleigh/w/multicontainer.cpp16
4 files changed, 47 insertions, 14 deletions
diff --git a/src/user/raleigh/w/button.cpp b/src/user/raleigh/w/button.cpp
index 5b5f756..b035ee2 100644
--- a/src/user/raleigh/w/button.cpp
+++ b/src/user/raleigh/w/button.cpp
@@ -1,9 +1,9 @@
#include <raleigh/w/button.h>
namespace raleigh {
- button::button(widget &inner, void (*on_click)(button &),
+ button::button(widget &inner, void (*on_click)(button_tag_t), button_tag_t tag,
_pixel_t border_color, _pixel_t bg_color, _pixel_t pressed_color)
- : inner(inner), on_click(on_click), border_color(border_color),
+ : inner(inner), on_click(on_click), tag(tag), border_color(border_color),
bg_color(bg_color), pressed_color(pressed_color), is_pressed(false) {
size = coord(inner.size.x + 2, inner.size.y + 2);
closest_opaque = this;
@@ -44,7 +44,7 @@ namespace raleigh {
inner.window_offset = coord(window_offset.x + 1, window_offset.y + 1);
inner.notify_window_change();
w->notify_needs_paint(*this);
- on_click(*this);
+ on_click(tag);
}
else {
is_pressed = true;
diff --git a/src/user/raleigh/w/colorpicker.cpp b/src/user/raleigh/w/colorpicker.cpp
index 5a9aa82..281eaaf 100644
--- a/src/user/raleigh/w/colorpicker.cpp
+++ b/src/user/raleigh/w/colorpicker.cpp
@@ -32,6 +32,12 @@ namespace raleigh {
pb_ptr[y * pitch + x] = picked_color;
}
+ void colorpicker::set_picked_color(_pixel_t c) {
+ picked_color = c;
+ if (w)
+ w->notify_needs_paint(*this);
+ }
+
void colorpicker::handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) {
if (up || (click_type != mouse_packet::LEFT))
return;
diff --git a/src/user/raleigh/w/entry.cpp b/src/user/raleigh/w/entry.cpp
index 991d75a..3053413 100644
--- a/src/user/raleigh/w/entry.cpp
+++ b/src/user/raleigh/w/entry.cpp
@@ -5,18 +5,10 @@
#include <knob/key.h>
namespace raleigh {
- entry::entry(uint32_t rows, uint32_t cols, const char *default_text,
- const char *font, _pixel_t bg, _pixel_t fg, _pixel_t border_color)
- : rows(rows), cols(cols), bg(bg), fg(fg), border_color(border_color),
- fi(get_font(font)), data(new char[rows * cols]),
- line_indices(new uint32_t[rows + 1]), has_focus(false) {
- size = coord(fi->space_width * (cols - 1) + fi->char_width + 6,
- fi->space_height * (rows - 1) + fi->char_height + 6);
- closest_opaque = this;
-
- const uint32_t l = strlen(default_text);
+ void entry::set_contents(const char *s) {
+ const uint32_t l = strlen(s);
const uint32_t cl = l > rows * cols - 1 ? rows * cols - 1 : l;
- blockcpy(data, default_text, cl);
+ blockcpy(data, s, cl);
data[cl] = '\0';
line_indices[0] = 0;
@@ -24,6 +16,21 @@ namespace raleigh {
cur_x = end_x;
cur_y = end_y;
cur_d = end_d;
+
+ next_paint_full = true;
+ if (w)
+ w->notify_needs_paint(*this);
+ }
+
+ entry::entry(uint32_t rows, uint32_t cols, const char *default_text,
+ const char *font, _pixel_t bg, _pixel_t fg, _pixel_t border_color)
+ : rows(rows), cols(cols), bg(bg), fg(fg), border_color(border_color),
+ fi(get_font(font)), data(new char[rows * cols]),
+ line_indices(new uint32_t[rows + 1]), has_focus(false) {
+ size = coord(fi->space_width * (cols - 1) + fi->char_width + 6,
+ fi->space_height * (rows - 1) + fi->char_height + 6);
+ closest_opaque = this;
+ set_contents(default_text);
}
void entry::get_indices(uint32_t from_y, uint32_t from_x, uint32_t from_d) {
@@ -260,4 +267,8 @@ namespace raleigh {
has_focus = false;
w->notify_needs_paint(*this);
}
+
+ const char *entry::get_contents() {
+ return data;
+ }
} \ No newline at end of file
diff --git a/src/user/raleigh/w/multicontainer.cpp b/src/user/raleigh/w/multicontainer.cpp
index edc60aa..d713f51 100644
--- a/src/user/raleigh/w/multicontainer.cpp
+++ b/src/user/raleigh/w/multicontainer.cpp
@@ -39,4 +39,20 @@ namespace raleigh {
set_size(determine_size());
set_child_offsets();
}
+
+ void multicontainer::add_end(widget &n) {
+ widgets.add_back(n);
+ set_size(determine_size());
+ set_child_offsets();
+ if (w)
+ w->notify_needs_paint(*this);
+ }
+
+ void multicontainer::add_start(widget &n) {
+ widgets.add_front(n);
+ set_size(determine_size());
+ set_child_offsets();
+ if (w)
+ w->notify_needs_paint(*this);
+ }
} \ No newline at end of file