コード例 #1
0
ファイル: toplevel.cpp プロジェクト: CobaltBlues/wxWidgets
void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
{
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );

    wxTopLevelWindowBase::SetIcons( icons );

    if ( icons.IsEmpty() )
        return;

    GdkWindow* window = m_widget->window;
    if (!window)
        return;

    wxIcon icon = icons.GetIcon(-1);
    if (icon.IsOk())
    {
        wxMask *mask = icon.GetMask();
        GdkBitmap *bm = NULL;
        if (mask) bm = mask->GetBitmap();

        gdk_window_set_icon( m_widget->window, NULL, icon.GetPixmap(), bm );
    }

    wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ),
                   (WXWindow)GDK_WINDOW_XWINDOW( window ), icons );
}
コード例 #2
0
ファイル: toplevel.cpp プロジェクト: catalinr/wxWidgets
void wxTopLevelWindowQt::SetIcons( const wxIconBundle& icons )
{
    wxTopLevelWindowBase::SetIcons( icons );

    QIcon qtIcons;
    for ( size_t i = 0; i < icons.GetIconCount(); i++ )
    {
        qtIcons.addPixmap( *icons.GetIconByIndex( i ).GetHandle() );
    }
    GetHandle()->setWindowIcon( qtIcons );
}
コード例 #3
0
ファイル: toplevel.cpp プロジェクト: raydtang/wxWidgets
void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons )
{
    base_type::SetIcons(icons);

    // Setting icons before window is realized can cause a GTK assertion if
    // another TLW is realized before this one, and it has this one as its
    // transient parent. The life demo exibits this problem.
    if (m_widget && gtk_widget_get_realized(m_widget))
    {
        GList* list = NULL;
        for (size_t i = icons.GetIconCount(); i--;)
            list = g_list_prepend(list, icons.GetIconByIndex(i).GetPixbuf());
        gtk_window_set_icon_list(GTK_WINDOW(m_widget), list);
        g_list_free(list);
    }
}
コード例 #4
0
ファイル: toplevel.cpp プロジェクト: chromylei/third_party
void wxTopLevelWindowX11::SetIcons(const wxIconBundle& icons )
{
    // this sets m_icon
    wxTopLevelWindowBase::SetIcons( icons );

    DoSetIcon( icons.GetIcon( -1 ) );
    wxSetIconsX11( wxGlobalDisplay(), X11GetMainWindow(), icons );
}
コード例 #5
0
ファイル: WxUtils.cpp プロジェクト: DINKIN/dolphin
wxIconBundle GetDolphinIconBundle()
{
  static wxIconBundle s_bundle;
  if (!s_bundle.IsEmpty())
    return s_bundle;

#ifdef _WIN32

  // Convert the Windows ICO file into a wxIconBundle by tearing it apart into each individual
  // sub-icon using the Win32 API. This is necessary because WX uses its own wxIcons internally
  // which (unlike QIcon in Qt) only contain 1 image per icon, hence why wxIconBundle exists.
  HINSTANCE dolphin = GetModuleHandleW(nullptr);
  for (int size : {16, 32, 48, 256})
  {
    // Extract resource from embedded DolphinWX.rc
    HANDLE win32_icon =
        LoadImageW(dolphin, L"\"DOLPHIN\"", IMAGE_ICON, size, size, LR_CREATEDIBSECTION);
    if (win32_icon && win32_icon != INVALID_HANDLE_VALUE)
    {
      wxIcon icon;
      icon.CreateFromHICON(reinterpret_cast<HICON>(win32_icon));
      s_bundle.AddIcon(icon);
    }
  }

#else

  for (const char* fname : {"Dolphin.png", "dolphin_logo.png", "*****@*****.**"})
  {
    wxImage image{StrToWxStr(File::GetSysDirectory() + RESOURCES_DIR DIR_SEP + fname),
                  wxBITMAP_TYPE_PNG};
    if (image.IsOk())
    {
      wxIcon icon;
      icon.CopyFromBitmap(image);
      s_bundle.AddIcon(icon);
    }
  }

#endif

  return s_bundle;
}
コード例 #6
0
void wxTopLevelWindowQt::SetIcons( const wxIconBundle& icons )
{
    wxTopLevelWindowBase::SetIcons( icons );
    
    QIcon qtIcons;
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( size_t i = 0; i < icons.GetIconCount(); i++ )
    {
        qtIcons.addPixmap( *icons.GetIconByIndex( i ).GetHandle() );
    }
    GetHandle()->setWindowIcon( qtIcons );
}
コード例 #7
0
ファイル: toplevel.cpp プロジェクト: nwhitehead/wxWidgets
void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons)
{
    wxTopLevelWindowBase::SetIcons(icons);

    if ( icons.IsEmpty() )
    {
        // FIXME: SetIcons(wxNullIconBundle) should unset existing icons,
        //        but we currently don't do that
        wxASSERT_MSG( m_icons.IsEmpty(), "unsetting icons doesn't work" );
        return;
    }

    DoSelectAndSetIcon(icons, SM_CXSMICON, SM_CYSMICON, ICON_SMALL);
    DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG);
}
コード例 #8
0
ファイル: toplevel.cpp プロジェクト: nwhitehead/wxWidgets
bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
                                             int smX,
                                             int smY,
                                             int i)
{
    const wxSize size(::GetSystemMetrics(smX), ::GetSystemMetrics(smY));

    wxIcon icon = icons.GetIcon(size, wxIconBundle::FALLBACK_NEAREST_LARGER);

    if ( !icon.IsOk() )
        return false;

    ::SendMessage(GetHwnd(), WM_SETICON, i, (LPARAM)GetHiconOf(icon));
    return true;
}
コード例 #9
0
ファイル: utilsx11.cpp プロジェクト: Zombiebest/Dolphin
void
wxSetIconsX11(WXDisplay* display, WXWindow window, const wxIconBundle& ib)
{
    size_t size = 0;

    const size_t numIcons = ib.GetIconCount();
    for ( size_t i = 0; i < numIcons; ++i )
    {
        const wxIcon icon = ib.GetIconByIndex(i);

        size += 2 + icon.GetWidth() * icon.GetHeight();
    }

    wxMAKE_ATOM(_NET_WM_ICON, (Display*)display);

    if ( size > 0 )
    {
        unsigned long* data = new unsigned long[size];
        unsigned long* ptr = data;

        for ( size_t i = 0; i < numIcons; ++i )
        {
            const wxImage image = ib.GetIconByIndex(i).ConvertToImage();
            int width = image.GetWidth(),
                height = image.GetHeight();
            unsigned char* imageData = image.GetData();
            unsigned char* imageDataEnd = imageData + ( width * height * 3 );
            bool hasMask = image.HasMask();
            unsigned char rMask, gMask, bMask;
            unsigned char r, g, b, a;

            if( hasMask )
            {
                rMask = image.GetMaskRed();
                gMask = image.GetMaskGreen();
                bMask = image.GetMaskBlue();
            }
            else // no mask, but still init the variables to avoid warnings
            {
                rMask =
                gMask =
                bMask = 0;
            }

            *ptr++ = width;
            *ptr++ = height;

            while ( imageData < imageDataEnd )
            {
                r = imageData[0];
                g = imageData[1];
                b = imageData[2];
                if( hasMask && r == rMask && g == gMask && b == bMask )
                    a = 0;
                else
                    a = 255;

                *ptr++ = ( a << 24 ) | ( r << 16 ) | ( g << 8 ) | b;

                imageData += 3;
            }
        }

        XChangeProperty( (Display*)display,
                         WindowCast(window),
                         _NET_WM_ICON,
                         XA_CARDINAL, 32,
                         PropModeReplace,
                         (unsigned char*)data, size );
        delete[] data;
    }
    else
    {
        XDeleteProperty( (Display*)display,
                         WindowCast(window),
                         _NET_WM_ICON );
    }
}
コード例 #10
0
ファイル: tabmdi.cpp プロジェクト: erwincoumans/wxWidgets
void wxAuiMDIChildFrame::SetIcons(const wxIconBundle& icons)
{
    // get icon with the system icon size
    SetIcon(icons.GetIcon(-1));
    m_icon_bundle = icons;
}