Esempio n. 1
0
File: adjust.c Progetto: cjxgm/clabs
void adjust_draw(ADJUST * adj)
{
	OBJECT * obj = &adj->obj;
	float u = obj->x + obj->w;
	float v = obj->y + obj->h;

	glColor3f(0.0, 0.25, 0.0);

	object_scissor(obj);
	glBegin(GL_QUADS); {
		glVertex2f(obj->x, obj->y);
		glVertex2f(u, obj->y);
		glVertex2f(u, v);
		glVertex2f(obj->x, v);
	} glEnd();

	glColor3f(0.8, 0.6, 1);
	PUSH; {
		glTranslatef(obj->x + 4, obj->y + 2, 0);
		glScalef(3, 3, 0);
		glTranslatef(0.5, 1, 0);
		char buf[16];
		sprintf(buf, "%d", adj->value);
		draw_string(buf);
	} POP;

	button_draw(&adj->inc);
	button_draw(&adj->dec);
}
Esempio n. 2
0
static int button_handle (struct ts_button *button, struct ts_sample *samp)
{
	//if inside ==1 that means user clicked area inside of button.
	int inside = (samp->x >= button->x) && (samp->y >= button->y) &&
		(samp->x < button->x + button->w) &&
		(samp->y < button->y + button->h);

	if (samp->pressure > 0) {
		if (inside) {
			if (!(button->flags & BUTTON_ACTIVE)) {
				//if button flag BUTTON_ACTIVE is not set
				button->flags |= BUTTON_ACTIVE;//set the BUTTON_ACTIVE flag bit on.
				button_draw (button);//draw button again.
			}
		} else if (button->flags & BUTTON_ACTIVE) {
			//if button flag BUTTON_ACTIVE is on
			button->flags &= ~BUTTON_ACTIVE;//set it inactive.
			button_draw (button);//draw button again.
		}
	} else if (button->flags & BUTTON_ACTIVE) {
		//if pressure is 0 and BUTTON is Active.
		button->flags &= ~BUTTON_ACTIVE;//inactivate the flag bit.
		button_draw (button);//draw button.
		return 1;
	}

	return 0;
}
Esempio n. 3
0
/*! 
  Draws the listbox
  \return  None
  \author  jfpatry
  \date    Created:  2000-09-18
  \date    Modified: 2000-09-18
*/
void listbox_draw( listbox_t *listbox )
{
    font_t *font;

    check_assertion( listbox != NULL, "listbox is NULL" );

    glDisable( GL_TEXTURE_2D );
    
    if(listbox->background_colour.a != 0.0) {
        glColor4dv( (scalar_t*)&listbox->border_colour );
        
        glRectf( listbox->pos.x, 
             listbox->pos.y,
             listbox->pos.x + listbox->w - listbox->arrow_width,
             listbox->pos.y + listbox->h );

        glColor4dv( (scalar_t*)&listbox->background_colour );

        glRectf( listbox->pos.x + listbox->border_width, 
             listbox->pos.y + listbox->border_width,
             listbox->pos.x + listbox->w - listbox->border_width -
             listbox->arrow_width,
             listbox->pos.y + listbox->h - listbox->border_width );
    }
    
    glEnable( GL_TEXTURE_2D );

    if ( !get_font_binding( listbox->font_binding, &font ) ) {
	print_warning( IMPORTANT_WARNING,
		       "Couldn't get font object for binding %s",
		       listbox->font_binding );
    } else {
	int w, asc, desc;
	char *string;

	string = listbox->label_gen_func( 
	    get_list_elem_data( listbox->cur_item ) );

	get_font_metrics( font, string, &w, &asc, &desc );

	bind_font_texture( font );

	glColor4f( 1.0, 1.0, 1.0, 1.0 );

	glPushMatrix();
	{
	    glTranslatef( 
		listbox->pos.x + listbox->border_width + listbox->text_pad,
		listbox->pos.y + listbox->h/2.0 - asc/2.0 + desc/2.0,
		0 );

	    draw_string( font, string );
	}
	glPopMatrix();
    }

    button_draw( listbox->up_button );
    button_draw( listbox->down_button );
}
Esempio n. 4
0
void SWInterface::StartMenuItemDraw ( Button *button, bool highlighted, bool clicked )
{

	int softwareTYPE;
	sscanf ( button->name, "hud_swmenu %d", &softwareTYPE );

	if ( softwareTYPE == currentsubmenu )
		button_draw ( button, true, clicked );

	else
		button_draw ( button, highlighted, clicked );

}
Esempio n. 5
0
File: tk.c Progetto: mattjakob/s3d
void button_make(Widget *w, char *s)
{
  mvregister(w->id,"b1+",button_pressed,w);
  mvregister(w->id,"b1-",button_released,w);
  w->d = s;
  button_draw(w, 1);
}
Esempio n. 6
0
void mappers_draw(mappers_t *m)
{
	int x,y;

	x = m->info.x;
	y = m->info.y;
	if(m->isshowing == 0)
		return;
	gui_draw_border(GUI_COLOR_DARKBLUE,x,y,m->info.w,m->info.h);
	gui_draw_border(GUI_COLOR_GREY,x,y,m->info.w,9);
	button_draw(&m->donebtn);
	if(nes->rom) {
		switch(nes->rom->boardid) {
			//nes-event
			case B_EVENT:
				gui_draw_text(GUI_TEXT,x+2,y+2,"NES-EVENT Configuration");
				mapper105_draw(m);
				break;
			//unif
			case -1:
			default:
				gui_draw_text(GUI_TEXT,x+2,y+2,"Mapper Configuration");
				text_draw(&m->label);
				break;
		}
	}
}
Esempio n. 7
0
void SWInterface::StartMenuItemDrawUnavailable ( Button *button, bool highlighted, bool clicked )
{

	// For now ;)

	button_draw ( button, highlighted, clicked );

}
Esempio n. 8
0
void menubar_draw(menubar_t *m)
{
	int i,x,y;

	x = m->info.x;
	y = m->info.y;
	/*
	HACK HACK HACK

	keeps the recent files menu updated
	*/
	for(i=0;i<10;i++) {
		char str[1024];
		char *fn;

		if((fn = strrchr(config.recent[i],'\\') + 1) == (char*)1)
			if((fn = strrchr(config.recent[i],'/') + 1) == (char*)1)
				fn = config.recent[i];
		sprintf(str,"%d. %s",i+1%10,fn);
		strcpy(m->menus[0].items[i].caption,str);
		m->menus[0].items[i].info.w = strlen(str) * 8;
	}
	/*
	END HACK
	*/
	load_draw(&m->load);
	video_draw(&m->video);
	input_draw(&m->input);
	gui_input_draw(&m->guiinput);
	sound_draw(&m->sound);
	devices_draw(&m->devices);
	palette_draw(&m->palette);
	options_draw(&m->options);
	mappers_draw(&m->mappers);
	paths_draw(&m->paths);
	supported_mappers_draw(&m->supported_mappers);
	tracer_draw(&m->tracer);
	rom_info_draw(&m->rom_info);
	memory_viewer_draw(&m->memory_viewer);
	nt_draw(&m->nametable_viewer);
	pt_draw(&m->patterntable_viewer);
	about_draw(&m->about);
	for(i=0;i<(m->info.h/2);i++)
		gui_draw_hline(GUI_TITLEBARBACKGROUND+i,x,y++,256);
	for(i++;i;i--)
		gui_draw_hline(GUI_TITLEBARBACKGROUND+i,x,y++,256);
	for(i=0;i<MAX_MENUS && m->menus[i].info.w;i++)
		menu_draw(&m->menus[i]);
#ifdef PS2
	i = 3;
#elif defined(WII)
	i = 2;
#else
	i = 0;
#endif
	for(;i<3;i++)
		button_draw(&m->buttons[i]);
}
Esempio n. 9
0
static void refresh_screen ()
{
	int i;

	fillrect (0, 0, xres - 1, yres - 1, 0);
	put_string_center (xres/2, yres/4,   "TSLIB test program", 1);
	put_string_center (xres/2, yres/4+20,"Touch screen to move crosshair", 2);

	for (i = 0; i < NR_BUTTONS; i++)
		button_draw (&buttons [i]);
}
Esempio n. 10
0
void load_draw(load_t *m)
{
	int x,y;

	x = m->info.x;
	y = m->info.y;
	if(m->isshowing == 0)
		return;
	gui_draw_border(GUI_COLOR_DARKBLUE,x,y,m->info.w,m->info.h);
	gui_draw_border(GUI_COLOR_GREY,x,y,m->info.w,9);
	gui_draw_text(GUI_TEXT,x+2,y+2,"Load ROM");
	button_draw(&m->closebtn);
	button_draw(&m->loadbtn);
	list_draw(&m->romlist);
	list_draw(&m->dirlist);
	edit_draw(&m->edit);
	text_draw(&m->pathtext);
	text_draw(&m->rominfo[0]);
	text_draw(&m->rominfo[1]);
}
Esempio n. 11
0
static int button_handle (struct ts_button *button, struct ts_sample *samp)
{
	int inside = (samp->x >= button->x) && (samp->y >= button->y) &&
		(samp->x < button->x + button->w) &&
		(samp->y < button->y + button->h);

	if (samp->pressure > 0) {
		if (inside) {
			if (!(button->flags & BUTTON_ACTIVE)) {
				button->flags |= BUTTON_ACTIVE;
				button_draw (button);
			}
		} else if (button->flags & BUTTON_ACTIVE) {
			button->flags &= ~BUTTON_ACTIVE;
			button_draw (button);
		}
	} else if (button->flags & BUTTON_ACTIVE) {
		button->flags &= ~BUTTON_ACTIVE;
		button_draw (button);
                return 1;
	}

        return 0;
}
Esempio n. 12
0
void about_draw(about_t *m)
{
	int i,x,y;

	x = m->info.x;
	y = m->info.y;
	if(m->isshowing == 0)
		return;
	gui_draw_border(GUI_WINDOWCLIENT,x,y,m->info.w,m->info.h);
	gui_draw_border(GUI_WINDOWBORDER,x,y,m->info.w,9);
	gui_draw_text(GUI_TEXT,x+2,y+2,"About");
	button_draw(&m->donebtn);
	for(i=0;i<20;i++)
		text_draw(&m->text[i]);
}
Esempio n. 13
0
File: tk.c Progetto: mattjakob/s3d
int  tk_redraw(void* p, int v, real x, real y, char* e)
{
  int i;
  fprintf(stderr, "redraw\n"); fflush(stderr);
  for (i=0; i<wi; i++) {
    switch (wa[i]->type) {
    case TK_BUTTON:
      button_draw(wa[i], 1); break;
    default:
      error("tk"); break;
    }
  }
  gpflush();
  return 0;
}
Esempio n. 14
0
void video_draw(video_t *m)
{
    int x,y;

    x = m->info.x;
    y = m->info.y;
    if(m->isshowing == 0)
        return;
    gui_draw_border(GUI_COLOR_DARKBLUE,x,y,m->info.w,m->info.h);
    gui_draw_border(GUI_COLOR_GREY,x,y,m->info.w,9);
    gui_draw_text(GUI_TEXT,x+2,y+2,"Video Configuration");
    button_draw(&m->donebtn);
    radiogroup_draw(&m->filter);
    radiogroup_draw(&m->videomode);
}
Esempio n. 15
0
static void refresh_screen()
{
	int i;

#ifdef DEBUG 
	printf("before refresh_screen!!\n");
#endif
	fillrect (0, 0, xres - 1, yres - 1, 0);
#ifdef DEBUG
	printf("after refresh_screen!!\n");
#endif

	for (i = 0; i < NR_BUTTONS; i++)
		button_draw (&buttons [i]);
}
Esempio n. 16
0
void options_draw(options_t *m)
{
	int x,y;

	x = m->info.x;
	y = m->info.y;
	if(m->isshowing == 0)
		return;
	gui_draw_border(GUI_WINDOWCLIENT,x,y,m->info.w,m->info.h);
	gui_draw_border(GUI_WINDOWBORDER,x,y,m->info.w,9);
	gui_draw_text(GUI_TEXT,x+2,y+2,"Options");
	button_draw(&m->donebtn);
	radiogroup_draw(&m->fdsbios);
	checkbox_draw(&m->showinfo);
}
Esempio n. 17
0
void rom_info_draw(rom_info_t *m)
{
    int x,y;

    x = m->info.x;
    y = m->info.y;
    if(m->isshowing == 0)
        return;
    gui_draw_border(GUI_WINDOWCLIENT,x,y,m->info.w,m->info.h);
    gui_draw_border(GUI_WINDOWBORDER,x,y,m->info.w,9);
    gui_draw_text(GUI_TEXT,x+2,y+2,"ROM Info");
    button_draw(&m->donebtn);
    for(x=0; x<20; x++) {
        if(m->labels[x].info.w)
            text_draw(&m->labels[x]);
    }
}
Esempio n. 18
0
// main renderer: called every cycle, and reads game state to draw different screens
// draws a 400 error if an unknown state is found, otherwise, just parses states
void main_render(Layer *layer, GContext *ctx) {
  int remaining;
  graphics_context_set_text_color(ctx, GColorBlack);
  if(!s_passcode_defined) {
    error_draw(ctx);
  } else switch (s_curr_state) {
      case 0:
        title_draw(ctx);
        break;
      case 1:
        button_draw(ctx);
        break;
      case 2:
        remaining = (int)(((double)s_timer_curr)/1000.0) + 1;
        passcode_draw(ctx, s_entry, &remaining, 0);
        break;
      case 3:
        graphics_draw_text(ctx, "Alert canceled", fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD), (GRect) {.origin = {0,60}, .size = {144,25}}, GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
Esempio n. 19
0
void sound_draw(sound_t *m)
{
	int x,y;

	x = m->info.x;
	y = m->info.y;
	if(m->isshowing == 0)
		return;
	gui_draw_border(GUI_WINDOWCLIENT,x,y,m->info.w,m->info.h);
	gui_draw_border(GUI_WINDOWBORDER,x,y,m->info.w,9);
	gui_draw_text(GUI_TEXT,x+2,y+2,"Sound Configuration");
	button_draw(&m->donebtn);
	checkbox_draw(&m->enabled);
	checkbox_draw(&m->sq1);
	checkbox_draw(&m->sq2);
	checkbox_draw(&m->tri);
	checkbox_draw(&m->noise);
	checkbox_draw(&m->dmc);
	checkbox_draw(&m->ext);
	text_draw(&m->tc);
}
Esempio n. 20
0
File: tk.c Progetto: mattjakob/s3d
int  button_released(void* p, int v, real x, real y, char* e)
{
  Widget *w = p;
  button_draw(w, 1);
  return w->f();
}
Esempio n. 21
0
static int button_handle (struct ts_button *button, struct ts_sample *samp)
{
	int inside = (samp->x >= button->x) && (samp->y >= button->y) &&
		(samp->x < button->x + button->w) &&
		(samp->y < button->y + button->h);

	if (samp->pressure > 0) {
		if (inside) {
			if (!(button->flags & BUTTON_ACTIVE)) {
				button->flags |= BUTTON_ACTIVE;
				button_draw (button);

				/*Calculator Process*/
				if(button->text[0] == 'C'){ // Clear
					opVal = 0;
					value = 0;
					isCaculate = 0;
				}
				else if(button->text[0] == "D"){ // DELete
					opVal = 0;
					value /= 10;
					isCaculate = 0;
				}
				else if(button->text[0] == '+'){
					if(opSort)
						caculate(opSort);
					opVal = value;
					value = 0;
					opSort = 1;
					isCaculate = 0;
				}
				else if(button->text[0] == '-'){
					if(opSort)
						caculate(opSort);
					opVal = value;
					value = 0;
					opSort = 2;
					isCaculate = 0;
				}
				else if(button->text[0] == '*'){
					if(opSort)
						caculate(opSort);
					opVal = value;
					value = 0;
					opSort = 3;
					isCaculate = 0;
				}
				else if(button->text[0] == '/'){
					if(opSort)
						caculate(opSort);
					opVal = value;
					value = 0;
					opSort = 4;
					isCaculate = 0;
				}
				else if(button->text[0] == '='){
					switch(opSort){
					case 1:
						opVal += value;
						break;
					case 2:
						opVal -= value;
						break;
					case 3: 
						opVal *= value;
						break;
					case 4:
						opVal /= value;
						break;
					}
					value = opVal;
					isCaculate = 1;
					opSort = 0;
				}
				else{ //number
					if(isCaculate){
						isCaculate = 0;
						value = 0;
					}
					value = 10*value + button->text[0] - '0';//char->int 
				}

				refresh_screen();

				char str_value[50];//int -> char for display
				sprintf(str_value,"%lf",value);
				put_string_center(xres/2,7*yres/50,str_value,1);

			}
		} else if (button->flags & BUTTON_ACTIVE) {
			button->flags &= ~BUTTON_ACTIVE;
			button_draw (button);
		}
	} else if (button->flags & BUTTON_ACTIVE) {
		button->flags &= ~BUTTON_ACTIVE;
		button_draw (button);
                return 1;
	}

        return 0;
}
Esempio n. 22
0
/*! 
  Callback to draw a button widget
  \author  jfpatry
  \date    Created:  2000-09-17
  \date    Modified: 2000-09-17
*/
static void button_draw_cb( void *widget )
{
    button_draw( (button_t*) widget );
}
Esempio n. 23
0
int main ()
{
  xcb_screen_iterator_t screen_iter;
  xcb_connection_t     *c;
  const xcb_setup_t    *setup;
  xcb_screen_t         *screen;
  xcb_generic_event_t  *e;
  xcb_generic_error_t  *error;
  xcb_void_cookie_t     cookie_window;
  xcb_void_cookie_t     cookie_map;
  xcb_window_t          window;
  uint32_t              mask;
  uint32_t              values[2];
  int                   screen_number;
  uint8_t               is_hand = 0;

  /* getting the connection */
  c = xcb_connect (NULL, &screen_number);
  if (!c) {
    fprintf (stderr, "ERROR: can't connect to an X server\n");
    return -1;
  }

  /* getting the current screen */
  setup = xcb_get_setup (c);

  screen = NULL;
  screen_iter = xcb_setup_roots_iterator (setup);
  for (; screen_iter.rem != 0; --screen_number, xcb_screen_next (&screen_iter))
    if (screen_number == 0)
      {
        screen = screen_iter.data;
        break;
      }
  if (!screen) {
    fprintf (stderr, "ERROR: can't get the current screen\n");
    xcb_disconnect (c);
    return -1;
  }

  /* creating the window */
  window = xcb_generate_id (c);
  mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
  values[0] = screen->white_pixel;
  values[1] =
    XCB_EVENT_MASK_KEY_RELEASE |
    XCB_EVENT_MASK_BUTTON_PRESS |
    XCB_EVENT_MASK_EXPOSURE |
    XCB_EVENT_MASK_POINTER_MOTION;
  cookie_window = xcb_create_window_checked (c,
                                             screen->root_depth,
                                             window, screen->root,
                                             20, 200, WIDTH, HEIGHT,
                                             0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
                                             screen->root_visual,
                                             mask, values);
  cookie_map = xcb_map_window_checked (c, window);

  /* error managing */
  error = xcb_request_check (c, cookie_window);
  if (error) {
    fprintf (stderr, "ERROR: can't create window : %d\n", error->error_code);
    xcb_disconnect (c);
    return -1;
  }
  error = xcb_request_check (c, cookie_map);
  if (error) {
    fprintf (stderr, "ERROR: can't map window : %d\n", error->error_code);
    xcb_disconnect (c);
    return -1;
  }

  cursor_set (c, screen, window, 68);

  xcb_flush(c);

  while (1) {
    e = xcb_poll_for_event(c);
    if (e) {
      switch (e->response_type & ~0x80) {
      case XCB_EXPOSE: {
        char *text;

        text = "click here to change cursor";
        button_draw (c, screen, window,
                     (WIDTH - 7 * strlen(text)) / 2,
                     (HEIGHT - 16) / 2, text);

        text = "Press ESC key to exit...";
        text_draw (c, screen, window, 10, HEIGHT - 10, text);
        break;
      }
      case XCB_BUTTON_PRESS: {
        xcb_button_press_event_t *ev;
        int                       length;

        ev = (xcb_button_press_event_t *)e;
        length = strlen ("click here to change cursor");

        if ((ev->event_x >= (WIDTH - 7 * length) / 2) &&
            (ev->event_x <= ((WIDTH - 7 * length) / 2 + 7 * length + 6)) &&
            (ev->event_y >= (HEIGHT - 16) / 2 - 19) &&
            (ev->event_y <= ((HEIGHT - 16) / 2)))
          is_hand = 1 - is_hand;

        is_hand ? cursor_set (c, screen, window, 58) : cursor_set (c, screen, window, 68);
      }
      case XCB_KEY_RELEASE: {
        xcb_key_release_event_t *ev;

        ev = (xcb_key_release_event_t *)e;

        switch (ev->detail) {
          /* ESC */
        case 9:
          free (e);
          xcb_disconnect (c);
          return 0;
        }
      }
      }
      free (e);
    }
  }

  return 0;
}
Esempio n. 24
0
File: tk.c Progetto: mattjakob/s3d
int  button_pressed(void* p, int v, real x, real y, char* e)
{
  button_draw(p, 0);
  return 0;
}