c
This commit is contained in:
parent
76a33f9395
commit
5d9bed0aa1
4 changed files with 456 additions and 0 deletions
BIN
examples/a.out
Executable file
BIN
examples/a.out
Executable file
Binary file not shown.
105
examples/example.cpp
Normal file
105
examples/example.cpp
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
// g++ example.cpp -I ../include/ -lMw
|
||||
|
||||
#include <Mw/StringDefs.h>
|
||||
#include <mwcxx/widget.hpp>
|
||||
|
||||
mw::Widget *window, *button, *button2, *button3, *button4, *button5, *button6;
|
||||
|
||||
void handler(MwWidget handle, void *user_data, void *call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
printf("hello world!\n");
|
||||
}
|
||||
|
||||
void handler_theme(MwWidget handle, void *user_data, void *call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
window->apply(MwNdarkTheme, window->get_integer(MwNdarkTheme) == 0 ? 1 : 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void handler_look(MwWidget handle, void *user_data, void *call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
window->apply(MwNmodernLook, window->get_integer(MwNmodernLook) == 0 ? 1 : 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void handler_font(MwWidget handle, void *user_data, void *call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
window->apply(MwNbitmapFont, window->get_integer(MwNbitmapFont) == 0 ? 1 : 0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void resize(MwWidget handle, void *user_data, void *call_data) {
|
||||
unsigned int w, h, mh;
|
||||
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
|
||||
w = MwGetInteger(handle, MwNwidth);
|
||||
h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
button->apply(MwNy, 50 + mh, MwNwidth, (w - 50 * 2) / 3, MwNheight,
|
||||
h - 125 - 50 * 3);
|
||||
|
||||
button2->apply(MwNx, 50 + (w - 50 * 2) / 3, MwNy, 50 + mh, MwNwidth,
|
||||
(w - 50 * 2) / 3, MwNheight, h - 125 - 50 * 3);
|
||||
|
||||
button3->apply(MwNx, 50 + (w - 50 * 2) / 3 * 2, MwNy, 50 + mh, MwNwidth,
|
||||
(w - 50 * 2) / 3, MwNheight, h - 125 - 50 * 3);
|
||||
|
||||
button4->apply(MwNx, 50 + (w - 50 * 2) / 3 * 0, MwNy, h - 50 - 125 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3);
|
||||
|
||||
button5->apply(MwNx, 50 + (w - 50 * 2) / 3 * 1, MwNy, h - 50 - 125 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3);
|
||||
|
||||
button6->apply(MwNx, 50 + (w - 50 * 2) / 3 * 2, MwNy, h - 50 - 125 + mh,
|
||||
MwNwidth, (w - 50 * 2) / 3);
|
||||
}
|
||||
|
||||
int main() {
|
||||
MwMenu m, m2;
|
||||
|
||||
MwLibraryInit();
|
||||
|
||||
window = new mw::Window("main", NULL, MwDEFAULT, MwDEFAULT, 400, 400,
|
||||
MwNtitle, "hello world");
|
||||
// menu = new mw::Menu("menu", window, 0, 0, 0, 0);
|
||||
button = new mw::Button("button", window, 50, 50, 100, 125, MwNtext, "theme");
|
||||
button2 =
|
||||
new mw::Button("button", window, 150, 50, 100, 125, MwNtext, "look");
|
||||
button3 =
|
||||
new mw::Button("button", window, 250, 50, 100, 125, MwNtext, "font");
|
||||
button4 = new mw::Button("button", window, 50, 225, 100, 125, MwNtext,
|
||||
"lorem ipsum", MwNbackground, "#f66", MwNforeground,
|
||||
"#000");
|
||||
button5 = new mw::Button("button", window, 150, 225, 100, 125, MwNtext,
|
||||
"lorem ipsum", MwNbackground, "#6f6", MwNforeground,
|
||||
"#000");
|
||||
button6 = new mw::Button("button", window, 250, 225, 100, 125, MwNtext,
|
||||
"lorem ipsum", MwNbackground, "#66f", MwNforeground,
|
||||
"#000");
|
||||
|
||||
window->add_user_handler(MwNresizeHandler, resize, NULL);
|
||||
button->add_user_handler(MwNactivateHandler, handler_theme, NULL);
|
||||
button2->add_user_handler(MwNactivateHandler, handler_look, NULL);
|
||||
button3->add_user_handler(MwNactivateHandler, handler_font, NULL);
|
||||
button4->add_user_handler(MwNactivateHandler, handler, NULL);
|
||||
button5->add_user_handler(MwNactivateHandler, handler, NULL);
|
||||
button6->add_user_handler(MwNactivateHandler, handler, NULL);
|
||||
|
||||
// resize(window, NULL, NULL);
|
||||
|
||||
window->loop();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue