Fixes to fonts, static text, radiobox, frame

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@944 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-10-30 19:37:03 +00:00
parent 5db1a502b4
commit 7bce6aec99
17 changed files with 162 additions and 86 deletions

View File

@@ -136,8 +136,6 @@ void wxComboBox::Append( const wxString &item, char *clientData )
GtkWidget *list_item = gtk_list_item_new_with_label( item );
if (m_widgetStyle) ApplyWidgetStyle();
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
@@ -145,6 +143,8 @@ void wxComboBox::Append( const wxString &item, char *clientData )
gtk_container_add( GTK_CONTAINER(list), list_item );
if (m_widgetStyle) ApplyWidgetStyle();
gtk_widget_show( list_item );
}

View File

@@ -102,6 +102,9 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight,
{
m_refData = new wxFontRefData();
if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS;
M_FONTDATA->m_family = FontIdOrFamily;
if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) )
{
M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily );
@@ -112,11 +115,12 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight,
M_FONTDATA->m_fontId = FontIdOrFamily;
M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily );
}
if (Style == wxDEFAULT) Style = wxSWISS;
if (Style == wxDEFAULT) Style = wxNORMAL;
M_FONTDATA->m_style = Style;
if (Weight == wxDEFAULT) Weight = wxNORMAL;
M_FONTDATA->m_weight = Weight;
if (PointSize == wxDEFAULT) PointSize = 10;
if (PointSize == wxDEFAULT) PointSize = 12;
M_FONTDATA->m_pointSize = PointSize;
M_FONTDATA->m_underlined = Underlined;
@@ -361,12 +365,19 @@ GdkFont *wxFont::GetInternalFont(float scale) const
}
else
{
/*
if (int_scale == 100) printf( "int_scale.\n" );
if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" );
if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" );
if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" );
if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" );
*/
if ((int_scale == 100) &&
(M_FONTDATA->m_style == wxSWISS) &&
(M_FONTDATA->m_family == wxSWISS) &&
(M_FONTDATA->m_style == wxNORMAL) &&
(M_FONTDATA->m_pointSize == 12) &&
(M_FONTDATA->m_weight == wxNORMAL) &&
(M_FONTDATA->m_underlined == FALSE) &&
(M_FONTDATA->m_style == wxNORMAL))
(M_FONTDATA->m_underlined == FALSE))
{
font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
}

View File

@@ -337,7 +337,9 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if (m_frameToolBar)
{
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT );
int y = 0;
if (m_frameMenuBar) y = wxMENU_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y );
gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
}

View File

@@ -144,8 +144,6 @@ void wxListBox::Append( const wxString &item, char *clientData )
GtkWidget *list_item = gtk_list_item_new_with_label( item );
if (m_widgetStyle) ApplyWidgetStyle();
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
@@ -159,6 +157,8 @@ void wxListBox::Append( const wxString &item, char *clientData )
gtk_container_add( GTK_CONTAINER(m_list), list_item );
if (m_widgetStyle) ApplyWidgetStyle();
gtk_widget_show( list_item );
ConnectWidget( list_item );

View File

@@ -104,7 +104,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y );
int tmp = 22+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
if (tmp > maxLen) maxLen = tmp;
width = m_width-10;

View File

@@ -54,37 +54,40 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe
gtk_label_set_justify(GTK_LABEL(m_widget), justify);
int y = 1;
if (newSize.x == -1) {
if (newSize.x == -1)
{
char *s = WXSTRINGCAST m_label;
char *nl = strchr(s, '\n');
if (nl) {
do {
if (nl)
{
do
{
*nl = 0;
int x = gdk_string_measure( m_widget->style->font, s );
if (x > newSize.x) {
newSize.x = x;
}
int x = gdk_string_measure( m_widget->style->font, s ) + 4;
if (x > newSize.x) newSize.x = x;
*nl++ = '\n';
if ((nl = strchr(s = nl, '\n'))) {
if ((nl = strchr(s = nl, '\n')))
{
++y;
} else {
int x = gdk_string_measure( m_widget->style->font, s );
if (x > newSize.x) {
newSize.x = x;
}
}
else
{
int x = gdk_string_measure( m_widget->style->font, s ) + 4;
if (x > newSize.x) newSize.x = x;
}
} while (nl);
} else {
newSize.x = gdk_string_measure( m_widget->style->font, label );
}
else
{
newSize.x = gdk_string_measure( m_widget->style->font, label ) + 4;
}
}
if (newSize.y == -1) {
if (y == 1) {
if (newSize.y == -1)
{
if (y == 1)
newSize.y = 26;
} else {
newSize.y
= y * (m_widget->style->font->ascent +m_widget->style->font->descent);
}
else
newSize.y = 4 + y * (m_widget->style->font->ascent + 2*m_widget->style->font->descent);
}
SetSize( newSize.x, newSize.y );

View File

@@ -136,8 +136,6 @@ void wxComboBox::Append( const wxString &item, char *clientData )
GtkWidget *list_item = gtk_list_item_new_with_label( item );
if (m_widgetStyle) ApplyWidgetStyle();
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
@@ -145,6 +143,8 @@ void wxComboBox::Append( const wxString &item, char *clientData )
gtk_container_add( GTK_CONTAINER(list), list_item );
if (m_widgetStyle) ApplyWidgetStyle();
gtk_widget_show( list_item );
}

View File

@@ -102,6 +102,9 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight,
{
m_refData = new wxFontRefData();
if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS;
M_FONTDATA->m_family = FontIdOrFamily;
if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) )
{
M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily );
@@ -112,11 +115,12 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight,
M_FONTDATA->m_fontId = FontIdOrFamily;
M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily );
}
if (Style == wxDEFAULT) Style = wxSWISS;
if (Style == wxDEFAULT) Style = wxNORMAL;
M_FONTDATA->m_style = Style;
if (Weight == wxDEFAULT) Weight = wxNORMAL;
M_FONTDATA->m_weight = Weight;
if (PointSize == wxDEFAULT) PointSize = 10;
if (PointSize == wxDEFAULT) PointSize = 12;
M_FONTDATA->m_pointSize = PointSize;
M_FONTDATA->m_underlined = Underlined;
@@ -361,12 +365,19 @@ GdkFont *wxFont::GetInternalFont(float scale) const
}
else
{
/*
if (int_scale == 100) printf( "int_scale.\n" );
if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" );
if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" );
if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" );
if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" );
*/
if ((int_scale == 100) &&
(M_FONTDATA->m_style == wxSWISS) &&
(M_FONTDATA->m_family == wxSWISS) &&
(M_FONTDATA->m_style == wxNORMAL) &&
(M_FONTDATA->m_pointSize == 12) &&
(M_FONTDATA->m_weight == wxNORMAL) &&
(M_FONTDATA->m_underlined == FALSE) &&
(M_FONTDATA->m_style == wxNORMAL))
(M_FONTDATA->m_underlined == FALSE))
{
font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
}

View File

@@ -337,7 +337,9 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
if (m_frameToolBar)
{
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT );
int y = 0;
if (m_frameMenuBar) y = wxMENU_HEIGHT;
gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y );
gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
}

View File

@@ -144,8 +144,6 @@ void wxListBox::Append( const wxString &item, char *clientData )
GtkWidget *list_item = gtk_list_item_new_with_label( item );
if (m_widgetStyle) ApplyWidgetStyle();
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
@@ -159,6 +157,8 @@ void wxListBox::Append( const wxString &item, char *clientData )
gtk_container_add( GTK_CONTAINER(m_list), list_item );
if (m_widgetStyle) ApplyWidgetStyle();
gtk_widget_show( list_item );
ConnectWidget( list_item );

View File

@@ -104,7 +104,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y );
int tmp = 22+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
if (tmp > maxLen) maxLen = tmp;
width = m_width-10;

View File

@@ -54,37 +54,40 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe
gtk_label_set_justify(GTK_LABEL(m_widget), justify);
int y = 1;
if (newSize.x == -1) {
if (newSize.x == -1)
{
char *s = WXSTRINGCAST m_label;
char *nl = strchr(s, '\n');
if (nl) {
do {
if (nl)
{
do
{
*nl = 0;
int x = gdk_string_measure( m_widget->style->font, s );
if (x > newSize.x) {
newSize.x = x;
}
int x = gdk_string_measure( m_widget->style->font, s ) + 4;
if (x > newSize.x) newSize.x = x;
*nl++ = '\n';
if ((nl = strchr(s = nl, '\n'))) {
if ((nl = strchr(s = nl, '\n')))
{
++y;
} else {
int x = gdk_string_measure( m_widget->style->font, s );
if (x > newSize.x) {
newSize.x = x;
}
}
else
{
int x = gdk_string_measure( m_widget->style->font, s ) + 4;
if (x > newSize.x) newSize.x = x;
}
} while (nl);
} else {
newSize.x = gdk_string_measure( m_widget->style->font, label );
}
else
{
newSize.x = gdk_string_measure( m_widget->style->font, label ) + 4;
}
}
if (newSize.y == -1) {
if (y == 1) {
if (newSize.y == -1)
{
if (y == 1)
newSize.y = 26;
} else {
newSize.y
= y * (m_widget->style->font->ascent +m_widget->style->font->descent);
}
else
newSize.y = 4 + y * (m_widget->style->font->ascent + 2*m_widget->style->font->descent);
}
SetSize( newSize.x, newSize.y );