git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@234 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-09 00:41:36 +00:00
parent 662f5796c5
commit 99de2b52fa
3 changed files with 22 additions and 7 deletions

View File

@@ -8,8 +8,8 @@ namespace MwOO {
class Text : public MwOO::Base { class Text : public MwOO::Base {
public: public:
Text(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h); Text(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void SetChecked(int value); void SetText(const char* value);
int GetChecked(void); const char* GetText(void);
void SetBackground(const char* value); void SetBackground(const char* value);
const char* GetBackground(void); const char* GetBackground(void);
void SetForeground(const char* value); void SetForeground(const char* value);

View File

@@ -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){ 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){ void MwOO::Text::SetText(const char* value){
MwSetInteger(this->widget, MwNchecked, value); MwSetText(this->widget, MwNtext, value);
} }
int MwOO::Text::GetChecked(void){ const char* MwOO::Text::GetText(void){
return MwGetInteger(this->widget, MwNchecked); return MwGetText(this->widget, MwNtext);
} }
void MwOO::Text::SetBackground(const char* value){ void MwOO::Text::SetBackground(const char* value){

View File

@@ -4,6 +4,7 @@
static int create(MwWidget handle) { static int create(MwWidget handle) {
MwSetDefault(handle); MwSetDefault(handle);
MwSetText(handle, MwNtext, "dkdqdnqwjkneqwewkeqkenkqwenneqweknqwenqwjkenqwkenqwkenkqwenkqwnejkqwenkwqnekqwneknqwkw");
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask); MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
return 0; return 0;
@@ -23,8 +24,12 @@ static void draw(MwWidget handle) {
MwDrawFrame(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0); MwDrawFrame(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0);
MwDrawRect(handle, &r, base); MwDrawRect(handle, &r, base);
if(str != NULL) { if(str != NULL) {
int w = MwTextWidth(handle, "M");
int h = MwTextHeight(handle, "M"); int h = MwTextHeight(handle, "M");
MwPoint p; MwPoint p;
char* show;
int len;
int i;
p.x = (r.height - h) / 2; p.x = (r.height - h) / 2;
p.y = r.height / 2; p.y = r.height / 2;
@@ -32,7 +37,17 @@ static void draw(MwWidget handle) {
/* limit so there isn't a crazy padding */ /* limit so there isn't a crazy padding */
if(p.x > 4) p.x = 4; 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); MwLLFreeColor(text);