void SWindow::windowSetTitle (char *fmt, ...) { int n; char *buf; va_list ap; int size = 1; buf = (char *) s_malloc(sizeof(char) * size); while (1) { va_start(ap, fmt); n = vsnprintf(buf, size, fmt, ap); va_end(ap); if ((n > -1) && (n < size)) { break; } if (n > -1) { size = n + 1; } else { size *= 2; } buf = (char *) s_realloc(buf, size); } s_window_set_title(objectWindow, buf); s_free(buf); }
int main (int argc, char *argv[]) { int x = 60; int y = 60; int w = 400; int h = 300; int mw = 1000; int mh = 1000; char *box; s_timer_t *timer; s_handler_t *hndl; s_window_t *window; s_window_init(&window); s_window_new(window, WINDOW_TYPE_MAIN, NULL); mw = window->surface->width; mh = window->surface->height; box = (char *) s_malloc(sizeof(char) * (mw / 4) * (mh / 4) * window->surface->bytesperpixel); s_window_set_title(window, "Demo - %s", argv[0]); s_window_set_coor(window, 0, x, y, w, h); s_fillbox(window->surface, mw/4, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 255, 0, 0)); s_fillbox(window->surface, mw/2, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 0, 255, 0)); s_fillbox(window->surface, mw/4, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 0, 0, 255)); s_fillbox(window->surface, mw/2, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 255, 255, 255)); s_getbox(window->surface, mw/4, mh/4, mw/4, mh/4, box); s_putbox(window->surface, 0, 0, mw/4, mh/4, box); s_free(box); s_fillbox(window->surface, 0, 0, 20, 20, s_rgbcolor(window->surface, 222, 222, 222)); s_fillbox(window->surface, 2, 2, 16, 16, s_rgbcolor(window->surface, 0, 0, 0)); s_handler_init(&hndl); hndl->type = MOUSE_HANDLER; hndl->mouse.x = 2; hndl->mouse.y = 2; hndl->mouse.w = 16; hndl->mouse.h = 16; hndl->mouse.p = timer_handler_p; hndl->mouse.button = MOUSE_BUTTON_LEFT; s_handler_add(window, hndl); s_timer_init(&timer); timer->timeval = 2000; timer->cb = timer0_cb; s_timer_add(window, timer); s_timer_init(&timer); timer->timeval = 2500; timer->cb = timer1_cb; s_timer_add(window, timer); s_window_show(window); s_window_main(window); return 0; }
static void hide_timer (s_window_t *window, s_timer_t *timer) { timer_count = (timer_count + 1) % 5; switch (timer_count) { case 0: s_window_hide(window); break; case 1: s_window_show(window); break; case 2: s_window_set_coor(window, 0, rand() % window->surface->width, rand() % window->surface->height, rand() % window->surface->width, rand() % window->surface->height); break; case 3: s_window_set_title(window, "Demo - hide / changed title"); break; case 4: s_window_set_title(window, "Demo - hide"); break; } }
void code_generate_window (s_hashtable_t *htable, s_xml_node_t *node) { s_window_type_t prop; s_xml_node_t *tmp; w_window_t *window; code_get_enum(htable, s_xml_node_get_attr_value(node, "type"), &prop); w_window_init(&window, prop, NULL); s_hashtable_add(htable, s_xml_node_get_attr_value(node, "id"), window->object); if ((tmp = s_xml_node_get_path(node, "title")) != NULL) { s_window_set_title(window->window, tmp->value); tmp->dontparse = 1; } if ((tmp = s_xml_node_get_path(node, "move")) != NULL) { code_generate_move(htable, tmp); tmp->dontparse = 1; } }
int main (int argc, char *argv[]) { int x; int y; int w; int h; s_window_t *window; s_window_init(&window); s_window_new(window, WINDOW_MAIN /*| WINDOW_NOFORM*/, NULL); s_window_set_title(window, "Demo - %s ", argv[0]); s_window_set_resizeable(window, 0); s_window_set_alwaysontop(window, 1); w = BOX_W * 3; h = BOX_H * 3; x = (window->surface->linear_buf_width - w) / 2; y = (window->surface->linear_buf_height - h) / 2; s_window_set_coor(window, WINDOW_NOFORM, x, y, w, h); window->surface->width = window->surface->buf->w; window->surface->height = window->surface->buf->h; s_free(window->surface->vbuf); window->surface->vbuf = s_malloc(window->surface->width * window->surface->height * window->surface->bytesperpixel); draw_boxes(window); handler_set(window, S_KEYCODE_RIGHTSHIFT, handler_shift_up); handler_set(window, S_KEYCODE_LEFTSHIFT, handler_shift_down); handler_set(window, S_KEYCODE_LEFT, handler_left); handler_set(window, S_KEYCODE_RIGHT, handler_right); handler_set(window, S_KEYCODE_UP, handler_up); handler_set(window, S_KEYCODE_DOWN, handler_down); handler_set(window, S_KEYCODE_SPACE, handler_set_map); handler_set(window, S_KEYCODE_i, handler_set_up); handler_set(window, S_KEYCODE_j, handler_set_left); handler_set(window, S_KEYCODE_k, handler_set_down); handler_set(window, S_KEYCODE_l, handler_set_right); s_window_show(window); s_window_main(window); return 0; }
int main (int argc, char *argv[]) { int x = 60; int y = 60; int w = 400; int h = 300; int mw = 1000; int mh = 1000; s_handler_t *hndl; s_window_t *window; s_window_init(&window); s_window_new(window, WINDOW_TYPE_MAIN, NULL); mw = window->surface->width; mh = window->surface->height; s_window_set_title(window, "Demo - %s ", argv[0]); s_window_set_coor(window, 0, x, y, MIN(mw, w), MIN(mh, h)); s_fillbox(window->surface, mw/4, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 255, 0, 0)); s_fillbox(window->surface, mw/2, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 0, 255, 0)); s_fillbox(window->surface, mw/4, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 0, 0, 255)); s_fillbox(window->surface, mw/2, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 255, 255, 255)); s_fillbox(window->surface, 0, 0, 20, 20, s_rgbcolor(window->surface, 222, 222, 222)); s_fillbox(window->surface, 2, 2, 16, 16, s_rgbcolor(window->surface, 0, 0, 0)); s_handler_init(&hndl); hndl->type = MOUSE_HANDLER; hndl->mouse.x = 0; hndl->mouse.y = 0; hndl->mouse.w = 20; hndl->mouse.h = 20; hndl->mouse.p = temp_handler; hndl->mouse.button = MOUSE_BUTTON_LEFT; s_handler_add(window, hndl); s_window_show(window); s_window_main(window); return 0; }
static void lxynth_set_title (struct graphics_device *dev, unsigned char *title) { lxynth_device_t *wd; DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__); wd = (lxynth_device_t *) dev->driver_data; s_free(wd->title); wd->title = strdup(title); s_thread_mutex_lock(lxynth_root->gd->mut); if (lxynth_root->gd->active != dev) { s_thread_mutex_unlock(lxynth_root->gd->mut); return; } s_window_set_title(lxynth_root->window, title); s_thread_mutex_unlock(lxynth_root->gd->mut); }
int main (int argc, char *argv[]) { int x = 60; int y = 60; int w = 300; int h = 200; int mw = 1000; int mh = 1000; s_timer_t *timer; s_window_t *window; srand(time(NULL)); s_window_init(&window); s_window_new(window, WINDOW_TYPE_MAIN, NULL); mw = window->surface->width; mh = window->surface->height; s_window_set_title(window, "Demo - %s", argv[0]); s_window_set_coor(window, 0, x, y, MIN(mw, w), MIN(mh, h)); s_fillbox(window->surface, mw/4, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 255, 0, 0)); s_fillbox(window->surface, mw/2, mh/4, mw/4, mh/4, s_rgbcolor(window->surface, 0, 255, 0)); s_fillbox(window->surface, mw/4, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 0, 0, 255)); s_fillbox(window->surface, mw/2, mh/2, mw/4, mh/4, s_rgbcolor(window->surface, 255, 255, 255)); s_timer_init(&timer); timer->timeval = SLEEP_TIME; timer->cb = hide_timer; s_timer_add(window, timer); s_window_atevent(window, s_event_dump); s_window_show(window); s_window_main(window); return 0; }
static void temp_handler (s_window_t *window, s_event_t *event, s_handler_t *handler) { int mw; int mh; s_handler_t *hndl; s_window_t *child; s_window_init(&child); s_window_new(child, WINDOW_TYPE_TEMP | WINDOW_TYPE_NOFORM, window); s_window_set_coor(child, 0, window->surface->buf->x + 30, window->surface->buf->y + 30, 150, 150); s_window_set_title(child, "Demo - Temp"); mw = child->surface->buf->w; mh = child->surface->buf->h; s_fillbox(child->surface, 0, 0, mw, mh, s_rgbcolor(child->surface, 255, 255, 255)); s_fillbox(child->surface, 1, 1, mw - 2, mh - 2, s_rgbcolor(child->surface, 0, 0, 0)); s_fillbox(child->surface, 2, 2, mw - 4, mh - 4, s_rgbcolor(child->surface, 180, 180, 180)); s_fillbox(child->surface, 2, 2, 20, 20, s_rgbcolor(window->surface, 0, 0, 0)); s_fillbox(child->surface, 4, 4, 16, 16, s_rgbcolor(window->surface, 255, 0, 0)); s_handler_init(&hndl); hndl->type = MOUSE_HANDLER; hndl->mouse.x = 2; hndl->mouse.y = 2; hndl->mouse.w = 20; hndl->mouse.h = 20; hndl->mouse.p = temp_handler; hndl->mouse.button = MOUSE_BUTTON_LEFT; s_handler_add(child, hndl); s_window_show(child); s_window_main(child); }
int main (int argc, char *argv[]) { int i; int x = 60; int y = 60; int w = 500; int h = 400; w_window_t *window; w_frame_t *frame; w_frame_t *square; w_button_t *button; w_textbox_t *textbox; w_checkbox_t *checkbox; srand(time(NULL)); w_window_init(&window, WINDOW_TYPE_MAIN, NULL); w = MIN(window->window->surface->width, w); h = MIN(window->window->surface->height, h); s_window_set_title(window->window, "Demo - %s", argv[0]); w_window_set_coor(window, x, y, w, h); w_frame_init(window, &frame, FRAME_PANEL | FRAME_RAISED, window->object); w_object_move(frame->object, 0, 0, w, h); w_object_show(frame->object); w_button_init(window, &button, frame->object); button->pressed = button0_pressed; button->object->draw = button0_draw; button->object->destroy = button0_destroy; w_object_move(button->object, 5, 5, 70, 20); w_object_show(button->object); w_textbox_init(window, &textbox, button->object); textbox->frame->style = FRAME_NOFRAME; w_textbox_set_str(textbox->object, "hide area"); w_object_move(textbox->object, 0, 0, 70, 20); w_object_show(textbox->object); w_button_init(window, &button, frame->object); button->object->effect->effect = EFFECT_POPIN | EFFECT_POPOUT; button->pressed = button1_pressed; button->object->destroy = button1_destroy; w_object_move(button->object, 80, 5, 55, 20); w_object_show(button->object); w_textbox_init(window, &textbox, button->object); textbox->frame->style = FRAME_NOFRAME; w_textbox_set_str(textbox->object, "blender"); w_object_move(textbox->object, 0, 0, 55, 20); w_object_show(textbox->object); w_button_init(window, &button, frame->object); button->object->effect->effect = EFFECT_FADEIN | EFFECT_FADEOUT; button->pressed = button2_pressed; button->object->destroy = button2_destroy; w_object_move(button->object, 140, 5, 85, 20); w_object_show(button->object); w_textbox_init(window, &textbox, button->object); textbox->frame->style = FRAME_NOFRAME; w_textbox_set_str(textbox->object, "random focus"); w_object_move(textbox->object, 0, 0, 85, 20); w_object_show(textbox->object); w_checkbox_init(window, &checkbox, frame->object); w_textbox_set_str(checkbox->text->object, "checkbox"); w_object_move(checkbox->object, 300, 5, 85, 20); w_object_show(checkbox->object); w_frame_init(window, &area, FRAME_PANEL | FRAME_SUNKEN, frame->object); area->object->effect->effect = EFFECT_FADEIN; w_object_move(area->object, 5, 60, w - 10, h - 130); w_object_show(area->object); for (i = 0; i < 4; i++) { w_frame_init(window, &square, FRAME_NOFRAME | FRAME_PLAIN, area->object); square->object->draw = object_draw_p[i]; w_object_move(square->object, (rand() + 1) % (w - 10), ((rand() + 1) % (h - 70)) + 1, (rand() + 1) % (w - 10), ((rand() + 1) % (h - 70)) + 1); w_object_show(square->object); } w_textbox_init(window, &textbox, frame->object); textbox->frame->style = FRAME_PANEL | FRAME_PLAIN; w_textbox_set_str(textbox->object, "this is a text box !"); w_object_move(textbox->object, 5, 30 + (h - 100) + 5, w - 10, 100 - 30 - 5 - 30); w_object_show(textbox->object); { w_editbox_t *editbox; w_editbox_init(window, &editbox, frame->object); w_object_move(editbox->object, 5, 30 + (h - 60) + 5, w - 10, 20); w_textbox_set_str(editbox->object, "this is an editable box !"); w_object_show(editbox->object); } w_frame_init(window, &frame, FRAME_NOFRAME, frame->object); w_object_move(frame->object, 5, 30, w - 10, 25); w_object_show(frame->object); w_button_init(window, &button, frame->object); w_object_move(button->object, 5, 2, 70, 20); w_object_show(button->object); w_textbox_init(window, &textbox, button->object); textbox->frame->style = FRAME_NOFRAME; w_textbox_set_str(textbox->object, "test 0"); w_object_move(textbox->object, 0, 0, 70, 20); w_object_show(textbox->object); w_button_init(window, &button, frame->object); w_object_move(button->object, 80, 2, 55, 20); w_object_show(button->object); w_textbox_init(window, &textbox, button->object); textbox->frame->style = FRAME_NOFRAME; w_textbox_set_str(textbox->object, "test 1"); w_object_move(textbox->object, 0, 0, 55, 20); w_object_show(textbox->object); w_button_init(window, &button, frame->object); w_object_move(button->object, 140, 2, 85, 20); w_object_show(button->object); w_textbox_init(window, &textbox, button->object); textbox->frame->style = FRAME_NOFRAME; w_textbox_set_str(textbox->object, "test 2"); w_object_move(textbox->object, 0, 0, 85, 20); w_object_show(textbox->object); w_checkbox_init(window, &checkbox, frame->object); w_textbox_set_str(checkbox->text->object, "test 3"); w_object_move(checkbox->object, 300, 2, 85, 20); w_object_show(checkbox->object); w_object_show(window->object); s_window_show(window->window); s_window_main(window->window); return 0; }
int main (int argc, char *argv[]) { int x; int y; int w; int h; s_font_t *font; s_handler_t *hndl; s_window_t *window; s_window_init(&window); s_window_new(window, WINDOW_MAIN | WINDOW_NOFORM | WINDOW_DESKTOP, NULL); s_window_set_resizeable(window, 0); s_window_set_alwaysontop(window, 1); s_window_set_title(window, "Xynth logout"); w = 300; h = 100; x = (window->surface->width - w) / 2; y = (window->surface->height - h) / 2; s_window_set_coor(window, WINDOW_NOFORM, x, y, w, h); s_free(window->surface->vbuf); window->surface->width = w; window->surface->height = h; window->surface->vbuf = (unsigned char *) malloc(w * h * window->surface->bytesperpixel); s_window_atevent(window, xynthlogout_atevent); s_fillbox(window->surface, 0, 0, w, h, s_rgbcolor(window->surface, 0, 0, 0)); for (y = 2; y < h - 2; y++) { s_fillbox(window->surface, 2, y, w - 4, 1, s_rgbcolor(window->surface, 255 - (int) ((float) y * 255.00 / 100.00), 255 - (int) ((float) y * 255.00 / 100.00), 255)); } s_font_init(&font, "arial.ttf"); s_font_set_str(font, "Close Xynth Windowing System..."); s_font_set_size(font, 16); s_font_get_glyph(font); s_image_get_handler(font->glyph.img); s_putboxrgba(window->surface, 18, 13, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba); s_fillbox(window->surface, 18, 15 + font->glyph.img->h + 2, font->glyph.img->w, 2, 0); s_font_uninit(font); s_fillbox(window->surface, 40, 48, 35, 35, s_rgbcolor(window->surface, 0, 0, 0)); s_fillbox(window->surface, 42, 50, 31, 31, s_rgbcolor(window->surface, 255, 30, 30)); s_font_init(&font, "arial.ttf"); s_font_set_str(font, "Shutdown"); s_font_set_size(font, 16); s_font_get_glyph(font); s_image_get_handler(font->glyph.img); s_putboxrgba(window->surface, 40 + 35 + 5, 48 + 12, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba); s_font_uninit(font); s_handler_init(&hndl); hndl->type = MOUSE_HANDLER; hndl->mouse.x = 40; hndl->mouse.y = 48; hndl->mouse.w = 35; hndl->mouse.h = 35; hndl->mouse.r = xynthlogout_logout; hndl->mouse.button = MOUSE_LEFTBUTTON; s_handler_add(window, hndl); s_fillbox(window->surface, 175, 48, 35, 35, s_rgbcolor(window->surface, 0, 0, 0)); s_fillbox(window->surface, 177, 50, 31, 31, s_rgbcolor(window->surface, 30, 255, 30)); s_font_init(&font, "arial.ttf"); s_font_set_str(font, "Cancel"); s_font_set_size(font, 16); s_font_get_glyph(font); s_image_get_handler(font->glyph.img); s_putboxrgba(window->surface, 175 + 35 + 5, 48 + 12, font->glyph.img->w, font->glyph.img->h, font->glyph.img->rgba); s_font_uninit(font); s_handler_init(&hndl); hndl->type = MOUSE_HANDLER; hndl->mouse.x = 175; hndl->mouse.y = 48; hndl->mouse.w = 35; hndl->mouse.h = 35; hndl->mouse.r = xynthlogout_cancel; hndl->mouse.button = MOUSE_LEFTBUTTON; s_handler_add(window, hndl); s_window_show(window); s_window_main(window); return 0; }