Corrected wxWindow::GetExtent

s econd attempt at accelerators (mdi sample works)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@666 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1998-09-04 12:43:41 +00:00
parent 741fd2033e
commit 66c135f346
8 changed files with 65 additions and 20 deletions

View File

@ -130,6 +130,7 @@ class wxBitmap: public wxObject
friend wxFrame;
friend wxDialog;
friend wxTreeCtrl;
friend wxNotebook;
GdkPixmap *GetPixmap() const;
GdkBitmap *GetBitmap() const;

View File

@ -130,6 +130,7 @@ class wxBitmap: public wxObject
friend wxFrame;
friend wxDialog;
friend wxTreeCtrl;
friend wxNotebook;
GdkPixmap *GetPixmap() const;
GdkBitmap *GetBitmap() const;

View File

@ -109,7 +109,6 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL);
InitToolBar(GetToolBar());
#ifdef __WXMSW__
// Accelerators
wxAcceleratorEntry entries[3];
entries[0].Set(wxACCEL_CTRL, (int) 'N', MDI_NEW_WINDOW);
@ -117,7 +116,6 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
entries[2].Set(wxACCEL_CTRL, (int) 'A', MDI_ABOUT);
wxAcceleratorTable accel(3, entries);
SetAcceleratorTable(accel);
#endif
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )

View File

@ -33,6 +33,7 @@ LIB_CPP_SRC=\
common/memory.cpp \
common/module.cpp \
common/object.cpp \
common/odbc.cpp \
common/postscrp.cpp \
common/prntbase.cpp \
common/resource.cpp \

View File

@ -13,6 +13,8 @@
#include "wx/accel.h"
#include <ctype.h>
//-----------------------------------------------------------------------------
// wxAcceleratorTable
//-----------------------------------------------------------------------------
@ -22,13 +24,24 @@ class wxAccelRefData: public wxObjectRefData
public:
wxAccelRefData(void);
~wxAccelRefData(void);
wxList m_accels;
};
wxAccelRefData::wxAccelRefData(void)
{
m_accels.DeleteContents( TRUE );
}
wxAccelRefData::~wxAccelRefData(void)
{
wxNode *node = m_accels.First();
while (node)
{
wxAcceleratorEntry *entry = (wxAcceleratorEntry *)node->Data();
delete entry;
node = node->Next();
}
}
//-----------------------------------------------------------------------------
@ -47,8 +60,11 @@ wxAcceleratorTable::wxAcceleratorTable( int n, wxAcceleratorEntry entries[] )
m_refData = new wxAccelRefData();
for (int i = 0; i < n; i++)
{
M_ACCELDATA->m_accels.Append( (wxObject*)
new wxAcceleratorEntry( entries[n].GetFlags(), entries[n].GetKeyCode(), entries[n].GetCommand() ) );
int flag = entries[i].GetFlags();
int keycode = entries[i].GetKeyCode();
int command = entries[i].GetCommand();
if ((keycode >= (int)'A') && (keycode <= (int)'Z')) keycode = (int)tolower( (char)keycode );
M_ACCELDATA->m_accels.Append( (wxObject*) new wxAcceleratorEntry( flag, keycode, command ) );
}
}

View File

@ -193,11 +193,17 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
if (!ret)
{
int command = win->GetAcceleratorTable()->GetCommand( event );
if (command != -1)
{
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
ret = win->GetEventHandler()->ProcessEvent( command_event );
wxWindow *ancestor = win;
while (ancestor)
{
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
if (command != -1)
{
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
ret = ancestor->GetEventHandler()->ProcessEvent( command_event );
break;
}
ancestor = ancestor->GetParent();
}
}
@ -1404,7 +1410,7 @@ void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
if (theFont) fontToUse = *theFont;
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
if (x) (*y) = gdk_string_width( font, string );
if (x) (*x) = gdk_string_width( font, string );
if (y) (*y) = font->ascent + font->descent;
if (descent) (*descent) = font->descent;
if (externalLeading) (*externalLeading) = 0; // ??

View File

@ -13,6 +13,8 @@
#include "wx/accel.h"
#include <ctype.h>
//-----------------------------------------------------------------------------
// wxAcceleratorTable
//-----------------------------------------------------------------------------
@ -22,13 +24,24 @@ class wxAccelRefData: public wxObjectRefData
public:
wxAccelRefData(void);
~wxAccelRefData(void);
wxList m_accels;
};
wxAccelRefData::wxAccelRefData(void)
{
m_accels.DeleteContents( TRUE );
}
wxAccelRefData::~wxAccelRefData(void)
{
wxNode *node = m_accels.First();
while (node)
{
wxAcceleratorEntry *entry = (wxAcceleratorEntry *)node->Data();
delete entry;
node = node->Next();
}
}
//-----------------------------------------------------------------------------
@ -47,8 +60,11 @@ wxAcceleratorTable::wxAcceleratorTable( int n, wxAcceleratorEntry entries[] )
m_refData = new wxAccelRefData();
for (int i = 0; i < n; i++)
{
M_ACCELDATA->m_accels.Append( (wxObject*)
new wxAcceleratorEntry( entries[n].GetFlags(), entries[n].GetKeyCode(), entries[n].GetCommand() ) );
int flag = entries[i].GetFlags();
int keycode = entries[i].GetKeyCode();
int command = entries[i].GetCommand();
if ((keycode >= (int)'A') && (keycode <= (int)'Z')) keycode = (int)tolower( (char)keycode );
M_ACCELDATA->m_accels.Append( (wxObject*) new wxAcceleratorEntry( flag, keycode, command ) );
}
}

View File

@ -193,11 +193,17 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
if (!ret)
{
int command = win->GetAcceleratorTable()->GetCommand( event );
if (command != -1)
{
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
ret = win->GetEventHandler()->ProcessEvent( command_event );
wxWindow *ancestor = win;
while (ancestor)
{
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
if (command != -1)
{
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
ret = ancestor->GetEventHandler()->ProcessEvent( command_event );
break;
}
ancestor = ancestor->GetParent();
}
}
@ -1404,7 +1410,7 @@ void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
if (theFont) fontToUse = *theFont;
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
if (x) (*y) = gdk_string_width( font, string );
if (x) (*x) = gdk_string_width( font, string );
if (y) (*y) = font->ascent + font->descent;
if (descent) (*descent) = font->descent;
if (externalLeading) (*externalLeading) = 0; // ??