mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
things
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@234 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user