Patch from Tomi Leppikangas <tomilepp@rak046.oulu.fi>.

Properly set the fonts of native widgets.
This commit is contained in:
ramiro%netscape.com 1999-06-25 10:43:43 +00:00
Родитель 610a92ba97
Коммит e418ee592e
8 изменённых файлов: 89 добавлений и 16 удалений

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

@ -132,3 +132,23 @@ NS_METHOD nsButton::GetLabel(nsString& aBuffer)
return (NS_OK);
}
//-------------------------------------------------------------------------
//
// set font for button
//
//-------------------------------------------------------------------------
/* virtual */
void nsButton::SetFontNative(GdkFont *aFont)
{
GtkStyle *style = gtk_style_copy(GTK_BIN (mWidget)->child->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
style->font = aFont;
gdk_font_ref(style->font);
gtk_widget_set_style(GTK_BIN (mWidget)->child, style);
gtk_style_unref(style);
}

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

@ -46,6 +46,8 @@ public:
virtual PRBool OnPaint(nsPaintEvent & aEvent) { return PR_FALSE; }
virtual PRBool OnResize(nsRect &aRect) { return PR_FALSE; }
virtual void SetFontNative(GdkFont *aFont);
protected:
NS_METHOD CreateNative(GtkWidget *parentWindow);

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

@ -352,3 +352,23 @@ nsComboBox::OnUnmapSignal(GtkWidget * aWidget)
InitEvent(event, NS_CONTROL_CHANGE, &point);
DispatchWindowEvent(&event);
}
//-------------------------------------------------------------------------
//
// Get handle for style
//
//-------------------------------------------------------------------------
/*virtual*/
void nsComboBox::SetFontNative(GdkFont *aFont)
{
GtkStyle *style = gtk_style_copy(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0))->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
style->font = aFont;
gdk_font_ref(style->font);
gtk_widget_set_style(GTK_BIN (mWidget)->child, style);
gtk_style_unref(style);
}

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

@ -59,6 +59,8 @@ public:
PRInt32 GetSelectedCount();
NS_IMETHOD GetSelectedIndices(PRInt32 aIndices[], PRInt32 aSize);
virtual void SetFontNative(GdkFont *aFont);
protected:
NS_IMETHOD CreateNative(GtkWidget *parentWindow);
virtual void InitCallbacks(char * aName = nsnull);

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

@ -393,3 +393,23 @@ nsListBox::OnDestroySignal(GtkWidget* aGtkWidget)
nsWidget::OnDestroySignal(aGtkWidget);
}
}
//-------------------------------------------------------------------------
//
// set font for listbox
//
//-------------------------------------------------------------------------
/*virtual*/
void nsListBox::SetFontNative(GdkFont *aFont)
{
GtkStyle *style = gtk_style_copy(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0))->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
style->font = aFont;
gdk_font_ref(style->font);
gtk_widget_set_style(GTK_WIDGET (g_list_nth_data(gtk_container_children(GTK_CONTAINER (mWidget)),0)), style);
gtk_style_unref(style);
}

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

@ -59,6 +59,8 @@ public:
NS_IMETHOD SelectItem(PRInt32 aPosition);
NS_IMETHOD Deselect() ;
virtual void SetFontNative(GdkFont *aFont);
protected:
NS_IMETHOD CreateNative(GtkWidget *parentWindow);
virtual void InitCallbacks(char * aName = nsnull);

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

@ -434,22 +434,8 @@ NS_METHOD nsWidget::SetFont(const nsFont &aFont)
return NS_ERROR_FAILURE;
}
if (mWidget) {
gtk_widget_ensure_style(mWidget);
GtkStyle *style = gtk_style_copy(mWidget->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
GdkFont *font = (GdkFont *)fontHandle;
style->font = font;
gdk_font_ref(style->font);
gtk_widget_set_style(mWidget, style);
gtk_style_unref(style);
}
if (mWidget)
SetFontNative((GdkFont *)fontHandle);
}
NS_RELEASE(mFontMetrics);
return NS_OK;
@ -1807,3 +1793,21 @@ nsWidget::GetWindowForSetBackground()
return gdk_window;
}
//////////////////////////////////////////////////////////////////////
// default setfont for most widgets
/*virtual*/
void nsWidget::SetFontNative(GdkFont *aFont)
{
GtkStyle *style = gtk_style_copy(mWidget->style);
// gtk_style_copy ups the ref count of the font
gdk_font_unref (style->font);
style->font = aFont;
gdk_font_ref(style->font);
gtk_widget_set_style(mWidget, style);
gtk_style_unref(style);
}

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

@ -154,6 +154,9 @@ class nsWidget : public nsBaseWidget
// Return the Gdk window whose background should change
virtual GdkWindow * GetWindowForSetBackground();
// Sets font for widgets
virtual void SetFontNative(GdkFont *aFont);
//////////////////////////////////////////////////////////////////
//
// GTK signal installers