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; }
/* Create a scrolled text area that displays a "message" */ static GtkWidget *create_log_text (GtkWidget **textpnt) { GtkWidget *text; GtkWidget *table; GtkWidget *vscrollbar; /* Create a table to hold the text widget and scrollbars */ table = gtk_table_new (1, 16, FALSE); /* Put a text widget in the upper left hand corner. Note the use of * GTK_SHRINK in the y direction */ #if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN) text = gtk_text_view_new (); gtk_text_buffer_get_start_iter (gtk_text_view_get_buffer(GTK_TEXT_VIEW (text)), &GLOBALS->iter_logfile_c_2); GLOBALS->bold_tag_logfile_c_2 = gtk_text_buffer_create_tag (GTK_TEXT_VIEW (text)->buffer, "bold", "weight", PANGO_WEIGHT_BOLD, NULL); GLOBALS->mono_tag_logfile_c_1 = gtk_text_buffer_create_tag (GTK_TEXT_VIEW (text)->buffer, "monospace", "family", "monospace", NULL); GLOBALS->size_tag_logfile_c_1 = gtk_text_buffer_create_tag (GTK_TEXT_VIEW (text)->buffer, "fsiz", "size", (GLOBALS->use_big_fonts ? 12 : 8) * PANGO_SCALE, NULL); #else text = gtk_text_new (NULL, NULL); #endif *textpnt = text; gtk_table_attach (GTK_TABLE (table), text, 0, 14, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK | GTK_EXPAND, 0, 0); gtk_widget_set_usize(GTK_WIDGET(text), 100, 100); #if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN) gtk_text_view_set_editable(GTK_TEXT_VIEW(text), TRUE); #else gtk_text_set_editable(GTK_TEXT(text), TRUE); #endif gtk_widget_show (text); /* And a VScrollbar in the upper right */ #if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN) { GtkTextViewClass *tc = (GtkTextViewClass*)GTK_OBJECT_GET_CLASS(GTK_OBJECT(text)); tc->set_scroll_adjustments(GTK_TEXT_VIEW (text), NULL, NULL); vscrollbar = gtk_vscrollbar_new (GTK_TEXT_VIEW (text)->vadjustment); } #else vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj); #endif gtk_table_attach (GTK_TABLE (table), vscrollbar, 15, 16, 0, 1, GTK_FILL, GTK_FILL | GTK_SHRINK | GTK_EXPAND, 0, 0); gtk_widget_show (vscrollbar); /* Add a handler to put a message in the text widget when it is realized */ gtk_signal_connect (GTK_OBJECT (text), "realize", GTK_SIGNAL_FUNC (log_realize_text), NULL); gtk_signal_connect(GTK_OBJECT(text), "button_release_event", GTK_SIGNAL_FUNC(button_release_event), NULL); #if defined(WAVE_USE_GTK2) && !defined(GTK_ENABLE_BROKEN) gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_CHAR); #else gtk_text_set_word_wrap(GTK_TEXT(text), FALSE); gtk_text_set_line_wrap(GTK_TEXT(text), TRUE); #endif return(table); }
static void gtk_plot_polar_real_paint (GtkWidget *widget) { GtkPlot *plot; GtkPlotText *child_text; GtkStyle *style; GdkPixmap *pixmap; GList *dataset; GList *text; gint width, height; gint xoffset, yoffset ; gdouble min; if(!gtk_widget_get_visible(widget)) return; plot = GTK_PLOT(widget); xoffset = plot->internal_allocation.x; yoffset = plot->internal_allocation.y; width = plot->internal_allocation.width; height = plot->internal_allocation.height; style = gtk_widget_get_style(widget); pixmap = plot->drawable; gtk_plot_pc_gsave(plot->pc); gtk_plot_pc_set_color(plot->pc, &plot->background); if(!gtk_plot_is_transparent(GTK_PLOT(plot))) gtk_plot_pc_draw_rectangle (plot->pc, TRUE, xoffset, yoffset, width , height); /* draw frame to guide the eyes*/ /* gdk_draw_rectangle (pixmap, gc, FALSE, xoffset, yoffset, width , height); */ /* draw the ticks & grid lines */ min = plot->left->ticks.min; plot->left->ticks.min = 0.0; gtk_plot_axis_ticks_recalc(plot->left); gtk_plot_axis_ticks_recalc(plot->bottom); plot->left->ticks.min = min; if(plot->left->is_visible) { GtkPlotVector tick_direction; tick_direction.x = 1.; tick_direction.y = 0.; plot->left->origin.x = (gfloat)width*plot->left_align; plot->left->origin.y = height; gtk_plot_polar_draw_axis(GTK_PLOT_POLAR(plot), plot->left, tick_direction); gtk_plot_polar_draw_labels(GTK_PLOT_POLAR(plot), plot->left, tick_direction); } if(plot->top->is_visible) { GtkPlotVector tick_direction; tick_direction.x = 0.; tick_direction.y = 1.; plot->left->direction.x = 1; plot->left->direction.y = 0; plot->left->origin.x = 0; plot->left->origin.y = (gfloat)height*plot->left_align; gtk_plot_polar_draw_axis(GTK_PLOT_POLAR(plot), plot->left, tick_direction); gtk_plot_polar_draw_labels(GTK_PLOT_POLAR(plot), plot->left, tick_direction); plot->left->direction.x = 0; plot->left->direction.y = -1; } if(plot->bottom->is_visible) { gtk_plot_polar_draw_circle(GTK_PLOT_POLAR(plot)); } gtk_plot_polar_draw_grids(GTK_PLOT_POLAR(plot)); dataset = plot->data_sets; while(dataset) { GTK_PLOT_DATA_CLASS(GTK_OBJECT_GET_CLASS(GTK_OBJECT(dataset->data)))->draw_data(GTK_PLOT_DATA(dataset->data)); dataset = dataset->next; } text = plot->text; while(text) { child_text = (GtkPlotText *) text->data; gtk_plot_draw_text(plot, *child_text); text = text->next; } GTK_PLOT_CLASS(GTK_OBJECT_GET_CLASS(GTK_OBJECT(plot)))->draw_legends(widget); gtk_plot_pc_grestore(plot->pc); }
void gtk_plot_gdk_set_drawable (GtkPlotGdk *gdk, GdkDrawable *drawable) { GTK_PLOT_GDK_CLASS(GTK_OBJECT_GET_CLASS(GTK_OBJECT(gdk)))->set_drawable(gdk, drawable); }