summaryrefslogtreecommitdiff
path: root/src/user/raleigh/w/label.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-08 14:46:19 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-08 14:46:19 -0500
commit8221fd5451f094defa9866f98026b74a969f7693 (patch)
tree9f0e9595fd15bdecbe667f823deded7428547b44 /src/user/raleigh/w/label.cpp
parent1a5ece4f52ef17c7c868e95eb26e98137d5cab6f (diff)
downloadportland-os-8221fd5451f094defa9866f98026b74a969f7693.tar.gz
resizable widgets, default widget implementation for some functions, reimplementing meminfo in raleigh
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