Example #1
0
void make_cancel_button(GtkWidget *fixed_base)
{
	GtkWidget *fixed;
	GtkWidget *event_box;
	GtkWidget *label;

	fixed = fixed_base;

	label = gtk_label_new(cancel_text);
	gtk_widget_set_size_request(label, cancel_label_width, cancel_label_height);
	gtk_widget_show(label);

	GdkColor white = {0, 65535, 65535, 65535};
	GtkRcStyle *rc_style = gtk_rc_style_new ();
	rc_style->fg[GTK_STATE_NORMAL] = white;
	rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;
	gtk_widget_modify_style(label, rc_style);
	gtk_rc_style_unref(rc_style);

	event_box = gtk_event_box_new();
	gtk_container_add(GTK_CONTAINER(event_box), label);
	gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box), FALSE);
	gtk_widget_show(event_box);
	g_signal_connect(G_OBJECT(event_box), "enter_notify_event",
						G_CALLBACK(cancel_enter), NULL);
	g_signal_connect(G_OBJECT(event_box), "leave_notify_event",
						G_CALLBACK(cancel_leave), NULL);
	g_signal_connect(G_OBJECT(event_box), "button_press_event",
						G_CALLBACK(cancel_press), NULL);

	gtk_widget_show(event_box);
	gtk_fixed_put(GTK_FIXED(fixed), event_box, cancel_label_pos_x, cancel_label_pos_y);
}
Example #2
0
/* Create a new tab. */
LXTab * lxterminal_tab_label_new(const gchar * str)
{
    /* Allocate LXTab structure. */
    LXTab * tab = g_slice_new0(LXTab);

    /* Create a horizontal box as the toplevel. */
    tab->main = gtk_hbox_new(FALSE, 4);

    /* Create the Close button. */
    tab->close_btn = gtk_button_new();
    gtk_button_set_relief(GTK_BUTTON(tab->close_btn), GTK_RELIEF_NONE);
    gtk_button_set_focus_on_click(GTK_BUTTON(tab->close_btn), FALSE);
    gtk_container_add(GTK_CONTAINER(tab->close_btn), gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU));

    /* Make the button as small as possible. */
    GtkRcStyle * rcstyle = gtk_rc_style_new();
    rcstyle->xthickness = rcstyle->ythickness = 0;
    gtk_widget_modify_style(tab->close_btn, rcstyle);
    gtk_rc_style_unref(rcstyle),

    /* Create the label. */
    tab->label = gtk_label_new(str);
    gtk_widget_set_size_request(GTK_WIDGET(tab->label), 100, -1);
    gtk_label_set_ellipsize(GTK_LABEL(tab->label), PANGO_ELLIPSIZE_END);
    gtk_misc_set_alignment(GTK_MISC(tab->label), 0.0, 0.5);
    gtk_misc_set_padding(GTK_MISC(tab->label), 0, 0);

    /* Pack everything, show the widget and return. */
    gtk_box_pack_start(GTK_BOX(tab->main), tab->label, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(tab->main), tab->close_btn, FALSE, FALSE, 0);
    gtk_widget_show_all(tab->main);
    return tab;
}
Example #3
0
/* AW: I pulled this code off the interwebs. It makes background 
 * transparency actually work */
void change_bg(PanelApplet *applet, PanelAppletBackgroundType type,
               GdkColor *color, GdkPixmap *pixmap)
{
  GtkRcStyle *rc_style;
  GtkStyle *style;

  /* reset style */
  gtk_widget_set_style(GTK_WIDGET(applet), NULL);
  rc_style = gtk_rc_style_new();
  gtk_widget_modify_style(GTK_WIDGET(applet), rc_style);
  gtk_rc_style_unref(rc_style);

  switch(type) {
    case PANEL_NO_BACKGROUND:
      break;
    case PANEL_COLOR_BACKGROUND:
      gtk_widget_modify_bg(GTK_WIDGET(applet), GTK_STATE_NORMAL, color);
      break;
    case PANEL_PIXMAP_BACKGROUND:
      style = gtk_style_copy(GTK_WIDGET(applet)->style);

      if(style->bg_pixmap[GTK_STATE_NORMAL])
        g_object_unref(style->bg_pixmap[GTK_STATE_NORMAL]);

      style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref(pixmap);
      gtk_widget_set_style(GTK_WIDGET(applet), style);
      g_object_unref(style);
      break;
  }
}
Example #4
0
/*----------------------------------------------------------------------------------------------------------------------*/
void SetColourD1(gint Index,gchar *ColourStr)                                                //Set colours for 1d plots
{
GdkColor Colour;

gdk_color_parse(ColourStr,&Colour);
if (D1Colour[Index] != NULL) gtk_rc_style_unref(D1Colour[Index]);
D1Colour[Index]=gtk_rc_style_new();
D1Colour[Index]->fg[GTK_STATE_NORMAL]=Colour;
D1Colour[Index]->color_flags[GTK_STATE_NORMAL]|=GTK_RC_FG;
}
Example #5
0
/*----------------------------------------------------------------------------------------------------------------------*/
void SetColourMB(gint Index,gchar *ColourStr)                                      //Set colours for multiple banana gates
{
GdkColor Colour;

gdk_color_parse(ColourStr,&Colour);
if (MBColour[Index] != NULL) gtk_rc_style_unref(MBColour[Index]);
MBColour[Index]=gtk_rc_style_new();
MBColour[Index]->fg[GTK_STATE_NORMAL]=Colour;
MBColour[Index]->color_flags[GTK_STATE_NORMAL]|=GTK_RC_FG;
}
Example #6
0
int wxComboBox::DoAppend( const wxString &item )
{
    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );

#ifdef __WXGTK24__
    if (!gtk_check_version(2,4,0))
    {
        GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
        gtk_combo_box_append_text( combobox,  wxGTK_CONV( item ) );
    }
    else
#endif
    {
        DisableEvents();

        GtkWidget *list = GTK_COMBO(m_widget)->list;
        GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) );

        gtk_container_add( GTK_CONTAINER(list), list_item );

        if (GTK_WIDGET_REALIZED(m_widget))
        {
            gtk_widget_realize( list_item );
            gtk_widget_realize( GTK_BIN(list_item)->child );
        }

        // Apply current widget style to the new list_item
        GtkRcStyle *style = CreateWidgetStyle();
        if (style)
        {
            gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
            GtkBin *bin = GTK_BIN( list_item );
            GtkWidget *label = GTK_WIDGET( bin->child );
            gtk_widget_modify_style( label, style );
            gtk_rc_style_unref( style );
        }

        gtk_widget_show( list_item );

        EnableEvents();
    }

    const unsigned int count = GetCount();

    if ( m_clientDataList.GetCount() < count )
        m_clientDataList.Append( (wxObject*) NULL );
    if ( m_clientObjectList.GetCount() < count )
        m_clientObjectList.Append( (wxObject*) NULL );

    InvalidateBestSize();

    return count - 1;
}
Example #7
0
void Color_Widget(char *colorstring, GtkWidget * widget)
{
  GtkRcStyle *rc_style;
  GdkColor color;

  gdk_color_parse (colorstring, &color);


  rc_style = gtk_rc_style_new ();
  /* Set foreground (fg) color in normal state to red */
  rc_style->fg[GTK_STATE_NORMAL] = color;
  rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;

  gtk_widget_modify_style (widget, rc_style);
  gtk_rc_style_unref (rc_style);
}
Example #8
0
static void set_bg(GtkWidget * widget, gpointer data)
  {
  GtkRcStyle *rc_style;

  rc_style = gtk_rc_style_new ();
  rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_BASE;
#if 1
  rc_style->base[GTK_STATE_NORMAL].red =   widget->style->bg[GTK_STATE_NORMAL].red;
  rc_style->base[GTK_STATE_NORMAL].green = widget->style->bg[GTK_STATE_NORMAL].green;
  rc_style->base[GTK_STATE_NORMAL].blue =  widget->style->bg[GTK_STATE_NORMAL].blue;
  rc_style->base[GTK_STATE_NORMAL].pixel = widget->style->bg[GTK_STATE_NORMAL].pixel;
#endif
  gtk_widget_modify_style(widget, rc_style);
#if GTK_MINOR_VERSION >= 12
  g_object_unref (rc_style);
#else
  gtk_rc_style_unref (rc_style);
#endif
  }
Example #9
0
int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
                              unsigned int pos,
                              void **clientData,
                              wxClientDataType type)
{
    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );

    DisableEvents();

    GtkWidget *list = GTK_COMBO(m_widget)->list;

    GtkRcStyle *style = CreateWidgetStyle();

    const unsigned int count = items.GetCount();
    for( unsigned int i = 0; i < count; ++i, ++pos )
    {
        GtkWidget *
            list_item = gtk_list_item_new_with_label( wxGTK_CONV( items[i] ) );

        if ( pos == GetCount() )
        {
            gtk_container_add( GTK_CONTAINER(list), list_item );
        }
        else // insert, not append
        {
            GList *gitem_list = g_list_alloc ();
            gitem_list->data = list_item;
            gtk_list_insert_items( GTK_LIST (list), gitem_list, pos );
        }

        if (GTK_WIDGET_REALIZED(m_widget))
        {
            gtk_widget_realize( list_item );
            gtk_widget_realize( GTK_BIN(list_item)->child );

            if (style)
            {
                gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
                GtkBin *bin = GTK_BIN( list_item );
                GtkWidget *label = GTK_WIDGET( bin->child );
                gtk_widget_modify_style( label, style );
            }

        }

        gtk_widget_show( list_item );

        if ( m_clientDataList.GetCount() < GetCount() )
            m_clientDataList.Insert( pos, NULL );
        if ( m_clientObjectList.GetCount() < GetCount() )
            m_clientObjectList.Insert( pos, NULL );

        AssignNewItemClientData(pos, clientData, i, type);
    }

    if ( style )
        gtk_rc_style_unref( style );

    EnableEvents();

    InvalidateBestSize();

    return pos - 1;
}
Example #10
0
void wxListBox::GtkAddItem( const wxString &item, int pos )
{
    wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );

    GtkWidget *list_item;

    wxString label(item);
#if wxUSE_CHECKLISTBOX
    if (m_hasCheckBoxes)
    {
        label.Prepend(wxCHECKLBOX_STRING);
    }
#endif // wxUSE_CHECKLISTBOX

    list_item = gtk_list_item_new_with_label( wxGTK_CONV( label ) );

    GList *gitem_list = g_list_alloc ();
    gitem_list->data = list_item;

    if (pos == -1)
        gtk_list_append_items( GTK_LIST (m_list), gitem_list );
    else
        gtk_list_insert_items( GTK_LIST (m_list), gitem_list, pos );

    gtk_signal_connect_after( GTK_OBJECT(list_item), "select",
      GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );

    if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED))
        gtk_signal_connect_after( GTK_OBJECT(list_item), "deselect",
          GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(list_item),
                        "button_press_event",
                        (GtkSignalFunc)gtk_listbox_button_press_callback,
                        (gpointer) this );

    gtk_signal_connect_after( GTK_OBJECT(list_item),
                        "button_release_event",
                        (GtkSignalFunc)gtk_listbox_button_release_callback,
                        (gpointer) this );

    gtk_signal_connect( GTK_OBJECT(list_item),
                           "key_press_event",
                           (GtkSignalFunc)gtk_listbox_key_press_callback,
                           (gpointer)this );


    gtk_signal_connect( GTK_OBJECT(list_item), "focus_in_event",
            GTK_SIGNAL_FUNC(gtk_listitem_focus_in_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(list_item), "focus_out_event",
            GTK_SIGNAL_FUNC(gtk_listitem_focus_out_callback), (gpointer)this );

    ConnectWidget( list_item );

    if (GTK_WIDGET_REALIZED(m_widget))
    {
        gtk_widget_show( list_item );

        gtk_widget_realize( list_item );
        gtk_widget_realize( GTK_BIN(list_item)->child );

#if wxUSE_TOOLTIPS
        if (m_tooltip) m_tooltip->Apply( this );
#endif
    }

    // Apply current widget style to the new list_item
    GtkRcStyle *style = CreateWidgetStyle();
    if (style)
    {
        gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
        GtkBin *bin = GTK_BIN( list_item );
        gtk_widget_modify_style( GTK_WIDGET( bin->child ), style );
        gtk_rc_style_unref( style );
    }
}
Example #11
0
bool wxNotebook::InsertPage( size_t position,
                             wxNotebookPage* win,
                             const wxString& text,
                             bool select,
                             int imageId )
{
    wxCHECK_MSG( m_widget != NULL, false, wxT("invalid notebook") );

    wxCHECK_MSG( win->GetParent() == this, false,
               wxT("Can't add a page whose parent is not the notebook!") );

    wxCHECK_MSG( position <= GetPageCount(), false,
                 wxT("invalid page index in wxNotebookPage::InsertPage()") );

    // Hack Alert! (Part II): See above in wxNotebook::AddChildGTK
    // why this has to be done.
    gtk_widget_unparent(win->m_widget);

    if (m_themeEnabled)
        win->SetThemeEnabled(true);

    GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);

    wxGtkNotebookPage* pageData = new wxGtkNotebookPage;

    m_pages.Insert(win, position);
    m_pagesData.Insert(position, pageData);

    // set the label image and text
    // this must be done before adding the page, as GetPageText
    // and GetPageImage will otherwise return wrong values in
    // the page-changed event that results from inserting the
    // first page.
    pageData->m_imageIndex = imageId;

    pageData->m_box = gtk_hbox_new(false, 1);
    gtk_container_set_border_width(GTK_CONTAINER(pageData->m_box), 2);

    pageData->m_image = NULL;
    if (imageId != -1)
    {
        if (m_imageList)
        {
            const wxBitmap* bitmap = m_imageList->GetBitmapPtr(imageId);
            pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf());
            gtk_box_pack_start(GTK_BOX(pageData->m_box),
                pageData->m_image, false, false, m_padding);
        }
        else
            wxFAIL_MSG("invalid notebook imagelist");
    }

    /* set the label text */
    pageData->m_label = gtk_label_new(wxGTK_CONV(wxStripMenuCodes(text)));
    gtk_box_pack_end(GTK_BOX(pageData->m_box),
        pageData->m_label, false, false, m_padding);

    gtk_widget_show_all(pageData->m_box);
    gtk_notebook_insert_page(notebook, win->m_widget, pageData->m_box, position);

    /* apply current style */
    GtkRcStyle *style = GTKCreateWidgetStyle();
    if ( style )
    {
        gtk_widget_modify_style(pageData->m_label, style);
        gtk_rc_style_unref(style);
    }

    if (select && GetPageCount() > 1)
    {
        SetSelection( position );
    }

    InvalidateBestSize();
    return true;
}
Example #12
0
bool wxNotebook::InsertPage( size_t position,
                             wxNotebookPage* win,
                             const wxString& text,
                             bool select,
                             int imageId )
{
    wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") );

    wxCHECK_MSG( win->GetParent() == this, FALSE,
               wxT("Can't add a page whose parent is not the notebook!") );

    wxCHECK_MSG( position <= GetPageCount(), FALSE,
                 wxT("invalid page index in wxNotebookPage::InsertPage()") );

    // Hack Alert! (Part II): See above in wxInsertChildInNotebook callback
    // why this has to be done.  NOTE: using gtk_widget_unparent here does not
    // work as it seems to undo too much and will cause errors in the
    // gtk_notebook_insert_page below, so instead just clear the parent by
    // hand here.
    win->m_widget->parent = NULL;

    // don't receive switch page during addition
    gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
      GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this );

    if (m_themeEnabled)
        win->SetThemeEnabled(true);

    GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);

    wxGtkNotebookPage *nb_page = new wxGtkNotebookPage();

    if ( position == GetPageCount() )
        m_pagesData.Append( nb_page );
    else
        m_pagesData.Insert( position, nb_page );

    m_pages.Insert(win, position);

    nb_page->m_box = gtk_hbox_new( FALSE, 1 );
    gtk_container_border_width( GTK_CONTAINER(nb_page->m_box), 2 );

    gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate",
      GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win );

    gtk_notebook_insert_page( notebook, win->m_widget, nb_page->m_box, position );

    nb_page->m_page = (GtkNotebookPage*) g_list_last(notebook->children)->data;

    /* set the label image */
    nb_page->m_image = imageId;

    if (imageId != -1)
    {
        wxASSERT( m_imageList != NULL );

        const wxBitmap *bmp = m_imageList->GetBitmapPtr(imageId);
        GdkPixmap *pixmap = bmp->GetPixmap();
        GdkBitmap *mask = NULL;
        if ( bmp->GetMask() )
        {
            mask = bmp->GetMask()->GetBitmap();
        }

        GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask );

        gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, m_padding);

        gtk_widget_show(pixmapwid);
    }

    /* set the label text */

    nb_page->m_text = text;
    if (nb_page->m_text.empty()) nb_page->m_text = wxEmptyString;

    nb_page->m_label = GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page->m_text)) );
    gtk_box_pack_end( GTK_BOX(nb_page->m_box), GTK_WIDGET(nb_page->m_label), FALSE, FALSE, m_padding );

    /* apply current style */
    GtkRcStyle *style = CreateWidgetStyle();
    if ( style )
    {
        gtk_widget_modify_style(GTK_WIDGET(nb_page->m_label), style);
        gtk_rc_style_unref(style);
    }

    /* show the label */
    gtk_widget_show( GTK_WIDGET(nb_page->m_label) );
    if (select && (m_pagesData.GetCount() > 1))
    {
      SetSelection( position );
    }

    gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page",
      GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this );

    InvalidateBestSize();
    return true;
}
Example #13
0
static void configuration_received_callback(bool_t res)
{

	char labels[1024];
	char values[1024];
	int i,nb_values=0;

	gdk_threads_enter();

	PRINT("%s %s\n",__FILE__,__FUNCTION__);

	GtkRcStyle *rc_style1,*rc_style2;
	GdkColor color1,white;

	  color1.red=40000;
	  color1.blue=40000;
	  color1.green=65535;
	  color1.pixel=0;
	  rc_style1=gtk_rc_style_new();
	 // rc_style1->bg[GTK_STATE_NORMAL]=color1;
	  rc_style1->base[GTK_STATE_NORMAL]=color1;
	 // rc_style1->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BG;
	  rc_style1->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BASE;

	  white.red=0xffff;
	  white.blue=0xffff;
	  white.green=0xffff;
	  white.pixel=0;

	  rc_style2=gtk_rc_style_new();
	  //rc_style2->bg[GTK_STATE_NORMAL]=color2;
	  rc_style2->base[GTK_STATE_NORMAL]=white;
	  //rc_style2->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BG;
	  rc_style2->color_flags[GTK_STATE_NORMAL]|=GTK_RC_BASE;


	if (!GTK_IS_WIDGET(ihm_config.config_values_frame)) //{ gtk_widget_destroy(ihm_config.config_values_frame); ihm_config.config_values_frame = NULL; }
	{
		if (ihm_config.config_values!=NULL){	vp_os_free(ihm_config.config_values); ihm_config.config_values = NULL;	}

		ihm_config.config_values_frame = gtk_scrolled_window_new(NULL,NULL);
		gtk_box_pack_start(GTK_BOX(ihm_config.config_frame_vbox),ihm_config.config_values_frame,TRUE, TRUE, 0);
		ihm_config.config_values_hbox  = gtk_hbox_new(FALSE,0);
		ihm_config.config_values_vbox1 = gtk_vbox_new(FALSE,0);
		ihm_config.config_values_vbox2 = gtk_vbox_new(FALSE,0);
		gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW (ihm_config.config_values_frame),ihm_config.config_values_hbox);
		gtk_box_pack_start(GTK_BOX(ihm_config.config_values_hbox),ihm_config.config_values_vbox1,TRUE, TRUE, 0);
		gtk_box_pack_start(GTK_BOX(ihm_config.config_values_hbox),ihm_config.config_values_vbox2,TRUE, TRUE, 0);

		#define DISPLAY(KEY,NAME,C_TYPE,RW)\
			ihm_config.config_values = vp_os_realloc(ihm_config.config_values,(nb_values+1)*sizeof(ihm_config_value_t)); \
			sprintf(labels,"%s:%s",KEY,CFG_STRINGIFY(NAME)); \
			ihm_config.config_values[nb_values].label = gtk_label_new(labels); \
			ihm_config.config_values[nb_values].value = gtk_entry_new(); \
			ihm_config.config_values[nb_values].hbox = gtk_hbox_new(FALSE,0); \
			if ((RW)&K_WRITE) ihm_config.config_values[nb_values].send_button = gtk_button_new_with_label("send"); else ihm_config.config_values[nb_values].send_button=NULL; \
			gtk_box_pack_start(GTK_BOX(ihm_config.config_values_vbox1),ihm_config.config_values[nb_values].label,FALSE, FALSE, ((RW)&K_WRITE)?6:5);\
			gtk_box_pack_start(GTK_BOX(ihm_config.config_values_vbox2),ihm_config.config_values[nb_values].hbox,FALSE, FALSE, 0);\
			gtk_box_pack_start(GTK_BOX(ihm_config.config_values[nb_values].hbox),ihm_config.config_values[nb_values].value,TRUE, TRUE, 0);\
			gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[nb_values].value),rc_style2); \
			if (ihm_config.config_values[nb_values].send_button)\
			{gtk_box_pack_start(GTK_BOX(ihm_config.config_values[nb_values].hbox),ihm_config.config_values[nb_values].send_button,FALSE, FALSE, 0);\
			gtk_signal_connect(GTK_OBJECT(ihm_config.config_values[nb_values].send_button), "clicked", G_CALLBACK(set_configuration_callback), NULL);}\
			nb_values++;

		#undef ARDRONE_CONFIG_KEY_IMM
		#undef ARDRONE_CONFIG_KEY_REF
		#undef ARDRONE_CONFIG_KEY_STR
		#define ARDRONE_CONFIG_KEY_IMM(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) DISPLAY(KEY,NAME,C_TYPE,RW)
		#define ARDRONE_CONFIG_KEY_REF(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) DISPLAY(KEY,NAME,C_TYPE,RW)
		#define ARDRONE_CONFIG_KEY_STR(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) DISPLAY(KEY,NAME,C_TYPE,RW)
		#include <config_keys.h>
	}

	//sprintf(labels,"%s:%s",STRINGIFY(abc),STRINGIFY(def));
	// sprintf(values,PRINTF_KEY(C_TYPE)),get_##NAME());
	//gtk_entry_set_text( GTK_ENTRY(ihm_config.config_values[nb_values].value) , values );


	//sprintf(values,PRINTF_KEY(uint32_t),123);

	i=0;

#define CONFIGURATION_GETTER(x) ardrone_control_config.x

#define ARDRONE_CONFIG_KEY_IMM(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK) \
		if(strcmp("" #INI_TYPE, "INI_FLOAT") == 0)	  { sprintf( values,"%f",(float)CONFIGURATION_GETTER(NAME)); } \
		else if(strcmp("" #INI_TYPE, "INI_INT") == 0) { sprintf( values,"%d",(int)CONFIGURATION_GETTER(NAME)); }  \
		else if(strcmp("" #INI_TYPE, "INI_BOOLEAN") == 0) { sprintf( values,"%s",(CONFIGURATION_GETTER(NAME)) ? "TRUE" : "FALSE"); }	   \
		if (strcmp(gtk_entry_get_text(GTK_ENTRY(ihm_config.config_values[i].value)),values)!=0) 	\
			gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[i].value),rc_style1); \
			else gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[i].value),rc_style2); \
		gtk_entry_set_text( GTK_ENTRY(ihm_config.config_values[i].value) , values );\
		i++;

		//PRINT(" Received parameter <%s:%s> with value <%f>\n",#KEY,#NAME,(float)CONFIGURATION_GETTER(NAME) );

#define ARDRONE_CONFIG_KEY_REF(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK)  \
		i++;

#define ARDRONE_CONFIG_KEY_STR(KEY, NAME, INI_TYPE, C_TYPE, C_TYPE_PTR, RW, DEFAULT, CALLBACK)  \
		if (strcmp(gtk_entry_get_text(GTK_ENTRY(ihm_config.config_values[i].value)),CONFIGURATION_GETTER(NAME))!=0) \
			gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[i].value),rc_style1); \
			else gtk_widget_modify_style(GTK_WIDGET(ihm_config.config_values[i].value),rc_style2); \
		gtk_entry_set_text( GTK_ENTRY(ihm_config.config_values[i].value) , CONFIGURATION_GETTER(NAME) ); i++;

#include <config_keys.h>

	ihm_config.nb_config_values = i;

	gtk_widget_show_all(ihm_config.window);
	gtk_rc_style_unref(rc_style1);
	gtk_rc_style_unref(rc_style2);

	gdk_threads_leave();
}
Example #14
0
bool wxNotebook::InsertPage( size_t position,
                             wxNotebookPage* win,
                             const wxString& text,
                             bool select,
                             int imageId )
{
    wxCHECK_MSG( m_widget != NULL, false, wxT("invalid notebook") );

    wxCHECK_MSG( win->GetParent() == this, false,
               wxT("Can't add a page whose parent is not the notebook!") );

    wxCHECK_MSG( position <= GetPageCount(), false,
                 _T("invalid page index in wxNotebookPage::InsertPage()") );

    // Hack Alert! (Part II): See above in wxInsertChildInNotebook callback
    // why this has to be done.  NOTE: using gtk_widget_unparent here does not
    // work as it seems to undo too much and will cause errors in the
    // gtk_notebook_insert_page below, so instead just clear the parent by
    // hand here.
    win->m_widget->parent = NULL;

    if (m_themeEnabled)
        win->SetThemeEnabled(true);

    GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);

    wxGtkNotebookPage *nb_page = new wxGtkNotebookPage();

    if ( position == GetPageCount() )
        m_pagesData.Append( nb_page );
    else
        m_pagesData.Insert( position, nb_page );

    m_pages.Insert(win, position);

    // set the label image and text
    // this must be done before adding the page, as GetPageText
    // and GetPageImage will otherwise return wrong values in
    // the page-changed event that results from inserting the
    // first page.
    nb_page->m_image = imageId;
    nb_page->m_text = wxStripMenuCodes(text);

    nb_page->m_box = gtk_hbox_new( FALSE, 1 );
    gtk_container_set_border_width((GtkContainer*)nb_page->m_box, 2);

    g_signal_connect (win->m_widget, "size_allocate",
                      G_CALLBACK (gtk_page_size_callback), win);

    gtk_notebook_insert_page(notebook, win->m_widget, nb_page->m_box, position);

    nb_page->m_page = gtk_notebook_get_nth_page(notebook, position);

    if (imageId != -1)
    {
        wxASSERT( m_imageList != NULL );

        const wxBitmap *bmp = m_imageList->GetBitmapPtr(imageId);
        GtkWidget* pixmapwid = gtk_image_new_from_pixbuf(bmp->GetPixbuf());
        gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, m_padding);
        gtk_widget_show(pixmapwid);
    }

    /* set the label text */
    nb_page->m_label = GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page->m_text)) );
    gtk_box_pack_end( GTK_BOX(nb_page->m_box), GTK_WIDGET(nb_page->m_label), FALSE, FALSE, m_padding );

    /* apply current style */
    GtkRcStyle *style = CreateWidgetStyle();
    if ( style )
    {
        gtk_widget_modify_style(GTK_WIDGET(nb_page->m_label), style);
        gtk_rc_style_unref(style);
    }

    /* show the label */
    gtk_widget_show( GTK_WIDGET(nb_page->m_label) );

    if (select && (m_pagesData.GetCount() > 1))
    {
        SetSelection( position );
    }

    InvalidateBestSize();
    return true;
}