コード例 #1
0
ファイル: ctree.c プロジェクト: amery/clip-itk
/* Set the pixmap in a node. */
int
clip_GTK_CTREENODESETPIXTEXT(ClipMachine * cm)
{
	C_widget   *cctree = _fetch_cw_arg(cm);
	C_object    *cnode = _fetch_cobject(cm,_clip_spar(cm,2));
	gint        column = _clip_parni(cm,3);
	gchar        *text = _clip_parc(cm,4);
	gint       spacing = _clip_parni(cm,5);
	C_widget  *cpixmap = _fetch_cwidget(cm,_clip_spar(cm,6));
	GdkPixmap *pixmap=NULL; GdkBitmap *mask=NULL;
	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT(3,NUMERIC_t); CHECKOPT(4,CHARACTER_t); CHECKOPT(5,NUMERIC_t);
	CHECKOPT2(6,MAP_t,NUMERIC_t); CHECKCWIDOPT(cpixmap,GTK_IS_PIXMAP);
	if (_clip_parinfo(cm,3)==UNDEF_t) column = 1;
	if (_clip_parinfo(cm,4)==UNDEF_t) text = "";
	if (cpixmap)
	{
		pixmap = GTK_PIXMAP(cpixmap->widget)->pixmap;
		mask = GTK_PIXMAP(cpixmap->widget)->mask;
	}
	LOCALE_TO_UTF(text);
	gtk_ctree_node_set_pixtext(GTK_CTREE(cctree->widget),
			GTK_CTREE_NODE(cnode->object), column-1,
			text,spacing,pixmap,mask);
	FREE_TEXT(text);
	return 0;
err:
	return 1;
}
コード例 #2
0
ファイル: trayicon.c プロジェクト: moreorless/claws-mail
static void set_trayicon_pixmap(TrayIconType icontype)
{
	GdkPixmap *pixmap = NULL;
	GdkBitmap *bitmap = NULL;

	switch(icontype) {
	case TRAYICON_NEW:
		pixmap = newmail_pixmap;
		bitmap = newmail_bitmap;
		break;
	case TRAYICON_NEWMARKED:
		pixmap = newmarkedmail_pixmap;
		bitmap = newmarkedmail_bitmap;
		break;
	case TRAYICON_UNREAD:
		pixmap = unreadmail_pixmap;
		bitmap = unreadmail_bitmap;
		break;
	case TRAYICON_UNREADMARKED:
		pixmap = unreadmarkedmail_pixmap;
		bitmap = unreadmarkedmail_bitmap;
		break;
	default:
		pixmap = nomail_pixmap;
		bitmap = nomail_bitmap;
		break;
	}

	gtk_pixmap_set(GTK_PIXMAP(image), pixmap, bitmap);
	gtk_widget_shape_combine_mask(GTK_WIDGET(trayicon), bitmap, GTK_WIDGET(image)->allocation.x, GTK_WIDGET(image)->allocation.y);
}
コード例 #3
0
ファイル: gdkdraw.c プロジェクト: amery/clip-angelo
/* Draws a line, using the foreground color and other attributes of the GdkGC. */
int
clip_GDK_DRAWLINE(ClipMachine * ClipMachineMemory)
{
   C_widget *cwid = _fetch_cw_arg(ClipMachineMemory);

   C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   gint      x1 = _clip_parni(ClipMachineMemory, 3);

   gint      y1 = _clip_parni(ClipMachineMemory, 4);

   gint      x2 = _clip_parni(ClipMachineMemory, 5);

   gint      y2 = _clip_parni(ClipMachineMemory, 6);

   GdkDrawable *drw = NULL;

   CHECKCWID(cwid, GTK_IS_WIDGET);
   CHECKOPT2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType);
   CHECKCOBJ(cgc, GDK_IS_GC(cgc));
   CHECKOPT(3, NUMERIC_type_of_ClipVarType);
   CHECKOPT(4, NUMERIC_type_of_ClipVarType);
   CHECKOPT(5, NUMERIC_type_of_ClipVarType);
   CHECKOPT(6, NUMERIC_type_of_ClipVarType);

   drw = cwid->widget->window;
   if (GTK_IS_PIXMAP(cwid->widget))
      drw = GTK_PIXMAP(cwid->widget)->pixmap;
   gdk_draw_line(drw, GDK_GC(cgc->object), x1, y1, x2, y2);
   return 0;
 err:
   return 1;
}
コード例 #4
0
ファイル: gdkdraw.c プロジェクト: amery/clip-angelo
/* Note: A rectangle drawn filled is 1 pixel smaller in both dimensions
 * than a rectangle outlined. Calling gdk_draw_rectangle (window, gc, TRUE, 0, 0, 20, 20)
 * results in a filled rectangle 20 pixels wide and 20 pixels high. Calling
 * gdk_draw_rectangle (window, gc, FALSE, 0, 0, 20, 20) results in an outlined
 * rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which makes
 * it 21 pixels wide and 21 pixels high. */
int
clip_GDK_DRAWRECTANGLE(ClipMachine * ClipMachineMemory)
{
   C_widget *cwid = _fetch_cw_arg(ClipMachineMemory);

   C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   gint      filled = BOOL_OPTION(ClipMachineMemory, 3, TRUE);

   gint      x = _clip_parni(ClipMachineMemory, 4);

   gint      y = _clip_parni(ClipMachineMemory, 5);

   gint      width = _clip_parni(ClipMachineMemory, 6);

   gint      height = _clip_parni(ClipMachineMemory, 7);

   GdkDrawable *drw = NULL;

   CHECKCWID(cwid, GTK_IS_WIDGET);
   CHECKOPT2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType);
   CHECKCOBJ(cgc, GDK_IS_GC(cgc));
   CHECKOPT(3, LOGICAL_type_of_ClipVarType);
   CHECKOPT(4, NUMERIC_type_of_ClipVarType);
   CHECKOPT(5, NUMERIC_type_of_ClipVarType);
   CHECKOPT(6, NUMERIC_type_of_ClipVarType);
   CHECKOPT(7, NUMERIC_type_of_ClipVarType);
   drw = cwid->widget->window;
   if (GTK_IS_PIXMAP(cwid->widget))
      drw = GTK_PIXMAP(cwid->widget)->pixmap;
   gdk_draw_rectangle(drw, GDK_GC(cgc->object), filled, x, y, width, height);
   return 0;
 err:
   return 1;
}
コード例 #5
0
ファイル: gailpixmap.c プロジェクト: Aridna/gtk2
static void  
gail_pixmap_get_image_size (AtkImage       *obj,
                            gint           *width,
                            gint           *height)
{
  GtkWidget *widget;
  GtkPixmap *pixmap;
 
  *width = -1;
  *height = -1;

  g_return_if_fail (GAIL_IS_PIXMAP (obj));

  widget = GTK_ACCESSIBLE (obj)->widget;
  if (widget == 0)
    /* State is defunct */
    return;

  g_return_if_fail (GTK_IS_PIXMAP (widget));

  pixmap = GTK_PIXMAP (widget);

  if (pixmap->pixmap)
    gdk_drawable_get_size (pixmap->pixmap, width, height);
}
コード例 #6
0
ファイル: tbargtk.cpp プロジェクト: Bluehorn/wxPython
 void SetPixmap(const wxBitmap& bitmap)
 {
     if (bitmap.Ok())
     {
         GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap()
                                            : (GdkBitmap *)NULL;
         gtk_pixmap_set( GTK_PIXMAP(m_pixmap), bitmap.GetPixmap(), mask );
     }
 }
コード例 #7
0
ファイル: gdkdraw.c プロジェクト: amery/clip-angelo
/* Alena */
int
clip_GDK_DRAWPIXMAP(ClipMachine * ClipMachineMemory)
{
   C_widget *cwid = _fetch_cw_arg(ClipMachineMemory);

   C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   C_widget *cpix = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3));

   gint      xsrc = _clip_parni(ClipMachineMemory, 4);

   gint      ysrc = _clip_parni(ClipMachineMemory, 5);

   gint      xdest = _clip_parni(ClipMachineMemory, 6);

   gint      ydest = _clip_parni(ClipMachineMemory, 7);

   gint      width = _clip_parni(ClipMachineMemory, 8);

   gint      height = _clip_parni(ClipMachineMemory, 9);

   GdkDrawable *drw = NULL;

   CHECKARG2(1, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType);
   CHECKCWID(cwid, GTK_IS_WIDGET);
   CHECKARG2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType);
   CHECKCOBJ(cgc, GDK_IS_GC(cgc));
   CHECKARG2(3, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType);
   CHECKCWID(cpix, GTK_IS_WIDGET);
   CHECKARG(4, NUMERIC_type_of_ClipVarType);
   CHECKARG(5, NUMERIC_type_of_ClipVarType);
   CHECKARG(6, NUMERIC_type_of_ClipVarType);
   CHECKARG(7, NUMERIC_type_of_ClipVarType);
   CHECKARG(8, NUMERIC_type_of_ClipVarType);
   CHECKARG(9, NUMERIC_type_of_ClipVarType);
   drw = cwid->widget->window;
   if (GTK_IS_PIXMAP(cwid->widget))
      drw = GTK_PIXMAP(cwid->widget)->pixmap;
   gdk_draw_pixmap(drw, GDK_GC(cgc->object), GTK_PIXMAP(cpix->widget)->pixmap, xsrc, ysrc, xdest, ydest, width, height);
   return 0;
 err:
   return 1;
}
コード例 #8
0
ファイル: noticeview.c プロジェクト: moreorless/claws-mail
void noticeview_set_icon(NoticeView *noticeview, StockPixmap icon)
{
	GdkPixmap *pixmap;
	GdkBitmap *bitmap;
	
	if (stock_pixmap_gdk(noticeview->window, icon, &pixmap, &bitmap) < 0)
		return;
	
	gtk_pixmap_set(GTK_PIXMAP(noticeview->icon), pixmap, bitmap);
}
コード例 #9
0
ファイル: gdkgc.c プロジェクト: amery/clip-itk
/* Sets the clip mask for a graphics context from a bitmap.
 * The clip mask is interpreted relative to the clip origin.
 * (See gdk_gc_set_clip_origin()). */
int
clip_GDK_GCSETCLIPMASK(ClipMachine * cm)
{
	C_object  *cgc = _fetch_co_arg(cm);
	C_widget *cxpm = _fetch_cwidget(cm,_clip_spar(cm,2));
	CHECKCOBJ(cgc,GDK_IS_GC(cgc));
	CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCWID(cxpm,GTK_IS_PIXMAP);
	gdk_gc_set_clip_mask(GDK_GC(cgc->object), GTK_PIXMAP(cxpm->widget)->pixmap);
	return 0;
err:
	return 1;
}
コード例 #10
0
ファイル: ctree.c プロジェクト: amery/clip-itk
/* Set the pixmap in a node. */
int
clip_GTK_CTREENODESETPIXMAP(ClipMachine * cm)
{
	C_widget   *cctree = _fetch_cw_arg(cm);
	C_object    *cnode = _fetch_cobject(cm,_clip_spar(cm,2));
	gint        column = _clip_parni(cm,3);
	C_widget  *cpixmap = _fetch_cwidget(cm,_clip_spar(cm,4));
	GdkPixmap *pixmap=NULL; GdkBitmap *mask=NULL;
	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT(3,NUMERIC_t);
	CHECKOPT2(4,MAP_t,NUMERIC_t); CHECKCWIDOPT(cpixmap,GTK_IS_PIXMAP);
	if (_clip_parinfo(cm,3)==UNDEF_t) column = 1;
	if (cpixmap)
	{
		pixmap = GTK_PIXMAP(cpixmap->widget)->pixmap;
		mask = GTK_PIXMAP(cpixmap->widget)->mask;
	}
	gtk_ctree_node_set_pixmap(GTK_CTREE(cctree->widget),
			GTK_CTREE_NODE(cnode->object), column-1,pixmap,mask);
	return 0;
err:
	return 1;
}
コード例 #11
0
ファイル: statbmp.cpp プロジェクト: czxxjtu/wxPython-1
void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
{
    m_bitmap = bitmap;

    if (m_bitmap.Ok())
    {
        GdkBitmap *mask = NULL;
        if (m_bitmap.GetMask())
            mask = m_bitmap.GetMask()->GetBitmap();

        gtk_pixmap_set(GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask);

        InvalidateBestSize();
        SetSize(GetBestSize());
    }
}
コード例 #12
0
ファイル: window.c プロジェクト: amery/clip-itk
// Set ICON PIXMAP property for window
int
clip_GTK_WINDOWSETICONPIXMAP(ClipMachine * cm)
{
	C_widget *cwin = _fetch_cw_arg(cm);
	C_widget *cpix = _fetch_cwidget(cm,_clip_spar(cm,2));
        GdkPixmap *pix;
        GdkBitmap *bit;
	CHECKCWID(cwin,GTK_IS_WINDOW);
	CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCWID(cpix,GTK_IS_PIXMAP);
	gtk_pixmap_get(GTK_PIXMAP(cpix->widget), &pix, &bit);
	gdk_window_set_icon(GDK_WINDOW(cwin->widget->window),
			    GDK_WINDOW(cpix->widget->window),
		pix, bit);
	return 0;
err:
	return 1;
}
コード例 #13
0
ファイル: tglbtn.cpp プロジェクト: vdm113/wxWidgets-ICC-patch
void wxToggleBitmapButton::OnSetBitmap()
{
    if (!m_bitmap.IsOk()) return;

    GdkBitmap *mask = NULL;
    if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();

    GtkWidget *child = BUTTON_CHILD(m_widget);
    if (child == NULL)
    {
        // initial bitmap
        GtkWidget *pixmap = gtk_pixmap_new(m_bitmap.GetPixmap(), mask);
        gtk_widget_show(pixmap);
        gtk_container_add(GTK_CONTAINER(m_widget), pixmap);
    }
    else
    {   // subsequent bitmaps
        GtkPixmap *g_pixmap = GTK_PIXMAP(child);
        gtk_pixmap_set(g_pixmap, m_bitmap.GetPixmap(), mask);
    }
}
コード例 #14
0
ファイル: bmpbuttn.cpp プロジェクト: chromylei/third_party
void wxBitmapButton::OnSetBitmap()
{
    wxCHECK_RET( m_widget != NULL, wxT("invalid bitmap button") );

    InvalidateBestSize();

    wxBitmap the_one;
    if (!IsThisEnabled())
        the_one = GetBitmapDisabled();
   else if (m_isSelected)
     the_one = GetBitmapPressed();
   else if (HasFocus())
     the_one = GetBitmapFocus();

   if (!the_one.IsOk())
     {
         the_one = GetBitmapLabel();
         if (!the_one.IsOk())
             return;
     }

    GdkBitmap *mask = NULL;
    if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap();

    GtkWidget *child = BUTTON_CHILD(m_widget);
    if (child == NULL)
    {
        // initial bitmap
        GtkWidget *pixmap;
        pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask);
        gtk_widget_show(pixmap);
        gtk_container_add(GTK_CONTAINER(m_widget), pixmap);
    }
    else
    {   // subsequent bitmaps
        GtkPixmap *pixmap = GTK_PIXMAP(child);
        gtk_pixmap_set(pixmap, the_one.GetPixmap(), mask);
    }
}
コード例 #15
0
ファイル: gdkdraw.c プロジェクト: amery/clip-angelo
/* Draws a number of characters in the given font or fontset. */
int
clip_GDK_DRAWTEXT(ClipMachine * ClipMachineMemory)
{
   C_widget *cwid = _fetch_cw_arg(ClipMachineMemory);

   C_object *cgc = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   C_object *font = _fetch_cobject(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3));

   gint      x = _clip_parni(ClipMachineMemory, 4);

   gint      y = _clip_parni(ClipMachineMemory, 5);

   gchar    *text = _clip_parc(ClipMachineMemory, 6);

   gint      length = _clip_parni(ClipMachineMemory, 7);

   GdkDrawable *drw = NULL;

   CHECKCWID(cwid, GTK_IS_WIDGET);
   CHECKOPT2(2, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType);
   CHECKCOBJ(cgc, GDK_IS_GC(cgc));
   CHECKOPT2(3, NUMERIC_type_of_ClipVarType, MAP_type_of_ClipVarType);
   CHECKCOBJ(cgc, GDK_IS_FONT(font));
   CHECKOPT(4, NUMERIC_type_of_ClipVarType);
   CHECKOPT(5, NUMERIC_type_of_ClipVarType);
   CHECKOPT(6, CHARACTER_type_of_ClipVarType);
   CHECKOPT(7, NUMERIC_type_of_ClipVarType);
   drw = cwid->widget->window;
   if (GTK_IS_PIXMAP(cwid->widget))
      drw = GTK_PIXMAP(cwid->widget)->pixmap;
   LOCALE_TO_UTF(text);
   gdk_draw_text(drw, GDK_FONT(font->object), GDK_GC(cgc->object), x, y, text, length);
   FREE_TEXT(text);
   return 0;
 err:
   return 1;
}
コード例 #16
0
ファイル: gdkwindow.c プロジェクト: amery/clip-itk
int
clip_GDK_WINDOWSETBACKPIXMAP(ClipMachine * cm)
{
	C_widget    *cwin = _fetch_cw_arg(cm);
        C_widget    *cpix = _fetch_cwidget(cm, _clip_spar(cm, 2));
        gboolean relative = _clip_parl(cm, 3);
	GdkWindow *win = NULL;
        GdkPixmap *pix = NULL;
        GdkBitmap *mask;

	CHECKCWID(cwin,GTK_IS_WIDGET); CHECKOPT(2, MAP_t);
	CHECKCWIDOPT(cpix,GTK_IS_PIXMAP);
	CHECKARG(3,LOGICAL_t);

	if (cwin && cwin->widget) win = (GdkWindow *)cwin->widget->window;

	if (cpix) gtk_pixmap_get(GTK_PIXMAP(cpix->widget), &pix, &mask);

	gdk_window_set_back_pixmap(win, pix, relative);

	return 0;
err:
	return 1;
}
コード例 #17
0
ファイル: ctree.c プロジェクト: amery/clip-itk
/* Change the information. Most parameters correspond to the parameters
   of gtk_ctree_insert_node. */
int
clip_GTK_CTREENODESETNODEINFO(ClipMachine * cm)
{
	C_widget   *cctree = _fetch_cw_arg(cm);
	C_object    *cnode = _fetch_cobject(cm,_clip_spar(cm,2));
	ClipVar    *cvtext = _clip_spar(cm,3);
	guint8     spacing = _clip_parni(cm,4);
	C_widget  *cclosed = _fetch_cwidget(cm,_clip_spar(cm,5));
	C_widget  *copened = _fetch_cwidget(cm,_clip_spar(cm,6));
	gboolean   is_leaf = _clip_parl(cm,7);
	gboolean  expanded = _clip_parl(cm,8);
	GtkCTreeNode *node = 0;
	GdkPixmap *pxm_closed=NULL, *pxm_opened=NULL;
	GdkBitmap *mask_closed=NULL, *mask_opened=NULL;
	int i;
	gchar * * columns = NULL;
	int ncolumns;

	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT2(3,ARRAY_t,CHARACTER_t); CHECKOPT(4,NUMERIC_t);
	CHECKOPT2(5,MAP_t,NUMERIC_t); CHECKCWIDOPT(cclosed,GTK_IS_PIXMAP);
	CHECKOPT2(6,MAP_t,NUMERIC_t); CHECKCWIDOPT(copened,GTK_IS_PIXMAP);
	CHECKOPT(7,LOGICAL_t); CHECKOPT(8,LOGICAL_t);

	if (cnode) node = GTK_CTREE_NODE(cnode->object);
	if (cclosed)
	{
		pxm_closed=GTK_PIXMAP(cclosed->widget)->pixmap;
		mask_closed=GTK_PIXMAP(cclosed->widget)->mask;
	}
	if (copened)
	{
		pxm_opened=GTK_PIXMAP(copened->widget)->pixmap;
		mask_opened=GTK_PIXMAP(copened->widget)->mask;
	}
	if (_clip_parinfo(cm,7)==UNDEF_t) is_leaf = TRUE;
	if (_clip_parinfo(cm,8)==UNDEF_t) expanded = FALSE;

	ncolumns = GTK_CLIST(cctree->widget)->columns;
	columns = (gchar**)calloc(sizeof(columns),ncolumns);
	for(i=0; i < ncolumns; i++ ) columns[i] = "";
	if (cvtext->t.type==ARRAY_t)
	{
		ClipArrVar *acol = (ClipArrVar*)_clip_vptr(cvtext);
		for(i=0; i < acol->count; i++ )
			if ( i < acol->count && acol->items[i].t.type == CHARACTER_t )
				{
				columns[i] = acol->items[i].s.str.buf;
				LOCALE_TO_UTF(columns[i]);
				}
	}
	if (cvtext->t.type==CHARACTER_t)
		{
		columns[0] = _clip_parc(cm,2);
		LOCALE_TO_UTF(columns[0]);
		}
	gtk_ctree_set_node_info(GTK_CTREE(cctree->widget),
		node,columns[0],spacing,pxm_closed,mask_closed,
		pxm_opened,mask_opened,is_leaf,expanded);
#ifdef OS_CYGWIN
	if (cvtext->t.type==ARRAY_t)
	{
		ClipArrVar *acol = (ClipArrVar*)_clip_vptr(cvtext);
		for(i=0; i < acol->count; i++ )
			if ( i < acol->count && acol->items[i].t.type == CHARACTER_t )
				FREE_TEXT(columns[i]);
	}
	if (cvtext->t.type==CHARACTER_t)
		FREE_TEXT(columns[0]);
#endif
	if (columns) free(columns);
	return 0;
err:
	return 1;
}
コード例 #18
0
ファイル: ctree.c プロジェクト: amery/clip-itk
/* Insert a new node to the tree. The position is specified through the
 * parent-sibling notation, as explained in the introduction above. */
int
clip_GTK_CTREEINSERTNODE(ClipMachine * cm)
{
	C_widget   *cctree = _fetch_cw_arg(cm);
	C_object  *cparent = _fetch_cobject(cm,_clip_spar(cm,2));
	C_object *csibling = _fetch_cobject(cm,_clip_spar(cm,3));
	ClipVar    *cvtext = _clip_spar(cm,4);
	guint8     spacing = _clip_parni(cm,5);
	C_widget  *cclosed = _fetch_cwidget(cm,_clip_spar(cm,6));
	C_widget  *copened = _fetch_cwidget(cm,_clip_spar(cm,7));
	gboolean   is_leaf = _clip_parl(cm,8);
	gboolean  expanded = _clip_parl(cm,9);
	GtkCTreeNode *new_node, *parent=NULL, *sibling=NULL;
	GdkPixmap *pxm_closed=NULL, *pxm_opened=NULL;
	GdkBitmap *mask_closed=NULL, *mask_opened=NULL;
	C_object *cnew_node;
	int i;
	gchar * * columns = NULL;
	int ncolumns;

	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cparent,cparent->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT2(3,MAP_t,NUMERIC_t); CHECKCOBJOPT(csibling,csibling->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT2(4,ARRAY_t,CHARACTER_t); CHECKOPT(5,NUMERIC_t);
	CHECKOPT2(6,MAP_t,NUMERIC_t); CHECKCWIDOPT(cclosed,GTK_IS_PIXMAP);
	CHECKOPT2(7,MAP_t,NUMERIC_t); CHECKCWIDOPT(copened,GTK_IS_PIXMAP);
	CHECKOPT(8,LOGICAL_t); CHECKOPT(9,LOGICAL_t);

	if (cparent) parent = GTK_CTREE_NODE(cparent->object);
	if (csibling) sibling = GTK_CTREE_NODE(csibling->object);
	if (cclosed)
	{
		pxm_closed=GTK_PIXMAP(cclosed->widget)->pixmap;
		mask_closed=GTK_PIXMAP(cclosed->widget)->mask;
	}
	if (copened)
	{
		pxm_opened=GTK_PIXMAP(copened->widget)->pixmap;
		mask_opened=GTK_PIXMAP(copened->widget)->mask;
	}
	if (_clip_parinfo(cm,8)==UNDEF_t) is_leaf = TRUE;
	if (_clip_parinfo(cm,9)==UNDEF_t) expanded = FALSE;

	ncolumns = GTK_CLIST(cctree->widget)->columns;
	columns = (gchar**)calloc(sizeof(columns),ncolumns);
	for(i=0; i < ncolumns; i++ ) columns[i] = "";
	if (cvtext->t.type==ARRAY_t)
	{
		ClipArrVar *acol = (ClipArrVar*)_clip_vptr(cvtext);
		for(i=0; i < acol->count; i++ )
			if ( i < acol->count && acol->items[i].t.type == CHARACTER_t )
				{
				columns[i] = acol->items[i].s.str.buf;
				LOCALE_TO_UTF(columns[i]);
				}
	}
	if (cvtext->t.type==CHARACTER_t)
		{
		columns[0] = _clip_parc(cm,2);
		LOCALE_TO_UTF(columns[0]);
		}

	new_node = gtk_ctree_insert_node(GTK_CTREE(cctree->widget),
		parent,sibling,columns,spacing,pxm_closed,mask_closed,
		pxm_opened,mask_opened,is_leaf,expanded);
	if (new_node)
	{
		cnew_node = _register_object(cm,new_node,GTK_TYPE_CTREE_NODE,NULL,NULL);
		if (cnew_node) _clip_mclone(cm,RETPTR(cm),&cnew_node->obj);
		gtk_ctree_node_set_row_data_full(GTK_CTREE(cctree->widget),
			new_node,cnew_node,(GtkDestroyNotify)destroy_c_object);
	}

#ifdef OS_CYGWIN
	if (cvtext->t.type==ARRAY_t)
	{
		ClipArrVar *acol = (ClipArrVar*)_clip_vptr(cvtext);
		for(i=0; i < acol->count; i++ )
			if ( i < acol->count && acol->items[i].t.type == CHARACTER_t )
				FREE_TEXT(columns[i]);
	}
	if (cvtext->t.type==CHARACTER_t)
		FREE_TEXT(columns[0]);
#endif
	if (columns) free(columns);
	return 0;
err:
	return 1;
}
コード例 #19
0
ファイル: about_cb.c プロジェクト: debrouxl/tiemu
gint display_about_dbox()
{
  GtkWidget *dbox;
  gpointer user_data;
  FILE *fd;
  gchar buffer[MAXCHARS];
  GdkFont *fixed_font;
  GtkWidget *text;
  gchar tempstr[MAXCHARS];

  dbox = create_about_dbox();
  
  /* Set text */
  user_data = gtk_object_get_data(GTK_OBJECT(dbox), "text1");
  text = GTK_WIDGET(user_data);
  gtk_text_freeze(GTK_TEXT (text));
  gtk_editable_delete_text(GTK_EDITABLE(text), 0, -1);

  strcpy(buffer, inst_paths.base_dir);  // retrieve base path
  strcat(buffer, SHARE_DIR);          //
  strcat(buffer, DIR_SEPARATOR);
#if defined(__LINUX__)
  strcat(buffer, "COPYING");
#elif defined(__WIN32__)
  strcat(buffer, "Copying.txt");
#endif

  if(access(buffer, F_OK) == 0 )
    {
#if defined(__LINUX__)
      fixed_font = gdk_font_load ("-misc-clean-medium-r-*-*-*-140-*-*-*-*-*-*");
#elif defined(__WIN32__)
      fixed_font = gdk_font_load ("-adobe-courier-medium-r-normal--12-120-75-75-p-70-iso8859-1");
#endif
      if( (fd=fopen (buffer, "r")) != NULL)
	{
	  memset (buffer, 0, sizeof(buffer));
	  while(fread (buffer, 1, sizeof(buffer)-1, fd))
            {
	      process_buffer(buffer);
              gtk_text_insert (GTK_TEXT (text), fixed_font, NULL, NULL, buffer, strlen (buffer));
              memset (buffer, 0, sizeof(buffer));
            }
	  fclose (fd);
	}
    }
  gtk_text_thaw(GTK_TEXT (text));

  /* Set label */
  user_data = gtk_object_get_data(GTK_OBJECT(dbox), "label5");
#ifdef HAVE_LIBTIFFEP
  g_snprintf(tempstr, sizeof(tempstr), 
	     "* TILP version %s (cable=%s, tiffep=%s)", 
	     GTKTIEMU_VERSION,
	     ticable_get_version(),
	     tiffep_get_version());
#else
  g_snprintf(tempstr, sizeof(tempstr),
	     "* TILP version %s (%s %s)", 
	     GTKTIEMU_VERSION,
	     ticable_get_version(),
	     "NA");
#endif
  gtk_label_set_text(GTK_LABEL(user_data), tempstr);

  /* Set pixmap */
  user_data = gtk_object_get_data(GTK_OBJECT(dbox), "pixmap2");
  #if 0
  /* buggy code -- avoid segfault ... */
  GtkWidget *tmp_pixmapwid = GTK_WIDGET(user_data);
  GdkPixmap *pixmap;
  GdkBitmap *mask;
  GtkStyle *style;
  FILE *f;
  gchar buffer[MAXCHARS];

  return;

  /* Create the base filename */
  strcpy(buffer, inst_paths.base_dir);  // retrieve base path
  strcat(buffer, SHARE_DIR);          //
  strcat(buffer, DIR_SEPARATOR);
#if defined(__LINUX__)
  strcat(buffer, "logo.jpg");
#elif defined(__WIN32__)
  strcat(buffer, "logo.jpg");
#endif
  DISPLAY("logo: <%s>\n", buffer);
  /* Try to access the file */
  if(access(buffer, F_OK) == 0 )
    {
      /* Open and load file */
      f = fopen(buffer, "rb");
      if(f == NULL)
	g_error("Unable to open the logo (logo.jpg).\n");
      img.depth = 3; // > 2 colors
      read_jpg_format(f, &img);
      fclose(f);

      convert_bytemap_to_pixmap(&img);

      style = gtk_widget_get_style(widget);
      pixmap = gdk_pixmap_create_from_xpm_d(widget->window, &mask,
					    &style->bg[GTK_STATE_NORMAL],
					    (gchar **)(img.pixmap));
      gtk_pixmap_set(GTK_PIXMAP(tmp_pixmapwid), pixmap, mask);      
    }
  else 
    g_warning("Unable to open the logo (logo.jpg).\n");
#endif

  gtk_widget_show_all(dbox);
  return 0;
}
コード例 #20
0
static void
gtk_border_combo_update (GtkWidget * widget, GtkBorderCombo * border_combo)
{
  gint i,j;
  gint focus_row = -1, focus_col = -1;
  gint new_row = -1, new_col = -1;
  gint new_selection=FALSE;
  gint row,column;
  GdkPixmap *window;

  row=border_combo->row;
  column=border_combo->column;

  for(i=0 ; i<border_combo->nrows; i++)
    for(j=0; j<border_combo->ncols; j++){    
      if(GTK_WIDGET_HAS_FOCUS(border_combo->button[i][j])){
            focus_row=i;
            focus_col=j;
      }
      if(border_combo->button[i][j]->state==GTK_STATE_ACTIVE){
        if(i != row || j != column){
            new_selection=TRUE;
            new_row=i;
            new_col=j;
        }
      }
    }

  if(!new_selection && focus_row >= 0 && focus_col >= 0){
     if(focus_row != row || focus_col != column){
       new_selection = TRUE;
       new_row=focus_row;
       new_col=focus_col;
     }
  }

  if(new_selection){
      if(row >= 0 && column >= 0){
          gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(border_combo->button[row][column]), FALSE);
          gtk_widget_queue_draw(border_combo->button[row][column]);
      }
      border_combo->row=new_row;
      border_combo->column=new_col;
      window=GTK_PIXMAP(GTK_BIN(GTK_COMBO_BUTTON(border_combo)->button)
                                                         ->child)->pixmap;
      gdk_window_copy_area(window,
                           widget->style->fg_gc[GTK_STATE_NORMAL],
                           0,0,
 GTK_PIXMAP(GTK_BIN(border_combo->button[new_row][new_col])->child)->pixmap,
                           0,0,16,16);

      gtk_widget_queue_draw(GTK_COMBO_BUTTON(border_combo)->button);
      
      gtk_signal_emit (GTK_OBJECT(border_combo), border_combo_signals[CHANGED],
                       new_row * border_combo->ncols + new_col);
  }

  if(!new_selection && row >= 0 && column >= 0){
          gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(border_combo->button[row][column]), TRUE);
          gtk_widget_queue_draw(border_combo->button[row][column]);

          gtk_signal_emit (GTK_OBJECT(border_combo),                     
                           border_combo_signals[CHANGED],
                           row * border_combo->ncols + column);
  }


  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_COMBO_BUTTON(border_combo)->arrow), FALSE);

  gtk_grab_remove(GTK_COMBO_BUTTON(border_combo)->popwin);
  gdk_pointer_ungrab(GDK_CURRENT_TIME);
  gtk_widget_hide(GTK_COMBO_BUTTON(border_combo)->popwin);
  return;

}
コード例 #21
0
ファイル: gdkgc.c プロジェクト: amery/clip-itk
/* The GdkGCValues structure holds a set of values used to create or
   modify a graphics context.
GdkColor foreground;	the foreground color.
GdkColor background;	the background color.
GdkFont *font;		the default font..
GdkFunction function;	the bitwise operation used when drawing.
GdkFill fill;		the fill style.
GdkPixmap *tile;	the tile pixmap.
GdkPixmap *stipple;	the stipple bitmap.
GdkPixmap *clip_mask;	the clip mask bitmap.
GdkSubwindowMode subwindow_mode; the subwindow mode.
gint ts_x_origin;	the x origin of the tile or stipple.
gint ts_y_origin;	the y origin of the tile or stipple.
gint clip_x_origin;	the x origin of the clip mask.
gint clip_y_origin;	the y origin of the clip mask.
gint graphics_exposures; whether graphics exposures are enabled.
gint line_width;	the line width
GdkLineStyle line_style; the way dashed lines are drawn
GdkCapStyle cap_style;	the way the ends of lines are drawn
GdkJoinStyle join_style; the way joins between lines are drawn
*/
int
clip_GDK_GCNEWWITHVALUES(ClipMachine * cm)
{
	ClipVar    *cv = _clip_spar(cm,1);
	C_widget *cwid = _fetch_cwidget(cm,_clip_spar(cm,2));
	ClipVar  *cval = _clip_spar(cm,3);
	long      mask = _clip_parnl(cm,4);
	GdkGC *gc;
	GdkGCValues gcv;
	GdkFont *font = 0;
	C_object *cgc, *cfont;
	ClipVar *c;
	C_widget *cw;
	double d;
	CHECKOPT(1,MAP_t); CHECKARG2(2,NUMERIC_t,MAP_t);
	CHECKARG(3,MAP_t); CHECKARG(4,NUMERIC_t);

	/* the foreground color. */
	if ( (c = _clip_mget( cm, cval, HASH_FOREGROUND )) != NULL )
		_map_colors_to_gdk(cm, c, &gcv.foreground);
	/* the background color. */
	if ( (c = _clip_mget( cm, cval, HASH_BACKGROUND )) != NULL )
		_map_colors_to_gdk(cm, c, &gcv.background);
	/* Set default font */
	switch ( _clip_mtype(cm,cval,HASH_FONT) )
	{
		case CHARACTER_t:
			c = _clip_mget(cm,cval,HASH_FONT);
			font = gdk_font_load(c->s.str.buf);
			break;
		case MAP_t:
		case NUMERIC_t:
			cfont = _fetch_cobject(cm,_clip_mget(cm,cval,HASH_FONT));
			if (cfont)
			{
				font = (GdkFont*)cfont->object;
				cfont->ref_count++;
			}
			break;
		default:
			break;
	}
	if (font)
	{
		gcv.font = font;
		gdk_font_ref (gcv.font);
	}
	/* the bitwise operation used when drawing. */
	/* Determines how the bit values for the source pixels are combined with the
	   bit values for destination pixels to produce the final result. The sixteen
	   values here correspond to the 16 different possible 2x2 truth tables. Only
	   a couple of these values are usually useful; for colored images, only
	   GDK_COPY, GDK_XOR and GDK_INVERT are generally useful. For bitmaps, GDK_AND
	   and GDK_OR are also useful. */
	_clip_mgetn(cm,cval,HASH_FUNCTION,&d);
	gcv.function = (GdkFunction)d;
	/* the fill style. */
	_clip_mgetn(cm,cval,HASH_FILL,&d);
	gcv.fill = (GdkFill)d;
	/* the tile pixmap. */
	if ( (c = _clip_mget( cm, cval, HASH_TILE )) != NULL )
	{
		cw = _fetch_cwidget(cm,c);
		gcv.tile = cw ? GTK_PIXMAP(cw->widget)->pixmap : NULL;
	}
	/* the stipple pixmap. */
	if ( (c = _clip_mget( cm, cval, HASH_STIPPLE )) != NULL )
	{
		cw = _fetch_cwidget(cm,c);
		gcv.stipple = cw ? GTK_PIXMAP(cw->widget)->pixmap : NULL;
	}
	/* the clip mask bitmap. */
	if ( (c = _clip_mget( cm, cval, HASH_CLIPMASK )) != NULL )
	{
		cw = _fetch_cwidget(cm,c);
		gcv.clip_mask = cw ? GTK_PIXMAP(cw->widget)->pixmap : NULL;
	}
	/* the subwindow mode. */
	_clip_mgetn(cm,cval,HASH_SUBWINDOWMODE,&d);
	gcv.subwindow_mode = (GdkSubwindowMode)d;
	/* the x origin of the tile or stipple. */
	_clip_mgetn(cm,cval,HASH_TSXORIGIN,&d);
	gcv.ts_x_origin = (gint)d;
	/* the y origin of the tile or stipple. */
	_clip_mgetn(cm,cval,HASH_TSYORIGIN,&d);
	gcv.ts_y_origin = (gint)d;
	/* the x origin of the clip mask. */
	_clip_mgetn(cm,cval,HASH_CLIPXORIGIN,&d);
	gcv.clip_x_origin = (gint)d;
	/* the y origin of the clip mask. */
	_clip_mgetn(cm,cval,HASH_CLIPYORIGIN,&d);
	gcv.clip_y_origin = (gint)d;
	/* whether graphics exposures are enabled. */
	_clip_mgetn(cm,cval,HASH_GRAPHICSEXPOSURES,&d);
	gcv.graphics_exposures = (gint)d;
	/* the line width */
	_clip_mgetn(cm,cval,HASH_LINEWITDH,&d);
	gcv.line_width = (gint)d;
	/* the way dashed lines are drawn */
	_clip_mgetn(cm,cval,HASH_LINESTYLE,&d);
	gcv.line_style = (GdkLineStyle)d;
	/* the way the ends of lines are drawn */
	_clip_mgetn(cm,cval,HASH_CAPSTYLE,&d);
	gcv.cap_style = (GdkCapStyle)d;
	/* the way joins between lines are drawn */
	_clip_mgetn(cm,cval,HASH_JOINSTYLE,&d);
	gcv.join_style = (GdkJoinStyle)d;

	gc = gdk_gc_new_with_values(cwid->widget->window, &gcv, mask);
	if (gc)
	{
//		gdk_gc_ref(gc);
		cgc = _register_object(cm,gc,GDK_OBJECT_GC,cv,
			(coDestructor)gdk_object_gc_destructor);
		if (cgc)
		{
			cgc->ref_count=1;
			_clip_mclone(cm,RETPTR(cm),&cgc->obj);
		}
		else
			gdk_gc_unref(gc);

	}
	return 0;
err:
	return 1;
}
コード例 #22
0
ファイル: tbargtk.cpp プロジェクト: Bluehorn/wxPython
bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{
    wxToolBarTool *tool = (wxToolBarTool *)toolBase;

    // if we have inserted a space before all the tools we must change the GTK
    // index by 1
    size_t posGtk = m_xMargin > 1 ? pos + 1 : pos;

    if ( tool->IsButton() )
    {
        if ( !HasFlag(wxTB_NOICONS) )
        {
            wxBitmap bitmap = tool->GetNormalBitmap();

            wxCHECK_MSG( bitmap.Ok(), false,
                         wxT("invalid bitmap for wxToolBar icon") );

            wxCHECK_MSG( bitmap.GetBitmap() == NULL, false,
                         wxT("wxToolBar doesn't support GdkBitmap") );

            wxCHECK_MSG( bitmap.GetPixmap() != NULL, false,
                         wxT("wxToolBar::Add needs a wxBitmap") );

            GtkWidget *tool_pixmap = (GtkWidget *)NULL;

            GdkPixmap *pixmap = bitmap.GetPixmap();

            GdkBitmap *mask = (GdkBitmap *)NULL;
            if ( bitmap.GetMask() )
                mask = bitmap.GetMask()->GetBitmap();

            tool_pixmap = gtk_pixmap_new( pixmap, mask );
            gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE );

            gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );

            tool->m_pixmap = tool_pixmap;
        }
    }

    switch ( tool->GetStyle() )
    {
        case wxTOOL_STYLE_BUTTON:
            // for a radio button we need the widget which starts the radio
            // group it belongs to, i.e. the first radio button immediately
            // preceding this one
            {
                GtkWidget *widget = NULL;

                if ( tool->IsRadio() )
                {
                    wxToolBarToolsList::compatibility_iterator node
                        = wxToolBarToolsList::compatibility_iterator();
                    if ( pos )
                        node = m_tools.Item(pos - 1);

                    while ( node )
                    {
                        wxToolBarTool *toolNext = (wxToolBarTool *)node->GetData();
                        if ( !toolNext->IsRadio() )
                            break;

                        widget = toolNext->m_item;

                        node = node->GetPrevious();
                    }

                    if ( !widget )
                    {
                        // this is the first button in the radio button group,
                        // it will be toggled automatically by GTK so bring the
                        // internal flag in sync
                        tool->Toggle(true);
                    }
                }

                tool->m_item = gtk_toolbar_insert_element
                               (
                                  m_toolbar,
                                  tool->GetGtkChildType(),
                                  widget,
                                  tool->GetLabel().empty()
                                    ? NULL
                                    : (const char*) wxGTK_CONV( tool->GetLabel() ),
                                  tool->GetShortHelp().empty()
                                    ? NULL
                                    : (const char*) wxGTK_CONV( tool->GetShortHelp() ),
                                  "", // tooltip_private_text (?)
                                  tool->m_pixmap,
                                  (GtkSignalFunc)gtk_toolbar_callback,
                                  (gpointer)tool,
                                  posGtk
                               );

                if ( !tool->m_item )
                {
                    wxFAIL_MSG( _T("gtk_toolbar_insert_element() failed") );

                    return false;
                }

                gtk_signal_connect( GTK_OBJECT(tool->m_item),
                                    "enter_notify_event",
                                    GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
                                    (gpointer)tool );
                gtk_signal_connect( GTK_OBJECT(tool->m_item),
                                    "leave_notify_event",
                                    GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
                                    (gpointer)tool );
            }
            break;

        case wxTOOL_STYLE_SEPARATOR:
            gtk_toolbar_insert_space( m_toolbar, posGtk );

            // skip the rest
            return true;

        case wxTOOL_STYLE_CONTROL:
            gtk_toolbar_insert_widget(
                                       m_toolbar,
                                       tool->GetControl()->m_widget,
                                       (const char *) NULL,
                                       (const char *) NULL,
                                       posGtk
                                      );
            break;
    }

    GtkRequisition req;
    (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
        (m_widget, &req );
    m_width = req.width + m_xMargin;
    m_height = req.height + 2*m_yMargin;
    InvalidateBestSize();

    return true;
}
コード例 #23
0
ファイル: notebook.cpp プロジェクト: beanhome/dev
bool wxNotebook::SetPageImage( size_t page, int image )
{
    /* HvdH 28-12-98: now it works, but it's a bit of a kludge */

    wxGtkNotebookPage* nb_page = GetNotebookPage(page);

    if (!nb_page) return FALSE;

    /* Optimization posibility: return immediately if image unchanged.
     * Not enabled because it may break existing (stupid) code that
     * manipulates the imagelist to cycle images */

    /* if (image == nb_page->m_image) return true; */

    /* For different cases:
       1) no image -> no image
       2) image -> no image
       3) no image -> image
       4) image -> image */

    if (image == -1 && nb_page->m_image == -1)
        return true; /* Case 1): Nothing to do. */

    GtkWidget *pixmapwid = NULL;

    if (nb_page->m_image != -1)
    {
        /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */

        GList *child = gtk_container_children(GTK_CONTAINER(nb_page->m_box));
        while (child)
        {
            if (GTK_IS_PIXMAP(child->data))
            {
                pixmapwid = GTK_WIDGET(child->data);
                break;
            }
            child = child->next;
        }

        /* We should have the pixmap widget now */
        wxASSERT(pixmapwid != NULL);

        if (image == -1)
        {
            /* If there's no new widget, just remove the old from the box */
            gtk_container_remove(GTK_CONTAINER(nb_page->m_box), pixmapwid);
            nb_page->m_image = -1;

            return true; /* Case 2) */
        }
    }

    /* Only cases 3) and 4) left */
    wxASSERT( m_imageList != NULL ); /* Just in case */

    /* Construct the new pixmap */
    const wxBitmap *bmp = m_imageList->GetBitmapPtr(image);
    GdkPixmap *pixmap = bmp->GetPixmap();
    GdkBitmap *mask = NULL;
    if ( bmp->GetMask() )
    {
        mask = bmp->GetMask()->GetBitmap();
    }

    if (pixmapwid == NULL)
    {
        /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */
        pixmapwid = gtk_pixmap_new (pixmap, mask );

        /* CHECKME: Are these pack flags okay? */
        gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, m_padding);
        gtk_widget_show(pixmapwid);
    }
    else
    {
        /* Case 4) Simply replace the pixmap */
        gtk_pixmap_set(GTK_PIXMAP(pixmapwid), pixmap, mask);
    }

    nb_page->m_image = image;

    return true;
}