コード例 #1
0
ファイル: fish.c プロジェクト: lanoxx/gnome-panel
static void
fish_applet_realize (GtkWidget  *widget,
		     FishApplet *fish)
{
	if (!fish->surface)
		update_surface (fish);
}
コード例 #2
0
ファイル: menu_item.hpp プロジェクト: xianyinchen/viewer
  void draw(RenderContext& ctx, float x, float y)
  {
    MenuItem::draw(ctx, x, y);

    update_surface();

    m_value_surface->draw(ctx, x+300.0f - m_value_surface->get_width(), y);
  }
コード例 #3
0
ファイル: smallmap_image.cpp プロジェクト: AMDmi3/pingus
SmallMapImage::SmallMapImage(Server* s, int width, int height)
  : server(s),
    canvas(width, height),
    sur(),
    update_count(0),
    colmap_serial(0)
{
  update_surface();
}
コード例 #4
0
ファイル: functions.cpp プロジェクト: macfij/another-snake
// Function is used on option values in Option state. Mainly it is a wrapper
// on update_surface. However, there are various usages of it. If isNum 
// argument is -1, then it means that value of surface should not be changed,
// but only its color. 
void val_update_surface(optionValue* v, TTF_Font* f, SDL_Color c, int isNum, 
                        int optPos, bool focus, bool enable) {
    // do nothing if EXIT option
    if (optPos == 7) return;

    std::string local;

    // case resolution
    if (optPos == 3) {
        if (isNum != -1) {
            local = lexical_cast<std::string>(resolution[isNum][0]) +
                    "x" + lexical_cast<std::string>(resolution[isNum][1]);
            update_surface(&(v->entry), f, local.c_str(), c);
            v->curr = local;
        }
        else { // use the old value
            update_surface(&(v->entry), f, v->curr.c_str(), c);
        }
        return;
    }
    // update int on surface - case Speed and Snake size;
    // curr holds the current value of an option.
    if (optPos == 0 || optPos == 1) {
        if (isNum != -1) {
            local = lexical_cast<std::string>(isNum);
            update_surface(&(v->entry), f, local.c_str(), c);
            v->curr = local;
        }
        else {
            update_surface(&(v->entry), f, v->curr.c_str(), c);
        }
    }
    // update other value surfaces
    else {
        if (enable) {
            if (focus) { // if enabled and the focus is on that option: e.g. ON
                update_surface(&(v->entry), f, v->msg[0].c_str(), c);
            }
            else { // if enabled and not focused, e.g. On
                update_surface(&(v->entry), f, v->msg[1].c_str(), c);
            }
        }
        else {
            if (focus) { // if not enabled and focused, e.g. OFF
                update_surface(&(v->entry), f, v->msg[2].c_str(), c);
            }
            else { // if not enabled and not focused, e.g. Off
                update_surface(&(v->entry), f, v->msg[3].c_str(), c);
            }
        }

    }
}
コード例 #5
0
ファイル: fish.c プロジェクト: lanoxx/gnome-panel
static void
fish_applet_update_rotate (FishApplet *fish,
			   gboolean    rotate)
{
	fish->rotate = rotate;

	if (fish->orientation == PANEL_APPLET_ORIENT_LEFT ||
	    fish->orientation == PANEL_APPLET_ORIENT_RIGHT)
		update_surface (fish);
}
コード例 #6
0
ファイル: smallmap_image.cpp プロジェクト: AMDmi3/pingus
Sprite
SmallMapImage::get_surface ()
{
  if (sur)
  {
    return sur;
  }
  else
  {
    update_surface();
    return sur;
  }
}
コード例 #7
0
ファイル: fish.c プロジェクト: lanoxx/gnome-panel
static void
check_april_fools (FishApplet *fish)
{
	struct tm *tm;
	time_t     now;

	time (&now);
	tm = localtime (&now);

	if (fish->april_fools && 
	    (tm->tm_mon  != fools_month ||
	     tm->tm_mday != fools_day   ||
	     tm->tm_hour >= fools_hour_end)) {
		fish->april_fools = FALSE;
		update_surface (fish);
	} else if (tm->tm_mon  == fools_month    &&
		 tm->tm_mday == fools_day        &&
		 tm->tm_hour >= fools_hour_start &&
		 tm->tm_hour <= fools_hour_end) {
		fish->april_fools = TRUE;
		update_surface (fish);
	}
}
コード例 #8
0
ファイル: fish.c プロジェクト: lanoxx/gnome-panel
static void
fish_applet_change_orient (PanelApplet       *applet,
			   PanelAppletOrient  orientation)
{
	FishApplet *fish = (FishApplet *) applet;

	if (fish->orientation == orientation)
		return;

	fish->orientation = orientation;

	if (fish->surface)
		update_surface (fish);
}
コード例 #9
0
ファイル: color.c プロジェクト: ivan111/onsen
void main(void)
{
    int sid = create_window(128, 128, "color");

    for (int y = 0; y < 128; y ++) {
        for (int x = 0; x < 128; x++) {
            unsigned int color = RGB(x*2, y*2, 0);
            draw_pixel(sid, x, y, color);
        }
    }

    update_surface(sid);

    getkey(1);

    exit(0);
}
コード例 #10
0
ファイル: fish.c プロジェクト: lanoxx/gnome-panel
static void
setup_fish_widget (FishApplet *fish)
{
	GtkWidget *widget = (GtkWidget *) fish;

	fish->frame = gtk_frame_new (NULL);
	gtk_frame_set_shadow_type (GTK_FRAME (fish->frame), GTK_SHADOW_IN);
	gtk_container_add (GTK_CONTAINER (widget), fish->frame);

	fish->drawing_area = gtk_drawing_area_new ();
	gtk_container_add (GTK_CONTAINER (fish->frame), fish->drawing_area);

	g_signal_connect (fish->drawing_area, "realize",
			  G_CALLBACK (fish_applet_realize), fish);
	g_signal_connect (fish->drawing_area, "unrealize",
			  G_CALLBACK (fish_applet_unrealize), fish);
	g_signal_connect (fish->drawing_area, "size-allocate",
			  G_CALLBACK (fish_applet_size_allocate), fish);
	g_signal_connect (fish->drawing_area, "draw",
			  G_CALLBACK (fish_applet_draw), fish);

	gtk_widget_add_events (widget, GDK_ENTER_NOTIFY_MASK | 
				       GDK_LEAVE_NOTIFY_MASK |
				       GDK_BUTTON_RELEASE_MASK);

	g_signal_connect_swapped (widget, "enter_notify_event",
				  G_CALLBACK (fish_enter_notify), fish);
	g_signal_connect_swapped (widget, "leave_notify_event",
				  G_CALLBACK (fish_leave_notify), fish);
	g_signal_connect_swapped (widget, "button_release_event",
				  G_CALLBACK (handle_button_release), fish);

	gtk_widget_add_events (fish->drawing_area, GDK_BUTTON_RELEASE_MASK);
	g_signal_connect_swapped (fish->drawing_area, "button_release_event",
				  G_CALLBACK (handle_button_release), fish);

	load_fish_image (fish);

	update_surface (fish);

	g_signal_connect (fish, "key_press_event",
			  G_CALLBACK (handle_keypress), fish);

	gtk_widget_show_all (widget);
}
コード例 #11
0
ファイル: smallmap_image.cpp プロジェクト: AMDmi3/pingus
void
SmallMapImage::update (float delta)
{
  float smallmap_update_time = 1.0f;

  update_count += delta;

  if (update_count > smallmap_update_time)
  {
    update_count = 0.0f;
    CollisionMap* colmap = server->get_world()->get_colmap();

    if (colmap_serial != colmap->get_serial())
    {
      update_surface();
    }
  }
}
コード例 #12
0
ファイル: fish.c プロジェクト: lanoxx/gnome-panel
static void
fish_applet_update_image (FishApplet *fish,
			  const char *image)
{
	char     *keyfile_path;
	GKeyFile *keyfile;

	if (image[0] == '\0')
		image = FISH_IMAGE_DEFAULT;
	keyfile_path = g_build_filename (FISH_ICONDIR, image, NULL);

	keyfile = g_key_file_new ();
	if (!g_key_file_load_from_file (keyfile, keyfile_path,
					G_KEY_FILE_NONE, NULL)) {
		if (g_strcmp0 (image, FISH_IMAGE_DEFAULT) == 0) {
			g_critical ("Cannot load default image ('%s')", image);
			g_assert_not_reached ();
		}

		g_key_file_free (keyfile);
		g_free (keyfile_path);

		fish_applet_update_image (fish, FISH_IMAGE_DEFAULT);
		return;
	}

	fish->image = g_key_file_get_string (keyfile, "Fish Animation",
					     "image", NULL);
	fish->n_frames = g_key_file_get_integer (keyfile, "Fish Animation",
						 "frames", NULL);
	if (fish->n_frames <= 0)
		fish->n_frames = 1;

	load_fish_image (fish);
	update_surface (fish);

	g_key_file_free (keyfile);
	g_free (keyfile_path);
}
コード例 #13
0
ファイル: fish.c プロジェクト: lanoxx/gnome-panel
static gboolean
update_surface_in_idle (gpointer data)
{
	update_surface (FISH_APPLET (data));
	return FALSE;
}