diff --git a/example.c b/example.c index 3db4bb6..6c48f80 100644 --- a/example.c +++ b/example.c @@ -10,7 +10,9 @@ int main(){ MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400, MwNtitle, "hello world", NULL); - MwWidget button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 300, NULL); + MwWidget button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 300, + MwNtext, "lorem ipsum", + NULL); MwAddUserHandler(button, MwNactivateHandler, handler, NULL); diff --git a/include/Mw/StringDefs.h b/include/Mw/StringDefs.h index bd55933..0adebde 100644 --- a/include/Mw/StringDefs.h +++ b/include/Mw/StringDefs.h @@ -8,6 +8,7 @@ #define MwNheight "Iheight" #define MwNtitle "Stitle" +#define MwNtext "Stext" #define MwNbackground "Sbackground" #define MwNforeground "Sforeground" diff --git a/src/button.c b/src/button.c index 0d1271b..934acc0 100644 --- a/src/button.c +++ b/src/button.c @@ -6,10 +6,13 @@ static void create(MwWidget handle) { } static void draw(MwWidget handle) { - MwRect r; - MwPoint point; - MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground)); - MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground)); + MwRect r; + MwPoint point; + MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground)); + MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground)); + const char* str = MwGetText(handle, MwNtext); + + if(str == NULL) str = ""; r.x = 0; r.y = 0; @@ -22,7 +25,7 @@ static void draw(MwWidget handle) { point.x = r.x + r.width / 2; point.y = r.x + r.height / 2; - MwDrawText(handle, &point, "test", text); + MwDrawText(handle, &point, str, text); MwLLFreeColor(text); MwLLFreeColor(base);