summaryrefslogtreecommitdiff
path: root/src/user/raleigh/w/label.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/raleigh/w/label.cpp')
-rw-r--r--src/user/raleigh/w/label.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/user/raleigh/w/label.cpp b/src/user/raleigh/w/label.cpp
index 046737f..21df2a2 100644
--- a/src/user/raleigh/w/label.cpp
+++ b/src/user/raleigh/w/label.cpp
@@ -4,12 +4,27 @@
namespace raleigh {
label::label(const char *value, const char *font, bool bg_transparent, _pixel_t fg, _pixel_t bg)
- : value(value), fi(get_font(font)), bg_transparent(bg_transparent), fg(fg), bg(bg) {
- size = coord(fi->space_width * (strlen(value) - 1) + fi->char_width, fi->char_height);
+ : fi(get_font(font)), bg_transparent(bg_transparent), fg(fg), bg(bg) {
+
+ v_size = strlen(value) + 1;
+ this->value = new char[v_size];
+ blockcpy(this->value, value, v_size);
+ size = coord(fi->space_width * (v_size - 2) + fi->char_width, fi->char_height);
+
closest_opaque = 0;
}
- void label::notify_window_change() {}
+ void label::change_value(const char *new_value) {
+ delete[] value;
+ const uint32_t ns = strlen(new_value) + 1;
+ if (ns != v_size) {
+ v_size = ns;
+ value = new char[ns];
+ set_size(coord(fi->space_width * (ns - 2) + fi->char_width, fi->char_height));
+ }
+ blockcpy(value, new_value, ns);
+ w->notify_needs_paint(*this);
+ }
void label::paint(_pixel_t *pixbuf, uint32_t pitch) {
if (!bg_transparent)
@@ -23,13 +38,7 @@ namespace raleigh {
}
}
- void label::handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) { }
-
void label::notify_has_opaque_parent(widget *parent) {
closest_opaque = parent;
}
-
- void label::handle_key(struct key_packet kp) {};
- void label::on_focus() {};
- void label::on_unfocus() {};
} \ No newline at end of file