void initialize_window(float width, float height, unsigned char fullscreen) { /* Initialize the SDL library (starts the event loop) */ if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0 ) { fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } /* Clean up on exit, exit on window close and interrupt */ atexit(SDL_Quit); window.option = SDL_GL_DOUBLEBUFFER | SDL_OPENGL | SDL_RESIZABLE | (SDL_FULLSCREEN * fullscreen); /* The mouse isn't much use unless we have a display for reference */ if (SDL_SetVideoMode(width, height, BITS_PER_PIXEL, window.option) == NULL ) { fprintf(stderr, "Couldn't set %fx%fx%d video mode: %s\n",width,height,BITS_PER_PIXEL,SDL_GetError()); exit(1); } SDL_WM_SetCaption("Over the sea",NULL); SDL_JoystickEventState(SDL_ENABLE); SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(10, 10); glDisable(GL_DEPTH_TEST); resize_handler(width,height); char fakeParam[] = "fake"; char *fakeargv[] = { fakeParam, NULL }; int fakeargc = 1; glutInit( &fakeargc, fakeargv); }
static void keyboard_focus_handler(struct window *window, struct input *device, void *data) { struct gears *gears = data; struct rectangle allocation; window_get_child_allocation(gears->window, &allocation); resize_handler(window, allocation.width, allocation.height, gears); }
int windowEventHandler(const SDL_Event* event) { switch(event->type) { case SDL_VIDEORESIZE: resize_handler(event->resize.w,event->resize.h); return 1; default: break; } return 0; }
void option_handler (BOARD_WIDGET* board) { int ch; int i; while ((ch = getch ()) != '\n') { wdeleteln (board -> headerWnd); wmove (board -> headerWnd, 0, 0); wattron (board -> headerWnd, A_BOLD); wprintw (board -> headerWnd, "set options [bs]"); wrefresh (board -> headerWnd); switch (ch) { case 'b' : i = 0; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "Base_col [0-7] : %d", i); wrefresh (board -> headerWnd); while ((ch = getch ()) != '\n') { switch (ch) { case KEY_UP : i = (++i < 8) ? i : 7; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "Base_color [0-7] : %d", i); wrefresh (board -> headerWnd); break; case KEY_DOWN : i = (--i > 0) ? i : 0; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "Base_color [0-7] : %d", i); wrefresh (board -> headerWnd); break; } usleep (1000); } set_colors (board, COLOR_PAIR (i), board -> point_info -> selected_color); break; case 's' : i = 0; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "selected_color [0-7] : %d", i); wrefresh (board -> headerWnd); while ((ch = getch ()) != '\n') { switch (ch) { case KEY_UP : i = (++i < 8) ? i : 7; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "selected_color [0-7] : %d", i); wrefresh (board -> headerWnd); break; case KEY_DOWN : i = (--i > 0) ? i : 0; werase (board -> headerWnd); wbkgd (board -> headerWnd, COLOR_PAIR (i) | A_BOLD); wprintw (board -> headerWnd, "selected_color [0-7] : %d", i); wrefresh (board -> headerWnd); break; } usleep (1000); } set_colors (board, board -> point_info -> base_color, COLOR_PAIR (i)); break; } usleep (1000); } resize_handler (board); }
void board_eventhandler (BOARD_WIDGET* board, GNode* root) { int ch; int selected_data_index; STOCKINFO* temp; GNode* temp_node; GNode* market; bool flag; int remember_index; int i; activate_board (board); while ((ch = getch ()) != 'q') { switch (ch) { case KEY_UP : scrollup_handler (board); break; case KEY_DOWN : scrolldown_handler (board); break; case KEY_PPAGE : pageup_handler (board); break; case KEY_NPAGE : pagedown_handler (board); break; case KEY_RESIZE : /* clear_board (board); */ resize_handler (board); break; case '\n' : if ((*(int*) (board -> userdata) & 0x000f) == 1) { selected_data_index = board -> firstrow_index + board -> selected_index; temp = (STOCKINFO*) g_ptr_array_index ( board -> dataTable, selected_data_index); if (temp -> depth <= 2) { market = g_node_find (root, G_LEVEL_ORDER, G_TRAVERSE_NON_LEAVES, (gpointer) temp); temp_node = g_node_first_child (market); flag = ((STOCKINFO*) (temp_node -> data)) -> IsActivated; open_close_branch (market, !flag); clear_board (board); g_ptr_array_unref (board -> dataTable); board -> dataTable = node_to_array (root, board -> dataTable); remember_index = board -> selected_index; set_rowIndex (board, 0); /*set_rowIndex (board, -1);*/ set_rowIndex (board, remember_index); board -> wndFlag = true; board -> dataFlag = true; update_board (board); } break; } break; case 'o' : option_handler (board); break; } usleep (1000); } inactivate_board (board); }