本文整理汇总了C++中wxBitmap::GetPixbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ wxBitmap::GetPixbuf方法的具体用法?C++ wxBitmap::GetPixbuf怎么用?C++ wxBitmap::GetPixbuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxBitmap
的用法示例。
在下文中一共展示了wxBitmap::GetPixbuf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPageImage
bool wxNotebook::SetPageImage( size_t page, int image )
{
wxCHECK_MSG(page < GetPageCount(), false, "invalid notebook index");
wxGtkNotebookPage* pageData = GetNotebookPage(page);
if (image >= 0)
{
wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist");
const wxBitmap bitmap = GetImageList()->GetBitmap(image);
if (pageData->m_image)
{
gtk_image_set_from_pixbuf(
GTK_IMAGE(pageData->m_image), bitmap.GetPixbuf());
}
else
{
pageData->m_image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf());
gtk_widget_show(pageData->m_image);
gtk_box_pack_start(GTK_BOX(pageData->m_box),
pageData->m_image, false, false, m_padding);
}
}
else if (pageData->m_image)
{
gtk_widget_destroy(pageData->m_image);
pageData->m_image = NULL;
}
pageData->m_imageIndex = image;
return true;
}
示例2: SetItemBitmap
void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap)
{
if ( bitmap.IsOk() )
{
if ( m_bitmapSize.x < 0 )
{
m_bitmapSize.x = bitmap.GetWidth();
m_bitmapSize.y = bitmap.GetHeight();
}
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
GtkTreeModel *model = gtk_combo_box_get_model( combobox );
GtkTreeIter iter;
if ( gtk_tree_model_iter_nth_child( model, &iter, NULL, n ) )
{
GValue value0 = { 0, };
g_value_init( &value0, G_TYPE_OBJECT );
g_value_set_object( &value0, bitmap.GetPixbuf() );
gtk_list_store_set_value( GTK_LIST_STORE(model), &iter,
m_bitmapCellIndex, &value0 );
g_value_unset( &value0 );
}
}
}
示例3: GTKDoShowBitmap
void wxAnyButton::GTKDoShowBitmap(const wxBitmap& bitmap)
{
wxASSERT_MSG( bitmap.IsOk(), "invalid bitmap" );
GtkWidget *image;
if ( DontShowLabel() )
{
image = gtk_bin_get_child(GTK_BIN(m_widget));
}
else // have both label and bitmap
{
#ifdef __WXGTK26__
if ( !gtk_check_version(2,6,0) )
{
image = gtk_button_get_image(GTK_BUTTON(m_widget));
}
else
#endif // __WXGTK26__
{
// buttons with both label and bitmap are only supported with GTK+
// 2.6 so far
//
// it shouldn't be difficult to implement them ourselves for the
// previous GTK+ versions by stuffing a container with a label and
// an image inside GtkButton but there doesn't seem to be much
// point in doing this for ancient GTK+ versions
return;
}
}
wxCHECK_RET( image && GTK_IS_IMAGE(image), "must have image widget" );
gtk_image_set_from_pixbuf(GTK_IMAGE(image), bitmap.GetPixbuf());
}
示例4: GTKDoShowBitmap
void wxAnyButton::GTKDoShowBitmap(const wxBitmap& bitmap)
{
wxASSERT_MSG( bitmap.IsOk(), "invalid bitmap" );
GtkWidget *image;
if ( DontShowLabel() )
{
image = gtk_bin_get_child(GTK_BIN(m_widget));
}
else // have both label and bitmap
{
image = gtk_button_get_image(GTK_BUTTON(m_widget));
}
wxCHECK_RET( image && GTK_IS_IMAGE(image), "must have image widget" );
gtk_image_set_from_pixbuf(GTK_IMAGE(image), bitmap.GetPixbuf());
}
示例5: InsertPage
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(m_pages.begin() + position, win);
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_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
#ifndef __WXGTK3__
gtk_container_set_border_width(GTK_CONTAINER(pageData->m_box), 2);
#endif
pageData->m_image = NULL;
if (imageId != -1)
{
if (HasImageList())
{
const wxBitmap bitmap = GetImageList()->GetBitmap(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 */
#ifdef __WXGTK3__
GTKApplyStyle(pageData->m_label, NULL);
#else
GtkRcStyle *style = GTKCreateWidgetStyle();
if ( style )
{
gtk_widget_modify_style(pageData->m_label, style);
g_object_unref(style);
}
#endif
if (select && GetPageCount() > 1)
{
SetSelection( position );
}
InvalidateBestSize();
return true;
}