diff --git a/include/MwOO/Widget/Text.h b/include/MwOO/Widget/Text.h index 683dbe5..908f504 100644 --- a/include/MwOO/Widget/Text.h +++ b/include/MwOO/Widget/Text.h @@ -8,8 +8,8 @@ namespace MwOO { class Text : public MwOO::Base { public: Text(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h); - void SetChecked(int value); - int GetChecked(void); + void SetText(const char* value); + const char* GetText(void); void SetBackground(const char* value); const char* GetBackground(void); void SetForeground(const char* value); diff --git a/oosrc/widget/text.cc b/oosrc/widget/text.cc index 4d54ed7..91f76f5 100644 --- a/oosrc/widget/text.cc +++ b/oosrc/widget/text.cc @@ -5,12 +5,12 @@ MwOO::Text::Text(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwTextClass, widget_name, parent, x, y, w, h){ } -void MwOO::Text::SetChecked(int value){ - MwSetInteger(this->widget, MwNchecked, value); +void MwOO::Text::SetText(const char* value){ + MwSetText(this->widget, MwNtext, value); } -int MwOO::Text::GetChecked(void){ - return MwGetInteger(this->widget, MwNchecked); +const char* MwOO::Text::GetText(void){ + return MwGetText(this->widget, MwNtext); } void MwOO::Text::SetBackground(const char* value){ diff --git a/src/widget/text.c b/src/widget/text.c index 0cffe60..4d689dd 100644 --- a/src/widget/text.c +++ b/src/widget/text.c @@ -4,6 +4,7 @@ static int create(MwWidget handle) { MwSetDefault(handle); + MwSetText(handle, MwNtext, "dkdqdnqwjkneqwewkeqkenkqwenneqweknqwenqwjkenqwkenqwkenkqwenkqwnejkqwenkwqnekqwneknqwkw"); MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask); return 0; @@ -23,8 +24,12 @@ static void draw(MwWidget handle) { MwDrawFrame(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0); MwDrawRect(handle, &r, base); if(str != NULL) { + int w = MwTextWidth(handle, "M"); int h = MwTextHeight(handle, "M"); MwPoint p; + char* show; + int len; + int i; p.x = (r.height - h) / 2; p.y = r.height / 2; @@ -32,7 +37,17 @@ static void draw(MwWidget handle) { /* limit so there isn't a crazy padding */ if(p.x > 4) p.x = 4; - MwDrawText(handle, &p, str, 0, MwALIGNMENT_BEGINNING, text); + len = (r.width - p.x * 2) / w; + show = malloc(len + 1); + memset(show, 0, len + 1); + + for(i = 0; i < len; i++) { + show[i] = str[i]; + } + + MwDrawText(handle, &p, show, 0, MwALIGNMENT_BEGINNING, text); + + free(show); } MwLLFreeColor(text);