Пример #1
0
// Operations
bool wxTaskBarIconEx::SetIcon(const wxIcon& icon, const wxString& message)
{
    if (!IsOK())
        return false;

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

    wxBitmap bitmap = icon;

    if (!g_pStatusIcon)
    {
        g_pStatusIcon = gtk_status_icon_new_from_pixbuf(bitmap.GetPixbuf());
        g_signal_connect(g_pStatusIcon, "activate", G_CALLBACK(status_icon_activate), this);
        g_signal_connect(g_pStatusIcon, "popup_menu", G_CALLBACK(status_icon_popup_menu), this);
    }

    gtk_status_icon_set_from_pixbuf(g_pStatusIcon, bitmap.GetPixbuf());
    if (!message.empty())
    {
        gtk_status_icon_set_tooltip(g_pStatusIcon, message.mb_str());
    }
    gtk_status_icon_set_visible(g_pStatusIcon, TRUE);

    return true;
}
Пример #2
0
bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const wxString message, unsigned int timeout, unsigned int iconballoon)
{
    if (!IsOK())
        return false;

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

    memset(&notifyData, 0, sizeof(notifyData));
    notifyData.cbSize           = sizeof(notifyData);
    notifyData.hWnd             = (HWND) m_hWnd;
    notifyData.uID              = 99;
    notifyData.uCallbackMessage = sm_taskbarMsg;
    notifyData.uFlags           = NIF_MESSAGE | NIF_INFO | NIF_TIP | NIF_ICON;
    notifyData.dwInfoFlags      = iconballoon | NIIF_NOSOUND;
    notifyData.uTimeout         = timeout;
    notifyData.uVersion         = NOTIFYICON_VERSION;

    lstrcpyn(notifyData.szInfo, WXSTRINGCAST message, sizeof(notifyData.szInfo));
    lstrcpyn(notifyData.szInfoTitle, WXSTRINGCAST title, sizeof(notifyData.szInfoTitle));
    lstrcpyn(notifyData.szTip, WXSTRINGCAST wxEmptyString, sizeof(notifyData.szTip));
    notifyData.hIcon            = (HICON) icon.GetHICON();

    UpdateIcon();
    return m_iconAdded;
}
Пример #3
0
void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
{
    wxCHECK_RET( Ok(), "invalid dc" );
    wxCHECK_RET( icon.Ok(), "invalid icon" );

    DoDrawBitmap(icon, x, y, true);
}
Пример #4
0
// Set icon
void wxMDIChildFrame::SetIcon(const wxIcon& icon)
{
    m_icons = wxIconBundle( icon );

    if (icon.Ok())
    {
        // Not appropriate since there are no icons in
        // a tabbed window
    }
}
Пример #5
0
void wxGCDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
{
    wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid DC") );
    wxCHECK_RET( icon.Ok(), wxT("wxGCDC(cg)::DoDrawIcon - invalid icon") );

    wxCoord w = icon.GetWidth();
    wxCoord h = icon.GetHeight();

    m_graphicContext->DrawIcon( icon , x, y, w, h );
}
Пример #6
0
void wxTopLevelWindowBase::SetIcon(const wxIcon& icon)
{
    // passing wxNullIcon to SetIcon() is possible (it means that we shouldn't
    // have any icon), but adding an invalid icon to wxIconBundle is not
    wxIconBundle icons;
    if ( icon.Ok() )
        icons.AddIcon(icon);

    SetIcons(icons);
}
Пример #7
0
void wxStdRenderer::DrawFrameIcon(wxDC& dc,
                                  const wxRect& rect,
                                  const wxIcon& icon,
                                  int flags)
{
    if ( icon.Ok() )
    {
        wxRect r = GetFrameClientArea(rect, flags & ~wxTOPLEVEL_TITLEBAR);
        dc.DrawIcon(icon, r.x, r.y);
    }
}
Пример #8
0
void wxFrame::DoSetIcon(const wxIcon& icon)
{
    if (!m_frameShell)
        return;

    if (!icon.Ok() || !icon.GetDrawable())
        return;

    XtVaSetValues((Widget) m_frameShell,
                  XtNiconPixmap, icon.GetDrawable(),
                  NULL);
}
Пример #9
0
// Operations
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
{
    // NB: we have to create the window lazily because of backward compatibility,
    //     old applications may create a wxTaskBarIcon instance before wxApp
    //     is initialized (as samples/taskbar used to do)
    if (!m_win)
    {
        m_win = new wxTaskBarIconWindow(this);
    }

    m_icon = icon;
    m_strTooltip = tooltip;

    NotifyIconData notifyData(GetHwndOf(m_win));

    if (icon.Ok())
    {
        notifyData.uFlags |= NIF_ICON;
        notifyData.hIcon = GetHiconOf(icon);
    }

    // set NIF_TIP even for an empty tooltip: otherwise it would be impossible
    // to remove an existing tooltip using this function
    notifyData.uFlags |= NIF_TIP;
    if ( !tooltip.empty() )
    {
        wxStrlcpy(notifyData.szTip, tooltip.wx_str(), WXSIZEOF(notifyData.szTip));
    }

    bool ok = wxShellNotifyIcon(m_iconAdded ? NIM_MODIFY
                                            : NIM_ADD, &notifyData) != 0;

    if ( !ok )
    {
        wxLogLastError(wxT("wxShellNotifyIcon(NIM_MODIFY/ADD)"));
    }

    if ( !m_iconAdded && ok )
        m_iconAdded = true;

    return ok;
}
Пример #10
0
// Operations
bool gcTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
{
#ifdef WIN32
	m_icon = icon;
	m_strTooltip = tooltip;

	NotifyIconData notifyData(GetHwndOf(m_win));

	if (icon.Ok())
	{
		notifyData.uFlags |= NIF_ICON;
		notifyData.hIcon = GetHiconOf(icon);
	}

	// set NIF_TIP even for an empty tooltip: otherwise it would be impossible
	// to remove an existing tooltip using this function
	notifyData.uFlags |= NIF_TIP;
	if ( !tooltip.empty() )
	{
		wxStrlcpy(notifyData.szTip, tooltip.wx_str(), WXSIZEOF(notifyData.szTip));
	}

	bool ok = wxShellNotifyIcon(m_iconAdded ? NIM_MODIFY
											: NIM_ADD, &notifyData) != 0;

	if ( !ok )
	{
		wxLogLastError(wxT("wxShellNotifyIcon(NIM_MODIFY/ADD)"));
	}

	if ( !m_iconAdded && ok )
		m_iconAdded = true;

	return ok;
#else
	return wxTaskBarIcon::SetIcon(icon, tooltip);
#endif
}
Пример #11
0
// Operations
bool wxTaskBarIconEx::SetIcon(const wxIcon& icon)
{
    if (!IsOK())
        return FALSE;

    memset(&notifyData, 0, sizeof(notifyData));
    notifyData.cbSize           = sizeof(notifyData);
    notifyData.hWnd             = (HWND) m_hWnd;
    notifyData.uID              = 99;
    notifyData.uCallbackMessage = sm_taskbarMsg;
    notifyData.uFlags           = NIF_MESSAGE;
    notifyData.uVersion         = NOTIFYICON_VERSION;

    if (icon.Ok())
    {
        notifyData.uFlags |= NIF_ICON;
        notifyData.hIcon = (HICON) icon.GetHICON();
    }


    UpdateIcon();
    return m_iconAdded;
}
Пример #12
0
// Operations
bool wxTaskBarIconEx::SetIcon(const wxIcon& icon)
{
    if (!IsOK())
        return false;

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

    memset(&notifyData, 0, sizeof(notifyData));
    notifyData.cbSize           = sizeof(notifyData);
    notifyData.hWnd             = (HWND) m_hWnd;
    notifyData.uID              = 99;
    notifyData.uCallbackMessage = sm_taskbarMsg;
    notifyData.uFlags           = NIF_MESSAGE | NIF_ICON;
    notifyData.uVersion         = NOTIFYICON_VERSION;

    lstrcpyn(notifyData.szInfo, WXSTRINGCAST wxEmptyString, sizeof(notifyData.szInfo));
    lstrcpyn(notifyData.szInfoTitle, WXSTRINGCAST wxEmptyString, sizeof(notifyData.szInfoTitle));
    lstrcpyn(notifyData.szTip, WXSTRINGCAST wxEmptyString, sizeof(notifyData.szTip));
    notifyData.hIcon            = (HICON) icon.GetHICON();

    UpdateIcon();
    return m_iconAdded;
}
Пример #13
0
bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const wxString message, unsigned int iconballoon)
{
    wxLogTrace(wxT("Function Start/End"), wxT("wxTaskBarIconEx::SetBalloon - Function Begin"));

    bool retval = false;
    GError* error = NULL;

    if (!IsOK())
        return false;

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

    if (!SetIcon(icon, wxEmptyString))
        return false;

    gchar* desired_icon = NULL;
    switch(iconballoon)
    {
        case BALLOONTYPE_INFO:
            desired_icon = GTK_STOCK_DIALOG_INFO;
            break;
        case BALLOONTYPE_WARNING:
            desired_icon = GTK_STOCK_DIALOG_WARNING;
            break;
        case BALLOONTYPE_ERROR:
            desired_icon = GTK_STOCK_DIALOG_ERROR;
            break;
    }

    if (!g_pNotification)
    {
        // Old Style
        if (my_notify_notification_new_with_status_icon) {
            g_pNotification =
                (*my_notify_notification_new_with_status_icon)(
                    title.mb_str(),
                    message.mb_str(),
                    desired_icon,
                    g_pStatusIcon
                );
        }

        // New Style
        if (my_notify_notification_new) {
            g_pNotification =
                (*my_notify_notification_new)(
                    title.mb_str(),
                    message.mb_str(),
                    gtk_status_icon_get_icon_name(g_pStatusIcon)
            );
        }

        g_signal_connect(
            g_pNotification,
            "closed",
            G_CALLBACK(status_icon_notification_closed),
            this
        );

        notify_notification_add_action(
            g_pNotification,
            "default",
            "Do Default Action",
            NOTIFY_ACTION_CALLBACK(status_icon_notification_actions),
            this,
            NULL
        );
    }
    else
    {
        notify_notification_update(
            g_pNotification,
            title.mb_str(),
            message.mb_str(),
            desired_icon
        );
    }

    retval = notify_notification_show(g_pNotification, &error);
    g_clear_error(&error);

    wxLogTrace(wxT("Function Start/End"), wxT("wxTaskBarIconEx::SetBalloon - Function End"));
    return retval;
}