Applied bitmap safer return patch.

Applied gtk pop up menu patch.
  Applied fontutil patch for better font matching in GTK 1.2


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@22227 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2003-07-22 08:57:09 +00:00
parent 8144bb6320
commit 1091d8a834
5 changed files with 75 additions and 32 deletions

View File

@@ -320,7 +320,14 @@ bool wxBitmap::CreateFromXpm( const char **bits )
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits ); M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits );
wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") ); if (!M_BMPDATA->m_pixmap)
{
UnRef();
wxFAIL_MSG( wxT("couldn't create pixmap") );
return FALSE;
}
if (mask) if (mask)
{ {
@@ -853,7 +860,12 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth
M_BMPDATA->m_height = height; M_BMPDATA->m_height = height;
M_BMPDATA->m_bpp = 1; M_BMPDATA->m_bpp = 1;
wxCHECK_RET( M_BMPDATA->m_bitmap, wxT("couldn't create bitmap") ); if (!M_BMPDATA->m_bitmap)
{
UnRef();
wxFAIL_MSG( wxT("couldn't create bitmap") );
}
} }
wxBitmap::~wxBitmap() wxBitmap::~wxBitmap()

View File

@@ -255,10 +255,6 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
// send any activate events at all // send any activate events at all
static int g_sendActivateEvent = -1; static int g_sendActivateEvent = -1;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
static guint32 gs_timeLastClick = 0;
extern bool g_mainThreadLocked; extern bool g_mainThreadLocked;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1581,8 +1577,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
if ( !g_captureWindow ) if ( !g_captureWindow )
win = FindWindowForMouseEvent(win, event.m_x, event.m_y); win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
gs_timeLastClick = gdk_event->time;
/* /*
wxPrintf( wxT("2) OnButtonPress from ") ); wxPrintf( wxT("2) OnButtonPress from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -4234,7 +4228,11 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
wxPopupMenuPositionCallback, // function to position it wxPopupMenuPositionCallback, // function to position it
NULL, // client data NULL, // client data
0, // button used to activate it 0, // button used to activate it
gs_timeLastClick // the time of activation #ifdef __WXGTK20__
gtk_get_current_event_time()
#else
GDK_CURRENT_TIME
#endif
); );
while (is_waiting) while (is_waiting)

View File

@@ -320,7 +320,14 @@ bool wxBitmap::CreateFromXpm( const char **bits )
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits ); M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits );
wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") ); if (!M_BMPDATA->m_pixmap)
{
UnRef();
wxFAIL_MSG( wxT("couldn't create pixmap") );
return FALSE;
}
if (mask) if (mask)
{ {
@@ -853,7 +860,12 @@ wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth
M_BMPDATA->m_height = height; M_BMPDATA->m_height = height;
M_BMPDATA->m_bpp = 1; M_BMPDATA->m_bpp = 1;
wxCHECK_RET( M_BMPDATA->m_bitmap, wxT("couldn't create bitmap") ); if (!M_BMPDATA->m_bitmap)
{
UnRef();
wxFAIL_MSG( wxT("couldn't create bitmap") );
}
} }
wxBitmap::~wxBitmap() wxBitmap::~wxBitmap()

View File

@@ -255,10 +255,6 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
// send any activate events at all // send any activate events at all
static int g_sendActivateEvent = -1; static int g_sendActivateEvent = -1;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
static guint32 gs_timeLastClick = 0;
extern bool g_mainThreadLocked; extern bool g_mainThreadLocked;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1581,8 +1577,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
if ( !g_captureWindow ) if ( !g_captureWindow )
win = FindWindowForMouseEvent(win, event.m_x, event.m_y); win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
gs_timeLastClick = gdk_event->time;
/* /*
wxPrintf( wxT("2) OnButtonPress from ") ); wxPrintf( wxT("2) OnButtonPress from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -4234,7 +4228,11 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
wxPopupMenuPositionCallback, // function to position it wxPopupMenuPositionCallback, // function to position it
NULL, // client data NULL, // client data
0, // button used to activate it 0, // button used to activate it
gs_timeLastClick // the time of activation #ifdef __WXGTK20__
gtk_get_current_event_time()
#else
GDK_CURRENT_TIME
#endif
); );
while (is_waiting) while (is_waiting)

View File

@@ -795,27 +795,49 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
*xFontName = newFontName; *xFontName = newFontName;
} }
// try to load exactly the font requested first
if( !font )
{
font = wxLoadQueryFont( pointSize, family, style, weight,
underlined, facename,
info.xregistry, info.xencoding,
xFontName );
}
if ( !font ) if ( !font )
{ {
// search up and down by stepsize 10 // search up and down by stepsize 10
int max_size = pointSize + 20 * (1 + (pointSize/180)); int max_size = pointSize + 20 * (1 + (pointSize/180));
int min_size = pointSize - 20 * (1 + (pointSize/180)); int min_size = pointSize - 20 * (1 + (pointSize/180));
int i; int i, round; // counters
// Search for smaller size (approx.) // first round: search for equal, then for smaller and for larger size with the given weight and style
for ( i = pointSize - 10; !font && i >= 10 && i >= min_size; i -= 10 ) int testweight = weight;
int teststyle = style;
for ( round = 0; round < 3; round++ )
{ {
font = wxLoadQueryFont(i, family, style, weight, underlined, // second round: use normal weight
if ( round == 1 )
{
if ( testweight != wxNORMAL )
{
testweight = wxNORMAL;
}
else
{
++round; // fall through to third round
}
}
// third round: ... and use normal style
if ( round == 2 )
{
if ( teststyle != wxNORMAL )
{
teststyle = wxNORMAL;
}
else
{
break;
}
}
// Search for equal or smaller size (approx.)
for ( i = pointSize; !font && i >= 10 && i >= min_size; i -= 10 )
{
font = wxLoadQueryFont(i, family, teststyle, testweight, underlined,
facename, info.xregistry, info.xencoding, facename, info.xregistry, info.xencoding,
xFontName); xFontName);
} }
@@ -823,9 +845,10 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
// Search for larger size (approx.) // Search for larger size (approx.)
for ( i = pointSize + 10; !font && i <= max_size; i += 10 ) for ( i = pointSize + 10; !font && i <= max_size; i += 10 )
{ {
font = wxLoadQueryFont(i, family, style, weight, underlined, font = wxLoadQueryFont(i, family, teststyle, testweight, underlined,
facename, info.xregistry, info.xencoding, facename, info.xregistry, info.xencoding,
xFontName); xFontName);
}
} }
// Try default family // Try default family