예제 #1
0
파일: ex3.c 프로젝트: Eddyding/GTK-2.0
int 
main(int argc,char *argv[])
{

	gtk_init(&argc,&argv);// 初始化图形显示环境。

	// 窗口
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window),
						g_locale_to_utf8("Add a entry to the window",-1,NULL,NULL,NULL)
						);

	// width & height
	gtk_widget_set_usize(window,300,150);
	// x & y
	gtk_widget_set_uposition(window,300,300);


	// 最大30
	entry = gtk_entry_new_with_max_length(30);

	gtk_container_add(GTK_CONTAINER(window),entry);
	
	// 显示窗口中的所有元件
	gtk_widget_show_all(window);


	//直接引用g_signal_connect宏,退出
    g_signal_connect(G_OBJECT(window),"delete_event"
            ,G_CALLBACK(gtk_main_quit),NULL);
	
	// 消息主循环
	gtk_main();
	return 0;
}
예제 #2
0
void
gtk_window_set_win_position (GtkWidget *widget,
			     gint	     x,
			     gint	     y)
{
  /* this is an quick & dirty hack */

  g_return_if_fail (widget);
  g_return_if_fail (GTK_WINDOW (widget));

  if ((x >= 0) && (y >= 0))
    gtk_widget_set_uposition (widget, x,y);
  else
    { 
      /* g_message ("Negative warp to %d,%d", x,y); */

      if (! GTK_WIDGET_REALIZED (widget))
	gtk_widget_realize (widget);

      widget -> allocation.x = x;
      widget -> allocation.y = y;

      gdk_window_set_hints (widget->window, x, y, 0, 0, 0, 0, GDK_HINT_POS);
      gdk_window_move (widget->window, x,y);
    }
}
예제 #3
0
/*
 * Función mostrarConsultaWindow()
 *
 * Parámetros de entrada:
 *      char * dir[3]: nombre direccion y telefono a mostrar
 *      
 * Parámetros de salida:
 *      Ninguno
 *
 * Descripción: 
 *      Mostrar en la pantalla una única consulta
 */
void mostrarConsultaWindow(char* dir[3])
{
    GtkWidget *datos;
    GtkWidget *window;
  
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_set_usize (GTK_WIDGET (window), 300, 300);
    gtk_window_set_policy(GTK_WINDOW (window), TRUE, TRUE, FALSE);      
    gtk_window_set_title (GTK_WINDOW (window), "Libro de direcciones");
    gtk_container_border_width (GTK_CONTAINER (window), 10);    
    gtk_widget_set_uposition( window, 300, 300 );   
  
    datos=gtk_clist_new(3);
    gtk_clist_set_column_title(GTK_CLIST(datos),0,"Nombre");    
    gtk_clist_set_column_title(GTK_CLIST(datos),1,"Direccion");
    gtk_clist_set_column_title(GTK_CLIST(datos),2,"Telefono");
    gtk_clist_column_titles_show(GTK_CLIST(datos));
    gtk_clist_set_column_width(GTK_CLIST(datos),0,100);
    gtk_clist_set_column_width(GTK_CLIST(datos),1,100);
    gtk_clist_set_column_width(GTK_CLIST(datos),2,50);          
    gtk_container_add (GTK_CONTAINER (window), datos); 
    gtk_clist_append(GTK_CLIST(datos),dir);   
    gtk_widget_show(datos);
    gtk_grab_add(window);
    gtk_widget_show(window);
} 
예제 #4
0
/*-----------------------------------------------------------------------------------------------------------------------*/
void StartCallBack(GtkWidget *W,GtkWidget *StartWin)
{
GtkWidget *Win,*But,*Label;
gchar Str[MAX_FNAME_LENGTH+25];

gtk_widget_destroy(GTK_WIDGET(StartWin));

if (!access(RunName,F_OK)) 
   {
   Win=gtk_dialog_new(); gtk_grab_add(Win);
   gtk_signal_connect_object(GTK_OBJECT(Win),"destroy",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
   gtk_window_set_title(GTK_WINDOW(Win),"Overwrite?"); gtk_container_border_width(GTK_CONTAINER(Win),5);
   gtk_widget_set_uposition(GTK_WIDGET(Win),400,400);
   sprintf(Str,"Overwrite %s?",RunName);
   Label=gtk_label_new(Str); gtk_misc_set_padding(GTK_MISC(Label),10,10);
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->vbox),Label,TRUE,TRUE,0);
   But=gtk_button_new_with_label("Yes");
   gtk_signal_connect(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(OverwriteStart),Win);
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->action_area),But,TRUE,TRUE,0);
   But=gtk_button_new_with_label("Cancel");
   gtk_signal_connect_object(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->action_area),But,TRUE,TRUE,0);
   gtk_widget_show_all(Win);
   return;
   } 
AcqOn=TRUE; StopSignal=FALSE;
pthread_create(&Acq,NULL,AcquireData,NULL);
}
예제 #5
0
파일: gtkcombo.c 프로젝트: Onjrew/OpenEV
static void
gtk_combo_popup_list (GtkCombo * combo)
{
  gint height, width, x, y;
  gint old_width, old_height;

  old_width = combo->popwin->allocation.width;
  old_height  = combo->popwin->allocation.height;

  gtk_combo_get_pos (combo, &x, &y, &height, &width);

  /* workaround for gtk_scrolled_window_size_allocate bug */
  if (old_width != width || old_height != height)
    {
      gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->hscrollbar);
      gtk_widget_hide (GTK_SCROLLED_WINDOW (combo->popup)->vscrollbar);
    }

  gtk_widget_set_uposition (combo->popwin, x, y);
  gtk_widget_set_usize (combo->popwin, width, height);
  gtk_widget_realize (combo->popwin);
  gdk_window_resize (combo->popwin->window, width, height);
  gtk_widget_show (combo->popwin);

  gtk_widget_grab_focus (combo->popwin);
}
예제 #6
0
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win )
{
    if (g_isIdle) wxapp_install_idle_handler();

    if (!win->m_hasVMT) return FALSE;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;

    if (!win->m_isDragging) return TRUE;

    win->m_isDragging = false;

    int x = (int)gdk_event->x;
    int y = (int)gdk_event->y;

    DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height );
    gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME );
    int org_x = 0;
    int org_y = 0;
    gdk_window_get_origin( widget->window, &org_x, &org_y );
    x += org_x - win->m_diffX;
    y += org_y - win->m_diffY;
    win->m_x = x;
    win->m_y = y;
    gtk_widget_set_uposition( win->m_widget, x, y );

    return TRUE;
}
예제 #7
0
static void fftscope_hide()
{
	gint x, y;

	if (scope_win) {
		gdk_window_get_root_origin(scope_win->window, &x, &y);
		gtk_widget_hide(scope_win);
		gtk_widget_set_uposition(scope_win, x, y);
	}
}
예제 #8
0
void WebBrowserObject::SetPosition(int x, int y, int w, int h)
{
    GUI_Widget::SetPosition(x, y, w, h);
    Lock();
    if (toplevel) {
        gtk_widget_set_uposition(toplevel, area.x, area.y);
        gtk_widget_set_usize(toplevel, area.w, area.h);
    }
    Unlock();
}
예제 #9
0
void ShowDialog(UIDialog* dialog, gchar* default_widget) 
{
	gint sw, sh;
	gint px, py;
	gint pw, ph;
	gint cw, ch;
	gint ox, oy;

	if( dialog->parent != NULL )
	{
		sw = gdk_screen_width();
		sh = gdk_screen_height();

		gtk_widget_realize(dialog->window);
		gtk_window_set_transient_for(GTK_WINDOW(dialog->window),
									GTK_WINDOW(dialog->parent->window));

		gdk_window_get_root_origin(dialog->parent->window->window, &px, &py);
		gdk_window_get_size(dialog->parent->window->window, &pw, &ph);
		gdk_window_get_size(dialog->window->window, &cw, &ch);

		ox = (pw - cw) / 2;
		if( ox < 20 )	ox = 20;

		oy = (ph - ch) / 2;
		if( oy < 20 )	oy = 20;

		if( px + ox + cw > sw ) 
			ox = sw - cw - px - 20;

		if( py + oy + ch > sh )
			oy = sh - ch - py - 20;

		if( dialog->pos_x == 0 )
			dialog->pos_x = px + ox;
		if( dialog->pos_y == 0 )
			dialog->pos_y = py + oy;
	}

	gtk_widget_set_uposition(dialog->window, dialog->pos_x, dialog->pos_y);

	if( default_widget )
	{
		GtkWidget* widget = LookupWidget(dialog->window, default_widget);

		if( widget )
		{
			gtk_widget_grab_focus(widget);
			gtk_widget_grab_default(widget);
		}
	}

	gtk_widget_show(dialog->window);
	gtk_main();
}
예제 #10
0
파일: juno_gui.C 프로젝트: kmtaylor/juno6
void mainWindow_motion( GtkWidget* widget, 
			GdkEventMotion* event, gpointer callback_data )
{
    if ( indrag )
    {
	gint x, y;
	gdk_window_get_pointer( NULL, &x, &y, NULL );
	gtk_widget_set_uposition( widget, x - offset_x, y - offset_y ); 
	gdk_flush();
    }
}
예제 #11
0
파일: noborder.c 프로젝트: flashlib/example
	static void shape_motion (GtkWidget *widget, GdkEventMotion *event)
	{
		gint xp, yp;
		CursorOffset * p;
		GdkModifierType mask;

		p = gtk_object_get_user_data (GTK_OBJECT (widget));

		//取得绝对位置
		gdk_window_get_pointer (root_win, &xp, &yp, &mask);
		gtk_widget_set_uposition (widget, xp  - p->x, yp  - p->y);
	}
예제 #12
0
TABVIEW *ZJ_Create_TabView(int x,int y,int width,int height)
{
	ptabview newtabview= (TABVIEW*)malloc(sizeof(TABVIEW));
	//newtabview->TabViewWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	/*newtabview->container = gtk_container_new(*/
	newtabview->fistlist = g_list_alloc();
	newtabview->fistlist->data = NULL;
	newtabview->TabViewFixed = gtk_fixed_new();
	newtabview->PageFixed = gtk_fixed_new();
	newtabview->pos = TV_POS_TOP;
	newtabview->focuslist = NULL;
	newtabview->current_page = NULL;
	if(x<0)
		x = 0;
	if(y<0)
		y = 0;
	if(width<=0)
		width = DEFAULT_TABVIEWWINDOW_W;
	if(height<=0)
		height = DEFAULT_TABVIEWWINDOW_H;
	newtabview->width = width;
	newtabview->height = height;
	newtabview->x = x;
	newtabview->y = y;
	newtabview->offset1 = 5;
	newtabview->offset2 = 5;
	newtabview->inborder = 0;
	newtabview->active_bg_Img_file = NULL;
	newtabview->normal_bg_Img_file = NULL;
	newtabview->prelight_bg_Img_file = NULL;
	gtk_widget_set_usize((GtkWidget *)(newtabview->TabViewFixed),width,height);
	gtk_widget_set_uposition((GtkWidget *)(newtabview->TabViewFixed),x,y);
	//gtk_widget_set_usize((GtkWidget *)(newtabview->TabViewFixed),width,height);

	
	gtk_widget_set_uposition((GtkWidget *)(newtabview->TabViewFixed),newtabview->offset1,y);
	gtk_container_add((GtkContainer*)newtabview->TabViewFixed,(GtkWidget *)newtabview->PageFixed);
	return newtabview;
}
예제 #13
0
파일: widget.c 프로젝트: amery/clip-itk
/* Alena:Sets a uposition of the widget */
int
clip_GTK_WIDGETSETUPOSITION(ClipMachine * cm)
{
	C_widget *cwid = _fetch_cw_arg(cm);
	gint         x = _clip_parni(cm, 2);
	gint         y = _clip_parni(cm, 3);
	CHECKOPT(2, NUMERIC_t);
	CHECKOPT(3, NUMERIC_t);
	CHECKCWID(cwid,GTK_IS_WIDGET);
	gtk_widget_set_uposition(cwid->widget, x, y);
	return 0;
err:
	return 1;
}
예제 #14
0
/*----------------------------------------------------------------------------------------------------------------------*/
void AtWin(gint X,gint Y,gint XSiz,gint YSiz,gchar *Messg)                          //A more flexible verison of Attention
{
GtkWidget *Win,*Label,*But;

Win=gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(Win),"Attention");
gtk_container_set_border_width(GTK_CONTAINER(Win),10);
gtk_widget_set_uposition(GTK_WIDGET(Win),X,Y); 
gtk_signal_connect_object(GTK_OBJECT(Win),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
But=gtk_button_new_from_stock(GTK_STOCK_DIALOG_INFO); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->vbox),But,TRUE,FALSE,5);
Label=gtk_label_new(Messg); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->vbox),Label,TRUE,FALSE,5);
But=gtk_button_new_with_label("Dismiss");
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->action_area),But,TRUE,FALSE,0);
gtk_signal_connect_object(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
gtk_widget_show_all(Win); 
}
예제 #15
0
Error GTKWindow::VulcanMindMeld(Window *pOther)
{
    Error eRet;
    Rect  oRect;

    m_pMindMeldMutex->Acquire();

    gdk_threads_enter();
    gdk_flush();
    gdk_threads_leave();

    oRect.x1 = oRect.x2 = oRect.y1 = oRect.y2 = 0;
    GetWindowPosition(oRect);

    eRet = Window::VulcanMindMeld(pOther);

    if (IsError(eRet)) {
        m_pMindMeldMutex->Release();
        return eRet;
    }

    Rect oNewRect, oSize;
    
    m_pCanvas->GetBackgroundRect(oSize);
    GdkBitmap *mask = ((GTKCanvas *)m_pCanvas)->GetMask();

    GetReloadWindowPos(oRect, oSize.Width(), oSize.Height(), oNewRect);

    gdk_threads_enter();
    gtk_widget_set_uposition(mainWindow, oNewRect.x1, oNewRect.y1);
    gtk_widget_set_usize(mainWindow, oNewRect.Width(), oNewRect.Height());
    if (mask)
        gdk_window_shape_combine_mask(mainWindow->window, mask, 0, 0);
    gdk_threads_leave();

    Pos NewPos;
    NewPos.x = oNewRect.x1;
    NewPos.y = oNewRect.y1;

    SaveWindowPos(NewPos);

    ((GTKCanvas *)m_pCanvas)->SetParent(this);
    m_pCanvas->Update();
 
    m_pMindMeldMutex->Release();

    return kError_NoErr;
}
예제 #16
0
/*------------------------------------------------------------------------------------------------------------------------*/
void Attention(gint XPos,gchar *Messg)            //Displays message in a modal window. XPos=horiz. shift wrt screen centre
{
GtkWidget *Win,*Label,*But;

Win=gtk_dialog_new();                                                                               /*Create dialog window*/
gtk_grab_add(Win);                                                                                     /*Make window modal*/
gtk_window_set_title(GTK_WINDOW(Win),"Attention");                                                          /*Window title*/
gtk_widget_set_uposition(GTK_WIDGET(Win),415+XPos,280); gtk_widget_set_usize(GTK_WIDGET(Win),300,100);
gtk_signal_connect_object(GTK_OBJECT(Win),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
Label=gtk_label_new("------ATTENTION-------"); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->vbox),Label,TRUE,FALSE,5);
Label=gtk_label_new(Messg); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->vbox),Label,TRUE,FALSE,5);
But=gtk_button_new_with_label("Dismiss");
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->action_area),But,TRUE,FALSE,0);
gtk_signal_connect_object(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
gtk_widget_show_all(Win);
}
예제 #17
0
/*-----------------------------------------------------------------------------------------------------------------------*/
void Start(GtkWidget *W,gpointer Data)
{
gint i;
GtkWidget *Win,*VBox,*HBox,*Label,*But,*Entry;
static GdkColor Black   = {0,0x0000,0x0000,0x0000};
static GdkColor Magenta = {0,0xFFFF,0x0000,0xFFFF};
static GdkColor Gray   = {0,0x8888,0x8888,0x8888};
static GdkColor Blue  =   {0,0x7777,0x7777,0xFFFF};
GtkStyle *Style1,*Style2,*Style3;
 
if (AcqOn) { Attention(100,"Counting is already started"); return; }

Style1=gtk_style_copy(gtk_widget_get_default_style());                                  //Copy default style to this style
for (i=0;i<5;i++) { Style1->fg[i]=Style1->text[i]=Magenta; Style1->bg[i]=Black; }             //Set colours for all states
Style2=gtk_style_copy(gtk_widget_get_default_style());                             //Copy default style to this style
for (i=0;i<5;i++) { Style2->fg[i]=Style2->text[i]=Black; Style2->bg[i]=Blue; }           //Set colours
Style3=gtk_style_copy(gtk_widget_get_default_style());                                             //Copy default style
for (i=0;i<5;i++) { Style3->fg[i]=Style3->text[i]=Black; Style3->bg[i]=Gray; }                   //Set colours

Win=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_grab_add(Win);                                    //Define a new modal window
gtk_window_set_title(GTK_WINDOW(Win),"Start Counting"); gtk_widget_set_uposition(GTK_WIDGET(Win),300,300);
gtk_widget_set_usize(GTK_WIDGET(Win),245,90); gtk_container_set_border_width(GTK_CONTAINER(Win),10);
VBox=gtk_vbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(Win),VBox);                       //VBox for the entire window

HBox=gtk_hbox_new(FALSE,10); gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,5);
Label=gtk_label_new("Run Name:"); gtk_box_pack_start(GTK_BOX(HBox),Label,FALSE,FALSE,5);
Entry=gtk_entry_new_with_max_length(35); gtk_box_pack_start(GTK_BOX(HBox),Entry,FALSE,FALSE,0);
SetStyleRecursively(Entry,Style1);
strcpy(RunName,"mydata"); gtk_entry_set_text(GTK_ENTRY(Entry),RunName);
gtk_widget_set_usize(GTK_WIDGET(Entry),130,25);
gtk_signal_connect(GTK_OBJECT(Entry),"changed",GTK_SIGNAL_FUNC(RunNameCallBack),NULL);

HBox=gtk_hbox_new(FALSE,10); gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,5);
But=gtk_button_new_with_label("Start"); SetStyleRecursively(But,Style2);
gtk_widget_set_usize(GTK_WIDGET(But),100,25);
gtk_box_pack_start(GTK_BOX(HBox),But,TRUE,FALSE,5);
gtk_signal_connect(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(StartCallBack),GTK_OBJECT(Win));
But=gtk_button_new_with_label("Cancel"); SetStyleRecursively(But,Style3);
gtk_widget_set_usize(GTK_WIDGET(But),100,25);
gtk_box_pack_start(GTK_BOX(HBox),But,TRUE,FALSE,5);
gtk_signal_connect(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(CancelCallBack),GTK_OBJECT(Win));
 
gtk_widget_show_all(Win);
gtk_style_unref(Style1); gtk_style_unref(Style2); gtk_style_unref(Style3);
}
예제 #18
0
파일: wheelbarrow.c 프로젝트: dimkr/gtk
int main (int argc,
          char *argv[] )
{
    /* GtkWidget is the storage type for widgets */
    GtkWidget *window, *pixmap, *fixed;
    GdkPixmap *gdk_pixmap;
    GdkBitmap *mask;
    GtkStyle *style;
    GdkGC *gc;
    
    /* Create the main window, and attach delete_event signal to terminate
     * the application.  Note that the main window will not have a titlebar
     * since we're making it a popup. */
    gtk_init (&argc, &argv);
    window = gtk_window_new( GTK_WINDOW_POPUP );
    gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                        GTK_SIGNAL_FUNC (close_application), NULL);
    gtk_widget_show (window);

    /* Now for the pixmap and the pixmap widget */
    style = gtk_widget_get_default_style();
    gc = style->black_gc;
    gdk_pixmap = gdk_pixmap_create_from_xpm_d( window->window, &mask,
                                             &style->bg[GTK_STATE_NORMAL],
                                             WheelbarrowFull_xpm );
    pixmap = gtk_pixmap_new( gdk_pixmap, mask );
    gtk_widget_show( pixmap );

    /* To display the pixmap, we use a fixed widget to place the pixmap */
    fixed = gtk_fixed_new();
    gtk_widget_set_usize( fixed, 200, 200 );
    gtk_fixed_put( GTK_FIXED(fixed), pixmap, 0, 0 );
    gtk_container_add( GTK_CONTAINER(window), fixed );
    gtk_widget_show( fixed );

    /* This masks out everything except for the image itself */
    gtk_widget_shape_combine_mask( window, mask, 0, 0 );
    
    /* show the window */
    gtk_widget_set_uposition( window, 20, 400 );
    gtk_widget_show( window );
    gtk_main ();
          
    return(0);
}
예제 #19
0
/*! \brief Creates a library dialog.
 *  \par Function Description
 *  This function create the library dialog if it is not already created.
 *  It does not show the dialog, use ghid_library_window_show for that.
 *
 */
void
ghid_library_window_create (GHidPort * out)
{
  GtkWidget *current_tab, *entry_filter;
  GtkNotebook *notebook;

  if (library_window)
    return;

  library_window = (GtkWidget *)g_object_new (GHID_TYPE_LIBRARY_WINDOW, NULL);

  g_signal_connect (library_window,
                    "response",
                    G_CALLBACK (library_window_callback_response), NULL);
  g_signal_connect (G_OBJECT (library_window), "configure_event",
                    G_CALLBACK (library_window_configure_event_cb), NULL);
  gtk_window_set_default_size (GTK_WINDOW (library_window),
                               ghidgui->library_window_width,
                               ghidgui->library_window_height);

  gtk_window_set_title (GTK_WINDOW (library_window), _("PCB Library"));
  gtk_window_set_wmclass (GTK_WINDOW (library_window), "PCB_Library",
                          "PCB");

  gtk_widget_realize (library_window);
  if (Settings.AutoPlace)
    gtk_widget_set_uposition (GTK_WIDGET (library_window), 10, 10);

  gtk_editable_select_region (GTK_EDITABLE
			      (GHID_LIBRARY_WINDOW (library_window)->
			       entry_filter), 0, -1);

  /* Set the focus to the filter entry only if it is in the current
     displayed tab */
  notebook = GTK_NOTEBOOK (GHID_LIBRARY_WINDOW (library_window)->viewtabs);
  current_tab = gtk_notebook_get_nth_page (notebook,
					   gtk_notebook_get_current_page
					   (notebook));
  entry_filter =
    GTK_WIDGET (GHID_LIBRARY_WINDOW (library_window)->entry_filter);
  if (gtk_widget_is_ancestor (entry_filter, current_tab))
    {
      gtk_widget_grab_focus (entry_filter);
    }
}
예제 #20
0
/*---------------------------------------------------------------------------------------------------------------------*/
void Attention(gint XPos,gchar *Messg)          //Displays message in a modal window. XPos=horiz. shift wrt screen centre
{
GtkWidget *Win,*Label,*But,*HBox;

Win=gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(Win),"Attention");
gtk_container_set_border_width(GTK_CONTAINER(Win),10);
gtk_widget_set_uposition(GTK_WIDGET(Win),415+XPos,280);
g_signal_connect_swapped(Win,"delete_event",G_CALLBACK(gtk_widget_destroy),Win);

HBox=gtk_hbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(Win)->vbox),HBox);

But=gtk_button_new_with_label("Information"); gtk_box_pack_start(GTK_BOX(HBox),But,TRUE,FALSE,5);
Label=gtk_label_new(Messg); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->vbox),Label,TRUE,FALSE,5);
But=gtk_button_new_with_label("Ok");
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->action_area),But,TRUE,FALSE,0);
gtk_signal_connect_object(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
gtk_widget_show_all(Win); 
}
예제 #21
0
파일: gtk.c 프로젝트: Centuriondan/xlennart
static void
gtk_ui_popup_dialog(int index) {
	GtkWidget *popup;
	int tx, ty, tw, th;
	int px, py, pw, ph;

	popup = dialogs[index];

	gdk_window_get_origin(toplevel->window, &tx, &ty);
	gdk_window_get_size(toplevel->window, &tw, &th);
	gdk_window_get_size(popup->window, &pw, &ph);
	px = tx + (tw - pw) / 2;
	py = ty + (th - ph) / 2;
	gtk_window_set_position(GTK_WINDOW(popup), GTK_WIN_POS_NONE);
	gtk_widget_set_uposition(popup, px, py);
	gtk_widget_show_all(popup);
	gtk_main();
}
예제 #22
0
bool wxTopLevelWindowGTK::Show( bool show )
{
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );

    if (show && !m_sizeSet)
    {
        /* by calling GtkOnSize here, we don't have to call
           either after showing the frame, which would entail
           much ugly flicker or from within the size_allocate
           handler, because GTK 1.1.X forbids that. */

        GtkOnSize( m_x, m_y, m_width, m_height );
    }

    if (show)
        gtk_widget_set_uposition( m_widget, m_x, m_y );

    return wxWindow::Show( show );
}
예제 #23
0
void e_canvas_popup_tooltip (ECanvas *canvas, GtkWidget *widget, int x, int y)
{
	if (canvas->tooltip_window && canvas->tooltip_window != widget) {
		e_canvas_hide_tooltip(canvas);
	}
	canvas->tooltip_window = widget;
	canvas->visibility_first = TRUE;
	if (canvas->toplevel == NULL) {
		canvas->toplevel = gtk_widget_get_toplevel (GTK_WIDGET(canvas));
		if (canvas->toplevel) {
			gtk_widget_add_events(canvas->toplevel, GDK_VISIBILITY_NOTIFY_MASK);
			g_object_ref (canvas->toplevel);
			canvas->visibility_notify_id =
				g_signal_connect (canvas->toplevel, "visibility_notify_event",
						  G_CALLBACK (e_canvas_visibility), canvas);
		}
	}
	gtk_widget_set_uposition (widget, x, y);
	gtk_widget_show (widget);
}
예제 #24
0
void ZJ_TabView_set_tab_pos(TABVIEW* tabview,TabviewPositionType  pos)
{
	GList* tmplist = NULL;
	int len = 0;
	int tabview_w,tabview_h;
	tabview->pos = pos;
	tmplist = tabview->fistlist;
	//gtk_fixed_set_has_window((GtkFixed *)(tabview->PageFixed),1);
	gtk_widget_get_size_request(tabview->TabViewFixed,&tabview_w,&tabview_h);
	//tabview_w = tabview->width;
	//tabview_h = tabview->height;
	tabview->pos = pos;
	while(tmplist->data)
	{
		switch(tabview->pos)
		{
		case TV_POS_TOP:
			gtk_widget_set_uposition((GtkWidget *)(((PAGE*)(tmplist->data))->tab_EventBox),len*DEFAULT_EVENTBOX_W,0);
			gtk_widget_set_uposition((GtkWidget *)(((PAGE*)(tmplist->data))->child),0,DEFAULT_EVENTBOX_H);
			break;
		case TV_POS_BOTTOM:
			gtk_widget_set_uposition((GtkWidget *)(((PAGE*)(tmplist->data))->tab_EventBox),len*DEFAULT_EVENTBOX_W,tabview_h-DEFAULT_EVENTBOX_H);
			gtk_widget_set_uposition((GtkWidget *)(((PAGE*)(tmplist->data))->child),0,0);
			break;
		case TV_POS_LEFT:
			gtk_widget_set_uposition((GtkWidget *)(((PAGE*)(tmplist->data))->tab_EventBox),0,len*DEFAULT_EVENTBOX_H);
			gtk_widget_set_uposition((GtkWidget *)(((PAGE*)(tmplist->data))->child),DEFAULT_EVENTBOX_W,0);
			break;
		case TV_POS_RIGHT:
			gtk_widget_set_uposition((GtkWidget *)(((PAGE*)(tmplist->data))->tab_EventBox),tabview_w-DEFAULT_EVENTBOX_W,len*DEFAULT_EVENTBOX_H);
			gtk_widget_set_uposition((GtkWidget *)(((PAGE*)(tmplist->data))->child),0,0);
			break;
		}
		tmplist = tmplist->next;
		len++;
	}
}
예제 #25
0
G_MODULE_EXPORT void theme_init(GTypeModule *module)
{
   /* prevent unloading of this theme: */
   g_type_module_use(module);

   metatheme_toolkit_init(&metatheme_toolkit);

   metatheme_rc_style_register_type (module);
   metatheme_style_register_type (module);

   gdk_event_handler_set(_event_handler, 0, NULL);

   mt_default_engine = NULL;
   mt_first_engine = mt_get_engine();

   /* create window for retrieving messages: */

   comm_window = gtk_window_new(GTK_WINDOW_POPUP);
   gtk_window_set_default_size(GTK_WINDOW(comm_window), 0, 0);
   gtk_widget_set_uposition(comm_window, 32000, 32000);
   gtk_widget_show(comm_window);
}
예제 #26
0
/*
 Creates the main window, setting size and position
*/
static void
libgadget_sidebar_create_sidebar (sidebar_core_s *core)
{
	/* Create a new window and set all its proprieties */
	core->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW(core->window), core->width, core->height);
	gtk_widget_set_uposition (GTK_WIDGET(core->window), (core->width_desktop - core->width), 0);
	
	/* Set widget's name */
	gtk_widget_set_name (core->window, "main_window");
	
	gtk_window_set_resizable (GTK_WINDOW(core->window), FALSE);
	gtk_widget_set_app_paintable (core->window, TRUE);
	gtk_window_set_decorated (GTK_WINDOW(core->window), FALSE);
	on_alpha_screen_changed (core->window, NULL, NULL);
	
	gtk_window_stick (GTK_WINDOW(core->window));
	gtk_window_set_keep_below (GTK_WINDOW(core->window), TRUE);
	gtk_window_set_modal (GTK_WINDOW(core->window), FALSE);
	gtk_window_set_type_hint (GTK_WINDOW(core->window), GDK_WINDOW_TYPE_HINT_DOCK);

}
예제 #27
0
파일: ex8.c 프로젝트: Eddyding/GTK-2.0
int 
main(int argc,char *argv[])
{

	gtk_init(&argc,&argv);// 初始化图形显示环境。

	// 窗口
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(window),
						g_locale_to_utf8("Button",-1,NULL,NULL,NULL)
						);

	// width & height
	gtk_widget_set_usize(window,250,150);
	// x & y
	gtk_widget_set_uposition(window,300,300);

	// 按钮
	button = gtk_button_new_with_label(
				g_locale_to_utf8("You have Clicked 0 times",-1,NULL,NULL,NULL));


	gtk_container_add(GTK_CONTAINER(window),button);

	// 显示窗口中的所有元件
	gtk_widget_show_all(window);

	//直接引用g_signal_connect宏,退出
    g_signal_connect(G_OBJECT(window),"delete_event"
            ,G_CALLBACK(gtk_main_quit),NULL);
	
  	g_signal_connect(G_OBJECT(button),"clicked"
            ,G_CALLBACK(on_clicked),NULL);
	// 消息主循环
	gtk_main();
	return 0;
}
예제 #28
0
void CUIHandler::ShowMainWindow()
{
    gtk_widget_set_uposition(mainWindow, mainWndPosX, mainWndPosY);
    gtk_widget_show_all(mainWindow);
    gtk_window_present(GTK_WINDOW(mainWindow));
}
예제 #29
0
/*-----------------------------------------------------------------------------------------------------------------------*/
int main(int argc,char *argv[])
{
GtkWidget *Win,*VBox,*VBox2,*HBox,*MenuBox,*MenuBar,*But;
gint i;
static GdkColor White = {0,0xFFFF,0xFFFF,0xFFFF};
static GdkColor Red   = {0,0xFFFF,0x0000,0x0000};
static GdkColor Blue  = {0,0x0000,0x0000,0xFFFF};
GtkStyle *RedStyle,*BlueStyle;

g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter();

gtk_init(&argc,&argv); 
AcqOn=FALSE; strcpy(SetupFName,""); StnNo=1; NScalers=4;
for (i=0;i<4;++i) SubA[i]=i;
Interval[0]=1; Interval[1]=5; Interval[2]=60;
Duration[0]=10; Duration[1]=60;

RedStyle=gtk_style_copy(gtk_widget_get_default_style());
for (i=0;i<5;i++) { RedStyle->fg[i]=RedStyle->text[i]=Red; RedStyle->bg[i]=White; }
BlueStyle=gtk_style_copy(gtk_widget_get_default_style());
for (i=0;i<5;i++) { BlueStyle->fg[i]=BlueStyle->text[i]=Blue; BlueStyle->bg[i]=White; }

Win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(Win),"delete_event",GTK_SIGNAL_FUNC(DeleteMain),NULL);
gtk_signal_connect(GTK_OBJECT(Win),"destroy",GTK_SIGNAL_FUNC(DestroyMain),NULL);
gtk_window_set_title(GTK_WINDOW(Win),"SCALER (07 Aug 2009)");
gtk_widget_set_uposition(GTK_WIDGET(Win),100,50);
gtk_widget_set_usize(GTK_WIDGET(Win),845,600);

VBox=gtk_vbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(Win),VBox);
MenuBox=gtk_vbox_new(FALSE,1);
gtk_box_pack_start(GTK_BOX(VBox),MenuBox,FALSE,FALSE,0);

GetMainMenu(Win,&MenuBar); 
gtk_box_pack_start(GTK_BOX(MenuBox),MenuBar,FALSE,TRUE,0); 

VBox2=gtk_vbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(VBox),VBox2,FALSE,FALSE,0);
gtk_container_set_border_width(GTK_CONTAINER(VBox2),10);
HBox=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(VBox2),HBox,FALSE,FALSE,0);
S_Start=gtk_label_new("Start:\n"); gtk_box_pack_start(GTK_BOX(HBox),S_Start,FALSE,FALSE,0);
HBox=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(VBox2),HBox,FALSE,FALSE,0);
S_Stop=gtk_label_new("Stop:\n"); gtk_box_pack_start(GTK_BOX(HBox),S_Stop,FALSE,FALSE,0);

HBox=gtk_hbox_new(FALSE,0); gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,0);
But=gtk_button_new_with_label("Elapsed"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,0);
gtk_widget_set_usize(But,56,24);

But=gtk_button_new_with_label("Scaler1"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,40);
gtk_widget_set_usize(But,50,24);

But=gtk_button_new_with_label("Rate1"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,-20);
gtk_widget_set_usize(But,50,24);

But=gtk_button_new_with_label("Scaler2"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,70);
gtk_widget_set_usize(But,50,24);

But=gtk_button_new_with_label("Rate2"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,-50);
gtk_widget_set_usize(But,50,24);

But=gtk_button_new_with_label("Scaler3"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,100);
gtk_widget_set_usize(But,50,24);

But=gtk_button_new_with_label("Rate3"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,-80);
gtk_widget_set_usize(But,50,24);

But=gtk_button_new_with_label("Scaler4"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,135);
gtk_widget_set_usize(But,50,24);

But=gtk_button_new_with_label("Rate4"); SetStyleRecursively(But,BlueStyle);
gtk_box_pack_start(GTK_BOX(HBox),But,FALSE,FALSE,-120);
gtk_widget_set_usize(But,50,24);
 
S_Output=gtk_text_new(NULL,NULL); gtk_widget_set_usize(GTK_WIDGET(S_Output),0,430);
SetStyleRecursively(S_Output,RedStyle);
gtk_box_pack_start(GTK_BOX(VBox),S_Output,FALSE,FALSE,0);
gtk_text_set_word_wrap(GTK_TEXT(S_Output),TRUE); gtk_text_set_editable(GTK_TEXT(S_Output),FALSE);

gtk_widget_show_all(Win);

//gdk_threads_enter(); 
gtk_main(); gdk_threads_leave();
gtk_style_unref(RedStyle); gtk_style_unref(BlueStyle);
return(0);
}
예제 #30
0
파일: gtkhelp.c 프로젝트: sharkcz/xtrkcad
void wControlSetBalloon( wControl_p b, wPos_t dx, wPos_t dy, const char * msg )
{
	PangoLayout * layout;
	wPos_t x, y;
	wPos_t w, h;
	wPos_t xx, yy;
	const char * msgConverted;	
	if (balloonVisible && balloonB == b &&
		balloonDx == dx && balloonDy == dy && balloonMsg == msg )
		return;

	if ( msg == NULL ) {
		if ( balloonF != NULL ) {
			gtk_widget_hide( balloonF );
			balloonVisible = FALSE;
		}
		balloonMsg = "";
		return;
	}
	msgConverted = gtkConvertInput(msg);
	if ( balloonF == NULL ) {
		balloonF = gtk_window_new( GTK_WINDOW_POPUP );
		gtk_window_set_policy( GTK_WINDOW (balloonF), FALSE, FALSE, TRUE );
		gtk_widget_realize( balloonF );
		balloonPI = gtk_label_new(msgConverted);
		gtk_container_add( GTK_CONTAINER(balloonF), balloonPI );
		gtk_container_border_width( GTK_CONTAINER(balloonF), 1 );
		gtk_widget_show( balloonPI );
	} else {
		gtk_label_set( GTK_LABEL(balloonPI), msgConverted );
	}
	balloonDx = dx;
	balloonDy = dy;
	balloonB = b;
	balloonMsg = msg;
	gtk_widget_hide( balloonF );
    layout = gtk_widget_create_pango_layout( balloonPI, msgConverted );
    pango_layout_get_pixel_size( layout, &w, &h );
	g_object_unref(G_OBJECT(layout));
	h = 16;
	gdk_window_get_position( GTK_WIDGET(b->parent->gtkwin)->window, &x, &y );
	gdk_window_get_origin( GTK_WIDGET(b->parent->gtkwin)->window, &x, &y );
	x += b->realX + dx;
	y += b->realY + b->h - dy;
	xx = gdk_screen_width();
	yy = gdk_screen_height();
	if ( x < 0 ) {
		x = 0;
	} else if ( x+w > xx ) {
		x = xx - w;
	}
	if ( y < 0 ) {
		y = 0;
	} else if ( y+h > yy ) {
		y = yy - h ;
	}
	gtk_widget_set_usize( balloonPI, w, h );
	gtk_widget_set_usize( balloonF, w+2, h+2 );
	gtk_widget_show( balloonF );
	gtk_widget_set_uposition( balloonF, x, y );
	/*gtk_widget_popup( balloonF, x, y );*/
	gdk_draw_rectangle( balloonF->window, balloonF->style->fg_gc[GTK_STATE_NORMAL], FALSE, 0, 0, w+1, h+1 );
	gtk_widget_queue_resize( GTK_WIDGET(balloonF) );
	/*gtk_widget_set_uposition( balloonF, x, y );*/
	balloonVisible = TRUE;
}