Adding default window icon; SetIcon() method for nsWindow. Gtk-only for now.

This commit is contained in:
mcafee%netscape.com 1999-04-04 08:20:51 +00:00
Родитель 1d5361baba
Коммит 7eeca18338
3 изменённых файлов: 47 добавлений и 0 удалений

Просмотреть файл

Просмотреть файл

@ -372,17 +372,60 @@ NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
return NS_OK;
}
NS_METHOD nsWindow::SetTitle(const nsString& aTitle)
{
if (!mShell)
return NS_ERROR_FAILURE;
char * titleStr = aTitle.ToNewCString();
gtk_window_set_title(GTK_WINDOW(mShell), titleStr);
delete[] titleStr;
// XXX Hack. Set the window icon here until we have
// a way to do this XP, from XUL.
SetIcon();
return NS_OK;
}
// Just give the window a default icon, Mozilla.
#include "mozicon50.xpm"
nsresult nsWindow::SetIcon()
{
static GdkPixmap *w_pixmap = NULL;
static GdkBitmap *w_mask = NULL;
GtkStyle *w_style;
w_style = gtk_widget_get_style (mShell);
if (w_pixmap == NULL) {
w_pixmap =
gdk_pixmap_create_from_xpm_d (mShell->window,
&w_mask,
&w_style->bg[GTK_STATE_NORMAL],
mozicon50_xpm);
}
return SetIcon(w_pixmap, w_mask);
}
// Set the iconify icon for the window.
nsresult nsWindow::SetIcon(GdkPixmap *pixmap,
GdkBitmap *mask)
{
if (!mShell)
return NS_ERROR_FAILURE;
gdk_window_set_icon(mShell->window, NULL, pixmap, mask);
return NS_OK;
}
/**
* Processes an Expose Event
*

Просмотреть файл

@ -58,6 +58,8 @@ public:
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
NS_IMETHOD SetTitle(const nsString& aTitle);
nsresult SetIcon(GdkPixmap *window_pixmap,
GdkBitmap *window_mask);
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar);
NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]);
@ -93,6 +95,8 @@ protected:
virtual void InitCallbacks(char * aName = nsnull);
NS_IMETHOD CreateNative(GtkWidget *parentWidget);
nsresult SetIcon();
nsIFontMetrics *mFontMetrics;
PRBool mVisible;