mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 00:50:53 +00:00
format
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@62 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
MwWidget window, button, button2, button3, button4;
|
||||
|
||||
void handler(MwWidget handle, void* user_data, void* call_data){
|
||||
void handler(MwWidget handle, void* user_data, void* call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
@@ -12,7 +12,7 @@ void handler(MwWidget handle, void* user_data, void* call_data){
|
||||
printf("hello world!\n");
|
||||
}
|
||||
|
||||
void resize(MwWidget handle, void* user_data, void* call_data){
|
||||
void resize(MwWidget handle, void* user_data, void* call_data) {
|
||||
unsigned int w, h;
|
||||
|
||||
(void)user_data;
|
||||
@@ -22,48 +22,48 @@ void resize(MwWidget handle, void* user_data, void* call_data){
|
||||
h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
MwVaApply(button,
|
||||
MwNwidth, w - 50 * 2,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
NULL);
|
||||
MwNwidth, w - 50 * 2,
|
||||
MwNheight, h - 125 - 50 * 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(button2,
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 0,
|
||||
MwNy, h - 50 - 125,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
NULL);
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 0,
|
||||
MwNy, h - 50 - 125,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(button3,
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 1,
|
||||
MwNy, h - 50 - 125,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
NULL);
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 1,
|
||||
MwNy, h - 50 - 125,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
NULL);
|
||||
|
||||
MwVaApply(button4,
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 2,
|
||||
MwNy, h - 50 - 125,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
NULL);
|
||||
MwNx, 50 + (w - 50 * 2) / 3 * 2,
|
||||
MwNy, h - 50 - 125,
|
||||
MwNwidth, (w - 50 * 2) / 3,
|
||||
NULL);
|
||||
}
|
||||
|
||||
int main(){
|
||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400,
|
||||
MwNtitle, "hello world",
|
||||
NULL);
|
||||
button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 125,
|
||||
MwNtext, "lorem ipsum",
|
||||
NULL);
|
||||
int main() {
|
||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400,
|
||||
MwNtitle, "hello world",
|
||||
NULL);
|
||||
button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 125,
|
||||
MwNtext, "lorem ipsum",
|
||||
NULL);
|
||||
button2 = MwVaCreateWidget(MwButtonClass, "button", window, 50, 225, 100, 125,
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#f66",
|
||||
NULL);
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#f66",
|
||||
NULL);
|
||||
button3 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 225, 100, 125,
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#6f6",
|
||||
NULL);
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#6f6",
|
||||
NULL);
|
||||
button4 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 225, 100, 125,
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#66f",
|
||||
NULL);
|
||||
MwNtext, "lorem ipsum",
|
||||
MwNbackground, "#66f",
|
||||
NULL);
|
||||
|
||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||
MwAddUserHandler(button, MwNactivateHandler, handler, NULL);
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
#include <GL/gl.h>
|
||||
|
||||
MwWidget window, opengl;
|
||||
int ow, oh;
|
||||
int ow, oh;
|
||||
double deg = 0;
|
||||
|
||||
void resize(MwWidget handle, void* user_data, void* call_data){
|
||||
void resize(MwWidget handle, void* user_data, void* call_data) {
|
||||
unsigned int w, h;
|
||||
|
||||
(void)user_data;
|
||||
@@ -17,12 +18,12 @@ void resize(MwWidget handle, void* user_data, void* call_data){
|
||||
h = MwGetInteger(handle, MwNheight);
|
||||
|
||||
MwVaApply(opengl,
|
||||
MwNwidth, (ow = w - 100),
|
||||
MwNheight, (oh = h - 100),
|
||||
NULL);
|
||||
MwNwidth, (ow = w - 100),
|
||||
MwNheight, (oh = h - 100),
|
||||
NULL);
|
||||
}
|
||||
|
||||
void tick(MwWidget handle, void* user_data, void* call_data){
|
||||
void tick(MwWidget handle, void* user_data, void* call_data) {
|
||||
(void)handle;
|
||||
(void)user_data;
|
||||
(void)call_data;
|
||||
@@ -39,19 +40,27 @@ void tick(MwWidget handle, void* user_data, void* call_data){
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(deg, 0, 0, 1);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(1, 0, 0); glVertex2f(0, 0.8);
|
||||
glColor3f(0, 1, 0); glVertex2f(-0.8, -0.8);
|
||||
glColor3f(0, 0, 1); glVertex2f(0.8, -0.8);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex2f(0, 0.8);
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex2f(-0.8, -0.8);
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex2f(0.8, -0.8);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
MwOpenGLSwapBuffer(opengl);
|
||||
|
||||
deg += 120.0 / (1000.0 / MwWaitMS);
|
||||
}
|
||||
|
||||
int main(){
|
||||
int main() {
|
||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400,
|
||||
MwNtitle, "hello world",
|
||||
NULL);
|
||||
MwNtitle, "hello world",
|
||||
NULL);
|
||||
opengl = MwCreateWidget(MwOpenGLClass, "opengl", window, 50, 50, (ow = 300), (oh = 300));
|
||||
|
||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||
|
||||
@@ -12,22 +12,22 @@
|
||||
#define SIZE 100
|
||||
|
||||
MwWidget buttons[6];
|
||||
double deg = 0;
|
||||
double deg = 0;
|
||||
|
||||
int ww, wh;
|
||||
|
||||
void handler(MwWidget w, void* user, void* client){
|
||||
int i;
|
||||
void handler(MwWidget w, void* user, void* client) {
|
||||
int i;
|
||||
double cdeg = deg;
|
||||
|
||||
(void)w;
|
||||
(void)user;
|
||||
(void)client;
|
||||
|
||||
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++){
|
||||
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
|
||||
double rad = cdeg / 180 * M_PI;
|
||||
int x = ww / 2;
|
||||
int y = wh / 2;
|
||||
int x = ww / 2;
|
||||
int y = wh / 2;
|
||||
|
||||
x += cos(rad) * (ww / 2 - SIZE / 2);
|
||||
y += sin(rad) * (wh / 2 - SIZE / 2);
|
||||
@@ -36,9 +36,9 @@ void handler(MwWidget w, void* user, void* client){
|
||||
y -= SIZE / 2;
|
||||
|
||||
MwVaApply(buttons[i],
|
||||
MwNx, x,
|
||||
MwNy, y,
|
||||
NULL);
|
||||
MwNx, x,
|
||||
MwNy, y,
|
||||
NULL);
|
||||
|
||||
cdeg += 360 / (sizeof(buttons) / sizeof(buttons[0]));
|
||||
}
|
||||
@@ -46,7 +46,7 @@ void handler(MwWidget w, void* user, void* client){
|
||||
deg += 120.0 / (1000.0 / MwWaitMS);
|
||||
}
|
||||
|
||||
void resize(MwWidget w, void* user, void* client){
|
||||
void resize(MwWidget w, void* user, void* client) {
|
||||
(void)w;
|
||||
(void)user;
|
||||
(void)client;
|
||||
@@ -55,16 +55,16 @@ void resize(MwWidget w, void* user, void* client){
|
||||
wh = MwGetInteger(w, MwNheight);
|
||||
}
|
||||
|
||||
int main(){
|
||||
int main() {
|
||||
MwWidget window = MwVaCreateWidget(MwWindowClass, "window", NULL, 0, 0, (ww = 500), (wh = 500),
|
||||
MwNtitle, "rotate",
|
||||
NULL);
|
||||
int i;
|
||||
MwNtitle, "rotate",
|
||||
NULL);
|
||||
int i;
|
||||
|
||||
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++){
|
||||
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
|
||||
const char* color = "";
|
||||
char fgcolor[5];
|
||||
int j;
|
||||
char fgcolor[5];
|
||||
int j;
|
||||
|
||||
if(i == 0) color = "#f66";
|
||||
if(i == 1) color = "#6f6";
|
||||
@@ -75,15 +75,15 @@ int main(){
|
||||
|
||||
fgcolor[0] = '#';
|
||||
fgcolor[4] = 0;
|
||||
for(j = 0; j < 3; j++){
|
||||
for(j = 0; j < 3; j++) {
|
||||
fgcolor[j + 1] = color[j + 1] == 'f' ? '6' : 'f';
|
||||
}
|
||||
|
||||
buttons[i] = MwVaCreateWidget(MwButtonClass, "button", window, 0, 0, SIZE, SIZE,
|
||||
MwNbackground, color,
|
||||
MwNforeground, fgcolor,
|
||||
MwNtext, "fancy",
|
||||
NULL);
|
||||
MwNbackground, color,
|
||||
MwNforeground, fgcolor,
|
||||
MwNtext, "fancy",
|
||||
NULL);
|
||||
}
|
||||
|
||||
MwAddUserHandler(window, MwNtickHandler, handler, NULL);
|
||||
|
||||
Reference in New Issue
Block a user