Source cleaning inspired by and included in patch '[ 1215450 ] cleanup: unreachable code.'
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34548 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -690,7 +690,7 @@ bool wxMenuBase::SendEvent(int id, int checked)
|
|||||||
bool processed = false;
|
bool processed = false;
|
||||||
|
|
||||||
// Try the menu's event handler
|
// Try the menu's event handler
|
||||||
if ( !processed )
|
// if ( !processed )
|
||||||
{
|
{
|
||||||
wxEvtHandler *handler = GetEventHandler();
|
wxEvtHandler *handler = GetEventHandler();
|
||||||
if ( handler )
|
if ( handler )
|
||||||
|
@@ -395,7 +395,7 @@ void wxSizerItem::DeleteWindows()
|
|||||||
m_window->Destroy();
|
m_window->Destroy();
|
||||||
//Putting this after the switch will result in a spacer
|
//Putting this after the switch will result in a spacer
|
||||||
//not being deleted properly on destruction
|
//not being deleted properly on destruction
|
||||||
m_kind = Item_None;
|
m_kind = Item_None;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Item_Sizer:
|
case Item_Sizer:
|
||||||
@@ -1053,23 +1053,19 @@ bool wxSizer::IsShown( size_t index ) const
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
wxGridSizer::wxGridSizer( int rows, int cols, int vgap, int hgap )
|
wxGridSizer::wxGridSizer( int rows, int cols, int vgap, int hgap )
|
||||||
: m_rows( rows )
|
: m_rows( ( cols == 0 && rows == 0 ) ? 1 : rows )
|
||||||
, m_cols( cols )
|
, m_cols( cols )
|
||||||
, m_vgap( vgap )
|
, m_vgap( vgap )
|
||||||
, m_hgap( hgap )
|
, m_hgap( hgap )
|
||||||
{
|
{
|
||||||
if (m_rows == 0 && m_cols == 0)
|
|
||||||
m_rows = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridSizer::wxGridSizer( int cols, int vgap, int hgap )
|
wxGridSizer::wxGridSizer( int cols, int vgap, int hgap )
|
||||||
: m_rows( 0 )
|
: m_rows( cols == 0 ? 1 : 0 )
|
||||||
, m_cols( cols )
|
, m_cols( cols )
|
||||||
, m_vgap( vgap )
|
, m_vgap( vgap )
|
||||||
, m_hgap( hgap )
|
, m_hgap( hgap )
|
||||||
{
|
{
|
||||||
if (m_rows == 0 && m_cols == 0)
|
|
||||||
m_rows = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxGridSizer::CalcRowsCols(int& nrows, int& ncols) const
|
int wxGridSizer::CalcRowsCols(int& nrows, int& ncols) const
|
||||||
@@ -1892,7 +1888,7 @@ void wxStdDialogButtonSizer::Realize()
|
|||||||
Add((wxWindow*)m_buttonHelp, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonHelp->ConvertDialogToPixels(wxSize(2, 0)).x);
|
Add((wxWindow*)m_buttonHelp, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonHelp->ConvertDialogToPixels(wxSize(2, 0)).x);
|
||||||
#else
|
#else
|
||||||
// GTK+1 and any other platform
|
// GTK+1 and any other platform
|
||||||
|
|
||||||
// Add(0, 0, 0, wxLEFT, 5); // Not sure what this was for but it unbalances the dialog
|
// Add(0, 0, 0, wxLEFT, 5); // Not sure what this was for but it unbalances the dialog
|
||||||
if (m_buttonHelp)
|
if (m_buttonHelp)
|
||||||
Add((wxWindow*)m_buttonHelp, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonHelp->ConvertDialogToPixels(wxSize(4, 0)).x);
|
Add((wxWindow*)m_buttonHelp, 0, wxALIGN_CENTRE | wxLEFT | wxRIGHT, m_buttonHelp->ConvertDialogToPixels(wxSize(4, 0)).x);
|
||||||
|
@@ -571,7 +571,7 @@ bool wxGridCellEditor::IsAcceptedKey(wxKeyEvent& event)
|
|||||||
// through in that case.
|
// through in that case.
|
||||||
if ((ctrl || alt) && !(ctrl && alt))
|
if ((ctrl || alt) && !(ctrl && alt))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
int key = event.GetUnicodeKey();
|
int key = event.GetUnicodeKey();
|
||||||
bool keyOk = true;
|
bool keyOk = true;
|
||||||
@@ -588,7 +588,7 @@ bool wxGridCellEditor::IsAcceptedKey(wxKeyEvent& event)
|
|||||||
return keyOk;
|
return keyOk;
|
||||||
#else // !wxUSE_UNICODE
|
#else // !wxUSE_UNICODE
|
||||||
int key = event.GetKeyCode();
|
int key = event.GetKeyCode();
|
||||||
if (key <= 255)
|
if (key <= 255)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
||||||
@@ -752,7 +752,7 @@ void wxGridCellTextEditor::StartingKey(wxKeyEvent& event)
|
|||||||
wxTextCtrl* tc = Text();
|
wxTextCtrl* tc = Text();
|
||||||
wxChar ch;
|
wxChar ch;
|
||||||
long pos;
|
long pos;
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
ch = event.GetUnicodeKey();
|
ch = event.GetUnicodeKey();
|
||||||
if (ch <= 127)
|
if (ch <= 127)
|
||||||
@@ -1106,7 +1106,7 @@ void wxGridCellFloatEditor::StartingKey(wxKeyEvent& event)
|
|||||||
tmpbuf[0] = (char) keycode;
|
tmpbuf[0] = (char) keycode;
|
||||||
tmpbuf[1] = '\0';
|
tmpbuf[1] = '\0';
|
||||||
wxString strbuf(tmpbuf, *wxConvCurrent);
|
wxString strbuf(tmpbuf, *wxConvCurrent);
|
||||||
#if wxUSE_INTL
|
#if wxUSE_INTL
|
||||||
bool is_decimal_point = ( strbuf ==
|
bool is_decimal_point = ( strbuf ==
|
||||||
wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER) );
|
wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER) );
|
||||||
#else
|
#else
|
||||||
@@ -1184,14 +1184,14 @@ bool wxGridCellFloatEditor::IsAcceptedKey(wxKeyEvent& event)
|
|||||||
tmpbuf[0] = (char) keycode;
|
tmpbuf[0] = (char) keycode;
|
||||||
tmpbuf[1] = '\0';
|
tmpbuf[1] = '\0';
|
||||||
wxString strbuf(tmpbuf, *wxConvCurrent);
|
wxString strbuf(tmpbuf, *wxConvCurrent);
|
||||||
#if wxUSE_INTL
|
#if wxUSE_INTL
|
||||||
bool is_decimal_point =
|
bool is_decimal_point =
|
||||||
( strbuf == wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,
|
( strbuf == wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT,
|
||||||
wxLOCALE_CAT_NUMBER) );
|
wxLOCALE_CAT_NUMBER) );
|
||||||
#else
|
#else
|
||||||
bool is_decimal_point = ( strbuf == _T(".") );
|
bool is_decimal_point = ( strbuf == _T(".") );
|
||||||
#endif
|
#endif
|
||||||
if ( (keycode < 128) &&
|
if ( (keycode < 128) &&
|
||||||
(wxIsdigit(keycode) || tolower(keycode) == 'e' ||
|
(wxIsdigit(keycode) || tolower(keycode) == 'e' ||
|
||||||
is_decimal_point || keycode == '+' || keycode == '-') )
|
is_decimal_point || keycode == '+' || keycode == '-') )
|
||||||
return true;
|
return true;
|
||||||
@@ -1375,11 +1375,11 @@ void wxGridCellBoolEditor::StartingKey(wxKeyEvent& event)
|
|||||||
case WXK_SPACE:
|
case WXK_SPACE:
|
||||||
CBox()->SetValue(!CBox()->GetValue());
|
CBox()->SetValue(!CBox()->GetValue());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '+':
|
case '+':
|
||||||
CBox()->SetValue(true);
|
CBox()->SetValue(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
CBox()->SetValue(false);
|
CBox()->SetValue(false);
|
||||||
break;
|
break;
|
||||||
@@ -1468,7 +1468,7 @@ void wxGridCellChoiceEditor::BeginEdit(int row, int col, wxGrid* grid)
|
|||||||
{
|
{
|
||||||
// find the right position, or default to the first if not found
|
// find the right position, or default to the first if not found
|
||||||
int pos = Combo()->FindString(m_startValue);
|
int pos = Combo()->FindString(m_startValue);
|
||||||
if (pos == -1)
|
if (pos == wxNOT_FOUND)
|
||||||
pos = 0;
|
pos = 0;
|
||||||
Combo()->SetSelection(pos);
|
Combo()->SetSelection(pos);
|
||||||
}
|
}
|
||||||
@@ -3783,7 +3783,7 @@ void wxGridWindow::OnMouseEvent( wxMouseEvent& event )
|
|||||||
{
|
{
|
||||||
if (event.ButtonDown(wxMOUSE_BTN_LEFT) && FindFocus() != this)
|
if (event.ButtonDown(wxMOUSE_BTN_LEFT) && FindFocus() != this)
|
||||||
SetFocus();
|
SetFocus();
|
||||||
|
|
||||||
m_owner->ProcessGridCellMouseEvent( event );
|
m_owner->ProcessGridCellMouseEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4905,6 +4905,7 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXGRID_CURSOR_SELECT_ROW:
|
case WXGRID_CURSOR_SELECT_ROW:
|
||||||
|
{
|
||||||
if ( (row = YToRow( y )) >= 0 )
|
if ( (row = YToRow( y )) >= 0 )
|
||||||
{
|
{
|
||||||
if ( m_selection )
|
if ( m_selection )
|
||||||
@@ -4916,6 +4917,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event )
|
|||||||
event.MetaDown() );
|
event.MetaDown() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// default label to suppress warnings about "enumeration value
|
// default label to suppress warnings about "enumeration value
|
||||||
// 'xxx' not handled in switch
|
// 'xxx' not handled in switch
|
||||||
@@ -5127,6 +5130,7 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXGRID_CURSOR_SELECT_COL:
|
case WXGRID_CURSOR_SELECT_COL:
|
||||||
|
{
|
||||||
if ( (col = XToCol( x )) >= 0 )
|
if ( (col = XToCol( x )) >= 0 )
|
||||||
{
|
{
|
||||||
if ( m_selection )
|
if ( m_selection )
|
||||||
@@ -5138,6 +5142,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event )
|
|||||||
event.MetaDown() );
|
event.MetaDown() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
// default label to suppress warnings about "enumeration value
|
// default label to suppress warnings about "enumeration value
|
||||||
// 'xxx' not handled in switch
|
// 'xxx' not handled in switch
|
||||||
|
@@ -443,14 +443,17 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
|
|||||||
coords2.GetRow(), coords2.GetCol(),
|
coords2.GetRow(), coords2.GetCol(),
|
||||||
topRow, leftCol, bottomRow, rightCol ) )
|
topRow, leftCol, bottomRow, rightCol ) )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return;
|
return;
|
||||||
case -1:
|
|
||||||
m_blockSelectionTopLeft.RemoveAt(n);
|
case -1:
|
||||||
m_blockSelectionBottomRight.RemoveAt(n);
|
m_blockSelectionTopLeft.RemoveAt(n);
|
||||||
n--; count--;
|
m_blockSelectionBottomRight.RemoveAt(n);
|
||||||
default:
|
n--; count--;
|
||||||
;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,13 +468,16 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
|
|||||||
m_rowSelection[n], m_grid->GetNumberCols()-1,
|
m_rowSelection[n], m_grid->GetNumberCols()-1,
|
||||||
topRow, leftCol, bottomRow, rightCol ) )
|
topRow, leftCol, bottomRow, rightCol ) )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return;
|
return;
|
||||||
case -1:
|
|
||||||
m_rowSelection.RemoveAt(n);
|
case -1:
|
||||||
n--; count--;
|
m_rowSelection.RemoveAt(n);
|
||||||
default:
|
n--; count--;
|
||||||
;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -484,13 +490,16 @@ void wxGridSelection::SelectBlock( int topRow, int leftCol,
|
|||||||
m_grid->GetNumberRows()-1, m_colSelection[n],
|
m_grid->GetNumberRows()-1, m_colSelection[n],
|
||||||
topRow, leftCol, bottomRow, rightCol ) )
|
topRow, leftCol, bottomRow, rightCol ) )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return;
|
return;
|
||||||
case -1:
|
|
||||||
m_colSelection.RemoveAt(n);
|
case -1:
|
||||||
n--; count--;
|
m_colSelection.RemoveAt(n);
|
||||||
default:
|
n--; count--;
|
||||||
;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -344,6 +344,7 @@ void wxGenericMDIParentFrame::DoHandleMenu(wxCommandEvent &event)
|
|||||||
{
|
{
|
||||||
#if 1 // What's best? Delayed deleting or immediate deleting?
|
#if 1 // What's best? Delayed deleting or immediate deleting?
|
||||||
delete m_pActiveChild;
|
delete m_pActiveChild;
|
||||||
|
m_pActiveChild = NULL;
|
||||||
#else
|
#else
|
||||||
ActivateNext();
|
ActivateNext();
|
||||||
|
|
||||||
|
@@ -475,7 +475,7 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event )
|
|||||||
// We must finish regardless of success, otherwise we'll get
|
// We must finish regardless of success, otherwise we'll get
|
||||||
// focus problems:
|
// focus problems:
|
||||||
Finish();
|
Finish();
|
||||||
|
|
||||||
if ( !AcceptChanges() )
|
if ( !AcceptChanges() )
|
||||||
m_owner->OnRenameCancelled( m_itemEdited );
|
m_owner->OnRenameCancelled( m_itemEdited );
|
||||||
}
|
}
|
||||||
@@ -2279,12 +2279,14 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
|||||||
{
|
{
|
||||||
wxColour colBg;
|
wxColour colBg;
|
||||||
if ( attr && attr->HasBackgroundColour() )
|
if ( attr && attr->HasBackgroundColour() )
|
||||||
{
|
{
|
||||||
drawItemBackground = true;
|
drawItemBackground = true;
|
||||||
colBg = attr->GetBackgroundColour();
|
colBg = attr->GetBackgroundColour();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
colBg = m_backgroundColour;
|
colBg = m_backgroundColour;
|
||||||
|
}
|
||||||
dc.SetBrush(wxBrush(colBg, wxSOLID));
|
dc.SetBrush(wxBrush(colBg, wxSOLID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3246,7 +3248,7 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
|
|||||||
{
|
{
|
||||||
// this facilitates multiple-item drag-and-drop
|
// this facilitates multiple-item drag-and-drop
|
||||||
|
|
||||||
if (item && HasFlag(wxTR_MULTIPLE))
|
if ( /* item && */ HasFlag(wxTR_MULTIPLE))
|
||||||
{
|
{
|
||||||
wxArrayTreeItemIds selections;
|
wxArrayTreeItemIds selections;
|
||||||
size_t count = GetSelections(selections);
|
size_t count = GetSelections(selections);
|
||||||
|
@@ -103,7 +103,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxImage image = bitmap.ConvertToImage();
|
wxImage image = bitmap.ConvertToImage();
|
||||||
if (!image.Ok()) return FALSE;
|
if (!image.Ok()) return false;
|
||||||
|
|
||||||
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
|
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
|
||||||
GdkGC *gc = gdk_gc_new( m_bitmap );
|
GdkGC *gc = gdk_gc_new( m_bitmap );
|
||||||
@@ -183,7 +183,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
|
|||||||
|
|
||||||
gdk_gc_unref( gc );
|
gdk_gc_unref( gc );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
||||||
@@ -191,7 +191,7 @@ bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
|||||||
unsigned char r,g,b;
|
unsigned char r,g,b;
|
||||||
wxPalette *pal = bitmap.GetPalette();
|
wxPalette *pal = bitmap.GetPalette();
|
||||||
|
|
||||||
wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") );
|
wxCHECK_MSG( pal, false, wxT("Cannot create mask from bitmap without palette") );
|
||||||
|
|
||||||
pal->GetRGB(paletteIndex, &r, &g, &b);
|
pal->GetRGB(paletteIndex, &r, &g, &b);
|
||||||
|
|
||||||
@@ -206,13 +206,13 @@ bool wxMask::Create( const wxBitmap& bitmap )
|
|||||||
m_bitmap = (GdkBitmap*) NULL;
|
m_bitmap = (GdkBitmap*) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bitmap.Ok()) return FALSE;
|
if (!bitmap.Ok()) return false;
|
||||||
|
|
||||||
wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") );
|
wxCHECK_MSG( bitmap.GetBitmap(), false, wxT("Cannot create mask from colour bitmap") );
|
||||||
|
|
||||||
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
|
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
|
||||||
|
|
||||||
if (!m_bitmap) return FALSE;
|
if (!m_bitmap) return false;
|
||||||
|
|
||||||
GdkGC *gc = gdk_gc_new( m_bitmap );
|
GdkGC *gc = gdk_gc_new( m_bitmap );
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ bool wxMask::Create( const wxBitmap& bitmap )
|
|||||||
|
|
||||||
gdk_gc_unref( gc );
|
gdk_gc_unref( gc );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkBitmap *wxMask::GetBitmap() const
|
GdkBitmap *wxMask::GetBitmap() const
|
||||||
@@ -307,7 +307,7 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
if (depth == -1)
|
if (depth == -1)
|
||||||
depth = visual->depth;
|
depth = visual->depth;
|
||||||
|
|
||||||
wxCHECK_MSG( (depth == visual->depth) || (depth == 1) || (depth == 32), FALSE,
|
wxCHECK_MSG( (depth == visual->depth) || (depth == 1) || (depth == 32), false,
|
||||||
wxT("invalid bitmap depth") )
|
wxT("invalid bitmap depth") )
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
@@ -340,7 +340,7 @@ bool wxBitmap::CreateFromXpm( const char **bits )
|
|||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
|
wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") )
|
||||||
|
|
||||||
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ 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") );
|
wxCHECK_MSG( M_BMPDATA->m_pixmap, false, wxT("couldn't create pixmap") );
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
{
|
{
|
||||||
@@ -362,7 +362,7 @@ bool wxBitmap::CreateFromXpm( const char **bits )
|
|||||||
|
|
||||||
M_BMPDATA->m_bpp = visual->depth; // Can we get a different depth from create_from_xpm_d() ?
|
M_BMPDATA->m_bpp = visual->depth; // Can we get a different depth from create_from_xpm_d() ?
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, int newx, int newy )
|
wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, int newx, int newy )
|
||||||
@@ -371,12 +371,12 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
|
|
||||||
if (newy==M_BMPDATA->m_width && newy==M_BMPDATA->m_height)
|
if (newy==M_BMPDATA->m_width && newy==M_BMPDATA->m_height)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
int width = wxMax(newx, 1);
|
int width = wxMax(newx, 1);
|
||||||
int height = wxMax(newy, 1);
|
int height = wxMax(newy, 1);
|
||||||
width = wxMin(width, clipwidth);
|
width = wxMin(width, clipwidth);
|
||||||
height = wxMin(height, clipheight);
|
height = wxMin(height, clipheight);
|
||||||
|
|
||||||
wxBitmap bmp;
|
wxBitmap bmp;
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
@@ -390,7 +390,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
8, width, height));
|
8, width, height));
|
||||||
gdk_pixbuf_scale(GetPixbuf(), bmp.GetPixbuf(),
|
gdk_pixbuf_scale(GetPixbuf(), bmp.GetPixbuf(),
|
||||||
0, 0, width, height,
|
0, 0, width, height,
|
||||||
clipx, clipy,
|
clipx, clipy,
|
||||||
(double)newx/GetWidth(), (double)newy/GetHeight(),
|
(double)newx/GetWidth(), (double)newy/GetHeight(),
|
||||||
GDK_INTERP_BILINEAR);
|
GDK_INTERP_BILINEAR);
|
||||||
}
|
}
|
||||||
@@ -409,7 +409,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
|
|
||||||
int bpp = -1;
|
int bpp = -1;
|
||||||
|
|
||||||
|
|
||||||
GdkGC *gc = NULL;
|
GdkGC *gc = NULL;
|
||||||
GdkPixmap *dstpix = NULL;
|
GdkPixmap *dstpix = NULL;
|
||||||
if (GetPixmap())
|
if (GetPixmap())
|
||||||
@@ -426,7 +426,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
|
|
||||||
char *dst = NULL;
|
char *dst = NULL;
|
||||||
long dstbyteperline = 0;
|
long dstbyteperline = 0;
|
||||||
|
|
||||||
if (GetBitmap())
|
if (GetBitmap())
|
||||||
{
|
{
|
||||||
bpp = 1;
|
bpp = 1;
|
||||||
@@ -435,7 +435,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
dstbyteperline++;
|
dstbyteperline++;
|
||||||
dst = (char*) malloc(dstbyteperline*height);
|
dst = (char*) malloc(dstbyteperline*height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// be careful to use the right scaling factor
|
// be careful to use the right scaling factor
|
||||||
float scx = (float)M_BMPDATA->m_width/(float)newx;
|
float scx = (float)M_BMPDATA->m_width/(float)newx;
|
||||||
float scy = (float)M_BMPDATA->m_height/(float)newy;
|
float scy = (float)M_BMPDATA->m_height/(float)newy;
|
||||||
@@ -468,7 +468,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
old_pixval = pixval;
|
old_pixval = pixval;
|
||||||
old_x = x;
|
old_x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bpp == 1)
|
if (bpp == 1)
|
||||||
{
|
{
|
||||||
if (!pixval)
|
if (!pixval)
|
||||||
@@ -477,7 +477,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
char shift = bit << w % 8;
|
char shift = bit << w % 8;
|
||||||
outbyte |= shift;
|
outbyte |= shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((w+1)%8==0)
|
if ((w+1)%8==0)
|
||||||
{
|
{
|
||||||
dst[h*dstbyteperline+w/8] = outbyte;
|
dst[h*dstbyteperline+w/8] = outbyte;
|
||||||
@@ -492,12 +492,12 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
gdk_draw_point( dstpix, gc, w, h);
|
gdk_draw_point( dstpix, gc, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not forget the last byte
|
// do not forget the last byte
|
||||||
if ((bpp == 1) && (width % 8 != 0))
|
if ((bpp == 1) && (width % 8 != 0))
|
||||||
dst[h*dstbyteperline+width/8] = outbyte;
|
dst[h*dstbyteperline+width/8] = outbyte;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_image_destroy( img );
|
gdk_image_destroy( img );
|
||||||
if (gc) gdk_gc_unref( gc );
|
if (gc) gdk_gc_unref( gc );
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
bmp = wxBitmap( (const char *)dst, width, height, 1 );
|
bmp = wxBitmap( (const char *)dst, width, height, 1 );
|
||||||
free( dst );
|
free( dst );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetMask())
|
if (GetMask())
|
||||||
{
|
{
|
||||||
dstbyteperline = width/8;
|
dstbyteperline = width/8;
|
||||||
@@ -520,7 +520,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
char outbyte = 0;
|
char outbyte = 0;
|
||||||
int old_x = -1;
|
int old_x = -1;
|
||||||
guint32 old_pixval = 0;
|
guint32 old_pixval = 0;
|
||||||
|
|
||||||
for (int w = 0; w < width; w++)
|
for (int w = 0; w < width; w++)
|
||||||
{
|
{
|
||||||
guint32 pixval;
|
guint32 pixval;
|
||||||
@@ -533,21 +533,21 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
old_pixval = pixval;
|
old_pixval = pixval;
|
||||||
old_x = x;
|
old_x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixval)
|
if (pixval)
|
||||||
{
|
{
|
||||||
char bit=1;
|
char bit=1;
|
||||||
char shift = bit << w % 8;
|
char shift = bit << w % 8;
|
||||||
outbyte |= shift;
|
outbyte |= shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((w+1)%8 == 0)
|
if ((w+1)%8 == 0)
|
||||||
{
|
{
|
||||||
dst[h*dstbyteperline+w/8] = outbyte;
|
dst[h*dstbyteperline+w/8] = outbyte;
|
||||||
outbyte = 0;
|
outbyte = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not forget the last byte
|
// do not forget the last byte
|
||||||
if (width % 8 != 0)
|
if (width % 8 != 0)
|
||||||
dst[h*dstbyteperline+width/8] = outbyte;
|
dst[h*dstbyteperline+width/8] = outbyte;
|
||||||
@@ -563,20 +563,20 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
free( tablex );
|
free( tablex );
|
||||||
free( tabley );
|
free( tabley );
|
||||||
}
|
}
|
||||||
|
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
|
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
wxCHECK_MSG( image.Ok(), false, wxT("invalid image") )
|
||||||
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
|
wxCHECK_MSG( depth == -1 || depth == 1, false, wxT("invalid bitmap depth") )
|
||||||
|
|
||||||
if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
|
if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
|
|
||||||
if (depth == 1)
|
if (depth == 1)
|
||||||
@@ -599,7 +599,7 @@ bool wxBitmap::CreateFromImageAsBitmap(const wxImage& img)
|
|||||||
// convert alpha channel to mask, if it is present:
|
// convert alpha channel to mask, if it is present:
|
||||||
wxImage image(img);
|
wxImage image(img);
|
||||||
image.ConvertAlphaToMask();
|
image.ConvertAlphaToMask();
|
||||||
|
|
||||||
int width = image.GetWidth();
|
int width = image.GetWidth();
|
||||||
int height = image.GetHeight();
|
int height = image.GetHeight();
|
||||||
|
|
||||||
@@ -692,14 +692,14 @@ bool wxBitmap::CreateFromImageAsBitmap(const wxImage& img)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// conversion to colour bitmap:
|
// conversion to colour bitmap:
|
||||||
bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
||||||
{
|
{
|
||||||
// convert alpha channel to mask, if it is present:
|
// convert alpha channel to mask, if it is present:
|
||||||
wxImage image(img);
|
wxImage image(img);
|
||||||
image.ConvertAlphaToMask();
|
image.ConvertAlphaToMask();
|
||||||
|
|
||||||
int width = image.GetWidth();
|
int width = image.GetWidth();
|
||||||
int height = image.GetHeight();
|
int height = image.GetHeight();
|
||||||
|
|
||||||
@@ -728,12 +728,12 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
|||||||
if (!image.HasMask() && (bpp > 12))
|
if (!image.HasMask() && (bpp > 12))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
static bool s_hasInitialized = FALSE;
|
static bool s_hasInitialized = false;
|
||||||
|
|
||||||
if (!s_hasInitialized)
|
if (!s_hasInitialized)
|
||||||
{
|
{
|
||||||
gdk_rgb_init();
|
gdk_rgb_init();
|
||||||
s_hasInitialized = TRUE;
|
s_hasInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkGC *gc = gdk_gc_new( GetPixmap() );
|
GdkGC *gc = gdk_gc_new( GetPixmap() );
|
||||||
@@ -747,7 +747,7 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
|||||||
width*3 );
|
width*3 );
|
||||||
|
|
||||||
gdk_gc_unref( gc );
|
gdk_gc_unref( gc );
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create picture image
|
// Create picture image
|
||||||
@@ -902,6 +902,7 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
|||||||
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
||||||
}
|
}
|
||||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@@ -949,17 +950,17 @@ bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
|
|||||||
wxASSERT( gdk_pixbuf_get_n_channels(pixbuf) == 4 );
|
wxASSERT( gdk_pixbuf_get_n_channels(pixbuf) == 4 );
|
||||||
wxASSERT( gdk_pixbuf_get_width(pixbuf) == width );
|
wxASSERT( gdk_pixbuf_get_width(pixbuf) == width );
|
||||||
wxASSERT( gdk_pixbuf_get_height(pixbuf) == height );
|
wxASSERT( gdk_pixbuf_get_height(pixbuf) == height );
|
||||||
|
|
||||||
M_BMPDATA->m_pixbuf = pixbuf;
|
M_BMPDATA->m_pixbuf = pixbuf;
|
||||||
SetHeight(height);
|
SetHeight(height);
|
||||||
SetWidth(width);
|
SetWidth(width);
|
||||||
SetDepth(wxTheApp->GetGdkVisual()->depth);
|
SetDepth(wxTheApp->GetGdkVisual()->depth);
|
||||||
|
|
||||||
// Copy the data:
|
// Copy the data:
|
||||||
unsigned char *in = image.GetData();
|
unsigned char *in = image.GetData();
|
||||||
unsigned char *out = gdk_pixbuf_get_pixels(pixbuf);
|
unsigned char *out = gdk_pixbuf_get_pixels(pixbuf);
|
||||||
unsigned char *alpha = image.GetAlpha();
|
unsigned char *alpha = image.GetAlpha();
|
||||||
|
|
||||||
int rowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * width;
|
int rowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * width;
|
||||||
|
|
||||||
for (int y = 0; y < height; y++, out += rowinc)
|
for (int y = 0; y < height; y++, out += rowinc)
|
||||||
@@ -972,7 +973,7 @@ bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
|
|||||||
out[3] = *alpha;
|
out[3] = *alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // __WXGTK20__
|
#endif // __WXGTK20__
|
||||||
@@ -982,7 +983,7 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
wxImage image;
|
wxImage image;
|
||||||
|
|
||||||
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
|
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
|
||||||
|
|
||||||
image.Create(GetWidth(), GetHeight());
|
image.Create(GetWidth(), GetHeight());
|
||||||
unsigned char *data = image.GetData();
|
unsigned char *data = image.GetData();
|
||||||
|
|
||||||
@@ -997,10 +998,10 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf = GetPixbuf();
|
GdkPixbuf *pixbuf = GetPixbuf();
|
||||||
wxASSERT( gdk_pixbuf_get_has_alpha(pixbuf) );
|
wxASSERT( gdk_pixbuf_get_has_alpha(pixbuf) );
|
||||||
|
|
||||||
int w = GetWidth();
|
int w = GetWidth();
|
||||||
int h = GetHeight();
|
int h = GetHeight();
|
||||||
|
|
||||||
image.SetAlpha();
|
image.SetAlpha();
|
||||||
|
|
||||||
unsigned char *alpha = image.GetAlpha();
|
unsigned char *alpha = image.GetAlpha();
|
||||||
@@ -1067,7 +1068,7 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
int red_shift_left = 0;
|
int red_shift_left = 0;
|
||||||
int green_shift_left = 0;
|
int green_shift_left = 0;
|
||||||
int blue_shift_left = 0;
|
int blue_shift_left = 0;
|
||||||
bool use_shift = FALSE;
|
bool use_shift = false;
|
||||||
|
|
||||||
if (GetPixmap())
|
if (GetPixmap())
|
||||||
{
|
{
|
||||||
@@ -1218,12 +1219,12 @@ bool wxBitmap::operator != ( const wxBitmap& bmp ) const
|
|||||||
|
|
||||||
bool wxBitmap::Ok() const
|
bool wxBitmap::Ok() const
|
||||||
{
|
{
|
||||||
return (m_refData != NULL) &&
|
return (m_refData != NULL) &&
|
||||||
(
|
(
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
M_BMPDATA->m_pixbuf ||
|
M_BMPDATA->m_pixbuf ||
|
||||||
#endif
|
#endif
|
||||||
M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap
|
M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,7 +1268,7 @@ void wxBitmap::SetMask( wxMask *mask )
|
|||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
||||||
{
|
{
|
||||||
*this = icon;
|
*this = icon;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
||||||
@@ -1335,7 +1336,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
|||||||
|
|
||||||
bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalette *WXUNUSED(palette) ) const
|
bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalette *WXUNUSED(palette) ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );
|
wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") );
|
||||||
|
|
||||||
// Try to save the bitmap via wxImage handlers:
|
// Try to save the bitmap via wxImage handlers:
|
||||||
{
|
{
|
||||||
@@ -1343,7 +1344,7 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett
|
|||||||
if (image.Ok()) return image.SaveFile( name, type );
|
if (image.Ok()) return image.SaveFile( name, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
|
bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
|
||||||
@@ -1351,7 +1352,7 @@ bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
|
|||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
if (!wxFileExists(name))
|
if (!wxFileExists(name))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
||||||
|
|
||||||
@@ -1383,12 +1384,12 @@ bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
|
|||||||
{
|
{
|
||||||
wxImage image;
|
wxImage image;
|
||||||
if ( !image.LoadFile( name, type ) || !image.Ok() )
|
if ( !image.LoadFile( name, type ) || !image.Ok() )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
*this = wxBitmap(image);
|
*this = wxBitmap(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPalette *wxBitmap::GetPalette() const
|
wxPalette *wxBitmap::GetPalette() const
|
||||||
@@ -1493,18 +1494,18 @@ GdkPixbuf *wxBitmap::GetPixbuf() const
|
|||||||
{
|
{
|
||||||
int width = GetWidth();
|
int width = GetWidth();
|
||||||
int height = GetHeight();
|
int height = GetHeight();
|
||||||
|
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
||||||
GetMask() != NULL,
|
GetMask() != NULL,
|
||||||
8, width, height);
|
8, width, height);
|
||||||
M_BMPDATA->m_pixbuf =
|
M_BMPDATA->m_pixbuf =
|
||||||
gdk_pixbuf_get_from_drawable(pixbuf, M_BMPDATA->m_pixmap, NULL,
|
gdk_pixbuf_get_from_drawable(pixbuf, M_BMPDATA->m_pixmap, NULL,
|
||||||
0, 0, 0, 0, width, height);
|
0, 0, 0, 0, width, height);
|
||||||
|
|
||||||
// apply the mask to created pixbuf:
|
// apply the mask to created pixbuf:
|
||||||
if (M_BMPDATA->m_pixbuf && M_BMPDATA->m_mask)
|
if (M_BMPDATA->m_pixbuf && M_BMPDATA->m_mask)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pmask =
|
GdkPixbuf *pmask =
|
||||||
gdk_pixbuf_get_from_drawable(NULL,
|
gdk_pixbuf_get_from_drawable(NULL,
|
||||||
M_BMPDATA->m_mask->GetBitmap(),
|
M_BMPDATA->m_mask->GetBitmap(),
|
||||||
NULL,
|
NULL,
|
||||||
@@ -1525,7 +1526,7 @@ GdkPixbuf *wxBitmap::GetPixbuf() const
|
|||||||
bmp[3] = 0;
|
bmp[3] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_pixbuf_unref(pmask);
|
gdk_pixbuf_unref(pmask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1571,26 +1572,26 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
if (bpp != 32)
|
if (bpp != 32)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
GdkPixbuf *pixbuf = GetPixbuf();
|
GdkPixbuf *pixbuf = GetPixbuf();
|
||||||
if (!pixbuf)
|
if (!pixbuf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (gdk_pixbuf_get_has_alpha( pixbuf ))
|
if (gdk_pixbuf_get_has_alpha( pixbuf ))
|
||||||
wxPrintf( wxT("Has alpha\n") );
|
wxPrintf( wxT("Has alpha\n") );
|
||||||
else
|
else
|
||||||
wxPrintf( wxT("No alpha.\n") );
|
wxPrintf( wxT("No alpha.\n") );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data.m_height = gdk_pixbuf_get_height( pixbuf );
|
data.m_height = gdk_pixbuf_get_height( pixbuf );
|
||||||
data.m_width = gdk_pixbuf_get_width( pixbuf );
|
data.m_width = gdk_pixbuf_get_width( pixbuf );
|
||||||
data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
|
data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
|
||||||
|
|
||||||
return gdk_pixbuf_get_pixels( pixbuf );
|
return gdk_pixbuf_get_pixels( pixbuf );
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
||||||
@@ -1598,7 +1599,7 @@ void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxBitmap::HasAlpha() const
|
bool wxBitmap::HasAlpha() const
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
return HasPixbuf();
|
return HasPixbuf();
|
||||||
@@ -1608,7 +1609,7 @@ bool wxBitmap::HasAlpha() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::UseAlpha()
|
void wxBitmap::UseAlpha()
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
GetPixbuf();
|
GetPixbuf();
|
||||||
#endif
|
#endif
|
||||||
@@ -1626,18 +1627,18 @@ wxBitmapHandler::~wxBitmapHandler()
|
|||||||
|
|
||||||
bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
|
bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||||
int desiredWidth, int desiredHeight)
|
int desiredWidth, int desiredHeight)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
|
bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void wxBitmap::InitStandardHandlers()
|
/* static */ void wxBitmap::InitStandardHandlers()
|
||||||
|
@@ -125,7 +125,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxButton)
|
|||||||
void wxBitmapButton::Init()
|
void wxBitmapButton::Init()
|
||||||
{
|
{
|
||||||
m_hasFocus =
|
m_hasFocus =
|
||||||
m_isSelected = FALSE;
|
m_isSelected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapButton::Create( wxWindow *parent,
|
bool wxBitmapButton::Create( wxWindow *parent,
|
||||||
@@ -137,14 +137,14 @@ bool wxBitmapButton::Create( wxWindow *parent,
|
|||||||
const wxValidator& validator,
|
const wxValidator& validator,
|
||||||
const wxString &name )
|
const wxString &name )
|
||||||
{
|
{
|
||||||
m_needParent = TRUE;
|
m_needParent = true;
|
||||||
m_acceptsFocus = TRUE;
|
m_acceptsFocus = true;
|
||||||
|
|
||||||
if (!PreCreation( parent, pos, size ) ||
|
if (!PreCreation( parent, pos, size ) ||
|
||||||
!CreateBase( parent, id, pos, size, style, validator, name ))
|
!CreateBase( parent, id, pos, size, style, validator, name ))
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( wxT("wxBitmapButton creation failed") );
|
wxFAIL_MSG( wxT("wxBitmapButton creation failed") );
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bmpNormal = bitmap;
|
m_bmpNormal = bitmap;
|
||||||
@@ -175,7 +175,7 @@ bool wxBitmapButton::Create( wxWindow *parent,
|
|||||||
|
|
||||||
PostCreation(size);
|
PostCreation(size);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::SetDefault()
|
void wxBitmapButton::SetDefault()
|
||||||
@@ -195,7 +195,7 @@ void wxBitmapButton::SetLabel( const wxString &label )
|
|||||||
|
|
||||||
wxString wxBitmapButton::GetLabel() const
|
wxString wxBitmapButton::GetLabel() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid button") );
|
wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid button") );
|
||||||
|
|
||||||
return wxControl::GetLabel();
|
return wxControl::GetLabel();
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ void wxBitmapButton::OnSetBitmap()
|
|||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid bitmap button") );
|
wxCHECK_RET( m_widget != NULL, wxT("invalid bitmap button") );
|
||||||
|
|
||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
|
|
||||||
wxBitmap the_one;
|
wxBitmap the_one;
|
||||||
if (!m_isEnabled)
|
if (!m_isEnabled)
|
||||||
the_one = m_bmpDisabled;
|
the_one = m_bmpDisabled;
|
||||||
@@ -222,19 +222,7 @@ void wxBitmapButton::OnSetBitmap()
|
|||||||
else if (m_hasFocus)
|
else if (m_hasFocus)
|
||||||
the_one = m_bmpFocus;
|
the_one = m_bmpFocus;
|
||||||
else
|
else
|
||||||
{
|
the_one = m_bmpNormal;
|
||||||
if (m_isSelected)
|
|
||||||
{
|
|
||||||
the_one = m_bmpSelected;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_hasFocus)
|
|
||||||
the_one = m_bmpFocus;
|
|
||||||
else
|
|
||||||
the_one = m_bmpNormal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!the_one.Ok()) the_one = m_bmpNormal;
|
if (!the_one.Ok()) the_one = m_bmpNormal;
|
||||||
if (!the_one.Ok()) return;
|
if (!the_one.Ok()) return;
|
||||||
@@ -281,34 +269,34 @@ wxSize wxBitmapButton::DoGetBestSize() const
|
|||||||
bool wxBitmapButton::Enable( bool enable )
|
bool wxBitmapButton::Enable( bool enable )
|
||||||
{
|
{
|
||||||
if ( !wxWindow::Enable(enable) )
|
if ( !wxWindow::Enable(enable) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::HasFocus()
|
void wxBitmapButton::HasFocus()
|
||||||
{
|
{
|
||||||
m_hasFocus = TRUE;
|
m_hasFocus = true;
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::NotFocus()
|
void wxBitmapButton::NotFocus()
|
||||||
{
|
{
|
||||||
m_hasFocus = FALSE;
|
m_hasFocus = false;
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::StartSelect()
|
void wxBitmapButton::StartSelect()
|
||||||
{
|
{
|
||||||
m_isSelected = TRUE;
|
m_isSelected = true;
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::EndSelect()
|
void wxBitmapButton::EndSelect()
|
||||||
{
|
{
|
||||||
m_isSelected = FALSE;
|
m_isSelected = false;
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -883,7 +883,7 @@ void wxTextCtrl::CalculateScrollbar()
|
|||||||
|
|
||||||
wxString wxTextCtrl::GetValue() const
|
wxString wxTextCtrl::GetValue() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_text != NULL, wxT(""), wxT("invalid text ctrl") );
|
wxCHECK_MSG( m_text != NULL, wxEmptyString, wxT("invalid text ctrl") );
|
||||||
|
|
||||||
wxString tmp;
|
wxString tmp;
|
||||||
if (m_windowStyle & wxTE_MULTILINE)
|
if (m_windowStyle & wxTE_MULTILINE)
|
||||||
@@ -1071,7 +1071,7 @@ wxString wxTextCtrl::GetLineText( long lineNo ) const
|
|||||||
|
|
||||||
if (text)
|
if (text)
|
||||||
{
|
{
|
||||||
wxString buf(wxT(""));
|
wxString buf;
|
||||||
long i;
|
long i;
|
||||||
int currentLine = 0;
|
int currentLine = 0;
|
||||||
for (i = 0; currentLine != lineNo && text[i]; i++ )
|
for (i = 0; currentLine != lineNo && text[i]; i++ )
|
||||||
@@ -1725,7 +1725,7 @@ bool wxTextCtrl::IsModified() const
|
|||||||
|
|
||||||
void wxTextCtrl::Clear()
|
void wxTextCtrl::Clear()
|
||||||
{
|
{
|
||||||
SetValue( wxT("") );
|
SetValue( wxEmptyString );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::OnChar( wxKeyEvent &key_event )
|
void wxTextCtrl::OnChar( wxKeyEvent &key_event )
|
||||||
@@ -1896,6 +1896,7 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
|
|||||||
// nothing to do
|
// nothing to do
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
gint l = gtk_text_buffer_get_char_count( m_buffer );
|
gint l = gtk_text_buffer_get_char_count( m_buffer );
|
||||||
|
|
||||||
@@ -1912,8 +1913,6 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
|
|||||||
wxTextAttr attr = wxTextAttr::Combine(style, m_defaultStyle, this);
|
wxTextAttr attr = wxTextAttr::Combine(style, m_defaultStyle, this);
|
||||||
|
|
||||||
wxGtkTextApplyTagsFromAttr( m_buffer, attr, &starti, &endi );
|
wxGtkTextApplyTagsFromAttr( m_buffer, attr, &starti, &endi );
|
||||||
|
|
||||||
return true;
|
|
||||||
#else
|
#else
|
||||||
// VERY dirty way to do that - removes the required text and re-adds it
|
// VERY dirty way to do that - removes the required text and re-adds it
|
||||||
// with styling (FIXME)
|
// with styling (FIXME)
|
||||||
@@ -1931,14 +1930,14 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
|
|||||||
gtk_editable_delete_text( GTK_EDITABLE(m_text), start, end );
|
gtk_editable_delete_text( GTK_EDITABLE(m_text), start, end );
|
||||||
gtk_editable_set_position( GTK_EDITABLE(m_text), start );
|
gtk_editable_set_position( GTK_EDITABLE(m_text), start );
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
wxWX2MBbuf buf = tmp.mbc_str();
|
wxWX2MBbuf buf = tmp.mbc_str();
|
||||||
const char *txt = buf;
|
const char *txt = buf;
|
||||||
size_t txtlen = strlen(buf);
|
size_t txtlen = strlen(buf);
|
||||||
#else
|
#else
|
||||||
const char *txt = tmp;
|
const char *txt = tmp;
|
||||||
size_t txtlen = tmp.length();
|
size_t txtlen = tmp.length();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// use the attributes from style which are set in it and fall back
|
// use the attributes from style which are set in it and fall back
|
||||||
// first to the default style and then to the text control default
|
// first to the default style and then to the text control default
|
||||||
@@ -1952,13 +1951,13 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
|
|||||||
gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */
|
gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */
|
||||||
SetInsertionPoint( old_pos );
|
SetInsertionPoint( old_pos );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else // singe line
|
|
||||||
{
|
// else single line
|
||||||
// cannot do this for GTK+'s Entry widget
|
// cannot do this for GTK+'s Entry widget
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
|
void wxTextCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
|
||||||
|
@@ -103,7 +103,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxImage image = bitmap.ConvertToImage();
|
wxImage image = bitmap.ConvertToImage();
|
||||||
if (!image.Ok()) return FALSE;
|
if (!image.Ok()) return false;
|
||||||
|
|
||||||
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
|
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
|
||||||
GdkGC *gc = gdk_gc_new( m_bitmap );
|
GdkGC *gc = gdk_gc_new( m_bitmap );
|
||||||
@@ -183,7 +183,7 @@ bool wxMask::Create( const wxBitmap& bitmap,
|
|||||||
|
|
||||||
gdk_gc_unref( gc );
|
gdk_gc_unref( gc );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
||||||
@@ -191,7 +191,7 @@ bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex )
|
|||||||
unsigned char r,g,b;
|
unsigned char r,g,b;
|
||||||
wxPalette *pal = bitmap.GetPalette();
|
wxPalette *pal = bitmap.GetPalette();
|
||||||
|
|
||||||
wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") );
|
wxCHECK_MSG( pal, false, wxT("Cannot create mask from bitmap without palette") );
|
||||||
|
|
||||||
pal->GetRGB(paletteIndex, &r, &g, &b);
|
pal->GetRGB(paletteIndex, &r, &g, &b);
|
||||||
|
|
||||||
@@ -206,13 +206,13 @@ bool wxMask::Create( const wxBitmap& bitmap )
|
|||||||
m_bitmap = (GdkBitmap*) NULL;
|
m_bitmap = (GdkBitmap*) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bitmap.Ok()) return FALSE;
|
if (!bitmap.Ok()) return false;
|
||||||
|
|
||||||
wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") );
|
wxCHECK_MSG( bitmap.GetBitmap(), false, wxT("Cannot create mask from colour bitmap") );
|
||||||
|
|
||||||
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
|
m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 );
|
||||||
|
|
||||||
if (!m_bitmap) return FALSE;
|
if (!m_bitmap) return false;
|
||||||
|
|
||||||
GdkGC *gc = gdk_gc_new( m_bitmap );
|
GdkGC *gc = gdk_gc_new( m_bitmap );
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ bool wxMask::Create( const wxBitmap& bitmap )
|
|||||||
|
|
||||||
gdk_gc_unref( gc );
|
gdk_gc_unref( gc );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkBitmap *wxMask::GetBitmap() const
|
GdkBitmap *wxMask::GetBitmap() const
|
||||||
@@ -307,7 +307,7 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
if (depth == -1)
|
if (depth == -1)
|
||||||
depth = visual->depth;
|
depth = visual->depth;
|
||||||
|
|
||||||
wxCHECK_MSG( (depth == visual->depth) || (depth == 1) || (depth == 32), FALSE,
|
wxCHECK_MSG( (depth == visual->depth) || (depth == 1) || (depth == 32), false,
|
||||||
wxT("invalid bitmap depth") )
|
wxT("invalid bitmap depth") )
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
@@ -340,7 +340,7 @@ bool wxBitmap::CreateFromXpm( const char **bits )
|
|||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
|
wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") )
|
||||||
|
|
||||||
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ 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") );
|
wxCHECK_MSG( M_BMPDATA->m_pixmap, false, wxT("couldn't create pixmap") );
|
||||||
|
|
||||||
if (mask)
|
if (mask)
|
||||||
{
|
{
|
||||||
@@ -362,7 +362,7 @@ bool wxBitmap::CreateFromXpm( const char **bits )
|
|||||||
|
|
||||||
M_BMPDATA->m_bpp = visual->depth; // Can we get a different depth from create_from_xpm_d() ?
|
M_BMPDATA->m_bpp = visual->depth; // Can we get a different depth from create_from_xpm_d() ?
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, int newx, int newy )
|
wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, int newx, int newy )
|
||||||
@@ -371,12 +371,12 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
|
|
||||||
if (newy==M_BMPDATA->m_width && newy==M_BMPDATA->m_height)
|
if (newy==M_BMPDATA->m_width && newy==M_BMPDATA->m_height)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
int width = wxMax(newx, 1);
|
int width = wxMax(newx, 1);
|
||||||
int height = wxMax(newy, 1);
|
int height = wxMax(newy, 1);
|
||||||
width = wxMin(width, clipwidth);
|
width = wxMin(width, clipwidth);
|
||||||
height = wxMin(height, clipheight);
|
height = wxMin(height, clipheight);
|
||||||
|
|
||||||
wxBitmap bmp;
|
wxBitmap bmp;
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
@@ -390,7 +390,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
8, width, height));
|
8, width, height));
|
||||||
gdk_pixbuf_scale(GetPixbuf(), bmp.GetPixbuf(),
|
gdk_pixbuf_scale(GetPixbuf(), bmp.GetPixbuf(),
|
||||||
0, 0, width, height,
|
0, 0, width, height,
|
||||||
clipx, clipy,
|
clipx, clipy,
|
||||||
(double)newx/GetWidth(), (double)newy/GetHeight(),
|
(double)newx/GetWidth(), (double)newy/GetHeight(),
|
||||||
GDK_INTERP_BILINEAR);
|
GDK_INTERP_BILINEAR);
|
||||||
}
|
}
|
||||||
@@ -409,7 +409,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
|
|
||||||
int bpp = -1;
|
int bpp = -1;
|
||||||
|
|
||||||
|
|
||||||
GdkGC *gc = NULL;
|
GdkGC *gc = NULL;
|
||||||
GdkPixmap *dstpix = NULL;
|
GdkPixmap *dstpix = NULL;
|
||||||
if (GetPixmap())
|
if (GetPixmap())
|
||||||
@@ -426,7 +426,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
|
|
||||||
char *dst = NULL;
|
char *dst = NULL;
|
||||||
long dstbyteperline = 0;
|
long dstbyteperline = 0;
|
||||||
|
|
||||||
if (GetBitmap())
|
if (GetBitmap())
|
||||||
{
|
{
|
||||||
bpp = 1;
|
bpp = 1;
|
||||||
@@ -435,7 +435,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
dstbyteperline++;
|
dstbyteperline++;
|
||||||
dst = (char*) malloc(dstbyteperline*height);
|
dst = (char*) malloc(dstbyteperline*height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// be careful to use the right scaling factor
|
// be careful to use the right scaling factor
|
||||||
float scx = (float)M_BMPDATA->m_width/(float)newx;
|
float scx = (float)M_BMPDATA->m_width/(float)newx;
|
||||||
float scy = (float)M_BMPDATA->m_height/(float)newy;
|
float scy = (float)M_BMPDATA->m_height/(float)newy;
|
||||||
@@ -468,7 +468,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
old_pixval = pixval;
|
old_pixval = pixval;
|
||||||
old_x = x;
|
old_x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bpp == 1)
|
if (bpp == 1)
|
||||||
{
|
{
|
||||||
if (!pixval)
|
if (!pixval)
|
||||||
@@ -477,7 +477,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
char shift = bit << w % 8;
|
char shift = bit << w % 8;
|
||||||
outbyte |= shift;
|
outbyte |= shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((w+1)%8==0)
|
if ((w+1)%8==0)
|
||||||
{
|
{
|
||||||
dst[h*dstbyteperline+w/8] = outbyte;
|
dst[h*dstbyteperline+w/8] = outbyte;
|
||||||
@@ -492,12 +492,12 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
gdk_draw_point( dstpix, gc, w, h);
|
gdk_draw_point( dstpix, gc, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not forget the last byte
|
// do not forget the last byte
|
||||||
if ((bpp == 1) && (width % 8 != 0))
|
if ((bpp == 1) && (width % 8 != 0))
|
||||||
dst[h*dstbyteperline+width/8] = outbyte;
|
dst[h*dstbyteperline+width/8] = outbyte;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_image_destroy( img );
|
gdk_image_destroy( img );
|
||||||
if (gc) gdk_gc_unref( gc );
|
if (gc) gdk_gc_unref( gc );
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
bmp = wxBitmap( (const char *)dst, width, height, 1 );
|
bmp = wxBitmap( (const char *)dst, width, height, 1 );
|
||||||
free( dst );
|
free( dst );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetMask())
|
if (GetMask())
|
||||||
{
|
{
|
||||||
dstbyteperline = width/8;
|
dstbyteperline = width/8;
|
||||||
@@ -520,7 +520,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
char outbyte = 0;
|
char outbyte = 0;
|
||||||
int old_x = -1;
|
int old_x = -1;
|
||||||
guint32 old_pixval = 0;
|
guint32 old_pixval = 0;
|
||||||
|
|
||||||
for (int w = 0; w < width; w++)
|
for (int w = 0; w < width; w++)
|
||||||
{
|
{
|
||||||
guint32 pixval;
|
guint32 pixval;
|
||||||
@@ -533,21 +533,21 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
old_pixval = pixval;
|
old_pixval = pixval;
|
||||||
old_x = x;
|
old_x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pixval)
|
if (pixval)
|
||||||
{
|
{
|
||||||
char bit=1;
|
char bit=1;
|
||||||
char shift = bit << w % 8;
|
char shift = bit << w % 8;
|
||||||
outbyte |= shift;
|
outbyte |= shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((w+1)%8 == 0)
|
if ((w+1)%8 == 0)
|
||||||
{
|
{
|
||||||
dst[h*dstbyteperline+w/8] = outbyte;
|
dst[h*dstbyteperline+w/8] = outbyte;
|
||||||
outbyte = 0;
|
outbyte = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not forget the last byte
|
// do not forget the last byte
|
||||||
if (width % 8 != 0)
|
if (width % 8 != 0)
|
||||||
dst[h*dstbyteperline+width/8] = outbyte;
|
dst[h*dstbyteperline+width/8] = outbyte;
|
||||||
@@ -563,20 +563,20 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
free( tablex );
|
free( tablex );
|
||||||
free( tabley );
|
free( tabley );
|
||||||
}
|
}
|
||||||
|
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
|
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
wxCHECK_MSG( image.Ok(), false, wxT("invalid image") )
|
||||||
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
|
wxCHECK_MSG( depth == -1 || depth == 1, false, wxT("invalid bitmap depth") )
|
||||||
|
|
||||||
if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
|
if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData();
|
m_refData = new wxBitmapRefData();
|
||||||
|
|
||||||
if (depth == 1)
|
if (depth == 1)
|
||||||
@@ -599,7 +599,7 @@ bool wxBitmap::CreateFromImageAsBitmap(const wxImage& img)
|
|||||||
// convert alpha channel to mask, if it is present:
|
// convert alpha channel to mask, if it is present:
|
||||||
wxImage image(img);
|
wxImage image(img);
|
||||||
image.ConvertAlphaToMask();
|
image.ConvertAlphaToMask();
|
||||||
|
|
||||||
int width = image.GetWidth();
|
int width = image.GetWidth();
|
||||||
int height = image.GetHeight();
|
int height = image.GetHeight();
|
||||||
|
|
||||||
@@ -692,14 +692,14 @@ bool wxBitmap::CreateFromImageAsBitmap(const wxImage& img)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// conversion to colour bitmap:
|
// conversion to colour bitmap:
|
||||||
bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
||||||
{
|
{
|
||||||
// convert alpha channel to mask, if it is present:
|
// convert alpha channel to mask, if it is present:
|
||||||
wxImage image(img);
|
wxImage image(img);
|
||||||
image.ConvertAlphaToMask();
|
image.ConvertAlphaToMask();
|
||||||
|
|
||||||
int width = image.GetWidth();
|
int width = image.GetWidth();
|
||||||
int height = image.GetHeight();
|
int height = image.GetHeight();
|
||||||
|
|
||||||
@@ -728,12 +728,12 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
|||||||
if (!image.HasMask() && (bpp > 12))
|
if (!image.HasMask() && (bpp > 12))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
static bool s_hasInitialized = FALSE;
|
static bool s_hasInitialized = false;
|
||||||
|
|
||||||
if (!s_hasInitialized)
|
if (!s_hasInitialized)
|
||||||
{
|
{
|
||||||
gdk_rgb_init();
|
gdk_rgb_init();
|
||||||
s_hasInitialized = TRUE;
|
s_hasInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GdkGC *gc = gdk_gc_new( GetPixmap() );
|
GdkGC *gc = gdk_gc_new( GetPixmap() );
|
||||||
@@ -747,7 +747,7 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
|||||||
width*3 );
|
width*3 );
|
||||||
|
|
||||||
gdk_gc_unref( gc );
|
gdk_gc_unref( gc );
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create picture image
|
// Create picture image
|
||||||
@@ -902,6 +902,7 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
|
|||||||
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
case GBR: pixel = (g << 16) | (b << 8) | r; break;
|
||||||
}
|
}
|
||||||
gdk_image_put_pixel( data_image, x, y, pixel );
|
gdk_image_put_pixel( data_image, x, y, pixel );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@@ -949,17 +950,17 @@ bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
|
|||||||
wxASSERT( gdk_pixbuf_get_n_channels(pixbuf) == 4 );
|
wxASSERT( gdk_pixbuf_get_n_channels(pixbuf) == 4 );
|
||||||
wxASSERT( gdk_pixbuf_get_width(pixbuf) == width );
|
wxASSERT( gdk_pixbuf_get_width(pixbuf) == width );
|
||||||
wxASSERT( gdk_pixbuf_get_height(pixbuf) == height );
|
wxASSERT( gdk_pixbuf_get_height(pixbuf) == height );
|
||||||
|
|
||||||
M_BMPDATA->m_pixbuf = pixbuf;
|
M_BMPDATA->m_pixbuf = pixbuf;
|
||||||
SetHeight(height);
|
SetHeight(height);
|
||||||
SetWidth(width);
|
SetWidth(width);
|
||||||
SetDepth(wxTheApp->GetGdkVisual()->depth);
|
SetDepth(wxTheApp->GetGdkVisual()->depth);
|
||||||
|
|
||||||
// Copy the data:
|
// Copy the data:
|
||||||
unsigned char *in = image.GetData();
|
unsigned char *in = image.GetData();
|
||||||
unsigned char *out = gdk_pixbuf_get_pixels(pixbuf);
|
unsigned char *out = gdk_pixbuf_get_pixels(pixbuf);
|
||||||
unsigned char *alpha = image.GetAlpha();
|
unsigned char *alpha = image.GetAlpha();
|
||||||
|
|
||||||
int rowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * width;
|
int rowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * width;
|
||||||
|
|
||||||
for (int y = 0; y < height; y++, out += rowinc)
|
for (int y = 0; y < height; y++, out += rowinc)
|
||||||
@@ -972,7 +973,7 @@ bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
|
|||||||
out[3] = *alpha;
|
out[3] = *alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // __WXGTK20__
|
#endif // __WXGTK20__
|
||||||
@@ -982,7 +983,7 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
wxImage image;
|
wxImage image;
|
||||||
|
|
||||||
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
|
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
|
||||||
|
|
||||||
image.Create(GetWidth(), GetHeight());
|
image.Create(GetWidth(), GetHeight());
|
||||||
unsigned char *data = image.GetData();
|
unsigned char *data = image.GetData();
|
||||||
|
|
||||||
@@ -997,10 +998,10 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf = GetPixbuf();
|
GdkPixbuf *pixbuf = GetPixbuf();
|
||||||
wxASSERT( gdk_pixbuf_get_has_alpha(pixbuf) );
|
wxASSERT( gdk_pixbuf_get_has_alpha(pixbuf) );
|
||||||
|
|
||||||
int w = GetWidth();
|
int w = GetWidth();
|
||||||
int h = GetHeight();
|
int h = GetHeight();
|
||||||
|
|
||||||
image.SetAlpha();
|
image.SetAlpha();
|
||||||
|
|
||||||
unsigned char *alpha = image.GetAlpha();
|
unsigned char *alpha = image.GetAlpha();
|
||||||
@@ -1067,7 +1068,7 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
int red_shift_left = 0;
|
int red_shift_left = 0;
|
||||||
int green_shift_left = 0;
|
int green_shift_left = 0;
|
||||||
int blue_shift_left = 0;
|
int blue_shift_left = 0;
|
||||||
bool use_shift = FALSE;
|
bool use_shift = false;
|
||||||
|
|
||||||
if (GetPixmap())
|
if (GetPixmap())
|
||||||
{
|
{
|
||||||
@@ -1218,12 +1219,12 @@ bool wxBitmap::operator != ( const wxBitmap& bmp ) const
|
|||||||
|
|
||||||
bool wxBitmap::Ok() const
|
bool wxBitmap::Ok() const
|
||||||
{
|
{
|
||||||
return (m_refData != NULL) &&
|
return (m_refData != NULL) &&
|
||||||
(
|
(
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
M_BMPDATA->m_pixbuf ||
|
M_BMPDATA->m_pixbuf ||
|
||||||
#endif
|
#endif
|
||||||
M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap
|
M_BMPDATA->m_bitmap || M_BMPDATA->m_pixmap
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,7 +1268,7 @@ void wxBitmap::SetMask( wxMask *mask )
|
|||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
||||||
{
|
{
|
||||||
*this = icon;
|
*this = icon;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
||||||
@@ -1335,7 +1336,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
|||||||
|
|
||||||
bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalette *WXUNUSED(palette) ) const
|
bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalette *WXUNUSED(palette) ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );
|
wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") );
|
||||||
|
|
||||||
// Try to save the bitmap via wxImage handlers:
|
// Try to save the bitmap via wxImage handlers:
|
||||||
{
|
{
|
||||||
@@ -1343,7 +1344,7 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett
|
|||||||
if (image.Ok()) return image.SaveFile( name, type );
|
if (image.Ok()) return image.SaveFile( name, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
|
bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
|
||||||
@@ -1351,7 +1352,7 @@ bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
|
|||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
if (!wxFileExists(name))
|
if (!wxFileExists(name))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
||||||
|
|
||||||
@@ -1383,12 +1384,12 @@ bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
|
|||||||
{
|
{
|
||||||
wxImage image;
|
wxImage image;
|
||||||
if ( !image.LoadFile( name, type ) || !image.Ok() )
|
if ( !image.LoadFile( name, type ) || !image.Ok() )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
*this = wxBitmap(image);
|
*this = wxBitmap(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPalette *wxBitmap::GetPalette() const
|
wxPalette *wxBitmap::GetPalette() const
|
||||||
@@ -1493,18 +1494,18 @@ GdkPixbuf *wxBitmap::GetPixbuf() const
|
|||||||
{
|
{
|
||||||
int width = GetWidth();
|
int width = GetWidth();
|
||||||
int height = GetHeight();
|
int height = GetHeight();
|
||||||
|
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
||||||
GetMask() != NULL,
|
GetMask() != NULL,
|
||||||
8, width, height);
|
8, width, height);
|
||||||
M_BMPDATA->m_pixbuf =
|
M_BMPDATA->m_pixbuf =
|
||||||
gdk_pixbuf_get_from_drawable(pixbuf, M_BMPDATA->m_pixmap, NULL,
|
gdk_pixbuf_get_from_drawable(pixbuf, M_BMPDATA->m_pixmap, NULL,
|
||||||
0, 0, 0, 0, width, height);
|
0, 0, 0, 0, width, height);
|
||||||
|
|
||||||
// apply the mask to created pixbuf:
|
// apply the mask to created pixbuf:
|
||||||
if (M_BMPDATA->m_pixbuf && M_BMPDATA->m_mask)
|
if (M_BMPDATA->m_pixbuf && M_BMPDATA->m_mask)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pmask =
|
GdkPixbuf *pmask =
|
||||||
gdk_pixbuf_get_from_drawable(NULL,
|
gdk_pixbuf_get_from_drawable(NULL,
|
||||||
M_BMPDATA->m_mask->GetBitmap(),
|
M_BMPDATA->m_mask->GetBitmap(),
|
||||||
NULL,
|
NULL,
|
||||||
@@ -1525,7 +1526,7 @@ GdkPixbuf *wxBitmap::GetPixbuf() const
|
|||||||
bmp[3] = 0;
|
bmp[3] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_pixbuf_unref(pmask);
|
gdk_pixbuf_unref(pmask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1571,26 +1572,26 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
if (bpp != 32)
|
if (bpp != 32)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
GdkPixbuf *pixbuf = GetPixbuf();
|
GdkPixbuf *pixbuf = GetPixbuf();
|
||||||
if (!pixbuf)
|
if (!pixbuf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (gdk_pixbuf_get_has_alpha( pixbuf ))
|
if (gdk_pixbuf_get_has_alpha( pixbuf ))
|
||||||
wxPrintf( wxT("Has alpha\n") );
|
wxPrintf( wxT("Has alpha\n") );
|
||||||
else
|
else
|
||||||
wxPrintf( wxT("No alpha.\n") );
|
wxPrintf( wxT("No alpha.\n") );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data.m_height = gdk_pixbuf_get_height( pixbuf );
|
data.m_height = gdk_pixbuf_get_height( pixbuf );
|
||||||
data.m_width = gdk_pixbuf_get_width( pixbuf );
|
data.m_width = gdk_pixbuf_get_width( pixbuf );
|
||||||
data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
|
data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
|
||||||
|
|
||||||
return gdk_pixbuf_get_pixels( pixbuf );
|
return gdk_pixbuf_get_pixels( pixbuf );
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
||||||
@@ -1598,7 +1599,7 @@ void wxBitmap::UngetRawData(wxPixelDataBase& data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxBitmap::HasAlpha() const
|
bool wxBitmap::HasAlpha() const
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
return HasPixbuf();
|
return HasPixbuf();
|
||||||
@@ -1608,7 +1609,7 @@ bool wxBitmap::HasAlpha() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmap::UseAlpha()
|
void wxBitmap::UseAlpha()
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
GetPixbuf();
|
GetPixbuf();
|
||||||
#endif
|
#endif
|
||||||
@@ -1626,18 +1627,18 @@ wxBitmapHandler::~wxBitmapHandler()
|
|||||||
|
|
||||||
bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
|
bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||||
int desiredWidth, int desiredHeight)
|
int desiredWidth, int desiredHeight)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
|
bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void wxBitmap::InitStandardHandlers()
|
/* static */ void wxBitmap::InitStandardHandlers()
|
||||||
|
@@ -125,7 +125,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxButton)
|
|||||||
void wxBitmapButton::Init()
|
void wxBitmapButton::Init()
|
||||||
{
|
{
|
||||||
m_hasFocus =
|
m_hasFocus =
|
||||||
m_isSelected = FALSE;
|
m_isSelected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapButton::Create( wxWindow *parent,
|
bool wxBitmapButton::Create( wxWindow *parent,
|
||||||
@@ -137,14 +137,14 @@ bool wxBitmapButton::Create( wxWindow *parent,
|
|||||||
const wxValidator& validator,
|
const wxValidator& validator,
|
||||||
const wxString &name )
|
const wxString &name )
|
||||||
{
|
{
|
||||||
m_needParent = TRUE;
|
m_needParent = true;
|
||||||
m_acceptsFocus = TRUE;
|
m_acceptsFocus = true;
|
||||||
|
|
||||||
if (!PreCreation( parent, pos, size ) ||
|
if (!PreCreation( parent, pos, size ) ||
|
||||||
!CreateBase( parent, id, pos, size, style, validator, name ))
|
!CreateBase( parent, id, pos, size, style, validator, name ))
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( wxT("wxBitmapButton creation failed") );
|
wxFAIL_MSG( wxT("wxBitmapButton creation failed") );
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bmpNormal = bitmap;
|
m_bmpNormal = bitmap;
|
||||||
@@ -175,7 +175,7 @@ bool wxBitmapButton::Create( wxWindow *parent,
|
|||||||
|
|
||||||
PostCreation(size);
|
PostCreation(size);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::SetDefault()
|
void wxBitmapButton::SetDefault()
|
||||||
@@ -195,7 +195,7 @@ void wxBitmapButton::SetLabel( const wxString &label )
|
|||||||
|
|
||||||
wxString wxBitmapButton::GetLabel() const
|
wxString wxBitmapButton::GetLabel() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid button") );
|
wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid button") );
|
||||||
|
|
||||||
return wxControl::GetLabel();
|
return wxControl::GetLabel();
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ void wxBitmapButton::OnSetBitmap()
|
|||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid bitmap button") );
|
wxCHECK_RET( m_widget != NULL, wxT("invalid bitmap button") );
|
||||||
|
|
||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
|
|
||||||
wxBitmap the_one;
|
wxBitmap the_one;
|
||||||
if (!m_isEnabled)
|
if (!m_isEnabled)
|
||||||
the_one = m_bmpDisabled;
|
the_one = m_bmpDisabled;
|
||||||
@@ -222,19 +222,7 @@ void wxBitmapButton::OnSetBitmap()
|
|||||||
else if (m_hasFocus)
|
else if (m_hasFocus)
|
||||||
the_one = m_bmpFocus;
|
the_one = m_bmpFocus;
|
||||||
else
|
else
|
||||||
{
|
the_one = m_bmpNormal;
|
||||||
if (m_isSelected)
|
|
||||||
{
|
|
||||||
the_one = m_bmpSelected;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_hasFocus)
|
|
||||||
the_one = m_bmpFocus;
|
|
||||||
else
|
|
||||||
the_one = m_bmpNormal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!the_one.Ok()) the_one = m_bmpNormal;
|
if (!the_one.Ok()) the_one = m_bmpNormal;
|
||||||
if (!the_one.Ok()) return;
|
if (!the_one.Ok()) return;
|
||||||
@@ -281,34 +269,34 @@ wxSize wxBitmapButton::DoGetBestSize() const
|
|||||||
bool wxBitmapButton::Enable( bool enable )
|
bool wxBitmapButton::Enable( bool enable )
|
||||||
{
|
{
|
||||||
if ( !wxWindow::Enable(enable) )
|
if ( !wxWindow::Enable(enable) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::HasFocus()
|
void wxBitmapButton::HasFocus()
|
||||||
{
|
{
|
||||||
m_hasFocus = TRUE;
|
m_hasFocus = true;
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::NotFocus()
|
void wxBitmapButton::NotFocus()
|
||||||
{
|
{
|
||||||
m_hasFocus = FALSE;
|
m_hasFocus = false;
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::StartSelect()
|
void wxBitmapButton::StartSelect()
|
||||||
{
|
{
|
||||||
m_isSelected = TRUE;
|
m_isSelected = true;
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapButton::EndSelect()
|
void wxBitmapButton::EndSelect()
|
||||||
{
|
{
|
||||||
m_isSelected = FALSE;
|
m_isSelected = false;
|
||||||
OnSetBitmap();
|
OnSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -883,7 +883,7 @@ void wxTextCtrl::CalculateScrollbar()
|
|||||||
|
|
||||||
wxString wxTextCtrl::GetValue() const
|
wxString wxTextCtrl::GetValue() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_text != NULL, wxT(""), wxT("invalid text ctrl") );
|
wxCHECK_MSG( m_text != NULL, wxEmptyString, wxT("invalid text ctrl") );
|
||||||
|
|
||||||
wxString tmp;
|
wxString tmp;
|
||||||
if (m_windowStyle & wxTE_MULTILINE)
|
if (m_windowStyle & wxTE_MULTILINE)
|
||||||
@@ -1071,7 +1071,7 @@ wxString wxTextCtrl::GetLineText( long lineNo ) const
|
|||||||
|
|
||||||
if (text)
|
if (text)
|
||||||
{
|
{
|
||||||
wxString buf(wxT(""));
|
wxString buf;
|
||||||
long i;
|
long i;
|
||||||
int currentLine = 0;
|
int currentLine = 0;
|
||||||
for (i = 0; currentLine != lineNo && text[i]; i++ )
|
for (i = 0; currentLine != lineNo && text[i]; i++ )
|
||||||
@@ -1725,7 +1725,7 @@ bool wxTextCtrl::IsModified() const
|
|||||||
|
|
||||||
void wxTextCtrl::Clear()
|
void wxTextCtrl::Clear()
|
||||||
{
|
{
|
||||||
SetValue( wxT("") );
|
SetValue( wxEmptyString );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::OnChar( wxKeyEvent &key_event )
|
void wxTextCtrl::OnChar( wxKeyEvent &key_event )
|
||||||
@@ -1896,6 +1896,7 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
|
|||||||
// nothing to do
|
// nothing to do
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
gint l = gtk_text_buffer_get_char_count( m_buffer );
|
gint l = gtk_text_buffer_get_char_count( m_buffer );
|
||||||
|
|
||||||
@@ -1912,8 +1913,6 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
|
|||||||
wxTextAttr attr = wxTextAttr::Combine(style, m_defaultStyle, this);
|
wxTextAttr attr = wxTextAttr::Combine(style, m_defaultStyle, this);
|
||||||
|
|
||||||
wxGtkTextApplyTagsFromAttr( m_buffer, attr, &starti, &endi );
|
wxGtkTextApplyTagsFromAttr( m_buffer, attr, &starti, &endi );
|
||||||
|
|
||||||
return true;
|
|
||||||
#else
|
#else
|
||||||
// VERY dirty way to do that - removes the required text and re-adds it
|
// VERY dirty way to do that - removes the required text and re-adds it
|
||||||
// with styling (FIXME)
|
// with styling (FIXME)
|
||||||
@@ -1931,14 +1930,14 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
|
|||||||
gtk_editable_delete_text( GTK_EDITABLE(m_text), start, end );
|
gtk_editable_delete_text( GTK_EDITABLE(m_text), start, end );
|
||||||
gtk_editable_set_position( GTK_EDITABLE(m_text), start );
|
gtk_editable_set_position( GTK_EDITABLE(m_text), start );
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
wxWX2MBbuf buf = tmp.mbc_str();
|
wxWX2MBbuf buf = tmp.mbc_str();
|
||||||
const char *txt = buf;
|
const char *txt = buf;
|
||||||
size_t txtlen = strlen(buf);
|
size_t txtlen = strlen(buf);
|
||||||
#else
|
#else
|
||||||
const char *txt = tmp;
|
const char *txt = tmp;
|
||||||
size_t txtlen = tmp.length();
|
size_t txtlen = tmp.length();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// use the attributes from style which are set in it and fall back
|
// use the attributes from style which are set in it and fall back
|
||||||
// first to the default style and then to the text control default
|
// first to the default style and then to the text control default
|
||||||
@@ -1952,13 +1951,13 @@ bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style )
|
|||||||
gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */
|
gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */
|
||||||
SetInsertionPoint( old_pos );
|
SetInsertionPoint( old_pos );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else // singe line
|
|
||||||
{
|
// else single line
|
||||||
// cannot do this for GTK+'s Entry widget
|
// cannot do this for GTK+'s Entry widget
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
|
void wxTextCtrl::DoApplyWidgetStyle(GtkRcStyle *style)
|
||||||
|
@@ -309,14 +309,10 @@ void wxHtmlParser::DoParsing(int begin_pos, int end_pos)
|
|||||||
}
|
}
|
||||||
else if (m_CurTag)
|
else if (m_CurTag)
|
||||||
{
|
{
|
||||||
// Add tag:
|
if (m_CurTag->HasEnding())
|
||||||
if (m_CurTag)
|
begin_pos = m_CurTag->GetEndPos2();
|
||||||
{
|
else
|
||||||
if (m_CurTag->HasEnding())
|
begin_pos = m_CurTag->GetBeginPos();
|
||||||
begin_pos = m_CurTag->GetEndPos2();
|
|
||||||
else
|
|
||||||
begin_pos = m_CurTag->GetBeginPos();
|
|
||||||
}
|
|
||||||
wxHtmlTag *t = m_CurTag;
|
wxHtmlTag *t = m_CurTag;
|
||||||
m_CurTag = m_CurTag->GetNextTag();
|
m_CurTag = m_CurTag->GetNextTag();
|
||||||
AddTag(*t);
|
AddTag(*t);
|
||||||
|
@@ -72,7 +72,7 @@ extern wxList wxPendingDelete;
|
|||||||
// set wxMAC_USE_RAEL to 1 if RunApplicationEventLoop should be used
|
// set wxMAC_USE_RAEL to 1 if RunApplicationEventLoop should be used
|
||||||
// if 0 the lower level CarbonEventLoop will be used
|
// if 0 the lower level CarbonEventLoop will be used
|
||||||
// on the long run RAEL should replace the low level event loop
|
// on the long run RAEL should replace the low level event loop
|
||||||
// we will have to clean up event handling to make sure we don't
|
// we will have to clean up event handling to make sure we don't
|
||||||
// miss handling of things like pending events etc
|
// miss handling of things like pending events etc
|
||||||
// perhaps we will also have to pipe events through an ueber-event-handler
|
// perhaps we will also have to pipe events through an ueber-event-handler
|
||||||
// to make sure we have one place to do all these house-keeping functions
|
// to make sure we have one place to do all these house-keeping functions
|
||||||
@@ -85,9 +85,9 @@ extern size_t g_numberOfThreads;
|
|||||||
|
|
||||||
// statics for implementation
|
// statics for implementation
|
||||||
|
|
||||||
static bool s_inYield = FALSE;
|
static bool s_inYield = false;
|
||||||
|
|
||||||
static bool s_inReceiveEvent = FALSE ;
|
static bool s_inReceiveEvent = false ;
|
||||||
static EventTime sleepTime = kEventDurationNoWait ;
|
static EventTime sleepTime = kEventDurationNoWait ;
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
|
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
|
||||||
@@ -178,7 +178,7 @@ short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
|
|||||||
PSN.lowLongOfPSN = kCurrentProcess ;
|
PSN.lowLongOfPSN = kCurrentProcess ;
|
||||||
SetFrontProcess( &PSN ) ;
|
SetFrontProcess( &PSN ) ;
|
||||||
|
|
||||||
for (i = 1; i <= itemsInList; i++)
|
for (i = 1; i <= itemsInList; i++)
|
||||||
{
|
{
|
||||||
wxString fName ;
|
wxString fName ;
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNU
|
|||||||
{
|
{
|
||||||
wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId);
|
wxCommandEvent exitEvent(wxEVT_COMMAND_MENU_SELECTED, s_macExitMenuItemId);
|
||||||
if (!win->ProcessEvent(exitEvent))
|
if (!win->ProcessEvent(exitEvent))
|
||||||
win->Close(TRUE ) ;
|
win->Close(true) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -297,7 +297,7 @@ void wxApp::MacPrintFile(const wxString & fileName )
|
|||||||
if (printout)
|
if (printout)
|
||||||
{
|
{
|
||||||
wxPrinter printer;
|
wxPrinter printer;
|
||||||
printer.Print(view->GetFrame(), printout, TRUE);
|
printer.Print(view->GetFrame(), printout, true);
|
||||||
delete printout;
|
delete printout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,10 +325,10 @@ void wxApp::MacReopenApp()
|
|||||||
// if there is no open window -> create a new one
|
// if there is no open window -> create a new one
|
||||||
// if all windows are hidden -> show the first
|
// if all windows are hidden -> show the first
|
||||||
// if some windows are not hidden -> do nothing
|
// if some windows are not hidden -> do nothing
|
||||||
|
|
||||||
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
|
wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst();
|
||||||
if ( node == NULL )
|
if ( node == NULL )
|
||||||
{
|
{
|
||||||
MacNewFile() ;
|
MacNewFile() ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -383,14 +383,14 @@ static const EventTypeSpec eventList[] =
|
|||||||
|
|
||||||
static pascal OSStatus
|
static pascal OSStatus
|
||||||
wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||||
{
|
{
|
||||||
wxMacCarbonEvent cEvent( event ) ;
|
wxMacCarbonEvent cEvent( event ) ;
|
||||||
MenuRef menuRef = cEvent.GetParameter<MenuRef>(kEventParamDirectObject) ;
|
MenuRef menuRef = cEvent.GetParameter<MenuRef>(kEventParamDirectObject) ;
|
||||||
wxMenu* menu = wxFindMenuFromMacMenu( menuRef ) ;
|
wxMenu* menu = wxFindMenuFromMacMenu( menuRef ) ;
|
||||||
|
|
||||||
if ( menu )
|
if ( menu )
|
||||||
{
|
{
|
||||||
wxEventType type=0;
|
wxEventType type=0;
|
||||||
MenuCommand cmd=0;
|
MenuCommand cmd=0;
|
||||||
switch (GetEventKind(event))
|
switch (GetEventKind(event))
|
||||||
{
|
{
|
||||||
@@ -402,7 +402,7 @@ wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *d
|
|||||||
break;
|
break;
|
||||||
case kEventMenuTargetItem:
|
case kEventMenuTargetItem:
|
||||||
cmd = cEvent.GetParameter<MenuCommand>(kEventParamMenuCommand,typeMenuCommand) ;
|
cmd = cEvent.GetParameter<MenuCommand>(kEventParamMenuCommand,typeMenuCommand) ;
|
||||||
if (cmd != 0)
|
if (cmd != 0)
|
||||||
type = wxEVT_MENU_HIGHLIGHT;
|
type = wxEVT_MENU_HIGHLIGHT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -423,12 +423,12 @@ wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *d
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxWindow *win = menu->GetInvokingWindow();
|
wxWindow *win = menu->GetInvokingWindow();
|
||||||
if (win)
|
if (win)
|
||||||
win->GetEventHandler()->ProcessEvent(wxevent);
|
win->GetEventHandler()->ProcessEvent(wxevent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return eventNotHandledErr;
|
return eventNotHandledErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,14 +440,14 @@ static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler
|
|||||||
|
|
||||||
wxMacCarbonEvent cEvent( event ) ;
|
wxMacCarbonEvent cEvent( event ) ;
|
||||||
cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ;
|
cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ;
|
||||||
|
|
||||||
wxMenuItem* item = NULL ;
|
wxMenuItem* item = NULL ;
|
||||||
MenuCommand id = command.commandID ;
|
MenuCommand id = command.commandID ;
|
||||||
// for items we don't really control
|
// for items we don't really control
|
||||||
if ( id == kHICommandPreferences )
|
if ( id == kHICommandPreferences )
|
||||||
{
|
{
|
||||||
id = wxApp::s_macPreferencesMenuItemId ;
|
id = wxApp::s_macPreferencesMenuItemId ;
|
||||||
|
|
||||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||||
if ( mbar )
|
if ( mbar )
|
||||||
{
|
{
|
||||||
@@ -459,7 +459,7 @@ static pascal OSStatus wxMacAppCommandEventHandler( EventHandlerCallRef handler
|
|||||||
{
|
{
|
||||||
GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , (UInt32*) &item ) ;
|
GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , (UInt32*) &item ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
switch( cEvent.GetKind() )
|
switch( cEvent.GetKind() )
|
||||||
@@ -532,7 +532,7 @@ pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef eve
|
|||||||
case kEventClassMouse :
|
case kEventClassMouse :
|
||||||
{
|
{
|
||||||
wxMacCarbonEvent cEvent( event ) ;
|
wxMacCarbonEvent cEvent( event ) ;
|
||||||
|
|
||||||
WindowRef window ;
|
WindowRef window ;
|
||||||
Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
|
Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
|
||||||
::FindWindow(screenMouseLocation, &window);
|
::FindWindow(screenMouseLocation, &window);
|
||||||
@@ -567,8 +567,8 @@ WXIMPORT char std::__throws_bad_alloc ;
|
|||||||
|
|
||||||
#if __WXDEBUG__
|
#if __WXDEBUG__
|
||||||
|
|
||||||
pascal static void wxMacAssertOutputHandler(OSType componentSignature, UInt32 options,
|
pascal static void wxMacAssertOutputHandler(OSType componentSignature, UInt32 options,
|
||||||
const char *assertionString, const char *exceptionLabelString,
|
const char *assertionString, const char *exceptionLabelString,
|
||||||
const char *errorString, const char *fileName, long lineNumber, void *value, ConstStr255Param outputMsg)
|
const char *errorString, const char *fileName, long lineNumber, void *value, ConstStr255Param outputMsg)
|
||||||
{
|
{
|
||||||
// flow into assert handling
|
// flow into assert handling
|
||||||
@@ -590,10 +590,10 @@ pascal static void wxMacAssertOutputHandler(OSType componentSignature, UInt32 op
|
|||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// flow into log
|
// flow into log
|
||||||
wxLogDebug( wxT("AssertMacros: %s %s %s file: %s, line: %ld (value %p)\n"),
|
wxLogDebug( wxT("AssertMacros: %s %s %s file: %s, line: %ld (value %p)\n"),
|
||||||
assertionStr.c_str() ,
|
assertionStr.c_str() ,
|
||||||
exceptionStr.c_str() ,
|
exceptionStr.c_str() ,
|
||||||
errorStr.c_str(),
|
errorStr.c_str(),
|
||||||
fileNameStr.c_str(), lineNumber ,
|
fileNameStr.c_str(), lineNumber ,
|
||||||
value ) ;
|
value ) ;
|
||||||
#else
|
#else
|
||||||
@@ -675,7 +675,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
CFRelease( url ) ;
|
CFRelease( url ) ;
|
||||||
CFStringRef path = CFURLCopyFileSystemPath ( urlParent , kCFURLPOSIXPathStyle ) ;
|
CFStringRef path = CFURLCopyFileSystemPath ( urlParent , kCFURLPOSIXPathStyle ) ;
|
||||||
CFRelease( urlParent ) ;
|
CFRelease( urlParent ) ;
|
||||||
wxString cwd = wxMacCFStringHolder(path).AsString(wxLocale::GetSystemEncoding());
|
wxString cwd = wxMacCFStringHolder(path).AsString(wxLocale::GetSystemEncoding());
|
||||||
wxSetWorkingDirectory( cwd ) ;
|
wxSetWorkingDirectory( cwd ) ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -736,7 +736,7 @@ bool wxApp::OnInitGui()
|
|||||||
sQuitHandler , 0 , FALSE ) ;
|
sQuitHandler , 0 , FALSE ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxApp::CleanUp()
|
void wxApp::CleanUp()
|
||||||
@@ -774,7 +774,7 @@ void wxApp::CleanUp()
|
|||||||
{
|
{
|
||||||
RemoveEventHandler( (EventHandlerRef)(wxTheApp->m_macEventHandler) );
|
RemoveEventHandler( (EventHandlerRef)(wxTheApp->m_macEventHandler) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sm_isEmbedded)
|
if (!sm_isEmbedded)
|
||||||
{
|
{
|
||||||
AERemoveEventHandler( kCoreEventClass , kAEOpenDocuments ,
|
AERemoveEventHandler( kCoreEventClass , kAEOpenDocuments ,
|
||||||
@@ -787,7 +787,7 @@ void wxApp::CleanUp()
|
|||||||
sRAppHandler , FALSE ) ;
|
sRAppHandler , FALSE ) ;
|
||||||
AERemoveEventHandler( kCoreEventClass , kAEQuitApplication ,
|
AERemoveEventHandler( kCoreEventClass , kAEQuitApplication ,
|
||||||
sQuitHandler , FALSE ) ;
|
sQuitHandler , FALSE ) ;
|
||||||
|
|
||||||
DisposeAEEventHandlerUPP( sODocHandler ) ;
|
DisposeAEEventHandlerUPP( sODocHandler ) ;
|
||||||
DisposeAEEventHandlerUPP( sOAppHandler ) ;
|
DisposeAEEventHandlerUPP( sOAppHandler ) ;
|
||||||
DisposeAEEventHandlerUPP( sPDocHandler ) ;
|
DisposeAEEventHandlerUPP( sPDocHandler ) ;
|
||||||
@@ -917,7 +917,7 @@ wxApp::wxApp()
|
|||||||
|
|
||||||
int wxApp::MainLoop()
|
int wxApp::MainLoop()
|
||||||
{
|
{
|
||||||
m_keepGoing = TRUE;
|
m_keepGoing = true;
|
||||||
#if wxMAC_USE_RAEL
|
#if wxMAC_USE_RAEL
|
||||||
RunApplicationEventLoop() ;
|
RunApplicationEventLoop() ;
|
||||||
#else
|
#else
|
||||||
@@ -931,7 +931,7 @@ int wxApp::MainLoop()
|
|||||||
|
|
||||||
void wxApp::ExitMainLoop()
|
void wxApp::ExitMainLoop()
|
||||||
{
|
{
|
||||||
m_keepGoing = FALSE;
|
m_keepGoing = false;
|
||||||
#if wxMAC_USE_RAEL
|
#if wxMAC_USE_RAEL
|
||||||
QuitApplicationEventLoop() ;
|
QuitApplicationEventLoop() ;
|
||||||
#endif
|
#endif
|
||||||
@@ -943,7 +943,7 @@ bool wxApp::Pending()
|
|||||||
// without the receive event (with pull param = false ) nothing is ever reported
|
// without the receive event (with pull param = false ) nothing is ever reported
|
||||||
EventRef theEvent;
|
EventRef theEvent;
|
||||||
ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &theEvent);
|
ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &theEvent);
|
||||||
return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ;
|
return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch a message.
|
// Dispatch a message.
|
||||||
@@ -987,7 +987,7 @@ void wxApp::Exit()
|
|||||||
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
|
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if (GetTopWindow())
|
if (GetTopWindow())
|
||||||
GetTopWindow()->Close(TRUE);
|
GetTopWindow()->Close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default behaviour: close the application with prompts. The
|
// Default behaviour: close the application with prompts. The
|
||||||
@@ -997,7 +997,7 @@ void wxApp::OnQueryEndSession(wxCloseEvent& event)
|
|||||||
if (GetTopWindow())
|
if (GetTopWindow())
|
||||||
{
|
{
|
||||||
if (!GetTopWindow()->Close(!event.CanVeto()))
|
if (!GetTopWindow()->Close(!event.CanVeto()))
|
||||||
event.Veto(TRUE);
|
event.Veto(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,10 +1018,10 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
wxFAIL_MSG( wxT("wxYield called recursively" ) );
|
wxFAIL_MSG( wxT("wxYield called recursively" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_inYield = TRUE;
|
s_inYield = true;
|
||||||
|
|
||||||
// by definition yield should handle all non-processed events
|
// by definition yield should handle all non-processed events
|
||||||
|
|
||||||
@@ -1052,9 +1052,9 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
} while( status == noErr ) ;
|
} while( status == noErr ) ;
|
||||||
|
|
||||||
wxMacProcessNotifierAndPendingEvents() ;
|
wxMacProcessNotifierAndPendingEvents() ;
|
||||||
s_inYield = FALSE;
|
s_inYield = false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxApp::MacDoOneEvent()
|
void wxApp::MacDoOneEvent()
|
||||||
@@ -1090,7 +1090,7 @@ void wxApp::MacDoOneEvent()
|
|||||||
|
|
||||||
/*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr )
|
/*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr )
|
||||||
{
|
{
|
||||||
// Override to process unhandled events as you please
|
// Override to process unhandled events as you please
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxApp::MacHandleOneEvent( WXEVENTREF evr )
|
void wxApp::MacHandleOneEvent( WXEVENTREF evr )
|
||||||
@@ -1116,102 +1116,118 @@ long wxMacTranslateKey(unsigned char key, unsigned char code)
|
|||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case kHomeCharCode :
|
case kHomeCharCode :
|
||||||
retval = WXK_HOME;
|
retval = WXK_HOME;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kEnterCharCode :
|
case kEnterCharCode :
|
||||||
retval = WXK_RETURN;
|
retval = WXK_RETURN;
|
||||||
break;
|
break;
|
||||||
case kEndCharCode :
|
case kEndCharCode :
|
||||||
retval = WXK_END;
|
retval = WXK_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kHelpCharCode :
|
case kHelpCharCode :
|
||||||
retval = WXK_HELP;
|
retval = WXK_HELP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kBackspaceCharCode :
|
case kBackspaceCharCode :
|
||||||
retval = WXK_BACK;
|
retval = WXK_BACK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kTabCharCode :
|
case kTabCharCode :
|
||||||
retval = WXK_TAB;
|
retval = WXK_TAB;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPageUpCharCode :
|
case kPageUpCharCode :
|
||||||
retval = WXK_PAGEUP;
|
retval = WXK_PAGEUP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPageDownCharCode :
|
case kPageDownCharCode :
|
||||||
retval = WXK_PAGEDOWN;
|
retval = WXK_PAGEDOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kReturnCharCode :
|
case kReturnCharCode :
|
||||||
retval = WXK_RETURN;
|
retval = WXK_RETURN;
|
||||||
break;
|
break;
|
||||||
case kFunctionKeyCharCode :
|
|
||||||
|
case kFunctionKeyCharCode :
|
||||||
|
{
|
||||||
|
switch( code )
|
||||||
{
|
{
|
||||||
switch( code )
|
case 0x7a :
|
||||||
{
|
retval = WXK_F1 ;
|
||||||
case 0x7a :
|
break;
|
||||||
retval = WXK_F1 ;
|
case 0x78 :
|
||||||
break;
|
retval = WXK_F2 ;
|
||||||
case 0x78 :
|
break;
|
||||||
retval = WXK_F2 ;
|
case 0x63 :
|
||||||
break;
|
retval = WXK_F3 ;
|
||||||
case 0x63 :
|
break;
|
||||||
retval = WXK_F3 ;
|
case 0x76 :
|
||||||
break;
|
retval = WXK_F4 ;
|
||||||
case 0x76 :
|
break;
|
||||||
retval = WXK_F4 ;
|
case 0x60 :
|
||||||
break;
|
retval = WXK_F5 ;
|
||||||
case 0x60 :
|
break;
|
||||||
retval = WXK_F5 ;
|
case 0x61 :
|
||||||
break;
|
retval = WXK_F6 ;
|
||||||
case 0x61 :
|
break;
|
||||||
retval = WXK_F6 ;
|
case 0x62:
|
||||||
break;
|
retval = WXK_F7 ;
|
||||||
case 0x62:
|
break;
|
||||||
retval = WXK_F7 ;
|
case 0x64 :
|
||||||
break;
|
retval = WXK_F8 ;
|
||||||
case 0x64 :
|
break;
|
||||||
retval = WXK_F8 ;
|
case 0x65 :
|
||||||
break;
|
retval = WXK_F9 ;
|
||||||
case 0x65 :
|
break;
|
||||||
retval = WXK_F9 ;
|
case 0x6D :
|
||||||
break;
|
retval = WXK_F10 ;
|
||||||
case 0x6D :
|
break;
|
||||||
retval = WXK_F10 ;
|
case 0x67 :
|
||||||
break;
|
retval = WXK_F11 ;
|
||||||
case 0x67 :
|
break;
|
||||||
retval = WXK_F11 ;
|
case 0x6F :
|
||||||
break;
|
retval = WXK_F12 ;
|
||||||
case 0x6F :
|
break;
|
||||||
retval = WXK_F12 ;
|
case 0x69 :
|
||||||
break;
|
retval = WXK_F13 ;
|
||||||
case 0x69 :
|
break;
|
||||||
retval = WXK_F13 ;
|
case 0x6B :
|
||||||
break;
|
retval = WXK_F14 ;
|
||||||
case 0x6B :
|
break;
|
||||||
retval = WXK_F14 ;
|
case 0x71 :
|
||||||
break;
|
retval = WXK_F15 ;
|
||||||
case 0x71 :
|
break;
|
||||||
retval = WXK_F15 ;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case kEscapeCharCode :
|
||||||
|
retval = WXK_ESCAPE ;
|
||||||
break ;
|
break ;
|
||||||
case kEscapeCharCode :
|
|
||||||
retval = WXK_ESCAPE ;
|
case kLeftArrowCharCode :
|
||||||
|
retval = WXK_LEFT ;
|
||||||
break ;
|
break ;
|
||||||
case kLeftArrowCharCode :
|
|
||||||
retval = WXK_LEFT ;
|
case kRightArrowCharCode :
|
||||||
|
retval = WXK_RIGHT ;
|
||||||
break ;
|
break ;
|
||||||
case kRightArrowCharCode :
|
|
||||||
retval = WXK_RIGHT ;
|
case kUpArrowCharCode :
|
||||||
|
retval = WXK_UP ;
|
||||||
break ;
|
break ;
|
||||||
case kUpArrowCharCode :
|
|
||||||
retval = WXK_UP ;
|
case kDownArrowCharCode :
|
||||||
|
retval = WXK_DOWN ;
|
||||||
break ;
|
break ;
|
||||||
case kDownArrowCharCode :
|
|
||||||
retval = WXK_DOWN ;
|
case kDeleteCharCode :
|
||||||
|
retval = WXK_DELETE ;
|
||||||
break ;
|
break ;
|
||||||
case kDeleteCharCode :
|
|
||||||
retval = WXK_DELETE ;
|
default:
|
||||||
default:
|
|
||||||
break ;
|
break ;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
@@ -1252,9 +1268,9 @@ bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below
|
|||||||
//if OS X > 10.2 (i.e. 10.2.x)
|
//if OS X > 10.2 (i.e. 10.2.x)
|
||||||
//a known apple bug prevents the system from determining led
|
//a known apple bug prevents the system from determining led
|
||||||
//states with GetKeys... can only determine caps lock led
|
//states with GetKeys... can only determine caps lock led
|
||||||
return !!(GetCurrentKeyModifiers() & wxMacKeyCodeToModifier(key));
|
return !!(GetCurrentKeyModifiers() & wxMacKeyCodeToModifier(key));
|
||||||
//else
|
//else
|
||||||
// KeyMapByteArray keymap;
|
// KeyMapByteArray keymap;
|
||||||
// GetKeys((BigEndianLong*)keymap);
|
// GetKeys((BigEndianLong*)keymap);
|
||||||
// return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey));
|
// return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey));
|
||||||
}
|
}
|
||||||
@@ -1340,35 +1356,34 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi
|
|||||||
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
if ( handled && event.GetSkipped() )
|
if ( handled && event.GetSkipped() )
|
||||||
handled = false ;
|
handled = false ;
|
||||||
|
|
||||||
|
#if wxUSE_ACCEL
|
||||||
if ( !handled )
|
if ( !handled )
|
||||||
{
|
{
|
||||||
#if wxUSE_ACCEL
|
wxWindow *ancestor = focus;
|
||||||
if (!handled)
|
while (ancestor)
|
||||||
{
|
{
|
||||||
wxWindow *ancestor = focus;
|
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
||||||
while (ancestor)
|
if (command != -1)
|
||||||
{
|
{
|
||||||
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
||||||
if (command != -1)
|
handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
|
||||||
{
|
break;
|
||||||
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
|
||||||
handled = ancestor->GetEventHandler()->ProcessEvent( command_event );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (ancestor->IsTopLevel())
|
|
||||||
break;
|
|
||||||
ancestor = ancestor->GetParent();
|
|
||||||
}
|
}
|
||||||
|
if (ancestor->IsTopLevel())
|
||||||
|
break;
|
||||||
|
ancestor = ancestor->GetParent();
|
||||||
}
|
}
|
||||||
#endif // wxUSE_ACCEL
|
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
if (!handled)
|
if (!handled)
|
||||||
{
|
{
|
||||||
wxTopLevelWindowMac *tlw = focus->MacGetTopLevelWindow() ;
|
wxTopLevelWindowMac *tlw = focus->MacGetTopLevelWindow() ;
|
||||||
|
|
||||||
if (tlw)
|
if (tlw)
|
||||||
{
|
{
|
||||||
event.Skip( FALSE ) ;
|
event.Skip( false ) ;
|
||||||
event.SetEventType( wxEVT_CHAR_HOOK );
|
event.SetEventType( wxEVT_CHAR_HOOK );
|
||||||
// raw value again
|
// raw value again
|
||||||
event.m_keyCode = realkeyval ;
|
event.m_keyCode = realkeyval ;
|
||||||
@@ -1378,10 +1393,10 @@ bool wxApp::MacSendKeyDownEvent( wxWindow* focus , long keymessage , long modifi
|
|||||||
handled = false ;
|
handled = false ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !handled )
|
if ( !handled )
|
||||||
{
|
{
|
||||||
event.Skip( FALSE ) ;
|
event.Skip( false ) ;
|
||||||
event.SetEventType( wxEVT_CHAR ) ;
|
event.SetEventType( wxEVT_CHAR ) ;
|
||||||
// raw value again
|
// raw value again
|
||||||
event.m_keyCode = realkeyval ;
|
event.m_keyCode = realkeyval ;
|
||||||
|
@@ -39,10 +39,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject )
|
|||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
|
|
||||||
// Implementation Notes
|
// Implementation Notes
|
||||||
// --------------------
|
// --------------------
|
||||||
//
|
//
|
||||||
// we are always working with a 32 bit deep pixel buffer
|
// we are always working with a 32 bit deep pixel buffer
|
||||||
// under QuickDraw its alpha parts are going to be ignored in the GWorld,
|
// under QuickDraw its alpha parts are going to be ignored in the GWorld,
|
||||||
// therefore we have a separate GWorld there for blitting the mask in
|
// therefore we have a separate GWorld there for blitting the mask in
|
||||||
|
|
||||||
// under Quartz then content is transformed into a CGImageRef representing the same data
|
// under Quartz then content is transformed into a CGImageRef representing the same data
|
||||||
@@ -61,18 +61,18 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi
|
|||||||
wxBitmapRefData * bmap = bitmap.GetBitmapData() ;
|
wxBitmapRefData * bmap = bitmap.GetBitmapData() ;
|
||||||
if ( bmap == NULL )
|
if ( bmap == NULL )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( ( bmap->HasNativeSize() && forceType == 0 ) || forceType == kControlContentIconRef )
|
if ( ( bmap->HasNativeSize() && forceType == 0 ) || forceType == kControlContentIconRef )
|
||||||
{
|
{
|
||||||
wxBitmap scaleBmp ;
|
wxBitmap scaleBmp ;
|
||||||
|
|
||||||
wxBitmapRefData* bmp = bmap ;
|
wxBitmapRefData* bmp = bmap ;
|
||||||
|
|
||||||
if ( !bmap->HasNativeSize() )
|
if ( !bmap->HasNativeSize() )
|
||||||
{
|
{
|
||||||
// as PICT conversion will only result in a 16x16 icon, let's attempt
|
// as PICT conversion will only result in a 16x16 icon, let's attempt
|
||||||
// a few scales for better results
|
// a few scales for better results
|
||||||
|
|
||||||
int w = bitmap.GetWidth() ;
|
int w = bitmap.GetWidth() ;
|
||||||
int h = bitmap.GetHeight() ;
|
int h = bitmap.GetHeight() ;
|
||||||
int sz = wxMax( w , h ) ;
|
int sz = wxMax( w , h ) ;
|
||||||
@@ -82,7 +82,7 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi
|
|||||||
bmp = scaleBmp.GetBitmapData() ;
|
bmp = scaleBmp.GetBitmapData() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info->contentType = kControlContentIconRef ;
|
info->contentType = kControlContentIconRef ;
|
||||||
info->u.iconRef = bmp->GetIconRef() ;
|
info->u.iconRef = bmp->GetIconRef() ;
|
||||||
AcquireIconRef( info->u.iconRef ) ;
|
AcquireIconRef( info->u.iconRef ) ;
|
||||||
@@ -157,16 +157,16 @@ wxBitmapRefData::wxBitmapRefData()
|
|||||||
Init() ;
|
Init() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmapRefData::wxBitmapRefData( int w , int h , int d )
|
wxBitmapRefData::wxBitmapRefData( int w , int h , int d )
|
||||||
{
|
{
|
||||||
Init() ;
|
Init() ;
|
||||||
Create( w , h , d ) ;
|
Create( w , h , d ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapRefData::Create( int w , int h , int d )
|
bool wxBitmapRefData::Create( int w , int h , int d )
|
||||||
{
|
{
|
||||||
m_width = w ;
|
m_width = w ;
|
||||||
m_height = h ;
|
m_height = h ;
|
||||||
m_depth = d ;
|
m_depth = d ;
|
||||||
|
|
||||||
m_bytesPerRow = w * 4 ;
|
m_bytesPerRow = w * 4 ;
|
||||||
@@ -178,18 +178,18 @@ bool wxBitmapRefData::Create( int w , int h , int d )
|
|||||||
m_hBitmap = NULL ;
|
m_hBitmap = NULL ;
|
||||||
Rect rect = { 0 , 0 , m_height , m_width } ;
|
Rect rect = { 0 , 0 , m_height , m_width } ;
|
||||||
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_hBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
|
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_hBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
|
||||||
(char*) data , m_bytesPerRow ) ) ;
|
(char*) data , m_bytesPerRow ) ) ;
|
||||||
wxASSERT_MSG( m_hBitmap , wxT("Unable to create GWorld context") ) ;
|
wxASSERT_MSG( m_hBitmap , wxT("Unable to create GWorld context") ) ;
|
||||||
m_ok = ( m_hBitmap != NULL ) ;
|
m_ok = ( m_hBitmap != NULL ) ;
|
||||||
|
|
||||||
return m_ok ;
|
return m_ok ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapRefData::UseAlpha( bool use )
|
void wxBitmapRefData::UseAlpha( bool use )
|
||||||
{
|
{
|
||||||
if ( m_hasAlpha == use )
|
if ( m_hasAlpha == use )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
m_hasAlpha = use ;
|
m_hasAlpha = use ;
|
||||||
if ( m_hasAlpha )
|
if ( m_hasAlpha )
|
||||||
{
|
{
|
||||||
@@ -202,7 +202,7 @@ void wxBitmapRefData::UseAlpha( bool use )
|
|||||||
wxASSERT( m_hMaskBitmap == NULL ) ;
|
wxASSERT( m_hMaskBitmap == NULL ) ;
|
||||||
Rect rect = { 0 , 0 , height , width } ;
|
Rect rect = { 0 , 0 , height , width } ;
|
||||||
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_hMaskBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
|
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_hMaskBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
|
||||||
(char*) data , m_maskBytesPerRow ) ) ;
|
(char*) data , m_maskBytesPerRow ) ) ;
|
||||||
wxASSERT_MSG( m_hMaskBitmap , wxT("Unable to create GWorld context for alpha mask") ) ;
|
wxASSERT_MSG( m_hMaskBitmap , wxT("Unable to create GWorld context for alpha mask") ) ;
|
||||||
m_maskMemBuf.UngetWriteBuf(size) ;
|
m_maskMemBuf.UngetWriteBuf(size) ;
|
||||||
#if !wxMAC_USE_CORE_GRAPHICS
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
@@ -223,14 +223,14 @@ void *wxBitmapRefData::GetRawAccess() const
|
|||||||
return m_memBuf.GetData() ;
|
return m_memBuf.GetData() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *wxBitmapRefData::BeginRawAccess()
|
void *wxBitmapRefData::BeginRawAccess()
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ) ;
|
wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ) ;
|
||||||
wxASSERT( m_rawAccessCount == 0 ) ;
|
wxASSERT( m_rawAccessCount == 0 ) ;
|
||||||
++m_rawAccessCount ;
|
++m_rawAccessCount ;
|
||||||
// we must destroy an existing cached image, as
|
// we must destroy an existing cached image, as
|
||||||
// the bitmap data may change now
|
// the bitmap data may change now
|
||||||
wxASSERT_MSG( m_pictHandle == NULL && m_iconRef == NULL ,
|
wxASSERT_MSG( m_pictHandle == NULL && m_iconRef == NULL ,
|
||||||
wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ;
|
wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ;
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
if ( m_cgImageRef )
|
if ( m_cgImageRef )
|
||||||
@@ -257,7 +257,7 @@ bool wxBitmapRefData::HasNativeSize()
|
|||||||
int w = GetWidth() ;
|
int w = GetWidth() ;
|
||||||
int h = GetHeight() ;
|
int h = GetHeight() ;
|
||||||
int sz = wxMax( w , h ) ;
|
int sz = wxMax( w , h ) ;
|
||||||
|
|
||||||
if ( sz == 128 || sz == 48 || sz == 32 || sz == 16 )
|
if ( sz == 128 || sz == 48 || sz == 32 || sz == 16 )
|
||||||
return true ;
|
return true ;
|
||||||
return false ;
|
return false ;
|
||||||
@@ -268,17 +268,17 @@ IconRef wxBitmapRefData::GetIconRef()
|
|||||||
if ( m_iconRef == NULL )
|
if ( m_iconRef == NULL )
|
||||||
{
|
{
|
||||||
// Create Icon Family Handle
|
// Create Icon Family Handle
|
||||||
|
|
||||||
IconFamilyHandle iconFamily = NULL ;
|
IconFamilyHandle iconFamily = NULL ;
|
||||||
|
|
||||||
iconFamily = (IconFamilyHandle) NewHandle(8) ;
|
iconFamily = (IconFamilyHandle) NewHandle(8) ;
|
||||||
(**iconFamily).resourceType = kIconFamilyType ;
|
(**iconFamily).resourceType = kIconFamilyType ;
|
||||||
(**iconFamily).resourceSize = sizeof(OSType) + sizeof(Size);
|
(**iconFamily).resourceSize = sizeof(OSType) + sizeof(Size);
|
||||||
|
|
||||||
int w = GetWidth() ;
|
int w = GetWidth() ;
|
||||||
int h = GetHeight() ;
|
int h = GetHeight() ;
|
||||||
int sz = wxMax( w , h ) ;
|
int sz = wxMax( w , h ) ;
|
||||||
|
|
||||||
OSType dataType = 0 ;
|
OSType dataType = 0 ;
|
||||||
OSType maskType = 0 ;
|
OSType maskType = 0 ;
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
|||||||
{
|
{
|
||||||
// setup the header properly
|
// setup the header properly
|
||||||
|
|
||||||
Handle data = NULL ;
|
Handle data = NULL ;
|
||||||
Handle maskdata = NULL ;
|
Handle maskdata = NULL ;
|
||||||
unsigned char * maskptr = NULL ;
|
unsigned char * maskptr = NULL ;
|
||||||
unsigned char * ptr = NULL ;
|
unsigned char * ptr = NULL ;
|
||||||
@@ -315,13 +315,13 @@ IconRef wxBitmapRefData::GetIconRef()
|
|||||||
size_t masksize ;
|
size_t masksize ;
|
||||||
|
|
||||||
size = sz * sz * 4 ;
|
size = sz * sz * 4 ;
|
||||||
data = NewHandle( size) ;
|
data = NewHandle( size) ;
|
||||||
HLock( data ) ;
|
HLock( data ) ;
|
||||||
ptr = (unsigned char*) *data ;
|
ptr = (unsigned char*) *data ;
|
||||||
memset( ptr , 0, size ) ;
|
memset( ptr , 0, size ) ;
|
||||||
|
|
||||||
masksize = sz * sz ;
|
masksize = sz * sz ;
|
||||||
maskdata = NewHandle( masksize ) ;
|
maskdata = NewHandle( masksize ) ;
|
||||||
HLock( maskdata ) ;
|
HLock( maskdata ) ;
|
||||||
maskptr = (unsigned char*) *maskdata ;
|
maskptr = (unsigned char*) *maskdata ;
|
||||||
memset( maskptr , 0 , masksize ) ;
|
memset( maskptr , 0 , masksize ) ;
|
||||||
@@ -340,12 +340,12 @@ IconRef wxBitmapRefData::GetIconRef()
|
|||||||
unsigned char r = *source ++ ;
|
unsigned char r = *source ++ ;
|
||||||
unsigned char g = *source ++ ;
|
unsigned char g = *source ++ ;
|
||||||
unsigned char b = *source ++ ;
|
unsigned char b = *source ++ ;
|
||||||
|
|
||||||
*dest++ = 0 ;
|
*dest++ = 0 ;
|
||||||
*dest++ = r ;
|
*dest++ = r ;
|
||||||
*dest++ = g ;
|
*dest++ = g ;
|
||||||
*dest++ = b ;
|
*dest++ = b ;
|
||||||
|
|
||||||
if ( mask )
|
if ( mask )
|
||||||
*maskdest++ = *masksource++ ;
|
*maskdest++ = *masksource++ ;
|
||||||
else if ( hasAlpha )
|
else if ( hasAlpha )
|
||||||
@@ -354,7 +354,7 @@ IconRef wxBitmapRefData::GetIconRef()
|
|||||||
*maskdest++ = 0xFF ;
|
*maskdest++ = 0xFF ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus err = SetIconFamilyData( iconFamily, dataType , data ) ;
|
OSStatus err = SetIconFamilyData( iconFamily, dataType , data ) ;
|
||||||
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
|
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
|
||||||
|
|
||||||
@@ -370,16 +370,16 @@ IconRef wxBitmapRefData::GetIconRef()
|
|||||||
PicHandle pic = GetPictHandle() ;
|
PicHandle pic = GetPictHandle() ;
|
||||||
SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ;
|
SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// transform into IconRef
|
// transform into IconRef
|
||||||
|
|
||||||
static int iconCounter = 2 ;
|
static int iconCounter = 2 ;
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
OSStatus err =
|
OSStatus err =
|
||||||
#endif
|
#endif
|
||||||
RegisterIconRefFromIconFamily( 'WXNG' , (OSType) iconCounter, iconFamily, &m_iconRef ) ;
|
RegisterIconRefFromIconFamily( 'WXNG' , (OSType) iconCounter, iconFamily, &m_iconRef ) ;
|
||||||
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
|
wxASSERT_MSG( err == noErr , wxT("Error when adding bitmap") ) ;
|
||||||
// we have to retain a reference, as Unregister will decrement it
|
// we have to retain a reference, as Unregister will decrement it
|
||||||
AcquireIconRef( m_iconRef ) ;
|
AcquireIconRef( m_iconRef ) ;
|
||||||
UnregisterIconRef( 'WXNG' , (OSType) iconCounter ) ;
|
UnregisterIconRef( 'WXNG' , (OSType) iconCounter ) ;
|
||||||
DisposeHandle( (Handle) iconFamily ) ;
|
DisposeHandle( (Handle) iconFamily ) ;
|
||||||
@@ -398,7 +398,7 @@ PicHandle wxBitmapRefData::GetPictHandle()
|
|||||||
GWorldPtr mask = NULL ;
|
GWorldPtr mask = NULL ;
|
||||||
int height = GetHeight() ;
|
int height = GetHeight() ;
|
||||||
int width = GetWidth() ;
|
int width = GetWidth() ;
|
||||||
|
|
||||||
Rect rect = { 0 , 0 , height , width } ;
|
Rect rect = { 0 , 0 , height , width } ;
|
||||||
|
|
||||||
GetGWorld( &origPort , &origDev ) ;
|
GetGWorld( &origPort , &origDev ) ;
|
||||||
@@ -435,7 +435,7 @@ PicHandle wxBitmapRefData::GetPictHandle()
|
|||||||
Rect portRect ;
|
Rect portRect ;
|
||||||
GetPortBounds( wp , &portRect ) ;
|
GetPortBounds( wp , &portRect ) ;
|
||||||
m_pictHandle = OpenPicture(&portRect);
|
m_pictHandle = OpenPicture(&portRect);
|
||||||
|
|
||||||
if(m_pictHandle)
|
if(m_pictHandle)
|
||||||
{
|
{
|
||||||
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
|
RGBColor white = { 0xffff ,0xffff , 0xffff } ;
|
||||||
@@ -483,7 +483,7 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
|
|||||||
int h = m_height ;
|
int h = m_height ;
|
||||||
CGImageAlphaInfo alphaInfo = kCGImageAlphaNoneSkipFirst ;
|
CGImageAlphaInfo alphaInfo = kCGImageAlphaNoneSkipFirst ;
|
||||||
wxMemoryBuffer* membuf = NULL ;
|
wxMemoryBuffer* membuf = NULL ;
|
||||||
|
|
||||||
if ( m_bitmapMask )
|
if ( m_bitmapMask )
|
||||||
{
|
{
|
||||||
membuf = new wxMemoryBuffer( imageSize ) ;
|
membuf = new wxMemoryBuffer( imageSize ) ;
|
||||||
@@ -515,13 +515,13 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
|
|||||||
membuf = new wxMemoryBuffer( m_memBuf ) ;
|
membuf = new wxMemoryBuffer( m_memBuf ) ;
|
||||||
}
|
}
|
||||||
CGColorSpaceRef colorSpace = wxMacGetGenericRGBColorSpace();
|
CGColorSpaceRef colorSpace = wxMacGetGenericRGBColorSpace();
|
||||||
CGDataProviderRef dataProvider =
|
CGDataProviderRef dataProvider =
|
||||||
CGDataProviderCreateWithData( membuf , (const void *)membuf->GetData() , imageSize,
|
CGDataProviderCreateWithData( membuf , (const void *)membuf->GetData() , imageSize,
|
||||||
wxMacMemoryBufferReleaseProc );
|
wxMacMemoryBufferReleaseProc );
|
||||||
image =
|
image =
|
||||||
::CGImageCreate( w, h, 8 , 32 , 4 * m_width , colorSpace, alphaInfo ,
|
::CGImageCreate( w, h, 8 , 32 , 4 * m_width , colorSpace, alphaInfo ,
|
||||||
dataProvider, NULL , false , kCGRenderingIntentDefault );
|
dataProvider, NULL , false , kCGRenderingIntentDefault );
|
||||||
CGDataProviderRelease( dataProvider);
|
CGDataProviderRelease( dataProvider);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -533,7 +533,7 @@ CGImageRef wxBitmapRefData::CGImageCreate() const
|
|||||||
// we keep it for later use
|
// we keep it for later use
|
||||||
m_cgImageRef = image ;
|
m_cgImageRef = image ;
|
||||||
CGImageRetain( image ) ;
|
CGImageRetain( image ) ;
|
||||||
}
|
}
|
||||||
return image ;
|
return image ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -545,7 +545,7 @@ GWorldPtr wxBitmapRefData::GetHBITMAP(GWorldPtr* mask) const
|
|||||||
{
|
{
|
||||||
*mask = NULL ;
|
*mask = NULL ;
|
||||||
if ( m_bitmapMask )
|
if ( m_bitmapMask )
|
||||||
*mask = (GWorldPtr) m_bitmapMask->GetHBITMAP() ;
|
*mask = (GWorldPtr) m_bitmapMask->GetHBITMAP() ;
|
||||||
else if ( m_hasAlpha )
|
else if ( m_hasAlpha )
|
||||||
{
|
{
|
||||||
#if !wxMAC_USE_CORE_GRAPHICS
|
#if !wxMAC_USE_CORE_GRAPHICS
|
||||||
@@ -562,16 +562,16 @@ GWorldPtr wxBitmapRefData::GetHBITMAP(GWorldPtr* mask) const
|
|||||||
return m_hBitmap ;
|
return m_hBitmap ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBitmapRefData::UpdateAlphaMask() const
|
void wxBitmapRefData::UpdateAlphaMask() const
|
||||||
{
|
{
|
||||||
if ( m_hasAlpha )
|
if ( m_hasAlpha )
|
||||||
{
|
{
|
||||||
unsigned char *sourcemask = (unsigned char *) GetRawAccess() ;
|
unsigned char *sourcemask = (unsigned char *) GetRawAccess() ;
|
||||||
unsigned char *destalphabase = (unsigned char *) m_maskMemBuf.GetData() ;
|
unsigned char *destalphabase = (unsigned char *) m_maskMemBuf.GetData() ;
|
||||||
|
|
||||||
int h = GetHeight() ;
|
int h = GetHeight() ;
|
||||||
int w = GetWidth() ;
|
int w = GetWidth() ;
|
||||||
|
|
||||||
for ( int y = 0 ; y < h ; ++y , destalphabase += m_maskBytesPerRow )
|
for ( int y = 0 ; y < h ; ++y , destalphabase += m_maskBytesPerRow )
|
||||||
{
|
{
|
||||||
unsigned char* destalpha = destalphabase ;
|
unsigned char* destalpha = destalphabase ;
|
||||||
@@ -646,10 +646,10 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|||||||
IconFamilyHandle iconFamily = NULL ;
|
IconFamilyHandle iconFamily = NULL ;
|
||||||
Handle imagehandle = NewHandle(0) ;
|
Handle imagehandle = NewHandle(0) ;
|
||||||
Handle maskhandle = NewHandle(0) ;
|
Handle maskhandle = NewHandle(0) ;
|
||||||
|
|
||||||
OSType maskType = 0;
|
OSType maskType = 0;
|
||||||
OSType dataType = 0;
|
OSType dataType = 0;
|
||||||
IconSelectorValue selector = 0 ;
|
IconSelectorValue selector = 0 ;
|
||||||
if ( w == 128 )
|
if ( w == 128 )
|
||||||
{
|
{
|
||||||
dataType = kThumbnail32BitData ;
|
dataType = kThumbnail32BitData ;
|
||||||
@@ -677,12 +677,12 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|||||||
|
|
||||||
|
|
||||||
OSStatus err = ( IconRefToIconFamily( MAC_WXHICON(icon.GetHICON()) , selector , &iconFamily ) ) ;
|
OSStatus err = ( IconRefToIconFamily( MAC_WXHICON(icon.GetHICON()) , selector , &iconFamily ) ) ;
|
||||||
|
|
||||||
err =( GetIconFamilyData( iconFamily , dataType , imagehandle ) ) ;
|
err =( GetIconFamilyData( iconFamily , dataType , imagehandle ) ) ;
|
||||||
err =( GetIconFamilyData( iconFamily , maskType , maskhandle ) ) ;
|
err =( GetIconFamilyData( iconFamily , maskType , maskhandle ) ) ;
|
||||||
size_t imagehandlesize = GetHandleSize( imagehandle ) ;
|
size_t imagehandlesize = GetHandleSize( imagehandle ) ;
|
||||||
size_t maskhandlesize = GetHandleSize( maskhandle ) ;
|
size_t maskhandlesize = GetHandleSize( maskhandle ) ;
|
||||||
|
|
||||||
if ( imagehandlesize != 0 && maskhandlesize != 0 )
|
if ( imagehandlesize != 0 && maskhandlesize != 0 )
|
||||||
{
|
{
|
||||||
wxASSERT( GetHandleSize( imagehandle ) == w * 4 * h ) ;
|
wxASSERT( GetHandleSize( imagehandle ) == w * 4 * h ) ;
|
||||||
@@ -690,7 +690,7 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|||||||
UseAlpha() ;
|
UseAlpha() ;
|
||||||
unsigned char *source = (unsigned char *) *imagehandle ;
|
unsigned char *source = (unsigned char *) *imagehandle ;
|
||||||
unsigned char *sourcemask = (unsigned char *) *maskhandle ;
|
unsigned char *sourcemask = (unsigned char *) *maskhandle ;
|
||||||
|
|
||||||
unsigned char* destination = (unsigned char*) BeginRawAccess() ;
|
unsigned char* destination = (unsigned char*) BeginRawAccess() ;
|
||||||
for ( int y = 0 ; y < h ; ++y )
|
for ( int y = 0 ; y < h ; ++y )
|
||||||
{
|
{
|
||||||
@@ -709,11 +709,11 @@ bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
|||||||
created = true ;
|
created = true ;
|
||||||
}
|
}
|
||||||
DisposeHandle( (Handle) iconFamily ) ;
|
DisposeHandle( (Handle) iconFamily ) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !created )
|
if ( !created )
|
||||||
{
|
{
|
||||||
wxMemoryDC dc ;
|
wxMemoryDC dc ;
|
||||||
dc.SelectObject( *this ) ;
|
dc.SelectObject( *this ) ;
|
||||||
dc.DrawIcon( icon , 0 , 0 ) ;
|
dc.DrawIcon( icon , 0 , 0 ) ;
|
||||||
@@ -804,7 +804,7 @@ void* wxBitmap::GetRawAccess() const
|
|||||||
return M_BITMAPDATA->GetRawAccess() ;
|
return M_BITMAPDATA->GetRawAccess() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* wxBitmap::BeginRawAccess()
|
void* wxBitmap::BeginRawAccess()
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Ok() , NULL , wxT("invalid bitmap") ) ;
|
wxCHECK_MSG( Ok() , NULL , wxT("invalid bitmap") ) ;
|
||||||
return M_BITMAPDATA->BeginRawAccess() ;
|
return M_BITMAPDATA->BeginRawAccess() ;
|
||||||
@@ -819,14 +819,14 @@ void wxBitmap::EndRawAccess()
|
|||||||
bool wxBitmap::CreateFromXpm(const char **bits)
|
bool wxBitmap::CreateFromXpm(const char **bits)
|
||||||
{
|
{
|
||||||
#if wxUSE_IMAGE
|
#if wxUSE_IMAGE
|
||||||
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
|
wxCHECK_MSG( bits != NULL, false, wxT("invalid bitmap data") )
|
||||||
wxXPMDecoder decoder;
|
wxXPMDecoder decoder;
|
||||||
wxImage img = decoder.ReadData(bits);
|
wxImage img = decoder.ReadData(bits);
|
||||||
wxCHECK_MSG( img.Ok(), FALSE, wxT("invalid bitmap data") )
|
wxCHECK_MSG( img.Ok(), false, wxT("invalid bitmap data") )
|
||||||
*this = wxBitmap(img);
|
*this = wxBitmap(img);
|
||||||
return TRUE;
|
return true;
|
||||||
#else
|
#else
|
||||||
return FALSE;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -867,7 +867,7 @@ wxBitmap wxBitmap::GetSubBitmap(const wxRect &rect) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret.EndRawAccess() ;
|
ret.EndRawAccess() ;
|
||||||
|
|
||||||
if ( M_BITMAPDATA->m_bitmapMask )
|
if ( M_BITMAPDATA->m_bitmapMask )
|
||||||
{
|
{
|
||||||
wxMemoryBuffer maskbuf ;
|
wxMemoryBuffer maskbuf ;
|
||||||
@@ -943,7 +943,7 @@ bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int
|
|||||||
if ( handler == NULL ) {
|
if ( handler == NULL ) {
|
||||||
wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
|
wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
|
||||||
|
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler->Create(this, data, type, width, height, depth);
|
return handler->Create(this, data, type, width, height, depth);
|
||||||
@@ -964,7 +964,7 @@ wxBitmap::wxBitmap(const wxImage& image, int depth)
|
|||||||
// Create picture
|
// Create picture
|
||||||
|
|
||||||
bool hasAlpha = false ;
|
bool hasAlpha = false ;
|
||||||
|
|
||||||
if ( image.HasMask() )
|
if ( image.HasMask() )
|
||||||
{
|
{
|
||||||
// takes precedence, don't mix with alpha info
|
// takes precedence, don't mix with alpha info
|
||||||
@@ -973,10 +973,10 @@ wxBitmap::wxBitmap(const wxImage& image, int depth)
|
|||||||
{
|
{
|
||||||
hasAlpha = image.HasAlpha() ;
|
hasAlpha = image.HasAlpha() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hasAlpha )
|
if ( hasAlpha )
|
||||||
UseAlpha() ;
|
UseAlpha() ;
|
||||||
|
|
||||||
unsigned char* destination = (unsigned char*) BeginRawAccess() ;
|
unsigned char* destination = (unsigned char*) BeginRawAccess() ;
|
||||||
|
|
||||||
register unsigned char* data = image.GetData();
|
register unsigned char* data = image.GetData();
|
||||||
@@ -1054,7 +1054,7 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
alpha = image.GetAlpha() ;
|
alpha = image.GetAlpha() ;
|
||||||
}
|
}
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
// The following masking algorithm is the same as well in msw/gtk:
|
// The following masking algorithm is the same as well in msw/gtk:
|
||||||
// the colour used as transparent one in wxImage and the one it is
|
// the colour used as transparent one in wxImage and the one it is
|
||||||
// replaced with when it really occurs in the bitmap
|
// replaced with when it really occurs in the bitmap
|
||||||
@@ -1104,22 +1104,24 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type,
|
bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type,
|
||||||
const wxPalette *palette) const
|
const wxPalette *palette) const
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
wxBitmapHandler *handler = FindHandler(type);
|
||||||
|
|
||||||
if ( handler )
|
if ( handler )
|
||||||
{
|
{
|
||||||
return handler->SaveFile(this, filename, type, palette);
|
success = handler->SaveFile(this, filename, type, palette);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if wxUSE_IMAGE
|
#if wxUSE_IMAGE
|
||||||
wxImage image = ConvertToImage();
|
wxImage image = ConvertToImage();
|
||||||
return image.SaveFile(filename, type);
|
success = image.SaveFile(filename, type);
|
||||||
|
#else
|
||||||
|
wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
|
return success;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::Ok() const
|
bool wxBitmap::Ok() const
|
||||||
@@ -1284,7 +1286,7 @@ wxMask::~wxMask()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMask::Init()
|
void wxMask::Init()
|
||||||
{
|
{
|
||||||
m_width = m_height = m_bytesPerRow = 0 ;
|
m_width = m_height = m_bytesPerRow = 0 ;
|
||||||
m_maskBitmap = NULL ;
|
m_maskBitmap = NULL ;
|
||||||
@@ -1298,7 +1300,7 @@ void *wxMask::GetRawAccess() const
|
|||||||
// this can be a k8IndexedGrayPixelFormat GWorld, because it never stores other values than black or white
|
// this can be a k8IndexedGrayPixelFormat GWorld, because it never stores other values than black or white
|
||||||
// so no rainbox colors will be created by QD when blitting
|
// so no rainbox colors will be created by QD when blitting
|
||||||
|
|
||||||
void wxMask::RealizeNative()
|
void wxMask::RealizeNative()
|
||||||
{
|
{
|
||||||
if ( m_maskBitmap )
|
if ( m_maskBitmap )
|
||||||
{
|
{
|
||||||
@@ -1307,7 +1309,7 @@ void wxMask::RealizeNative()
|
|||||||
}
|
}
|
||||||
Rect rect = { 0 , 0 , m_height , m_width } ;
|
Rect rect = { 0 , 0 , m_height , m_width } ;
|
||||||
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_maskBitmap , k8IndexedGrayPixelFormat , &rect , NULL , NULL , 0 ,
|
verify_noerr( NewGWorldFromPtr( (GWorldPtr*) &m_maskBitmap , k8IndexedGrayPixelFormat , &rect , NULL , NULL , 0 ,
|
||||||
(char*) m_memBuf.GetData() , m_bytesPerRow ) ) ;
|
(char*) m_memBuf.GetData() , m_bytesPerRow ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a mask from a mono bitmap (copies the bitmap).
|
// Create a mask from a mono bitmap (copies the bitmap).
|
||||||
@@ -1349,7 +1351,7 @@ bool wxMask::Create(const wxBitmap& bitmap)
|
|||||||
}
|
}
|
||||||
m_memBuf.UngetWriteBuf( size ) ;
|
m_memBuf.UngetWriteBuf( size ) ;
|
||||||
RealizeNative() ;
|
RealizeNative() ;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a mask from a bitmap and a colour indicating
|
// Create a mask from a bitmap and a colour indicating
|
||||||
@@ -1381,7 +1383,7 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
|||||||
}
|
}
|
||||||
m_memBuf.UngetWriteBuf( size ) ;
|
m_memBuf.UngetWriteBuf( size ) ;
|
||||||
RealizeNative() ;
|
RealizeNative() ;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WXHBITMAP wxMask::GetHBITMAP() const
|
WXHBITMAP wxMask::GetHBITMAP() const
|
||||||
@@ -1399,18 +1401,18 @@ wxBitmapHandler::~wxBitmapHandler()
|
|||||||
|
|
||||||
bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
|
bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||||
int desiredWidth, int desiredHeight)
|
int desiredWidth, int desiredHeight)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
|
bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1451,10 +1453,10 @@ bool wxPICTResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, lo
|
|||||||
dc.SelectObject( *bitmap ) ;
|
dc.SelectObject( *bitmap ) ;
|
||||||
mf.Play( &dc ) ;
|
mf.Play( &dc ) ;
|
||||||
dc.SelectObject( wxNullBitmap ) ;
|
dc.SelectObject( wxNullBitmap ) ;
|
||||||
return TRUE ;
|
return true ;
|
||||||
}
|
}
|
||||||
#endif //wxUSE_METAFILE
|
#endif //wxUSE_METAFILE
|
||||||
return FALSE ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -46,17 +46,17 @@ wxColourDialog::wxColourDialog(wxWindow *parent, wxColourData *data)
|
|||||||
bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
|
bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
|
||||||
{
|
{
|
||||||
m_dialogParent = parent;
|
m_dialogParent = parent;
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
m_colourData = *data;
|
m_colourData = *data;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxColourDialog::ShowModal()
|
int wxColourDialog::ShowModal()
|
||||||
{
|
{
|
||||||
Point where ;
|
Point where ;
|
||||||
RGBColor currentColor = *((RGBColor*)m_colourData.m_dataColour.GetPixel()) , newColor ;
|
RGBColor currentColor = *((RGBColor*)m_colourData.m_dataColour.GetPixel()) , newColor ;
|
||||||
|
|
||||||
where.h = where.v = -1;
|
where.h = where.v = -1;
|
||||||
|
|
||||||
if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor ))
|
if (GetColor( where, "\pSelect a new palette color.", ¤tColor, &newColor ))
|
||||||
@@ -64,10 +64,6 @@ int wxColourDialog::ShowModal()
|
|||||||
m_colourData.m_dataColour.Set( (WXCOLORREF*) &newColor ) ;
|
m_colourData.m_dataColour.Set( (WXCOLORREF*) &newColor ) ;
|
||||||
return wxID_OK;
|
return wxID_OK;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return wxID_CANCEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
}
|
}
|
||||||
|
@@ -51,62 +51,47 @@ wxDirDialog::wxDirDialog(wxWindow *parent,
|
|||||||
int wxDirDialog::ShowModal()
|
int wxDirDialog::ShowModal()
|
||||||
{
|
{
|
||||||
NavDialogOptions mNavOptions;
|
NavDialogOptions mNavOptions;
|
||||||
NavObjectFilterUPP mNavFilterUPP = NULL;
|
NavObjectFilterUPP mNavFilterUPP = NULL;
|
||||||
NavPreviewUPP mNavPreviewUPP = NULL ;
|
NavReplyRecord mNavReply;
|
||||||
NavReplyRecord mNavReply;
|
|
||||||
AEDesc* mDefaultLocation = NULL ;
|
|
||||||
bool mSelectDefault = false ;
|
|
||||||
|
|
||||||
::NavGetDefaultDialogOptions(&mNavOptions);
|
::NavGetDefaultDialogOptions(&mNavOptions);
|
||||||
|
|
||||||
mNavFilterUPP = nil;
|
mNavReply.validRecord = false;
|
||||||
mNavPreviewUPP = nil;
|
mNavReply.replacing = false;
|
||||||
mSelectDefault = false;
|
mNavReply.isStationery = false;
|
||||||
mNavReply.validRecord = false;
|
mNavReply.translationNeeded = false;
|
||||||
mNavReply.replacing = false;
|
|
||||||
mNavReply.isStationery = false;
|
|
||||||
mNavReply.translationNeeded = false;
|
|
||||||
mNavReply.selection.descriptorType = typeNull;
|
mNavReply.selection.descriptorType = typeNull;
|
||||||
mNavReply.selection.dataHandle = nil;
|
mNavReply.selection.dataHandle = nil;
|
||||||
mNavReply.keyScript = smSystemScript;
|
mNavReply.keyScript = smSystemScript;
|
||||||
mNavReply.fileTranslation = nil;
|
mNavReply.fileTranslation = nil;
|
||||||
|
|
||||||
// Set default location, the location
|
// Set default location, the location
|
||||||
// that's displayed when the dialog
|
// that's displayed when the dialog
|
||||||
// first appears
|
// first appears
|
||||||
|
|
||||||
if ( mDefaultLocation ) {
|
|
||||||
|
|
||||||
if (mSelectDefault) {
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
|
|
||||||
} else {
|
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
OSErr err = ::NavChooseFolder(
|
OSErr err = ::NavChooseFolder(
|
||||||
mDefaultLocation,
|
NULL,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
&mNavOptions,
|
&mNavOptions,
|
||||||
NULL,
|
NULL,
|
||||||
mNavFilterUPP,
|
mNavFilterUPP,
|
||||||
0L); // User Data
|
0L); // User Data
|
||||||
|
|
||||||
if ( (err != noErr) && (err != userCanceledErr) ) {
|
if ( (err != noErr) && (err != userCanceledErr) ) {
|
||||||
m_path = wxT("") ;
|
m_path = wxEmptyString ;
|
||||||
return wxID_CANCEL ;
|
return wxID_CANCEL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNavReply.validRecord) { // User chose a folder
|
if (mNavReply.validRecord) { // User chose a folder
|
||||||
|
|
||||||
FSRef folderInfo;
|
FSRef folderInfo;
|
||||||
AEDesc specDesc ;
|
AEDesc specDesc ;
|
||||||
|
|
||||||
OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSRef, &specDesc);
|
OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSRef, &specDesc);
|
||||||
if ( err != noErr ) {
|
if ( err != noErr ) {
|
||||||
m_path = wxT("") ;
|
m_path = wxEmptyString ;
|
||||||
return wxID_CANCEL ;
|
return wxID_CANCEL ;
|
||||||
}
|
}
|
||||||
folderInfo = **(FSRef**) specDesc.dataHandle;
|
folderInfo = **(FSRef**) specDesc.dataHandle;
|
||||||
if (specDesc.dataHandle != nil) {
|
if (specDesc.dataHandle != nil) {
|
||||||
::AEDisposeDesc(&specDesc);
|
::AEDisposeDesc(&specDesc);
|
||||||
|
@@ -40,7 +40,7 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
|
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
|
||||||
|
|
||||||
#define WX_MAC_STATUSBAR_HEIGHT 18
|
#define WX_MAC_STATUSBAR_HEIGHT 18
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// creation/destruction
|
// creation/destruction
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -48,15 +48,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
|
|||||||
void wxFrame::Init()
|
void wxFrame::Init()
|
||||||
{
|
{
|
||||||
m_frameMenuBar = NULL;
|
m_frameMenuBar = NULL;
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
m_frameToolBar = NULL ;
|
m_frameToolBar = NULL ;
|
||||||
#endif
|
#endif
|
||||||
m_frameStatusBar = NULL;
|
m_frameStatusBar = NULL;
|
||||||
m_winLastFocused = NULL ;
|
m_winLastFocused = NULL ;
|
||||||
|
|
||||||
m_iconized = FALSE;
|
m_iconized = false;
|
||||||
|
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
m_hwndToolTip = 0;
|
m_hwndToolTip = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -70,18 +70,18 @@ bool wxFrame::Create(wxWindow *parent,
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
|
if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
wxModelessWindows.Append(this);
|
wxModelessWindows.Append(this);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFrame::~wxFrame()
|
wxFrame::~wxFrame()
|
||||||
{
|
{
|
||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = true;
|
||||||
DeleteAllBars();
|
DeleteAllBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,18 +89,18 @@ wxFrame::~wxFrame()
|
|||||||
bool wxFrame::Enable(bool enable)
|
bool wxFrame::Enable(bool enable)
|
||||||
{
|
{
|
||||||
if ( !wxWindow::Enable(enable) )
|
if ( !wxWindow::Enable(enable) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() )
|
if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() )
|
||||||
{
|
{
|
||||||
int iMaxMenu = m_frameMenuBar->GetMenuCount();
|
int iMaxMenu = m_frameMenuBar->GetMenuCount();
|
||||||
for ( int i = 0 ; i < iMaxMenu ; ++ i )
|
for ( int i = 0 ; i < iMaxMenu ; ++ i )
|
||||||
{
|
{
|
||||||
m_frameMenuBar->EnableTop( i , enable ) ;
|
m_frameMenuBar->EnableTop( i , enable ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
|
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
|
||||||
@@ -121,7 +121,7 @@ void wxFrame::PositionStatusBar()
|
|||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
GetClientSize(&w, &h);
|
GetClientSize(&w, &h);
|
||||||
|
|
||||||
// Since we wish the status bar to be directly under the client area,
|
// Since we wish the status bar to be directly under the client area,
|
||||||
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
|
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
|
||||||
m_frameStatusBar->SetSize(0, h, w, WX_MAC_STATUSBAR_HEIGHT);
|
m_frameStatusBar->SetSize(0, h, w, WX_MAC_STATUSBAR_HEIGHT);
|
||||||
@@ -222,14 +222,14 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
|
|||||||
void wxFrame::DoGetClientSize(int *x, int *y) const
|
void wxFrame::DoGetClientSize(int *x, int *y) const
|
||||||
{
|
{
|
||||||
wxTopLevelWindow::DoGetClientSize( x , y ) ;
|
wxTopLevelWindow::DoGetClientSize( x , y ) ;
|
||||||
|
|
||||||
#if wxUSE_STATUSBAR
|
#if wxUSE_STATUSBAR
|
||||||
if ( GetStatusBar() && GetStatusBar()->IsShown() && y )
|
if ( GetStatusBar() && GetStatusBar()->IsShown() && y )
|
||||||
{
|
{
|
||||||
if ( y) *y -= WX_MAC_STATUSBAR_HEIGHT;
|
*y -= WX_MAC_STATUSBAR_HEIGHT;
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
wxToolBar *toolbar = GetToolBar();
|
wxToolBar *toolbar = GetToolBar();
|
||||||
if ( toolbar && toolbar->IsShown() )
|
if ( toolbar && toolbar->IsShown() )
|
||||||
@@ -249,7 +249,7 @@ void wxFrame::DoGetClientSize(int *x, int *y) const
|
|||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFrame::MacIsChildOfClientArea( const wxWindow* child ) const
|
bool wxFrame::MacIsChildOfClientArea( const wxWindow* child ) const
|
||||||
{
|
{
|
||||||
#if wxUSE_STATUSBAR
|
#if wxUSE_STATUSBAR
|
||||||
if ( child == GetStatusBar() )
|
if ( child == GetStatusBar() )
|
||||||
@@ -268,14 +268,14 @@ void wxFrame::DoSetClientSize(int clientwidth, int clientheight)
|
|||||||
{
|
{
|
||||||
int currentclientwidth , currentclientheight ;
|
int currentclientwidth , currentclientheight ;
|
||||||
int currentwidth , currentheight ;
|
int currentwidth , currentheight ;
|
||||||
|
|
||||||
GetClientSize( ¤tclientwidth , ¤tclientheight ) ;
|
GetClientSize( ¤tclientwidth , ¤tclientheight ) ;
|
||||||
if ( clientwidth == -1 )
|
if ( clientwidth == -1 )
|
||||||
clientwidth = currentclientwidth ;
|
clientwidth = currentclientwidth ;
|
||||||
if ( clientheight == -1 )
|
if ( clientheight == -1 )
|
||||||
clientheight = currentclientheight ;
|
clientheight = currentclientheight ;
|
||||||
GetSize( ¤twidth , ¤theight ) ;
|
GetSize( ¤twidth , ¤theight ) ;
|
||||||
|
|
||||||
// find the current client size
|
// find the current client size
|
||||||
|
|
||||||
// Find the difference between the entire window (title bar and all)
|
// Find the difference between the entire window (title bar and all)
|
||||||
@@ -315,7 +315,7 @@ void wxFrame::PositionToolBar()
|
|||||||
{
|
{
|
||||||
int tx, ty, tw, th;
|
int tx, ty, tw, th;
|
||||||
tx = ty = 0 ;
|
tx = ty = 0 ;
|
||||||
|
|
||||||
GetToolBar()->GetSize(& tw, & th);
|
GetToolBar()->GetSize(& tw, & th);
|
||||||
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
|
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
|
||||||
{
|
{
|
||||||
|
@@ -23,17 +23,16 @@
|
|||||||
#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
|
#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
|
||||||
|
|
||||||
#ifdef __DARWIN__
|
#ifdef __DARWIN__
|
||||||
#include <CoreServices/CoreServices.h>
|
#include <CoreServices/CoreServices.h>
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <MacHeaders.c>
|
#include <MacHeaders.c>
|
||||||
#define OTUNIXERRORS 1
|
#define OTUNIXERRORS 1
|
||||||
#include <OpenTransport.h>
|
#include <OpenTransport.h>
|
||||||
#include <OpenTransportProviders.h>
|
#include <OpenTransportProviders.h>
|
||||||
#include <OpenTptInternet.h>
|
#include <OpenTptInternet.h>
|
||||||
#endif
|
#endif
|
||||||
#if TARGET_CARBON && !defined(OTAssert)
|
#if TARGET_CARBON && !defined(OTAssert)
|
||||||
#define OTAssert( str , cond ) /* does not exists in Carbon */
|
#define OTAssert( str , cond ) /* does not exists in Carbon */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -61,22 +60,22 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifndef __GSOCKET_STANDALONE__
|
#ifndef __GSOCKET_STANDALONE__
|
||||||
|
|
||||||
#include "wx/mac/macnotfy.h"
|
#include "wx/mac/macnotfy.h"
|
||||||
#include "wx/mac/gsockmac.h"
|
#include "wx/mac/gsockmac.h"
|
||||||
#include "wx/gsocket.h"
|
#include "wx/gsocket.h"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include "gsockmac.h"
|
#include "gsockmac.h"
|
||||||
#include "gsocket.h"
|
#include "gsocket.h"
|
||||||
|
|
||||||
#endif /* __GSOCKET_STANDALONE__ */
|
#endif /* __GSOCKET_STANDALONE__ */
|
||||||
|
|
||||||
#ifndef ntohl
|
#ifndef ntohl
|
||||||
#define ntohl(x) (x)
|
#define ntohl(x) (x)
|
||||||
#define ntohs(x) (x)
|
#define ntohs(x) (x)
|
||||||
#define htonl(x) (x)
|
#define htonl(x) (x)
|
||||||
#define htons(x) (x)
|
#define htons(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void wxCYield() ;
|
void wxCYield() ;
|
||||||
@@ -95,104 +94,104 @@ OTNotifyUPP gOTNotifierUPP = NULL ;
|
|||||||
OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode);
|
OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode);
|
||||||
|
|
||||||
/* Input: ep - endpointref on which to negotiate the option
|
/* Input: ep - endpointref on which to negotiate the option
|
||||||
enableReuseIPMode - desired option setting - true/false
|
enableReuseIPMode - desired option setting - true/false
|
||||||
Return: kOTNoError indicates that the option was successfully negotiated
|
Return: kOTNoError indicates that the option was successfully negotiated
|
||||||
OSStatus is an error if < 0, otherwise, the status field is
|
OSStatus is an error if < 0, otherwise, the status field is
|
||||||
returned and is > 0.
|
returned and is > 0.
|
||||||
|
|
||||||
IMPORTANT NOTE: The endpoint is assumed to be in synchronous more, otherwise
|
IMPORTANT NOTE: The endpoint is assumed to be in synchronous more, otherwise
|
||||||
this code will not function as desired
|
this code will not function as desired
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
|
OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
|
||||||
|
|
||||||
{
|
{
|
||||||
UInt8 buf[kOTFourByteOptionSize]; // define buffer for fourByte Option size
|
UInt8 buf[kOTFourByteOptionSize]; // define buffer for fourByte Option size
|
||||||
TOption* opt; // option ptr to make items easier to access
|
TOption* opt; // option ptr to make items easier to access
|
||||||
TOptMgmt req;
|
TOptMgmt req;
|
||||||
TOptMgmt ret;
|
TOptMgmt ret;
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
|
|
||||||
if (!OTIsSynchronous(ep))
|
|
||||||
{
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
opt = (TOption*)buf; // set option ptr to buffer
|
|
||||||
req.opt.buf = buf;
|
|
||||||
req.opt.len = sizeof(buf);
|
|
||||||
req.flags = T_NEGOTIATE; // negotiate for option
|
|
||||||
|
|
||||||
ret.opt.buf = buf;
|
if (!OTIsSynchronous(ep))
|
||||||
ret.opt.maxlen = kOTFourByteOptionSize;
|
{
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
opt = (TOption*)buf; // set option ptr to buffer
|
||||||
|
req.opt.buf = buf;
|
||||||
|
req.opt.len = sizeof(buf);
|
||||||
|
req.flags = T_NEGOTIATE; // negotiate for option
|
||||||
|
|
||||||
opt->level = INET_IP; // dealing with an IP Level function
|
ret.opt.buf = buf;
|
||||||
|
ret.opt.maxlen = kOTFourByteOptionSize;
|
||||||
|
|
||||||
|
opt->level = INET_IP; // dealing with an IP Level function
|
||||||
#ifdef __DARWIN__
|
#ifdef __DARWIN__
|
||||||
opt->name = kIP_REUSEADDR;
|
opt->name = kIP_REUSEADDR;
|
||||||
#else
|
#else
|
||||||
opt->name = IP_REUSEADDR;
|
opt->name = IP_REUSEADDR;
|
||||||
#endif
|
#endif
|
||||||
opt->len = kOTFourByteOptionSize;
|
opt->len = kOTFourByteOptionSize;
|
||||||
opt->status = 0;
|
opt->status = 0;
|
||||||
*(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
|
*(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
|
||||||
|
|
||||||
err = OTOptionManagement(ep, &req, &ret);
|
err = OTOptionManagement(ep, &req, &ret);
|
||||||
|
|
||||||
// if no error then return the option status value
|
// if no error then return the option status value
|
||||||
if (err == kOTNoError)
|
if (err == kOTNoError)
|
||||||
{
|
{
|
||||||
if (opt->status != T_SUCCESS)
|
if (opt->status != T_SUCCESS)
|
||||||
err = opt->status;
|
err = opt->status;
|
||||||
else
|
else
|
||||||
err = kOTNoError;
|
err = kOTNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pascal void OTInetEventHandler(void*s, OTEventCode event, OTResult, void *cookie) ;
|
pascal void OTInetEventHandler(void*s, OTEventCode event, OTResult, void *cookie) ;
|
||||||
pascal void OTInetEventHandler(void*s, OTEventCode event, OTResult result, void *cookie)
|
pascal void OTInetEventHandler(void*s, OTEventCode event, OTResult result, void *cookie)
|
||||||
{
|
{
|
||||||
int wakeUp = true ;
|
int wakeUp = true ;
|
||||||
GSocket* sock = (GSocket*) s ;
|
GSocket* sock = (GSocket*) s ;
|
||||||
|
|
||||||
if ( event == kOTSyncIdleEvent )
|
|
||||||
{
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( s )
|
if ( event == kOTSyncIdleEvent )
|
||||||
{
|
{
|
||||||
wxMacAddEvent( sock->m_mac_events , _GSocket_Internal_Proc , event , s , wakeUp ) ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
if ( s )
|
||||||
|
{
|
||||||
|
wxMacAddEvent( sock->m_mac_events , _GSocket_Internal_Proc , event , s , wakeUp ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetDefaultEndpointModes(EndpointRef ep , void *data )
|
static void SetDefaultEndpointModes(EndpointRef ep , void *data )
|
||||||
// This routine sets the supplied endpoint into the default
|
// This routine sets the supplied endpoint into the default
|
||||||
// mode used in this application. The specifics are:
|
// mode used in this application. The specifics are:
|
||||||
// blocking, synchronous, and using synch idle events with
|
// blocking, synchronous, and using synch idle events with
|
||||||
// the standard YieldingNotifier.
|
// the standard YieldingNotifier.
|
||||||
{
|
{
|
||||||
OSStatus junk = kOTNoError ;
|
OSStatus junk = kOTNoError ;
|
||||||
OTAssert ("SetDefaultEndpointModes:invalid ref", ep != kOTInvalidEndpointRef ) ;
|
OTAssert ("SetDefaultEndpointModes:invalid ref", ep != kOTInvalidEndpointRef ) ;
|
||||||
junk = OTSetAsynchronous(ep);
|
junk = OTSetAsynchronous(ep);
|
||||||
OTAssert("SetDefaultEndpointModes: Could not set asynchronous", junk == noErr);
|
OTAssert("SetDefaultEndpointModes: Could not set asynchronous", junk == noErr);
|
||||||
/*
|
/*
|
||||||
junk = OTSetBlocking(ep);
|
junk = OTSetBlocking(ep);
|
||||||
OTAssert("SetDefaultEndpointModes: Could not set blocking", junk == noErr);
|
OTAssert("SetDefaultEndpointModes: Could not set blocking", junk == noErr);
|
||||||
junk = OTSetSynchronous(ep);
|
junk = OTSetSynchronous(ep);
|
||||||
OTAssert("SetDefaultEndpointModes: Could not set synchronous", junk == noErr);
|
OTAssert("SetDefaultEndpointModes: Could not set synchronous", junk == noErr);
|
||||||
junk = OTSetBlocking(ep);
|
junk = OTSetBlocking(ep);
|
||||||
OTAssert("SetDefaultEndpointModes: Could not set blocking", junk == noErr);
|
OTAssert("SetDefaultEndpointModes: Could not set blocking", junk == noErr);
|
||||||
*/
|
*/
|
||||||
junk = OTInstallNotifier(ep, gOTNotifierUPP, data);
|
junk = OTInstallNotifier(ep, gOTNotifierUPP, data);
|
||||||
OTAssert("SetDefaultEndpointModes: Could not install notifier", junk == noErr);
|
OTAssert("SetDefaultEndpointModes: Could not install notifier", junk == noErr);
|
||||||
/*
|
/*
|
||||||
junk = OTUseSyncIdleEvents(ep, true);
|
junk = OTUseSyncIdleEvents(ep, true);
|
||||||
OTAssert("SetDefaultEndpointModes: Could not use sync idle events", junk == noErr);
|
OTAssert("SetDefaultEndpointModes: Could not use sync idle events", junk == noErr);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,19 +222,19 @@ bool GSocket_Verify_Inited()
|
|||||||
InitOpenTransportInContext(kInitOTForApplicationMask, &clientcontext);
|
InitOpenTransportInContext(kInitOTForApplicationMask, &clientcontext);
|
||||||
gOTInited = 1 ;
|
gOTInited = 1 ;
|
||||||
gInetSvcRef = OTOpenInternetServicesInContext(kDefaultInternetServicesPath,
|
gInetSvcRef = OTOpenInternetServicesInContext(kDefaultInternetServicesPath,
|
||||||
NULL, &err, clientcontext);
|
NULL, &err, clientcontext);
|
||||||
#else
|
#else
|
||||||
if ( gInetSvcRef )
|
if ( gInetSvcRef )
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
InitOpenTransport() ;
|
InitOpenTransport() ;
|
||||||
gOTInited = 1 ;
|
gOTInited = 1 ;
|
||||||
gInetSvcRef = OTOpenInternetServices(kDefaultInternetServicesPath, NULL, &err);
|
gInetSvcRef = OTOpenInternetServices(kDefaultInternetServicesPath, NULL, &err);
|
||||||
#endif
|
#endif
|
||||||
if ( gInetSvcRef == NULL || err != kOTNoError )
|
if ( gInetSvcRef == NULL || err != kOTNoError )
|
||||||
{
|
{
|
||||||
OTAssert("Could not open Inet Services", err == noErr);
|
OTAssert("Could not open Inet Services", err == noErr);
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
gOTNotifierUPP = NewOTNotifyUPP( OTInetEventHandler ) ;
|
gOTNotifierUPP = NewOTNotifyUPP( OTInetEventHandler ) ;
|
||||||
return true ;
|
return true ;
|
||||||
@@ -245,8 +244,8 @@ void GSocket_Cleanup()
|
|||||||
{
|
{
|
||||||
if ( gOTInited != 0 )
|
if ( gOTInited != 0 )
|
||||||
{
|
{
|
||||||
if ( gInetSvcRef != NULL )
|
if ( gInetSvcRef != NULL )
|
||||||
OTCloseProvider( gInetSvcRef );
|
OTCloseProvider( gInetSvcRef );
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
CloseOpenTransportInContext( NULL ) ;
|
CloseOpenTransportInContext( NULL ) ;
|
||||||
#else
|
#else
|
||||||
@@ -279,25 +278,25 @@ GSocket::GSocket()
|
|||||||
m_non_blocking = false;
|
m_non_blocking = false;
|
||||||
m_timeout = 1*1000;
|
m_timeout = 1*1000;
|
||||||
/* 10 sec * 1000 millisec */
|
/* 10 sec * 1000 millisec */
|
||||||
m_takesEvents = true ;
|
m_takesEvents = true ;
|
||||||
m_mac_events = wxMacGetNotifierTable() ;
|
m_mac_events = wxMacGetNotifierTable() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSocket::~GSocket()
|
GSocket::~GSocket()
|
||||||
{
|
{
|
||||||
assert(this);
|
assert(this);
|
||||||
|
|
||||||
/* Check that the socket is really shutdowned */
|
/* Check that the socket is really shutdowned */
|
||||||
if (m_endpoint != kOTInvalidEndpointRef)
|
if (m_endpoint != kOTInvalidEndpointRef)
|
||||||
Shutdown();
|
Shutdown();
|
||||||
|
|
||||||
|
|
||||||
/* Destroy private addresses */
|
/* Destroy private addresses */
|
||||||
if (m_local)
|
if (m_local)
|
||||||
GAddress_destroy(m_local);
|
GAddress_destroy(m_local);
|
||||||
|
|
||||||
if (m_peer)
|
if (m_peer)
|
||||||
GAddress_destroy(m_peer);
|
GAddress_destroy(m_peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GSocket_Shutdown:
|
/* GSocket_Shutdown:
|
||||||
@@ -306,32 +305,32 @@ GSocket::~GSocket()
|
|||||||
*/
|
*/
|
||||||
void GSocket::Shutdown()
|
void GSocket::Shutdown()
|
||||||
{
|
{
|
||||||
OSStatus err ;
|
OSStatus err ;
|
||||||
int evt;
|
int evt;
|
||||||
|
|
||||||
assert(this);
|
assert(this);
|
||||||
|
|
||||||
/* If socket has been created, shutdown it */
|
/* If socket has been created, shutdown it */
|
||||||
if (m_endpoint != kOTInvalidEndpointRef )
|
if (m_endpoint != kOTInvalidEndpointRef )
|
||||||
{
|
{
|
||||||
err = OTSndOrderlyDisconnect( m_endpoint ) ;
|
err = OTSndOrderlyDisconnect( m_endpoint ) ;
|
||||||
if ( err != kOTNoError )
|
if ( err != kOTNoError )
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
err = OTRcvOrderlyDisconnect( m_endpoint ) ;
|
|
||||||
err = OTUnbind( m_endpoint ) ;
|
|
||||||
err = OTCloseProvider( m_endpoint ) ;
|
|
||||||
m_endpoint = kOTInvalidEndpointRef ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Disable GUI callbacks */
|
err = OTRcvOrderlyDisconnect( m_endpoint ) ;
|
||||||
for (evt = 0; evt < GSOCK_MAX_EVENT; evt++)
|
err = OTUnbind( m_endpoint ) ;
|
||||||
m_cbacks[evt] = NULL;
|
err = OTCloseProvider( m_endpoint ) ;
|
||||||
|
m_endpoint = kOTInvalidEndpointRef ;
|
||||||
|
}
|
||||||
|
|
||||||
m_detected = 0;
|
/* Disable GUI callbacks */
|
||||||
Disable_Events();
|
for (evt = 0; evt < GSOCK_MAX_EVENT; evt++)
|
||||||
wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ;
|
m_cbacks[evt] = NULL;
|
||||||
|
|
||||||
|
m_detected = 0;
|
||||||
|
Disable_Events();
|
||||||
|
wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -353,109 +352,109 @@ void GSocket::Shutdown()
|
|||||||
*/
|
*/
|
||||||
GSocketError GSocket::SetLocal(GAddress *address)
|
GSocketError GSocket::SetLocal(GAddress *address)
|
||||||
{
|
{
|
||||||
assert(this);
|
assert(this);
|
||||||
|
|
||||||
/* the socket must be initialized, or it must be a server */
|
/* the socket must be initialized, or it must be a server */
|
||||||
if ((m_endpoint != kOTInvalidEndpointRef && !m_server))
|
if ((m_endpoint != kOTInvalidEndpointRef && !m_server))
|
||||||
{
|
{
|
||||||
m_error = GSOCK_INVSOCK;
|
m_error = GSOCK_INVSOCK;
|
||||||
return GSOCK_INVSOCK;
|
return GSOCK_INVSOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check address */
|
/* check address */
|
||||||
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
||||||
{
|
{
|
||||||
m_error = GSOCK_INVADDR;
|
m_error = GSOCK_INVADDR;
|
||||||
return GSOCK_INVADDR;
|
return GSOCK_INVADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_local)
|
if (m_local)
|
||||||
GAddress_destroy(m_local);
|
GAddress_destroy(m_local);
|
||||||
|
|
||||||
m_local = GAddress_copy(address);
|
m_local = GAddress_copy(address);
|
||||||
|
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
GSocketError GSocket::SetPeer(GAddress *address)
|
GSocketError GSocket::SetPeer(GAddress *address)
|
||||||
{
|
{
|
||||||
assert(this);
|
assert(this);
|
||||||
|
|
||||||
/* check address */
|
/* check address */
|
||||||
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
if (address == NULL || address->m_family == GSOCK_NOFAMILY)
|
||||||
{
|
{
|
||||||
m_error = GSOCK_INVADDR;
|
m_error = GSOCK_INVADDR;
|
||||||
return GSOCK_INVADDR;
|
return GSOCK_INVADDR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_peer)
|
if (m_peer)
|
||||||
GAddress_destroy(m_peer);
|
GAddress_destroy(m_peer);
|
||||||
|
|
||||||
m_peer = GAddress_copy(address);
|
m_peer = GAddress_copy(address);
|
||||||
|
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
GAddress *GSocket::GetLocal()
|
GAddress *GSocket::GetLocal()
|
||||||
{
|
{
|
||||||
GAddress *address = NULL ;
|
GAddress *address = NULL ;
|
||||||
GSocketError err;
|
GSocketError err;
|
||||||
InetAddress loc ;
|
InetAddress loc ;
|
||||||
|
|
||||||
assert(this);
|
assert(this);
|
||||||
|
|
||||||
/* try to get it from the m_local var first */
|
/* try to get it from the m_local var first */
|
||||||
if (m_local)
|
if (m_local)
|
||||||
return GAddress_copy(m_local);
|
return GAddress_copy(m_local);
|
||||||
|
|
||||||
|
/* else, if the socket is initialized, try getsockname */
|
||||||
|
if (m_endpoint == kOTInvalidEndpointRef)
|
||||||
|
{
|
||||||
|
m_error = GSOCK_INVSOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* else, if the socket is initialized, try getsockname */
|
|
||||||
if (m_endpoint == kOTInvalidEndpointRef)
|
|
||||||
{
|
|
||||||
m_error = GSOCK_INVSOCK;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* we do not support multihoming with this code at the moment
|
/* we do not support multihoming with this code at the moment
|
||||||
OTGetProtAddress will have to be used then - but we don't have a handy
|
OTGetProtAddress will have to be used then - but we don't have a handy
|
||||||
method to use right now
|
method to use right now
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
InetInterfaceInfo info;
|
InetInterfaceInfo info;
|
||||||
OTInetGetInterfaceInfo(&info, kDefaultInetInterface);
|
OTInetGetInterfaceInfo(&info, kDefaultInetInterface);
|
||||||
loc.fHost = info.fAddress ;
|
loc.fHost = info.fAddress ;
|
||||||
loc.fPort = 0 ;
|
loc.fPort = 0 ;
|
||||||
loc.fAddressType = AF_INET ;
|
loc.fAddressType = AF_INET ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* got a valid address from getsockname, create a GAddress object */
|
/* got a valid address from getsockname, create a GAddress object */
|
||||||
address = GAddress_new();
|
address = GAddress_new();
|
||||||
if (address == NULL)
|
if (address == NULL)
|
||||||
{
|
{
|
||||||
m_error = GSOCK_MEMERR;
|
m_error = GSOCK_MEMERR;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = _GAddress_translate_from(address, &loc);
|
err = _GAddress_translate_from(address, &loc);
|
||||||
if (err != GSOCK_NOERROR)
|
if (err != GSOCK_NOERROR)
|
||||||
{
|
{
|
||||||
GAddress_destroy(address);
|
GAddress_destroy(address);
|
||||||
m_error = err;
|
m_error = err;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
GAddress *GSocket::GetPeer()
|
GAddress *GSocket::GetPeer()
|
||||||
{
|
{
|
||||||
assert(this);
|
assert(this);
|
||||||
|
|
||||||
/* try to get it from the m_peer var */
|
/* try to get it from the m_peer var */
|
||||||
if (m_peer)
|
if (m_peer)
|
||||||
return GAddress_copy(m_peer);
|
return GAddress_copy(m_peer);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Server specific parts */
|
/* Server specific parts */
|
||||||
@@ -464,11 +463,11 @@ GAddress *GSocket::GetPeer()
|
|||||||
* Sets up this socket as a server. The local address must have been
|
* Sets up this socket as a server. The local address must have been
|
||||||
* set with GSocket_SetLocal() before GSocket_SetServer() is called.
|
* set with GSocket_SetLocal() before GSocket_SetServer() is called.
|
||||||
* Returns GSOCK_NOERROR on success, one of the following otherwise:
|
* Returns GSOCK_NOERROR on success, one of the following otherwise:
|
||||||
*
|
*
|
||||||
* Error codes:
|
* Error codes:
|
||||||
* GSOCK_INVSOCK - the socket is in use.
|
* GSOCK_INVSOCK - the socket is in use.
|
||||||
* GSOCK_INVADDR - the local address has not been set.
|
* GSOCK_INVADDR - the local address has not been set.
|
||||||
* GSOCK_IOERR - low-level error.
|
* GSOCK_IOERR - low-level error.
|
||||||
*/
|
*/
|
||||||
GSocketError GSocket::SetServer()
|
GSocketError GSocket::SetServer()
|
||||||
{
|
{
|
||||||
@@ -536,7 +535,7 @@ GSocketError GSocket::SetServer()
|
|||||||
* GSOCK_TIMEDOUT - timeout, no incoming connections.
|
* GSOCK_TIMEDOUT - timeout, no incoming connections.
|
||||||
* GSOCK_WOULDBLOCK - the call would block and the socket is nonblocking.
|
* GSOCK_WOULDBLOCK - the call would block and the socket is nonblocking.
|
||||||
* GSOCK_MEMERR - couldn't allocate memory.
|
* GSOCK_MEMERR - couldn't allocate memory.
|
||||||
* GSOCK_IOERR - low-level error.
|
* GSOCK_IOERR - low-level error.
|
||||||
*/
|
*/
|
||||||
GSocket *GSocket::WaitConnection()
|
GSocket *GSocket::WaitConnection()
|
||||||
{
|
{
|
||||||
@@ -653,7 +652,7 @@ GSocketError GSocket::SetNonOriented()
|
|||||||
m_oriented = false;
|
m_oriented = false;
|
||||||
|
|
||||||
/* Create the socket */
|
/* Create the socket */
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
#if 0
|
#if 0
|
||||||
m_endpoint = socket(m_local->m_realfamily, SOCK_DGRAM, 0);
|
m_endpoint = socket(m_local->m_realfamily, SOCK_DGRAM, 0);
|
||||||
@@ -713,7 +712,7 @@ GSocketError GSocket::SetNonOriented()
|
|||||||
* GSOCK_TIMEDOUT - timeout, the connection failed.
|
* GSOCK_TIMEDOUT - timeout, the connection failed.
|
||||||
* GSOCK_WOULDBLOCK - connection in progress (nonblocking sockets only)
|
* GSOCK_WOULDBLOCK - connection in progress (nonblocking sockets only)
|
||||||
* GSOCK_MEMERR - couldn't allocate memory.
|
* GSOCK_MEMERR - couldn't allocate memory.
|
||||||
* GSOCK_IOERR - low-level error.
|
* GSOCK_IOERR - low-level error.
|
||||||
*/
|
*/
|
||||||
GSocketError GSocket::Connect(GSocketStream stream)
|
GSocketError GSocket::Connect(GSocketStream stream)
|
||||||
{
|
{
|
||||||
@@ -746,10 +745,10 @@ GSocketError GSocket::Connect(GSocketStream stream)
|
|||||||
|
|
||||||
/* Create the socket */
|
/* Create the socket */
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
m_endpoint =
|
m_endpoint =
|
||||||
OTOpenEndpointInContext( OTCreateConfiguration( kTCPName) , 0 , &info , &err , NULL ) ;
|
OTOpenEndpointInContext( OTCreateConfiguration( kTCPName) , 0 , &info , &err , NULL ) ;
|
||||||
#else
|
#else
|
||||||
m_endpoint =
|
m_endpoint =
|
||||||
OTOpenEndpoint( OTCreateConfiguration( kTCPName) , 0 , &info , &err ) ;
|
OTOpenEndpoint( OTCreateConfiguration( kTCPName) , 0 , &info , &err ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( m_endpoint == kOTInvalidEndpointRef || err != kOTNoError )
|
if ( m_endpoint == kOTInvalidEndpointRef || err != kOTNoError )
|
||||||
@@ -781,8 +780,8 @@ GSocketError GSocket::Connect(GSocketStream stream)
|
|||||||
* is in blocking mode, we select() for the specified timeout
|
* is in blocking mode, we select() for the specified timeout
|
||||||
* checking for writability to see if the connection request
|
* checking for writability to see if the connection request
|
||||||
* completes.
|
* completes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((err == kOTNoDataErr ) && (!m_non_blocking))
|
if ((err == kOTNoDataErr ) && (!m_non_blocking))
|
||||||
{
|
{
|
||||||
if (Output_Timeout() == GSOCK_TIMEDOUT)
|
if (Output_Timeout() == GSOCK_TIMEDOUT)
|
||||||
@@ -858,7 +857,7 @@ int GSocket::Read(char *buffer, int size)
|
|||||||
ret = Recv_Stream(buffer, size);
|
ret = Recv_Stream(buffer, size);
|
||||||
else
|
else
|
||||||
ret = Recv_Dgram(buffer, size);
|
ret = Recv_Dgram(buffer, size);
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
if (errno == EWOULDBLOCK)
|
if (errno == EWOULDBLOCK)
|
||||||
@@ -866,12 +865,12 @@ int GSocket::Read(char *buffer, int size)
|
|||||||
else
|
else
|
||||||
m_error = GSOCK_IOERR;
|
m_error = GSOCK_IOERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GSocket::Write(const char *buffer, int size)
|
int GSocket::Write(const char *buffer, int size)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
assert(this);
|
assert(this);
|
||||||
@@ -891,7 +890,7 @@ int GSocket::Write(const char *buffer, int size)
|
|||||||
ret = Send_Stream(buffer, size);
|
ret = Send_Stream(buffer, size);
|
||||||
else
|
else
|
||||||
ret = Send_Dgram(buffer, size);
|
ret = Send_Dgram(buffer, size);
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
if (errno == EWOULDBLOCK)
|
if (errno == EWOULDBLOCK)
|
||||||
@@ -907,7 +906,7 @@ int GSocket::Write(const char *buffer, int size)
|
|||||||
m_detected &= ~GSOCK_OUTPUT_FLAG;
|
m_detected &= ~GSOCK_OUTPUT_FLAG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -924,7 +923,7 @@ GSocketEventFlags GSocket::Select(GSocketEventFlags flags)
|
|||||||
wxMacProcessNotifierEvents() ;
|
wxMacProcessNotifierEvents() ;
|
||||||
/*
|
/*
|
||||||
state = OTGetEndpointState(m_endpoint);
|
state = OTGetEndpointState(m_endpoint);
|
||||||
|
|
||||||
if ( ( flags & GSOCK_INPUT_FLAG ) && ! ( m_detected & GSOCK_INPUT_FLAG ) )
|
if ( ( flags & GSOCK_INPUT_FLAG ) && ! ( m_detected & GSOCK_INPUT_FLAG ) )
|
||||||
{
|
{
|
||||||
size_t sz = 0 ;
|
size_t sz = 0 ;
|
||||||
@@ -992,7 +991,7 @@ GSocketError WXDLLIMPEXP_NET GSocket::GetError()
|
|||||||
* operation, there is still data available, the callback function will
|
* operation, there is still data available, the callback function will
|
||||||
* be called again.
|
* be called again.
|
||||||
* GSOCK_OUTPUT:
|
* GSOCK_OUTPUT:
|
||||||
* The socket is available for writing. That is, the next write call
|
* The socket is available for writing. That is, the next write call
|
||||||
* won't block. This event is generated only once, when the connection is
|
* won't block. This event is generated only once, when the connection is
|
||||||
* first established, and then only if a call failed with GSOCK_WOULDBLOCK,
|
* first established, and then only if a call failed with GSOCK_WOULDBLOCK,
|
||||||
* when the output buffer empties again. This means that the app should
|
* when the output buffer empties again. This means that the app should
|
||||||
@@ -1073,7 +1072,7 @@ int GSocket::Recv_Stream(char *buffer, int size)
|
|||||||
{
|
{
|
||||||
return -1 ;
|
return -1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we simulate another read event if there are still bytes
|
// we simulate another read event if there are still bytes
|
||||||
if ( m_takesEvents )
|
if ( m_takesEvents )
|
||||||
{
|
{
|
||||||
@@ -1290,7 +1289,7 @@ GSocketError _GAddress_Init_INET(GAddress *address)
|
|||||||
{
|
{
|
||||||
address->m_family = GSOCK_INET;
|
address->m_family = GSOCK_INET;
|
||||||
address->m_host = kOTAnyInetAddress ;
|
address->m_host = kOTAnyInetAddress ;
|
||||||
|
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1311,7 +1310,7 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
|
|||||||
address->m_host = INADDR_NONE ;
|
address->m_host = INADDR_NONE ;
|
||||||
address->m_error = GSOCK_NOHOST;
|
address->m_error = GSOCK_NOHOST;
|
||||||
return GSOCK_NOHOST;
|
return GSOCK_NOHOST;
|
||||||
}
|
}
|
||||||
address->m_host = hinfo.addrs[0] ;
|
address->m_host = hinfo.addrs[0] ;
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
@@ -1333,17 +1332,17 @@ GSocketError GAddress_INET_SetHostAddress(GAddress *address,
|
|||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct service_entry
|
struct service_entry
|
||||||
{
|
{
|
||||||
const char * name ;
|
const char * name ;
|
||||||
unsigned short port ;
|
unsigned short port ;
|
||||||
const char * protocol ;
|
const char * protocol ;
|
||||||
} ;
|
} ;
|
||||||
typedef struct service_entry service_entry ;
|
typedef struct service_entry service_entry ;
|
||||||
|
|
||||||
service_entry gServices[] =
|
service_entry gServices[] =
|
||||||
{
|
{
|
||||||
{ "http" , 80 , "tcp" }
|
{ "http" , 80 , "tcp" }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
|
GSocketError GAddress_INET_SetPortName(GAddress *address, const char *port,
|
||||||
@@ -1386,7 +1385,7 @@ GSocketError GAddress_INET_SetPort(GAddress *address, unsigned short port)
|
|||||||
assert(address != NULL);
|
assert(address != NULL);
|
||||||
CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
|
CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
|
||||||
address->m_port = port ;
|
address->m_port = port ;
|
||||||
|
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1395,8 +1394,8 @@ GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t
|
|||||||
InetDomainName name ;
|
InetDomainName name ;
|
||||||
if ( !GSocket_Verify_Inited() )
|
if ( !GSocket_Verify_Inited() )
|
||||||
return GSOCK_IOERR ;
|
return GSOCK_IOERR ;
|
||||||
|
|
||||||
assert(address != NULL);
|
assert(address != NULL);
|
||||||
CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
|
CHECK_ADDRESS(address, INET, GSOCK_INVADDR);
|
||||||
|
|
||||||
OTInetAddressToName( gInetSvcRef , address->m_host , name ) ;
|
OTInetAddressToName( gInetSvcRef , address->m_host , name ) ;
|
||||||
@@ -1406,16 +1405,16 @@ GSocketError GAddress_INET_GetHostName(GAddress *address, char *hostname, size_t
|
|||||||
|
|
||||||
unsigned long GAddress_INET_GetHostAddress(GAddress *address)
|
unsigned long GAddress_INET_GetHostAddress(GAddress *address)
|
||||||
{
|
{
|
||||||
assert(address != NULL);
|
assert(address != NULL);
|
||||||
CHECK_ADDRESS(address, INET, 0);
|
CHECK_ADDRESS(address, INET, 0);
|
||||||
|
|
||||||
return ntohl(address->m_host);
|
return ntohl(address->m_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short GAddress_INET_GetPort(GAddress *address)
|
unsigned short GAddress_INET_GetPort(GAddress *address)
|
||||||
{
|
{
|
||||||
assert(address != NULL);
|
assert(address != NULL);
|
||||||
CHECK_ADDRESS(address, INET, 0);
|
CHECK_ADDRESS(address, INET, 0);
|
||||||
|
|
||||||
return address->m_port;
|
return address->m_port;
|
||||||
}
|
}
|
||||||
@@ -1424,12 +1423,12 @@ void GSocket::Enable_Events()
|
|||||||
{
|
{
|
||||||
if ( m_takesEvents )
|
if ( m_takesEvents )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
{
|
{
|
||||||
OTResult state ;
|
OTResult state ;
|
||||||
m_takesEvents = true ;
|
m_takesEvents = true ;
|
||||||
state = OTGetEndpointState(m_endpoint);
|
state = OTGetEndpointState(m_endpoint);
|
||||||
|
|
||||||
{
|
{
|
||||||
OTByteCount sz = 0 ;
|
OTByteCount sz = 0 ;
|
||||||
OTCountDataBytes( m_endpoint , &sz ) ;
|
OTCountDataBytes( m_endpoint , &sz ) ;
|
||||||
@@ -1467,20 +1466,20 @@ GSocketError GSocket::Input_Timeout()
|
|||||||
Microseconds(&start);
|
Microseconds(&start);
|
||||||
now = start ;
|
now = start ;
|
||||||
m_takesEvents = false ;
|
m_takesEvents = false ;
|
||||||
|
|
||||||
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < m_timeout * 1000.0 )
|
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < m_timeout * 1000.0 )
|
||||||
{
|
{
|
||||||
OTResult state ;
|
OTResult state ;
|
||||||
OTByteCount sz = 0 ;
|
OTByteCount sz = 0 ;
|
||||||
state = OTGetEndpointState(m_endpoint);
|
state = OTGetEndpointState(m_endpoint);
|
||||||
|
|
||||||
OTCountDataBytes( m_endpoint , &sz ) ;
|
OTCountDataBytes( m_endpoint , &sz ) ;
|
||||||
if ( state == T_INCON || sz > 0 )
|
if ( state == T_INCON || sz > 0 )
|
||||||
{
|
{
|
||||||
m_takesEvents = formerTakesEvents ;
|
m_takesEvents = formerTakesEvents ;
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
Microseconds(&now);
|
Microseconds(&now);
|
||||||
}
|
}
|
||||||
m_takesEvents = formerTakesEvents ;
|
m_takesEvents = formerTakesEvents ;
|
||||||
m_error = GSOCK_TIMEDOUT;
|
m_error = GSOCK_TIMEDOUT;
|
||||||
@@ -1502,18 +1501,18 @@ GSocketError GSocket::Output_Timeout()
|
|||||||
Microseconds(&start);
|
Microseconds(&start);
|
||||||
now = start ;
|
now = start ;
|
||||||
m_takesEvents = false ;
|
m_takesEvents = false ;
|
||||||
|
|
||||||
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < m_timeout * 1000.0 )
|
while( (now.hi * 4294967296.0 + now.lo) - (start.hi * 4294967296.0 + start.lo) < m_timeout * 1000.0 )
|
||||||
{
|
{
|
||||||
OTResult state ;
|
OTResult state ;
|
||||||
state = OTGetEndpointState(m_endpoint);
|
state = OTGetEndpointState(m_endpoint);
|
||||||
|
|
||||||
if ( state == T_DATAXFER || state == T_INREL )
|
if ( state == T_DATAXFER || state == T_INREL )
|
||||||
{
|
{
|
||||||
m_takesEvents = formerTakesEvents ;
|
m_takesEvents = formerTakesEvents ;
|
||||||
return GSOCK_NOERROR;
|
return GSOCK_NOERROR;
|
||||||
}
|
}
|
||||||
Microseconds(&now);
|
Microseconds(&now);
|
||||||
}
|
}
|
||||||
m_takesEvents = formerTakesEvents ;
|
m_takesEvents = formerTakesEvents ;
|
||||||
m_error = GSOCK_TIMEDOUT;
|
m_error = GSOCK_TIMEDOUT;
|
||||||
@@ -1527,7 +1526,7 @@ GSocketError GSocket::Output_Timeout()
|
|||||||
* operation, there is still data available, the callback function will
|
* operation, there is still data available, the callback function will
|
||||||
* be called again.
|
* be called again.
|
||||||
* GSOCK_OUTPUT:
|
* GSOCK_OUTPUT:
|
||||||
* The socket is available for writing. That is, the next write call
|
* The socket is available for writing. That is, the next write call
|
||||||
* won't block. This event is generated only once, when the connection is
|
* won't block. This event is generated only once, when the connection is
|
||||||
* first established, and then only if a call failed with GSOCK_WOULDBLOCK,
|
* first established, and then only if a call failed with GSOCK_WOULDBLOCK,
|
||||||
* when the output buffer empties again. This means that the app should
|
* when the output buffer empties again. This means that the app should
|
||||||
@@ -1544,18 +1543,19 @@ GSocketError GSocket::Output_Timeout()
|
|||||||
|
|
||||||
void _GSocket_Internal_Proc(unsigned long e , void* d )
|
void _GSocket_Internal_Proc(unsigned long e , void* d )
|
||||||
{
|
{
|
||||||
|
GSocket *socket = (GSocket*) d ;
|
||||||
GSocket * socket = (GSocket*) d ;
|
|
||||||
OTEventCode ev = (OTEventCode) e ;
|
if ( !socket )
|
||||||
GSocketEvent event;
|
return ;
|
||||||
GSocketEvent event2;
|
|
||||||
GSocketCallback cback;
|
OTEventCode ev = (OTEventCode) e ;
|
||||||
char *data;
|
GSocketEvent event;
|
||||||
GSocketCallback cback2;
|
GSocketEvent event2;
|
||||||
char *data2;
|
GSocketCallback cback;
|
||||||
|
char *data;
|
||||||
|
GSocketCallback cback2;
|
||||||
|
char *data2;
|
||||||
|
|
||||||
if ( !socket )
|
|
||||||
return ;
|
|
||||||
event = GSOCK_MAX_EVENT ;
|
event = GSOCK_MAX_EVENT ;
|
||||||
event2 = GSOCK_MAX_EVENT ;
|
event2 = GSOCK_MAX_EVENT ;
|
||||||
cback = NULL;
|
cback = NULL;
|
||||||
@@ -1567,7 +1567,7 @@ void _GSocket_Internal_Proc(unsigned long e , void* d )
|
|||||||
* destroyed) and for safety, check that the m_endpoint field
|
* destroyed) and for safety, check that the m_endpoint field
|
||||||
* is what we expect it to be.
|
* is what we expect it to be.
|
||||||
*/
|
*/
|
||||||
if ((socket != NULL) && (socket->m_takesEvents))
|
if ( /* (socket != NULL) && */ (socket->m_takesEvents))
|
||||||
{
|
{
|
||||||
switch (ev)
|
switch (ev)
|
||||||
{
|
{
|
||||||
@@ -1579,7 +1579,7 @@ void _GSocket_Internal_Proc(unsigned long e , void* d )
|
|||||||
event2 = GSOCK_OUTPUT ;
|
event2 = GSOCK_OUTPUT ;
|
||||||
{
|
{
|
||||||
TCall retCall;
|
TCall retCall;
|
||||||
|
|
||||||
retCall.addr.buf = NULL;
|
retCall.addr.buf = NULL;
|
||||||
retCall.addr.maxlen = 0;
|
retCall.addr.maxlen = 0;
|
||||||
retCall.opt.buf = NULL;
|
retCall.opt.buf = NULL;
|
||||||
|
@@ -135,15 +135,15 @@ wxMenu *
|
|||||||
_wxMenuAt(const wxMenuList &menuList, size_t pos)
|
_wxMenuAt(const wxMenuList &menuList, size_t pos)
|
||||||
{
|
{
|
||||||
wxMenuList::compatibility_iterator menuIter = menuList.GetFirst();
|
wxMenuList::compatibility_iterator menuIter = menuList.GetFirst();
|
||||||
|
|
||||||
while (pos-- > 0) menuIter = menuIter->GetNext();
|
while (pos-- > 0) menuIter = menuIter->GetNext();
|
||||||
|
|
||||||
return menuIter->GetData() ;
|
return menuIter->GetData() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMenu::Init()
|
void wxMenu::Init()
|
||||||
{
|
{
|
||||||
m_doBreak = FALSE;
|
m_doBreak = false;
|
||||||
m_startRadioGroup = -1;
|
m_startRadioGroup = -1;
|
||||||
|
|
||||||
// create the menu
|
// create the menu
|
||||||
@@ -158,7 +158,7 @@ void wxMenu::Init()
|
|||||||
wxAssociateMenuWithMacMenu( (MenuRef)m_hMenu , this ) ;
|
wxAssociateMenuWithMacMenu( (MenuRef)m_hMenu , this ) ;
|
||||||
|
|
||||||
// if we have a title, insert it in the beginning of the menu
|
// if we have a title, insert it in the beginning of the menu
|
||||||
if ( !!m_title )
|
if ( !m_title.empty() )
|
||||||
{
|
{
|
||||||
Append(idMenuTitle, m_title) ;
|
Append(idMenuTitle, m_title) ;
|
||||||
AppendSeparator() ;
|
AppendSeparator() ;
|
||||||
@@ -250,7 +250,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
|
|||||||
{
|
{
|
||||||
GetMenuBar()->Refresh();
|
GetMenuBar()->Refresh();
|
||||||
}
|
}
|
||||||
return TRUE ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMenu::EndRadioGroup()
|
void wxMenu::EndRadioGroup()
|
||||||
@@ -263,7 +263,7 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") );
|
wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") );
|
||||||
|
|
||||||
bool check = FALSE;
|
bool check = false;
|
||||||
|
|
||||||
if ( item->GetKind() == wxITEM_RADIO )
|
if ( item->GetKind() == wxITEM_RADIO )
|
||||||
{
|
{
|
||||||
@@ -279,7 +279,7 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
|
|||||||
item->SetRadioGroupEnd(m_startRadioGroup);
|
item->SetRadioGroupEnd(m_startRadioGroup);
|
||||||
|
|
||||||
// ensure that we have a checked item in the radio group
|
// ensure that we have a checked item in the radio group
|
||||||
check = TRUE;
|
check = true;
|
||||||
}
|
}
|
||||||
else // extend the current radio group
|
else // extend the current radio group
|
||||||
{
|
{
|
||||||
@@ -310,7 +310,7 @@ wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
|
|||||||
if ( check )
|
if ( check )
|
||||||
{
|
{
|
||||||
// check the item initially
|
// check the item initially
|
||||||
item->Check(TRUE);
|
item->Check(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
@@ -354,15 +354,16 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
|
|||||||
|
|
||||||
void wxMenu::SetTitle(const wxString& label)
|
void wxMenu::SetTitle(const wxString& label)
|
||||||
{
|
{
|
||||||
m_title = label ;
|
m_title = label ;
|
||||||
UMASetMenuTitle(MAC_WXHMENU(m_hMenu) , label , wxFont::GetDefaultEncoding() ) ;
|
UMASetMenuTitle(MAC_WXHMENU(m_hMenu) , label , wxFont::GetDefaultEncoding() ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMenu::ProcessCommand(wxCommandEvent & event)
|
bool wxMenu::ProcessCommand(wxCommandEvent & event)
|
||||||
{
|
{
|
||||||
bool processed = FALSE;
|
bool processed = false;
|
||||||
|
|
||||||
// Try the menu's event handler
|
// Try the menu's event handler
|
||||||
if ( !processed && GetEventHandler())
|
if ( /* !processed && */ GetEventHandler())
|
||||||
{
|
{
|
||||||
processed = GetEventHandler()->ProcessEvent(event);
|
processed = GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
@@ -464,7 +465,7 @@ void wxMenu::MacBeforeDisplay( bool isSubMenu )
|
|||||||
( UMAGetSystemVersion() >= 0x1000 && (
|
( UMAGetSystemVersion() >= 0x1000 && (
|
||||||
item->GetId() == wxApp::s_macPreferencesMenuItemId ||
|
item->GetId() == wxApp::s_macPreferencesMenuItemId ||
|
||||||
item->GetId() == wxApp::s_macExitMenuItemId ) ) )
|
item->GetId() == wxApp::s_macExitMenuItemId ) ) )
|
||||||
|
|
||||||
{
|
{
|
||||||
ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ),
|
ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ),
|
||||||
pos + 1, kMenuItemAttrHidden, 0 );
|
pos + 1, kMenuItemAttrHidden, 0 );
|
||||||
@@ -654,7 +655,7 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
|
|
||||||
// clean-up the help menu before adding new items
|
// clean-up the help menu before adding new items
|
||||||
static MenuHandle mh = NULL ;
|
static MenuHandle mh = NULL ;
|
||||||
|
|
||||||
if ( mh != NULL )
|
if ( mh != NULL )
|
||||||
{
|
{
|
||||||
MenuItemIndex firstUserHelpMenuItem ;
|
MenuItemIndex firstUserHelpMenuItem ;
|
||||||
@@ -668,7 +669,7 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mh = NULL ;
|
mh = NULL ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId)
|
if ( UMAGetSystemVersion() >= 0x1000 && wxApp::s_macPreferencesMenuItemId)
|
||||||
@@ -725,7 +726,7 @@ void wxMenuBar::MacInstallMenuBar()
|
|||||||
{
|
{
|
||||||
mh = NULL ;
|
mh = NULL ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( item->IsSeparator() )
|
if ( item->IsSeparator() )
|
||||||
@@ -860,7 +861,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
{
|
{
|
||||||
wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title);
|
wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title);
|
||||||
if ( !menuOld )
|
if ( !menuOld )
|
||||||
return FALSE;
|
return false;
|
||||||
m_titles[pos] = title;
|
m_titles[pos] = title;
|
||||||
|
|
||||||
if ( IsAttached() )
|
if ( IsAttached() )
|
||||||
@@ -894,7 +895,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
||||||
{
|
{
|
||||||
if ( !wxMenuBarBase::Insert(pos, menu, title) )
|
if ( !wxMenuBarBase::Insert(pos, menu, title) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_titles.Insert(title, pos);
|
m_titles.Insert(title, pos);
|
||||||
|
|
||||||
@@ -919,7 +920,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
if (m_invokingWindow)
|
if (m_invokingWindow)
|
||||||
wxMenubarSetInvokingWindow( menu, m_invokingWindow );
|
wxMenubarSetInvokingWindow( menu, m_invokingWindow );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu *wxMenuBar::Remove(size_t pos)
|
wxMenu *wxMenuBar::Remove(size_t pos)
|
||||||
@@ -946,10 +947,10 @@ wxMenu *wxMenuBar::Remove(size_t pos)
|
|||||||
bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
|
bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
|
||||||
{
|
{
|
||||||
WXHMENU submenu = menu ? menu->GetHMenu() : 0;
|
WXHMENU submenu = menu ? menu->GetHMenu() : 0;
|
||||||
wxCHECK_MSG( submenu, FALSE, wxT("can't append invalid menu to menubar") );
|
wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") );
|
||||||
|
|
||||||
if ( !wxMenuBarBase::Append(menu, title) )
|
if ( !wxMenuBarBase::Append(menu, title) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_titles.Add(title);
|
m_titles.Add(title);
|
||||||
|
|
||||||
@@ -971,7 +972,7 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
|
|||||||
if (m_invokingWindow)
|
if (m_invokingWindow)
|
||||||
wxMenubarSetInvokingWindow( menu, m_invokingWindow );
|
wxMenubarSetInvokingWindow( menu, m_invokingWindow );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wxMenubarUnsetInvokingWindow( wxMenu *menu )
|
static void wxMenubarUnsetInvokingWindow( wxMenu *menu )
|
||||||
|
@@ -87,7 +87,7 @@ wxMetaFile::wxMetaFile(const wxString& file)
|
|||||||
m_refData = new wxMetafileRefData;
|
m_refData = new wxMetafileRefData;
|
||||||
|
|
||||||
M_METAFILEDATA->m_metafile = 0;
|
M_METAFILEDATA->m_metafile = 0;
|
||||||
wxASSERT_MSG( file.IsEmpty() , wxT("no file based metafile support yet") ) ;
|
wxASSERT_MSG( file.empty() , wxT("no file based metafile support yet") ) ;
|
||||||
/*
|
/*
|
||||||
if (!file.IsNull() && (file.Cmp("") == 0))
|
if (!file.IsNull() && (file.Cmp("") == 0))
|
||||||
M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
|
M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
|
||||||
@@ -98,23 +98,25 @@ wxMetaFile::~wxMetaFile()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMetaFile::Ok() const
|
bool wxMetaFile::Ok() const
|
||||||
{
|
{
|
||||||
return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0));
|
return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
WXHMETAFILE wxMetaFile::GetHMETAFILE() const
|
WXHMETAFILE wxMetaFile::GetHMETAFILE() const
|
||||||
{
|
{
|
||||||
return (WXHMETAFILE) M_METAFILEDATA->m_metafile;
|
return (WXHMETAFILE) M_METAFILEDATA->m_metafile;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMetaFile::SetClipboard(int width, int height)
|
bool wxMetaFile::SetClipboard(int width, int height)
|
||||||
{
|
{
|
||||||
|
bool success = true;
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
//TODO finishi this port , we need the data obj first
|
//TODO finishi this port , we need the data obj first
|
||||||
if (!m_refData)
|
if (!m_refData)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
bool alreadyOpen=wxTheClipboard->IsOpened() ;
|
bool alreadyOpen=wxTheClipboard->IsOpened() ;
|
||||||
if (!alreadyOpen)
|
if (!alreadyOpen)
|
||||||
{
|
{
|
||||||
@@ -123,18 +125,18 @@ bool wxMetaFile::SetClipboard(int width, int height)
|
|||||||
}
|
}
|
||||||
wxDataObject *data =
|
wxDataObject *data =
|
||||||
new wxMetafileDataObject( *this) ;
|
new wxMetafileDataObject( *this) ;
|
||||||
bool success = wxTheClipboard->SetData(data);
|
success = wxTheClipboard->SetData(data);
|
||||||
if (!alreadyOpen)
|
if (!alreadyOpen)
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
return (bool) success;
|
|
||||||
#endif
|
#endif
|
||||||
return TRUE ;
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMetafile::SetHMETAFILE(WXHMETAFILE mf)
|
void wxMetafile::SetHMETAFILE(WXHMETAFILE mf)
|
||||||
{
|
{
|
||||||
UnRef() ;
|
UnRef() ;
|
||||||
|
|
||||||
m_refData = new wxMetafileRefData;
|
m_refData = new wxMetafileRefData;
|
||||||
|
|
||||||
M_METAFILEDATA->m_metafile = (PicHandle) mf;
|
M_METAFILEDATA->m_metafile = (PicHandle) mf;
|
||||||
@@ -158,18 +160,18 @@ void wxMetafile::SetHMETAFILE(WXHMETAFILE mf)
|
|||||||
bool wxMetaFile::Play(wxDC *dc)
|
bool wxMetaFile::Play(wxDC *dc)
|
||||||
{
|
{
|
||||||
if (!m_refData)
|
if (!m_refData)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!dc->Ok() )
|
if (!dc->Ok() )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
{
|
{
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
QDPictRef cgPictRef = M_METAFILEDATA->m_qdPictRef ;
|
QDPictRef cgPictRef = M_METAFILEDATA->m_qdPictRef ;
|
||||||
CGContextRef cg = ((wxMacCGContext*)(dc->GetGraphicContext()))->GetNativeContext() ;
|
CGContextRef cg = ((wxMacCGContext*)(dc->GetGraphicContext()))->GetNativeContext() ;
|
||||||
CGRect bounds = QDPictGetBounds( cgPictRef ) ;
|
CGRect bounds = QDPictGetBounds( cgPictRef ) ;
|
||||||
|
|
||||||
CGContextSaveGState(cg);
|
CGContextSaveGState(cg);
|
||||||
CGContextTranslateCTM(cg, 0 , bounds.size.width );
|
CGContextTranslateCTM(cg, 0 , bounds.size.width );
|
||||||
CGContextScaleCTM(cg, 1, -1);
|
CGContextScaleCTM(cg, 1, -1);
|
||||||
QDPictDrawToCGContext( cg , bounds , cgPictRef ) ;
|
QDPictDrawToCGContext( cg , bounds , cgPictRef ) ;
|
||||||
@@ -180,7 +182,7 @@ bool wxMetaFile::Play(wxDC *dc)
|
|||||||
DrawPicture( pict , &(**pict).picFrame ) ;
|
DrawPicture( pict , &(**pict).picFrame ) ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxMetaFile::GetSize() const
|
wxSize wxMetaFile::GetSize() const
|
||||||
@@ -210,21 +212,21 @@ wxMetaFileDC::wxMetaFileDC(const wxString& filename ,
|
|||||||
const wxString& WXUNUSED(description) )
|
const wxString& WXUNUSED(description) )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( width == 0 || height == 0 , _T("no arbitration of metafilesize supported") ) ;
|
wxASSERT_MSG( width == 0 || height == 0 , _T("no arbitration of metafilesize supported") ) ;
|
||||||
wxASSERT_MSG( filename.IsEmpty() , _T("no file based metafile support yet")) ;
|
wxASSERT_MSG( filename.empty() , _T("no file based metafile support yet")) ;
|
||||||
|
|
||||||
m_metaFile = new wxMetaFile(filename) ;
|
m_metaFile = new wxMetaFile(filename) ;
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
#else
|
#else
|
||||||
Rect r={0,0,height,width} ;
|
Rect r={0,0,height,width} ;
|
||||||
|
|
||||||
RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ;
|
RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ;
|
||||||
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
|
||||||
|
|
||||||
m_metaFile->SetHMETAFILE( (WXHMETAFILE) OpenPicture( &r ) ) ;
|
m_metaFile->SetHMETAFILE( (WXHMETAFILE) OpenPicture( &r ) ) ;
|
||||||
::GetPort( (GrafPtr*) &m_macPort ) ;
|
::GetPort( (GrafPtr*) &m_macPort ) ;
|
||||||
m_ok = TRUE ;
|
m_ok = true ;
|
||||||
#endif
|
#endif
|
||||||
SetMapMode(wxMM_TEXT);
|
SetMapMode(wxMM_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMetaFileDC::~wxMetaFileDC()
|
wxMetaFileDC::~wxMetaFileDC()
|
||||||
|
@@ -33,7 +33,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
|||||||
{
|
{
|
||||||
int major,minor;
|
int major,minor;
|
||||||
wxGetOsVersion( &major, &minor );
|
wxGetOsVersion( &major, &minor );
|
||||||
|
|
||||||
switch( index )
|
switch( index )
|
||||||
{
|
{
|
||||||
case wxSYS_COLOUR_SCROLLBAR :
|
case wxSYS_COLOUR_SCROLLBAR :
|
||||||
@@ -84,7 +84,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
|||||||
case wxSYS_COLOUR_GRAYTEXT:
|
case wxSYS_COLOUR_GRAYTEXT:
|
||||||
return wxColor( 0xCC , 0xCC , 0xCC ) ;
|
return wxColor( 0xCC , 0xCC , 0xCC ) ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case wxSYS_COLOUR_3DDKSHADOW:
|
case wxSYS_COLOUR_3DDKSHADOW:
|
||||||
return wxColor( 0x44 , 0x44 , 0x44 ) ;
|
return wxColor( 0x44 , 0x44 , 0x44 ) ;
|
||||||
break ;
|
break ;
|
||||||
@@ -102,7 +102,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
|||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case wxSYS_COLOUR_INFOBK :
|
case wxSYS_COLOUR_INFOBK :
|
||||||
case wxSYS_COLOUR_APPWORKSPACE:
|
case wxSYS_COLOUR_APPWORKSPACE:
|
||||||
return *wxWHITE ;
|
return *wxWHITE ;
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
|||||||
case wxSYS_COLOUR_MENUHILIGHT:
|
case wxSYS_COLOUR_MENUHILIGHT:
|
||||||
// TODO
|
// TODO
|
||||||
return *wxBLACK;
|
return *wxBLACK;
|
||||||
|
|
||||||
case wxSYS_COLOUR_MAX:
|
case wxSYS_COLOUR_MAX:
|
||||||
wxFAIL_MSG( _T("unknown system colour index") );
|
wxFAIL_MSG( _T("unknown system colour index") );
|
||||||
break ;
|
break ;
|
||||||
@@ -134,17 +134,11 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
|
|||||||
case wxSYS_DEFAULT_GUI_FONT :
|
case wxSYS_DEFAULT_GUI_FONT :
|
||||||
{
|
{
|
||||||
return *wxSMALL_FONT ;
|
return *wxSMALL_FONT ;
|
||||||
} ;
|
} ;
|
||||||
break ;
|
break ;
|
||||||
case wxSYS_OEM_FIXED_FONT :
|
|
||||||
case wxSYS_ANSI_FIXED_FONT :
|
|
||||||
case wxSYS_SYSTEM_FIXED_FONT :
|
|
||||||
default :
|
default :
|
||||||
{
|
|
||||||
return *wxNORMAL_FONT ;
|
|
||||||
} ;
|
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
}
|
}
|
||||||
return *wxNORMAL_FONT;
|
return *wxNORMAL_FONT;
|
||||||
}
|
}
|
||||||
@@ -163,7 +157,7 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(w
|
|||||||
case wxSYS_MOUSE_BUTTONS:
|
case wxSYS_MOUSE_BUTTONS:
|
||||||
// we emulate a two button mouse (ctrl + click = right button )
|
// we emulate a two button mouse (ctrl + click = right button )
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
// TODO case wxSYS_BORDER_X:
|
// TODO case wxSYS_BORDER_X:
|
||||||
// TODO case wxSYS_BORDER_Y:
|
// TODO case wxSYS_BORDER_Y:
|
||||||
// TODO case wxSYS_CURSOR_X:
|
// TODO case wxSYS_CURSOR_X:
|
||||||
@@ -174,14 +168,14 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(w
|
|||||||
// TODO case wxSYS_DRAG_Y:
|
// TODO case wxSYS_DRAG_Y:
|
||||||
// TODO case wxSYS_EDGE_X:
|
// TODO case wxSYS_EDGE_X:
|
||||||
// TODO case wxSYS_EDGE_Y:
|
// TODO case wxSYS_EDGE_Y:
|
||||||
|
|
||||||
case wxSYS_HSCROLL_ARROW_X:
|
case wxSYS_HSCROLL_ARROW_X:
|
||||||
return 16;
|
return 16;
|
||||||
case wxSYS_HSCROLL_ARROW_Y:
|
case wxSYS_HSCROLL_ARROW_Y:
|
||||||
return 16;
|
return 16;
|
||||||
case wxSYS_HTHUMB_X:
|
case wxSYS_HTHUMB_X:
|
||||||
return 16;
|
return 16;
|
||||||
|
|
||||||
// TODO case wxSYS_ICON_X:
|
// TODO case wxSYS_ICON_X:
|
||||||
// TODO case wxSYS_ICON_Y:
|
// TODO case wxSYS_ICON_Y:
|
||||||
// TODO case wxSYS_ICONSPACING_X:
|
// TODO case wxSYS_ICONSPACING_X:
|
||||||
@@ -195,12 +189,12 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(w
|
|||||||
case wxSYS_SCREEN_Y:
|
case wxSYS_SCREEN_Y:
|
||||||
wxDisplaySize(NULL, &value);
|
wxDisplaySize(NULL, &value);
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
// TODO case wxSYS_FRAMESIZE_X:
|
// TODO case wxSYS_FRAMESIZE_X:
|
||||||
// TODO case wxSYS_FRAMESIZE_Y:
|
// TODO case wxSYS_FRAMESIZE_Y:
|
||||||
// TODO case wxSYS_SMALLICON_X:
|
// TODO case wxSYS_SMALLICON_X:
|
||||||
// TODO case wxSYS_SMALLICON_Y:
|
// TODO case wxSYS_SMALLICON_Y:
|
||||||
|
|
||||||
case wxSYS_HSCROLL_Y:
|
case wxSYS_HSCROLL_Y:
|
||||||
return 16;
|
return 16;
|
||||||
case wxSYS_VSCROLL_X:
|
case wxSYS_VSCROLL_X:
|
||||||
@@ -211,34 +205,34 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(w
|
|||||||
return 16;
|
return 16;
|
||||||
case wxSYS_VTHUMB_Y:
|
case wxSYS_VTHUMB_Y:
|
||||||
return 16;
|
return 16;
|
||||||
|
|
||||||
// TODO case wxSYS_CAPTION_Y:
|
// TODO case wxSYS_CAPTION_Y:
|
||||||
// TODO case wxSYS_MENU_Y:
|
// TODO case wxSYS_MENU_Y:
|
||||||
// TODO case wxSYS_NETWORK_PRESENT:
|
// TODO case wxSYS_NETWORK_PRESENT:
|
||||||
|
|
||||||
case wxSYS_PENWINDOWS_PRESENT:
|
case wxSYS_PENWINDOWS_PRESENT:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// TODO case wxSYS_SHOW_SOUNDS:
|
// TODO case wxSYS_SHOW_SOUNDS:
|
||||||
|
|
||||||
case wxSYS_SWAP_BUTTONS:
|
case wxSYS_SWAP_BUTTONS:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -1; // unsupported metric
|
break; // unsupported metric
|
||||||
}
|
}
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
|
bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case wxSYS_CAN_ICONIZE_FRAME:
|
case wxSYS_CAN_ICONIZE_FRAME:
|
||||||
case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
|
case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -98,7 +98,7 @@ static const EventTypeSpec eventList[] =
|
|||||||
|
|
||||||
// we have to catch these events on the toplevel window level, as controls don't get the
|
// we have to catch these events on the toplevel window level, as controls don't get the
|
||||||
// raw mouse events anymore
|
// raw mouse events anymore
|
||||||
|
|
||||||
{ kEventClassMouse , kEventMouseDown } ,
|
{ kEventClassMouse , kEventMouseDown } ,
|
||||||
{ kEventClassMouse , kEventMouseUp } ,
|
{ kEventClassMouse , kEventMouseUp } ,
|
||||||
{ kEventClassMouse , kEventMouseWheelMoved } ,
|
{ kEventClassMouse , kEventMouseWheelMoved } ,
|
||||||
@@ -166,9 +166,9 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
wxWindow* focus = wxWindow::DoFindFocus();
|
wxWindow* focus = wxWindow::DoFindFocus();
|
||||||
if ( focus == NULL )
|
if ( focus == NULL )
|
||||||
return result ;
|
return result ;
|
||||||
|
|
||||||
unsigned char charCode ;
|
unsigned char charCode ;
|
||||||
wxChar uniChar = 0 ;
|
wxChar uniChar = 0 ;
|
||||||
UInt32 keyCode ;
|
UInt32 keyCode ;
|
||||||
UInt32 modifiers ;
|
UInt32 modifiers ;
|
||||||
Point point ;
|
Point point ;
|
||||||
@@ -179,9 +179,9 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize , NULL ) == noErr )
|
if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize , NULL ) == noErr )
|
||||||
{
|
{
|
||||||
UniChar buf[2] ;
|
UniChar buf[2] ;
|
||||||
|
|
||||||
UniChar* charBuf = buf ;
|
UniChar* charBuf = buf ;
|
||||||
|
|
||||||
if ( dataSize > 4 )
|
if ( dataSize > 4 )
|
||||||
charBuf = new UniChar[ dataSize / sizeof( UniChar) ] ;
|
charBuf = new UniChar[ dataSize / sizeof( UniChar) ] ;
|
||||||
GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
|
GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ;
|
||||||
@@ -190,7 +190,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
#else
|
#else
|
||||||
wxMBConvUTF16BE converter ;
|
wxMBConvUTF16BE converter ;
|
||||||
converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
|
converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ;
|
||||||
#endif
|
#endif
|
||||||
if ( dataSize > 4 )
|
if ( dataSize > 4 )
|
||||||
delete[] charBuf ;
|
delete[] charBuf ;
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
|
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
|
||||||
GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
|
GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
|
||||||
sizeof( Point ), NULL, &point );
|
sizeof( Point ), NULL, &point );
|
||||||
|
|
||||||
UInt32 message = (keyCode << 8) + charCode;
|
UInt32 message = (keyCode << 8) + charCode;
|
||||||
switch( GetEventKind( event ) )
|
switch( GetEventKind( event ) )
|
||||||
{
|
{
|
||||||
@@ -211,7 +211,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
|
WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
|
||||||
WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
|
WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
|
||||||
wxTheApp->MacSetCurrentEvent( event , handler ) ;
|
wxTheApp->MacSetCurrentEvent( event , handler ) ;
|
||||||
if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
|
if ( /* focus && */ wxTheApp->MacSendKeyDownEvent(
|
||||||
focus , message , modifiers , when , point.h , point.v , uniChar ) )
|
focus , message , modifiers , when , point.h , point.v , uniChar ) )
|
||||||
{
|
{
|
||||||
result = noErr ;
|
result = noErr ;
|
||||||
@@ -220,7 +220,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
case kEventRawKeyUp :
|
case kEventRawKeyUp :
|
||||||
if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent(
|
if ( /* focus && */ wxTheApp->MacSendKeyUpEvent(
|
||||||
focus , message , modifiers , when , point.h , point.v , uniChar ) )
|
focus , message , modifiers , when , point.h , point.v , uniChar ) )
|
||||||
{
|
{
|
||||||
result = noErr ;
|
result = noErr ;
|
||||||
@@ -242,25 +242,25 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
event.SetTimestamp(when);
|
event.SetTimestamp(when);
|
||||||
event.SetEventObject(focus);
|
event.SetEventObject(focus);
|
||||||
|
|
||||||
if ( focus && (modifiers ^ wxApp::s_lastModifiers ) & controlKey )
|
if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & controlKey )
|
||||||
{
|
{
|
||||||
event.m_keyCode = WXK_CONTROL ;
|
event.m_keyCode = WXK_CONTROL ;
|
||||||
event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
|
event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
|
||||||
focus->GetEventHandler()->ProcessEvent( event ) ;
|
focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
}
|
}
|
||||||
if ( focus && (modifiers ^ wxApp::s_lastModifiers ) & shiftKey )
|
if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & shiftKey )
|
||||||
{
|
{
|
||||||
event.m_keyCode = WXK_SHIFT ;
|
event.m_keyCode = WXK_SHIFT ;
|
||||||
event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
|
event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
|
||||||
focus->GetEventHandler()->ProcessEvent( event ) ;
|
focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
}
|
}
|
||||||
if ( focus && (modifiers ^ wxApp::s_lastModifiers ) & optionKey )
|
if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & optionKey )
|
||||||
{
|
{
|
||||||
event.m_keyCode = WXK_ALT ;
|
event.m_keyCode = WXK_ALT ;
|
||||||
event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
|
event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
|
||||||
focus->GetEventHandler()->ProcessEvent( event ) ;
|
focus->GetEventHandler()->ProcessEvent( event ) ;
|
||||||
}
|
}
|
||||||
if ( focus && (modifiers ^ wxApp::s_lastModifiers ) & cmdKey )
|
if ( /* focus && */ (modifiers ^ wxApp::s_lastModifiers ) & cmdKey )
|
||||||
{
|
{
|
||||||
event.m_keyCode = WXK_COMMAND ;
|
event.m_keyCode = WXK_COMMAND ;
|
||||||
event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
|
event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
|
||||||
@@ -268,7 +268,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
}
|
}
|
||||||
wxApp::s_lastModifiers = modifiers ;
|
wxApp::s_lastModifiers = modifiers ;
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result ;
|
return result ;
|
||||||
@@ -289,9 +289,9 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
|
|||||||
UInt32 modifiers = cEvent.GetParameter<UInt32>(kEventParamKeyModifiers, typeUInt32) ;
|
UInt32 modifiers = cEvent.GetParameter<UInt32>(kEventParamKeyModifiers, typeUInt32) ;
|
||||||
Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
|
Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
|
||||||
|
|
||||||
// this parameter are not given for all events
|
// this parameter are not given for all events
|
||||||
EventMouseButton button = 0 ;
|
EventMouseButton button = 0 ;
|
||||||
UInt32 clickCount = 0 ;
|
UInt32 clickCount = 0 ;
|
||||||
cEvent.GetParameter<EventMouseButton>(kEventParamMouseButton, typeMouseButton , &button) ;
|
cEvent.GetParameter<EventMouseButton>(kEventParamMouseButton, typeMouseButton , &button) ;
|
||||||
cEvent.GetParameter<UInt32>(kEventParamClickCount, typeUInt32 , &clickCount ) ;
|
cEvent.GetParameter<UInt32>(kEventParamClickCount, typeUInt32 , &clickCount ) ;
|
||||||
|
|
||||||
@@ -302,24 +302,24 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
|
|||||||
wxevent.m_altDown = modifiers & optionKey;
|
wxevent.m_altDown = modifiers & optionKey;
|
||||||
wxevent.m_metaDown = modifiers & cmdKey;
|
wxevent.m_metaDown = modifiers & cmdKey;
|
||||||
wxevent.SetTimestamp( cEvent.GetTicks() ) ;
|
wxevent.SetTimestamp( cEvent.GetTicks() ) ;
|
||||||
// a control click is interpreted as a right click
|
// a control click is interpreted as a right click
|
||||||
if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
|
if ( button == kEventMouseButtonPrimary && (modifiers & controlKey) )
|
||||||
{
|
{
|
||||||
button = kEventMouseButtonSecondary ;
|
button = kEventMouseButtonSecondary ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise we report double clicks by connecting a left click with a ctrl-left click
|
// otherwise we report double clicks by connecting a left click with a ctrl-left click
|
||||||
if ( clickCount > 1 && button != lastButton )
|
if ( clickCount > 1 && button != lastButton )
|
||||||
clickCount = 1 ;
|
clickCount = 1 ;
|
||||||
|
|
||||||
// we must make sure that our synthetic 'right' button corresponds in
|
// we must make sure that our synthetic 'right' button corresponds in
|
||||||
// mouse down, moved and mouse up, and does not deliver a right down and left up
|
// mouse down, moved and mouse up, and does not deliver a right down and left up
|
||||||
|
|
||||||
if ( cEvent.GetKind() == kEventMouseDown )
|
if ( cEvent.GetKind() == kEventMouseDown )
|
||||||
lastButton = button ;
|
lastButton = button ;
|
||||||
|
|
||||||
if ( button == 0 )
|
if ( button == 0 )
|
||||||
lastButton = 0 ;
|
lastButton = 0 ;
|
||||||
else if ( lastButton )
|
else if ( lastButton )
|
||||||
button = lastButton ;
|
button = lastButton ;
|
||||||
|
|
||||||
@@ -386,7 +386,7 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent )
|
|||||||
default :
|
default :
|
||||||
wxevent.SetEventType(wxEVT_MOTION ) ;
|
wxevent.SetEventType(wxEVT_MOTION ) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlRef wxMacFindSubControl( wxTopLevelWindowMac* toplevelWindow, Point location , ControlRef superControl , ControlPartCode *outPart )
|
ControlRef wxMacFindSubControl( wxTopLevelWindowMac* toplevelWindow, Point location , ControlRef superControl , ControlPartCode *outPart )
|
||||||
@@ -394,18 +394,18 @@ ControlRef wxMacFindSubControl( wxTopLevelWindowMac* toplevelWindow, Point locat
|
|||||||
if ( superControl )
|
if ( superControl )
|
||||||
{
|
{
|
||||||
UInt16 childrenCount = 0 ;
|
UInt16 childrenCount = 0 ;
|
||||||
OSStatus err = CountSubControls( superControl , &childrenCount ) ;
|
OSStatus err = CountSubControls( superControl , &childrenCount ) ;
|
||||||
if ( err == errControlIsNotEmbedder )
|
if ( err == errControlIsNotEmbedder )
|
||||||
return NULL ;
|
return NULL ;
|
||||||
wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
|
wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
|
||||||
|
|
||||||
for ( UInt16 i = childrenCount ; i >=1 ; --i )
|
for ( UInt16 i = childrenCount ; i >=1 ; --i )
|
||||||
{
|
{
|
||||||
ControlHandle sibling ;
|
ControlHandle sibling ;
|
||||||
err = GetIndexedSubControl( superControl , i , & sibling ) ;
|
err = GetIndexedSubControl( superControl , i , & sibling ) ;
|
||||||
if ( err == errControlIsNotEmbedder )
|
if ( err == errControlIsNotEmbedder )
|
||||||
return NULL ;
|
return NULL ;
|
||||||
|
|
||||||
wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
|
wxASSERT_MSG( err == noErr , wxT("Unexpected error when accessing subcontrols") ) ;
|
||||||
if ( IsControlVisible( sibling ) )
|
if ( IsControlVisible( sibling ) )
|
||||||
{
|
{
|
||||||
@@ -425,7 +425,7 @@ ControlRef wxMacFindSubControl( wxTopLevelWindowMac* toplevelWindow, Point locat
|
|||||||
testLocation.h -= r.left ;
|
testLocation.h -= r.left ;
|
||||||
testLocation.v -= r.top ;
|
testLocation.v -= r.top ;
|
||||||
}
|
}
|
||||||
|
|
||||||
*outPart = TestControl( sibling , testLocation ) ;
|
*outPart = TestControl( sibling , testLocation ) ;
|
||||||
return sibling ;
|
return sibling ;
|
||||||
}
|
}
|
||||||
@@ -450,11 +450,11 @@ ControlRef wxMacFindControlUnderMouse( wxTopLevelWindowMac* toplevelWindow , Poi
|
|||||||
pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||||
{
|
{
|
||||||
wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
|
wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
|
||||||
|
|
||||||
OSStatus result = eventNotHandledErr ;
|
OSStatus result = eventNotHandledErr ;
|
||||||
|
|
||||||
wxMacCarbonEvent cEvent( event ) ;
|
wxMacCarbonEvent cEvent( event ) ;
|
||||||
|
|
||||||
Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
|
Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
|
||||||
Point windowMouseLocation = screenMouseLocation ;
|
Point windowMouseLocation = screenMouseLocation ;
|
||||||
|
|
||||||
@@ -463,7 +463,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
|
|
||||||
wxWindow* currentMouseWindow = NULL ;
|
wxWindow* currentMouseWindow = NULL ;
|
||||||
ControlRef control = NULL ;
|
ControlRef control = NULL ;
|
||||||
|
|
||||||
if ( window )
|
if ( window )
|
||||||
{
|
{
|
||||||
QDGlobalToLocalPoint( UMAGetWindowPort(window ) , &windowMouseLocation ) ;
|
QDGlobalToLocalPoint( UMAGetWindowPort(window ) , &windowMouseLocation ) ;
|
||||||
@@ -485,8 +485,8 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
if ( currentMouseWindow == NULL && cEvent.GetKind() == kEventMouseMoved )
|
if ( currentMouseWindow == NULL && cEvent.GetKind() == kEventMouseMoved )
|
||||||
{
|
{
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
// for wxToolBar to function we have to send certaint events to it
|
// for wxToolBar to function we have to send certaint events to it
|
||||||
// instead of its children (wxToolBarTools)
|
// instead of its children (wxToolBarTools)
|
||||||
ControlRef parent ;
|
ControlRef parent ;
|
||||||
GetSuperControl(control, &parent );
|
GetSuperControl(control, &parent );
|
||||||
wxWindow *wxParent = wxFindControlFromMacControl( parent ) ;
|
wxWindow *wxParent = wxFindControlFromMacControl( parent ) ;
|
||||||
@@ -495,14 +495,14 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
|
wxMouseEvent wxevent(wxEVT_LEFT_DOWN);
|
||||||
SetupMouseEvent( wxevent , cEvent ) ;
|
SetupMouseEvent( wxevent , cEvent ) ;
|
||||||
|
|
||||||
// handle all enter / leave events
|
// handle all enter / leave events
|
||||||
|
|
||||||
if ( currentMouseWindow != g_MacLastWindow )
|
if ( currentMouseWindow != g_MacLastWindow )
|
||||||
{
|
{
|
||||||
if ( g_MacLastWindow )
|
if ( g_MacLastWindow )
|
||||||
@@ -530,7 +530,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
}
|
}
|
||||||
g_MacLastWindow = currentMouseWindow ;
|
g_MacLastWindow = currentMouseWindow ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( windowPart == inMenuBar )
|
if ( windowPart == inMenuBar )
|
||||||
{
|
{
|
||||||
// special case menu bar, as we are having a low-level runloop we must do it ourselves
|
// special case menu bar, as we are having a low-level runloop we must do it ourselves
|
||||||
@@ -545,23 +545,23 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent();
|
wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent();
|
||||||
|
|
||||||
currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
|
currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
|
||||||
|
|
||||||
wxevent.SetEventObject( currentMouseWindow ) ;
|
wxevent.SetEventObject( currentMouseWindow ) ;
|
||||||
|
|
||||||
// make tooltips current
|
// make tooltips current
|
||||||
|
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
if ( wxevent.GetEventType() == wxEVT_MOTION
|
if ( wxevent.GetEventType() == wxEVT_MOTION
|
||||||
|| wxevent.GetEventType() == wxEVT_ENTER_WINDOW
|
|| wxevent.GetEventType() == wxEVT_ENTER_WINDOW
|
||||||
|| wxevent.GetEventType() == wxEVT_LEAVE_WINDOW )
|
|| wxevent.GetEventType() == wxEVT_LEAVE_WINDOW )
|
||||||
wxToolTip::RelayEvent( currentMouseWindow , wxevent);
|
wxToolTip::RelayEvent( currentMouseWindow , wxevent);
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) )
|
if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) )
|
||||||
{
|
{
|
||||||
if ((currentMouseWindowParent != NULL) &&
|
if ((currentMouseWindowParent != NULL) &&
|
||||||
(currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
|
(currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
|
||||||
currentMouseWindow = NULL;
|
currentMouseWindow = NULL;
|
||||||
|
|
||||||
result = noErr;
|
result = noErr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -579,15 +579,15 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
// if built-in find control is finding the wrong control (ie static box instead of overlaid
|
// if built-in find control is finding the wrong control (ie static box instead of overlaid
|
||||||
// button, we cannot let the standard handler do its job, but must handle manually
|
// button, we cannot let the standard handler do its job, but must handle manually
|
||||||
|
|
||||||
if ( ( cEvent.GetKind() == kEventMouseDown )
|
if ( ( cEvent.GetKind() == kEventMouseDown )
|
||||||
#ifdef __WXMAC_OSX__
|
#ifdef __WXMAC_OSX__
|
||||||
&&
|
&&
|
||||||
(FindControlUnderMouse(windowMouseLocation , window , &dummyPart) !=
|
(FindControlUnderMouse(windowMouseLocation , window , &dummyPart) !=
|
||||||
wxMacFindControlUnderMouse( toplevelWindow , windowMouseLocation , window , &dummyPart ) )
|
wxMacFindControlUnderMouse( toplevelWindow , windowMouseLocation , window , &dummyPart ) )
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ( currentMouseWindow->MacIsReallyEnabled() )
|
if ( currentMouseWindow->MacIsReallyEnabled() )
|
||||||
{
|
{
|
||||||
EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
|
EventModifiers modifiers = cEvent.GetParameter<EventModifiers>(kEventParamKeyModifiers, typeUInt32) ;
|
||||||
Point clickLocation = windowMouseLocation ;
|
Point clickLocation = windowMouseLocation ;
|
||||||
@@ -597,8 +597,8 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
|
|
||||||
HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
|
HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
|
||||||
modifiers , (ControlActionUPP ) -1 ) ;
|
modifiers , (ControlActionUPP ) -1 ) ;
|
||||||
|
|
||||||
if ((currentMouseWindowParent != NULL) &&
|
if ((currentMouseWindowParent != NULL) &&
|
||||||
(currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
|
(currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL))
|
||||||
currentMouseWindow = NULL;
|
currentMouseWindow = NULL;
|
||||||
}
|
}
|
||||||
@@ -612,7 +612,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update cursor
|
// update cursor
|
||||||
|
|
||||||
wxWindow* cursorTarget = currentMouseWindow ;
|
wxWindow* cursorTarget = currentMouseWindow ;
|
||||||
wxPoint cursorPoint( wxevent.m_x , wxevent.m_y ) ;
|
wxPoint cursorPoint( wxevent.m_x , wxevent.m_y ) ;
|
||||||
|
|
||||||
@@ -657,7 +657,7 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
|
|||||||
OSStatus result = eventNotHandledErr ;
|
OSStatus result = eventNotHandledErr ;
|
||||||
|
|
||||||
wxMacCarbonEvent cEvent( event ) ;
|
wxMacCarbonEvent cEvent( event ) ;
|
||||||
|
|
||||||
// WindowRef windowRef = cEvent.GetParameter<WindowRef>(kEventParamDirectObject) ;
|
// WindowRef windowRef = cEvent.GetParameter<WindowRef>(kEventParamDirectObject) ;
|
||||||
wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
|
wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
|
||||||
|
|
||||||
@@ -683,10 +683,12 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
|
|||||||
// we still sending an eventNotHandledErr in order to allow for default processing
|
// we still sending an eventNotHandledErr in order to allow for default processing
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
case kEventWindowShown :
|
case kEventWindowShown :
|
||||||
toplevelWindow->Refresh() ;
|
{
|
||||||
result = noErr ;
|
toplevelWindow->Refresh() ;
|
||||||
break ;
|
result = noErr ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
case kEventWindowClose :
|
case kEventWindowClose :
|
||||||
toplevelWindow->Close() ;
|
toplevelWindow->Close() ;
|
||||||
result = noErr ;
|
result = noErr ;
|
||||||
@@ -705,10 +707,10 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
|
|||||||
{
|
{
|
||||||
#if wxUSE_STATUSBAR
|
#if wxUSE_STATUSBAR
|
||||||
frame->PositionStatusBar();
|
frame->PositionStatusBar();
|
||||||
#endif
|
#endif
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
frame->PositionToolBar();
|
frame->PositionToolBar();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSizeEvent event( r.GetSize() , toplevelWindow->GetId() ) ;
|
wxSizeEvent event( r.GetSize() , toplevelWindow->GetId() ) ;
|
||||||
@@ -736,7 +738,7 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
|
|||||||
// all (Mac) rects are in content area coordinates, all wxRects in structure coordinates
|
// all (Mac) rects are in content area coordinates, all wxRects in structure coordinates
|
||||||
int left , top , right , bottom ;
|
int left , top , right , bottom ;
|
||||||
toplevelWindow->MacGetContentAreaInset( left , top , right , bottom ) ;
|
toplevelWindow->MacGetContentAreaInset( left , top , right , bottom ) ;
|
||||||
wxRect r( newRect.left - left , newRect.top - top ,
|
wxRect r( newRect.left - left , newRect.top - top ,
|
||||||
newRect.right - newRect.left + left + right , newRect.bottom - newRect.top + top + bottom ) ;
|
newRect.right - newRect.left + left + right , newRect.bottom - newRect.top + top + bottom ) ;
|
||||||
// this is a EVT_SIZING not a EVT_SIZE type !
|
// this is a EVT_SIZING not a EVT_SIZE type !
|
||||||
wxSizeEvent wxevent( r , toplevelWindow->GetId() ) ;
|
wxSizeEvent wxevent( r , toplevelWindow->GetId() ) ;
|
||||||
@@ -759,7 +761,7 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand
|
|||||||
toplevelWindow->wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
|
toplevelWindow->wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
|
||||||
}
|
}
|
||||||
|
|
||||||
result = noErr ;
|
result = noErr ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
@@ -870,26 +872,26 @@ void wxRemoveMacWindowAssociation(wxTopLevelWindowMac *win)
|
|||||||
|
|
||||||
wxTopLevelWindowMac *wxTopLevelWindowMac::s_macDeactivateWindow = NULL;
|
wxTopLevelWindowMac *wxTopLevelWindowMac::s_macDeactivateWindow = NULL;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
wxPoint m_position ;
|
wxPoint m_position ;
|
||||||
wxSize m_size ;
|
wxSize m_size ;
|
||||||
} FullScreenData ;
|
} FullScreenData ;
|
||||||
|
|
||||||
void wxTopLevelWindowMac::Init()
|
void wxTopLevelWindowMac::Init()
|
||||||
{
|
{
|
||||||
m_iconized =
|
m_iconized =
|
||||||
m_maximizeOnShow = FALSE;
|
m_maximizeOnShow = false;
|
||||||
m_macWindow = NULL ;
|
m_macWindow = NULL ;
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if ( UMAGetSystemVersion() >= 0x1030 )
|
if ( UMAGetSystemVersion() >= 0x1030 )
|
||||||
{
|
{
|
||||||
m_macUsesCompositing = TRUE;
|
m_macUsesCompositing = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_macUsesCompositing = FALSE;
|
m_macUsesCompositing = false;
|
||||||
}
|
}
|
||||||
m_macEventHandler = NULL ;
|
m_macEventHandler = NULL ;
|
||||||
m_macFullScreenData = NULL ;
|
m_macFullScreenData = NULL ;
|
||||||
@@ -931,7 +933,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent,
|
|||||||
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
|
MacCreateRealWindow( title, pos , size , MacRemoveBordersFromStyle(style) , name ) ;
|
||||||
|
|
||||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||||
|
|
||||||
if (GetExtraStyle() & wxFRAME_EX_METAL)
|
if (GetExtraStyle() & wxFRAME_EX_METAL)
|
||||||
MacSetMetalAppearance(true);
|
MacSetMetalAppearance(true);
|
||||||
|
|
||||||
@@ -940,7 +942,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent,
|
|||||||
if ( parent )
|
if ( parent )
|
||||||
parent->AddChild(this);
|
parent->AddChild(this);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTopLevelWindowMac::~wxTopLevelWindowMac()
|
wxTopLevelWindowMac::~wxTopLevelWindowMac()
|
||||||
@@ -963,7 +965,7 @@ wxTopLevelWindowMac::~wxTopLevelWindowMac()
|
|||||||
|
|
||||||
if ( wxModelessWindows.Find(this) )
|
if ( wxModelessWindows.Find(this) )
|
||||||
wxModelessWindows.DeleteObject(this);
|
wxModelessWindows.DeleteObject(this);
|
||||||
|
|
||||||
FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
|
FullScreenData *data = (FullScreenData *) m_macFullScreenData ;
|
||||||
delete data ;
|
delete data ;
|
||||||
m_macFullScreenData = NULL ;
|
m_macFullScreenData = NULL ;
|
||||||
@@ -981,7 +983,7 @@ void wxTopLevelWindowMac::Maximize(bool maximize)
|
|||||||
wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
|
wxMacPortStateHelper help( (GrafPtr) GetWindowPort( (WindowRef) m_macWindow) ) ;
|
||||||
wxMacWindowClipper clip (this);
|
wxMacWindowClipper clip (this);
|
||||||
#endif
|
#endif
|
||||||
if ( !IsWindowInStandardState( (WindowRef)m_macWindow, NULL, NULL) )
|
if ( !IsWindowInStandardState( (WindowRef)m_macWindow, NULL, NULL) )
|
||||||
{
|
{
|
||||||
Rect rect;
|
Rect rect;
|
||||||
GetWindowBounds((WindowRef)m_macWindow, kWindowGlobalPortRgn, &rect);
|
GetWindowBounds((WindowRef)m_macWindow, kWindowGlobalPortRgn, &rect);
|
||||||
@@ -1009,9 +1011,9 @@ bool wxTopLevelWindowMac::IsIconized() const
|
|||||||
|
|
||||||
void wxTopLevelWindowMac::Restore()
|
void wxTopLevelWindowMac::Restore()
|
||||||
{
|
{
|
||||||
if ( IsMaximized() )
|
if ( IsMaximized() )
|
||||||
Maximize(false);
|
Maximize(false);
|
||||||
else if ( IsIconized() )
|
else if ( IsIconized() )
|
||||||
Iconize(false);
|
Iconize(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1031,7 +1033,7 @@ void wxTopLevelWindowMac::SetIcon(const wxIcon& icon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
|
void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
|
||||||
{
|
{
|
||||||
wxTopLevelWindowBase::MacSetBackgroundBrush( brush ) ;
|
wxTopLevelWindowBase::MacSetBackgroundBrush( brush ) ;
|
||||||
|
|
||||||
if ( m_macBackgroundBrush.Ok() && m_macBackgroundBrush.GetStyle() != wxTRANSPARENT && m_macBackgroundBrush.MacGetBrushKind() == kwxMacBrushTheme )
|
if ( m_macBackgroundBrush.Ok() && m_macBackgroundBrush.GetStyle() != wxTRANSPARENT && m_macBackgroundBrush.MacGetBrushKind() == kwxMacBrushTheme )
|
||||||
@@ -1040,7 +1042,7 @@ void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowMac::MacInstallTopLevelWindowEventHandler()
|
void wxTopLevelWindowMac::MacInstallTopLevelWindowEventHandler()
|
||||||
{
|
{
|
||||||
if ( m_macEventHandler != NULL )
|
if ( m_macEventHandler != NULL )
|
||||||
{
|
{
|
||||||
@@ -1059,7 +1061,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
|
|||||||
OSStatus err = noErr ;
|
OSStatus err = noErr ;
|
||||||
SetName(name);
|
SetName(name);
|
||||||
m_windowStyle = style;
|
m_windowStyle = style;
|
||||||
m_isShown = FALSE;
|
m_isShown = false;
|
||||||
|
|
||||||
// create frame.
|
// create frame.
|
||||||
|
|
||||||
@@ -1067,12 +1069,12 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
|
|||||||
|
|
||||||
int x = (int)pos.x;
|
int x = (int)pos.x;
|
||||||
int y = (int)pos.y;
|
int y = (int)pos.y;
|
||||||
|
|
||||||
wxRect display = wxGetClientDisplayRect() ;
|
wxRect display = wxGetClientDisplayRect() ;
|
||||||
|
|
||||||
if ( x == wxDefaultPosition.x )
|
if ( x == wxDefaultPosition.x )
|
||||||
x = display.x ;
|
x = display.x ;
|
||||||
|
|
||||||
if ( y == wxDefaultPosition.y )
|
if ( y == wxDefaultPosition.y )
|
||||||
y = display.y ;
|
y = display.y ;
|
||||||
|
|
||||||
@@ -1116,7 +1118,7 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
|
|||||||
{
|
{
|
||||||
wclass = kDrawerWindowClass;
|
wclass = kDrawerWindowClass;
|
||||||
// we must force compositing on a drawer
|
// we must force compositing on a drawer
|
||||||
m_macUsesCompositing = TRUE ;
|
m_macUsesCompositing = true ;
|
||||||
}
|
}
|
||||||
#endif //10.2 and up
|
#endif //10.2 and up
|
||||||
else
|
else
|
||||||
@@ -1160,11 +1162,11 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
|
|||||||
group = GetWindowGroupOfClass(kUtilityWindowClass) ;
|
group = GetWindowGroupOfClass(kUtilityWindowClass) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if ( m_macUsesCompositing )
|
if ( m_macUsesCompositing )
|
||||||
attr |= kWindowCompositingAttribute;
|
attr |= kWindowCompositingAttribute;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( HasFlag(wxFRAME_SHAPED) )
|
if ( HasFlag(wxFRAME_SHAPED) )
|
||||||
{
|
{
|
||||||
WindowDefSpec customWindowDefSpec;
|
WindowDefSpec customWindowDefSpec;
|
||||||
@@ -1186,19 +1188,19 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
|
|||||||
wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") );
|
wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") );
|
||||||
|
|
||||||
// the create commands are only for content rect, so we have to set the size again as
|
// the create commands are only for content rect, so we have to set the size again as
|
||||||
// structure bounds
|
// structure bounds
|
||||||
SetWindowBounds( (WindowRef) m_macWindow , kWindowStructureRgn , &theBoundsRect ) ;
|
SetWindowBounds( (WindowRef) m_macWindow , kWindowStructureRgn , &theBoundsRect ) ;
|
||||||
|
|
||||||
wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ;
|
wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ;
|
||||||
UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ;
|
UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ;
|
||||||
m_peer = new wxMacControl(this , true /*isRootControl*/) ;
|
m_peer = new wxMacControl(this , true /*isRootControl*/) ;
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
|
|
||||||
if ( m_macUsesCompositing )
|
if ( m_macUsesCompositing )
|
||||||
{
|
{
|
||||||
// There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
|
// There is a bug in 10.2.X for ::GetRootControl returning the window view instead of
|
||||||
// the content view, so we have to retrieve it explicitly
|
// the content view, so we have to retrieve it explicitly
|
||||||
HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID ,
|
HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID ,
|
||||||
m_peer->GetControlRefAddr() ) ;
|
m_peer->GetControlRefAddr() ) ;
|
||||||
if ( !m_peer->Ok() )
|
if ( !m_peer->Ok() )
|
||||||
{
|
{
|
||||||
@@ -1278,11 +1280,11 @@ void wxTopLevelWindowMac::SetTitle(const wxString& title)
|
|||||||
bool wxTopLevelWindowMac::Show(bool show)
|
bool wxTopLevelWindowMac::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( !wxTopLevelWindowBase::Show(show) )
|
if ( !wxTopLevelWindowBase::Show(show) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
#if wxUSE_SYSTEM_OPTIONS //code contributed by Ryan Wilcox December 18, 2003
|
#if wxUSE_SYSTEM_OPTIONS //code contributed by Ryan Wilcox December 18, 2003
|
||||||
if ( (wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) ) && ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1) )
|
if ( (wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) ) && ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1) )
|
||||||
{
|
{
|
||||||
::ShowWindow( (WindowRef)m_macWindow );
|
::ShowWindow( (WindowRef)m_macWindow );
|
||||||
@@ -1314,21 +1316,21 @@ bool wxTopLevelWindowMac::Show(bool show)
|
|||||||
|
|
||||||
MacPropagateVisibilityChanged() ;
|
MacPropagateVisibilityChanged() ;
|
||||||
|
|
||||||
return TRUE ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
|
bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
|
||||||
{
|
{
|
||||||
if ( show )
|
if ( show )
|
||||||
{
|
{
|
||||||
FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
|
FullScreenData *data = (FullScreenData *)m_macFullScreenData ;
|
||||||
delete data ;
|
delete data ;
|
||||||
data = new FullScreenData() ;
|
data = new FullScreenData() ;
|
||||||
|
|
||||||
m_macFullScreenData = data ;
|
m_macFullScreenData = data ;
|
||||||
data->m_position = GetPosition() ;
|
data->m_position = GetPosition() ;
|
||||||
data->m_size = GetSize() ;
|
data->m_size = GetSize() ;
|
||||||
|
|
||||||
if ( style & wxFULLSCREEN_NOMENUBAR )
|
if ( style & wxFULLSCREEN_NOMENUBAR )
|
||||||
{
|
{
|
||||||
HideMenuBar() ;
|
HideMenuBar() ;
|
||||||
@@ -1337,12 +1339,12 @@ bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
|
|||||||
wxRect client = wxGetClientDisplayRect() ;
|
wxRect client = wxGetClientDisplayRect() ;
|
||||||
|
|
||||||
int x, y, w, h ;
|
int x, y, w, h ;
|
||||||
|
|
||||||
x = client.x ;
|
x = client.x ;
|
||||||
y = client.y ;
|
y = client.y ;
|
||||||
w = client.width ;
|
w = client.width ;
|
||||||
h = client.height ;
|
h = client.height ;
|
||||||
|
|
||||||
MacGetContentAreaInset( left , top , right , bottom ) ;
|
MacGetContentAreaInset( left , top , right , bottom ) ;
|
||||||
|
|
||||||
if ( style & wxFULLSCREEN_NOCAPTION )
|
if ( style & wxFULLSCREEN_NOCAPTION )
|
||||||
@@ -1375,12 +1377,12 @@ bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
|
|||||||
delete data ;
|
delete data ;
|
||||||
m_macFullScreenData = NULL ;
|
m_macFullScreenData = NULL ;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowMac::IsFullScreen() const
|
bool wxTopLevelWindowMac::IsFullScreen() const
|
||||||
{
|
{
|
||||||
return m_macFullScreenData != NULL ;
|
return m_macFullScreenData != NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we are still using coordinates of the content view, todo switch to structure bounds
|
// we are still using coordinates of the content view, todo switch to structure bounds
|
||||||
@@ -1429,18 +1431,18 @@ void wxTopLevelWindowMac::DoGetClientSize( int *width, int *height ) const
|
|||||||
if(height) *height = bounds.bottom - bounds.top ;
|
if(height) *height = bounds.bottom - bounds.top ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
|
void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
|
||||||
{
|
{
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
wxASSERT_MSG( m_macUsesCompositing ,
|
wxASSERT_MSG( m_macUsesCompositing ,
|
||||||
wxT("Cannot set metal appearance on a non-compositing window") ) ;
|
wxT("Cannot set metal appearance on a non-compositing window") ) ;
|
||||||
|
|
||||||
MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
|
MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
|
||||||
set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
|
set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowMac::MacGetMetalAppearance() const
|
bool wxTopLevelWindowMac::MacGetMetalAppearance() const
|
||||||
{
|
{
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
return MacGetWindowAttributes() & kWindowMetalAttribute ;
|
return MacGetWindowAttributes() & kWindowMetalAttribute ;
|
||||||
@@ -1449,67 +1451,67 @@ bool wxTopLevelWindowMac::MacGetMetalAppearance() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear )
|
void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear )
|
||||||
{
|
{
|
||||||
ChangeWindowAttributes ( (WindowRef) m_macWindow , attributesToSet, attributesToClear ) ;
|
ChangeWindowAttributes ( (WindowRef) m_macWindow , attributesToSet, attributesToClear ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUint32 wxTopLevelWindowMac::MacGetWindowAttributes() const
|
wxUint32 wxTopLevelWindowMac::MacGetWindowAttributes() const
|
||||||
{
|
{
|
||||||
UInt32 attr = 0 ;
|
UInt32 attr = 0 ;
|
||||||
GetWindowAttributes((WindowRef) m_macWindow , &attr ) ;
|
GetWindowAttributes((WindowRef) m_macWindow , &attr ) ;
|
||||||
return attr ;
|
return attr ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowMac::MacPerformUpdates()
|
void wxTopLevelWindowMac::MacPerformUpdates()
|
||||||
{
|
{
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if ( m_macUsesCompositing )
|
if ( m_macUsesCompositing )
|
||||||
{
|
{
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
||||||
// for composited windows this also triggers a redraw of all
|
// for composited windows this also triggers a redraw of all
|
||||||
// invalid views in the window
|
// invalid views in the window
|
||||||
if( UMAGetSystemVersion() >= 0x1030 )
|
if( UMAGetSystemVersion() >= 0x1030 )
|
||||||
HIWindowFlush((WindowRef) m_macWindow) ;
|
HIWindowFlush((WindowRef) m_macWindow) ;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// the only way to trigger the redrawing on earlier systems is to call
|
// the only way to trigger the redrawing on earlier systems is to call
|
||||||
// ReceiveNextEvent
|
// ReceiveNextEvent
|
||||||
|
|
||||||
EventRef currentEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ;
|
EventRef currentEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ;
|
||||||
UInt32 currentEventClass = 0 ;
|
UInt32 currentEventClass = 0 ;
|
||||||
UInt32 currentEventKind = 0 ;
|
UInt32 currentEventKind = 0 ;
|
||||||
if ( currentEvent != NULL )
|
if ( currentEvent != NULL )
|
||||||
{
|
{
|
||||||
currentEventClass = ::GetEventClass( currentEvent ) ;
|
currentEventClass = ::GetEventClass( currentEvent ) ;
|
||||||
currentEventKind = ::GetEventKind( currentEvent ) ;
|
currentEventKind = ::GetEventKind( currentEvent ) ;
|
||||||
}
|
}
|
||||||
if ( currentEventClass != kEventClassMenu )
|
if ( currentEventClass != kEventClassMenu )
|
||||||
{
|
{
|
||||||
// when tracking a menu, strange redraw errors occur if we flush now, so leave..
|
// when tracking a menu, strange redraw errors occur if we flush now, so leave..
|
||||||
EventRef theEvent;
|
EventRef theEvent;
|
||||||
OSStatus status = noErr ;
|
OSStatus status = noErr ;
|
||||||
status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ;
|
status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
BeginUpdate( (WindowRef) m_macWindow ) ;
|
BeginUpdate( (WindowRef) m_macWindow ) ;
|
||||||
|
|
||||||
RgnHandle updateRgn = NewRgn();
|
RgnHandle updateRgn = NewRgn();
|
||||||
if ( updateRgn )
|
if ( updateRgn )
|
||||||
{
|
{
|
||||||
GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn );
|
GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn );
|
||||||
UpdateControls( (WindowRef)m_macWindow , updateRgn ) ;
|
UpdateControls( (WindowRef)m_macWindow , updateRgn ) ;
|
||||||
// if ( !EmptyRgn( updateRgn ) )
|
// if ( !EmptyRgn( updateRgn ) )
|
||||||
// MacDoRedraw( updateRgn , 0 , true) ;
|
// MacDoRedraw( updateRgn , 0 , true) ;
|
||||||
DisposeRgn( updateRgn );
|
DisposeRgn( updateRgn );
|
||||||
}
|
}
|
||||||
EndUpdate( (WindowRef)m_macWindow ) ;
|
EndUpdate( (WindowRef)m_macWindow ) ;
|
||||||
QDFlushPortBuffer( GetWindowPort( (WindowRef)m_macWindow ) , NULL ) ;
|
QDFlushPortBuffer( GetWindowPort( (WindowRef)m_macWindow ) , NULL ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1545,7 +1547,7 @@ void wxTopLevelWindowMac::RequestUserAttention(int flags )
|
|||||||
|
|
||||||
bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
|
bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE,
|
wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), false,
|
||||||
_T("Shaped windows must be created with the wxFRAME_SHAPED style."));
|
_T("Shaped windows must be created with the wxFRAME_SHAPED style."));
|
||||||
|
|
||||||
// The empty region signifies that the shape should be removed from the
|
// The empty region signifies that the shape should be removed from the
|
||||||
@@ -1571,7 +1573,7 @@ bool wxTopLevelWindowMac::SetShape(const wxRegion& region)
|
|||||||
|
|
||||||
// Tell the window manager that the window has changed shape
|
// Tell the window manager that the window has changed shape
|
||||||
ReshapeCustomWindow((WindowRef)MacGetWindowRef());
|
ReshapeCustomWindow((WindowRef)MacGetWindowRef());
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -1635,10 +1637,10 @@ static void wxShapedMacWindowStructureRegion(WindowRef window, RgnHandle rgn)
|
|||||||
if (cachedRegion)
|
if (cachedRegion)
|
||||||
{
|
{
|
||||||
Rect windowRect;
|
Rect windowRect;
|
||||||
wxShapedMacWindowGetPos(window, &windowRect); //how big is the window
|
wxShapedMacWindowGetPos(window, &windowRect); // how big is the window
|
||||||
CopyRgn(cachedRegion, rgn); //make a copy of our cached region
|
CopyRgn(cachedRegion, rgn); // make a copy of our cached region
|
||||||
OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window
|
OffsetRgn(rgn, windowRect.left, windowRect.top); // position it over window
|
||||||
//MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size
|
//MapRgn(rgn, &mMaskSize, &windowRect); //scale it to our actual window size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1673,7 +1675,7 @@ static SInt32 wxShapedMacWindowHitTest(WindowRef window,SInt32 param)
|
|||||||
static RgnHandle tempRgn=nil;
|
static RgnHandle tempRgn=nil;
|
||||||
|
|
||||||
if(!tempRgn)
|
if(!tempRgn)
|
||||||
tempRgn=NewRgn();
|
tempRgn=NewRgn();
|
||||||
|
|
||||||
SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked
|
SetPt(&hitPoint,LoWord(param),HiWord(param));//get the point clicked
|
||||||
|
|
||||||
|
@@ -209,7 +209,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
thisWindow->GetPeer()->GetRect( &controlBounds ) ;
|
thisWindow->GetPeer()->GetRect( &controlBounds ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr )
|
if ( cEvent.GetParameter<RgnHandle>(kEventParamRgnHandle, &updateRgn) != noErr )
|
||||||
{
|
{
|
||||||
updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
|
updateRgn = (RgnHandle) visRegion.GetWXHRGN() ;
|
||||||
@@ -223,7 +223,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
OffsetRgn( allocatedRgn , -controlBounds.left , -controlBounds.top ) ;
|
OffsetRgn( allocatedRgn , -controlBounds.left , -controlBounds.top ) ;
|
||||||
// hide the given region by the new region that must be shifted
|
// hide the given region by the new region that must be shifted
|
||||||
wxMacNativeToWindow( thisWindow , allocatedRgn ) ;
|
wxMacNativeToWindow( thisWindow , allocatedRgn ) ;
|
||||||
updateRgn = allocatedRgn ;
|
updateRgn = allocatedRgn ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -268,10 +268,10 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
if ( cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) != noErr )
|
if ( cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, &cgContext) != noErr )
|
||||||
{
|
{
|
||||||
wxASSERT( thisWindow->GetPeer()->IsCompositing() == false ) ;
|
wxASSERT( thisWindow->GetPeer()->IsCompositing() == false ) ;
|
||||||
|
|
||||||
// this parameter is not provided on non-composited windows
|
// this parameter is not provided on non-composited windows
|
||||||
created = true ;
|
created = true ;
|
||||||
// rest of the code expects this to be already transformed and clipped for local
|
// rest of the code expects this to be already transformed and clipped for local
|
||||||
CGrafPtr port = GetWindowPort( (WindowRef) thisWindow->MacGetTopLevelWindowRef() ) ;
|
CGrafPtr port = GetWindowPort( (WindowRef) thisWindow->MacGetTopLevelWindowRef() ) ;
|
||||||
Rect bounds ;
|
Rect bounds ;
|
||||||
GetPortBounds( port , &bounds ) ;
|
GetPortBounds( port , &bounds ) ;
|
||||||
@@ -285,13 +285,13 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
|||||||
|
|
||||||
CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
|
CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ;
|
||||||
CGContextScaleCTM( cgContext , 1 , -1 ) ;
|
CGContextScaleCTM( cgContext , 1 , -1 ) ;
|
||||||
|
|
||||||
CGContextTranslateCTM( cgContext , controlBounds.left , controlBounds.top ) ;
|
CGContextTranslateCTM( cgContext , controlBounds.left , controlBounds.top ) ;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CGContextSetRGBFillColor( cgContext , 1.0 , 1.0 , 1.0 , 1.0 ) ;
|
CGContextSetRGBFillColor( cgContext , 1.0 , 1.0 , 1.0 , 1.0 ) ;
|
||||||
CGContextFillRect(cgContext , CGRectMake( 0 , 0 ,
|
CGContextFillRect(cgContext , CGRectMake( 0 , 0 ,
|
||||||
controlBounds.right - controlBounds.left ,
|
controlBounds.right - controlBounds.left ,
|
||||||
controlBounds.bottom - controlBounds.top ) );
|
controlBounds.bottom - controlBounds.top ) );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -471,6 +471,7 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
|
|||||||
break ;
|
break ;
|
||||||
case kEventClassService :
|
case kEventClassService :
|
||||||
result = wxMacWindowServiceEventHandler( handler, event , data ) ;
|
result = wxMacWindowServiceEventHandler( handler, event , data ) ;
|
||||||
|
break ;
|
||||||
default :
|
default :
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
@@ -725,17 +726,17 @@ void wxWindowMac::Init()
|
|||||||
m_peer = NULL ;
|
m_peer = NULL ;
|
||||||
m_frozenness = 0 ;
|
m_frozenness = 0 ;
|
||||||
#if WXWIN_COMPATIBILITY_2_4
|
#if WXWIN_COMPATIBILITY_2_4
|
||||||
m_backgroundTransparent = FALSE;
|
m_backgroundTransparent = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// as all windows are created with WS_VISIBLE style...
|
// as all windows are created with WS_VISIBLE style...
|
||||||
m_isShown = TRUE;
|
m_isShown = true;
|
||||||
|
|
||||||
m_hScrollBar = NULL ;
|
m_hScrollBar = NULL ;
|
||||||
m_vScrollBar = NULL ;
|
m_vScrollBar = NULL ;
|
||||||
m_macBackgroundBrush = wxNullBrush ;
|
m_macBackgroundBrush = wxNullBrush ;
|
||||||
|
|
||||||
m_macIsUserPane = TRUE;
|
m_macIsUserPane = true;
|
||||||
#if wxMAC_USE_CORE_GRAPHICS
|
#if wxMAC_USE_CORE_GRAPHICS
|
||||||
m_cgContextRef = NULL ;
|
m_cgContextRef = NULL ;
|
||||||
#endif
|
#endif
|
||||||
@@ -750,7 +751,7 @@ wxWindowMac::~wxWindowMac()
|
|||||||
{
|
{
|
||||||
SendDestroyEvent();
|
SendDestroyEvent();
|
||||||
|
|
||||||
m_isBeingDeleted = TRUE;
|
m_isBeingDeleted = true;
|
||||||
|
|
||||||
MacInvalidateBorders() ;
|
MacInvalidateBorders() ;
|
||||||
|
|
||||||
@@ -849,10 +850,10 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
|
|||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") );
|
wxCHECK_MSG( parent, false, wxT("can't create wxWindowMac without parent") );
|
||||||
|
|
||||||
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
|
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_windowVariant = parent->GetWindowVariant() ;
|
m_windowVariant = parent->GetWindowVariant() ;
|
||||||
|
|
||||||
@@ -890,10 +891,10 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id,
|
|||||||
wxWindowCreateEvent event(this);
|
wxWindowCreateEvent event(this);
|
||||||
GetEventHandler()->AddPendingEvent(event);
|
GetEventHandler()->AddPendingEvent(event);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMac::MacChildAdded()
|
void wxWindowMac::MacChildAdded()
|
||||||
{
|
{
|
||||||
if ( m_vScrollBar )
|
if ( m_vScrollBar )
|
||||||
{
|
{
|
||||||
@@ -1161,7 +1162,7 @@ bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos,
|
|||||||
int& w, int& h , bool adjustOrigin ) const
|
int& w, int& h , bool adjustOrigin ) const
|
||||||
{
|
{
|
||||||
bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
|
bool isCompositing = MacGetTopLevelWindow()->MacUsesCompositing() ;
|
||||||
|
|
||||||
// the desired size, minus the border pixels gives the correct size of the control
|
// the desired size, minus the border pixels gives the correct size of the control
|
||||||
|
|
||||||
x = (int)pos.x;
|
x = (int)pos.x;
|
||||||
@@ -1206,7 +1207,7 @@ void wxWindowMac::DoGetPosition(int *x, int *y) const
|
|||||||
{
|
{
|
||||||
Rect bounds ;
|
Rect bounds ;
|
||||||
m_peer->GetRect( &bounds ) ;
|
m_peer->GetRect( &bounds ) ;
|
||||||
|
|
||||||
int x1 = bounds.left ;
|
int x1 = bounds.left ;
|
||||||
int y1 = bounds.top ;
|
int y1 = bounds.top ;
|
||||||
|
|
||||||
@@ -1367,7 +1368,7 @@ void wxWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , in
|
|||||||
GetRegionBounds( rgn , &content ) ;
|
GetRegionBounds( rgn , &content ) ;
|
||||||
m_peer->GetRect( &structure ) ;
|
m_peer->GetRect( &structure ) ;
|
||||||
OffsetRect( &structure, -structure.left , -structure.top ) ;
|
OffsetRect( &structure, -structure.left , -structure.top ) ;
|
||||||
|
|
||||||
left = content.left - structure.left ;
|
left = content.left - structure.left ;
|
||||||
top = content.top - structure.top ;
|
top = content.top - structure.top ;
|
||||||
right = structure.right - content.right ;
|
right = structure.right - content.right ;
|
||||||
@@ -1443,17 +1444,17 @@ void wxWindowMac::DoGetClientSize(int *x, int *y) const
|
|||||||
bool wxWindowMac::SetCursor(const wxCursor& cursor)
|
bool wxWindowMac::SetCursor(const wxCursor& cursor)
|
||||||
{
|
{
|
||||||
if (m_cursor == cursor)
|
if (m_cursor == cursor)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (wxNullCursor == cursor)
|
if (wxNullCursor == cursor)
|
||||||
{
|
{
|
||||||
if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) )
|
if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) )
|
||||||
return FALSE ;
|
return false ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( ! wxWindowBase::SetCursor( cursor ) )
|
if ( ! wxWindowBase::SetCursor( cursor ) )
|
||||||
return FALSE ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxASSERT_MSG( m_cursor.Ok(),
|
wxASSERT_MSG( m_cursor.Ok(),
|
||||||
@@ -1487,7 +1488,7 @@ bool wxWindowMac::SetCursor(const wxCursor& cursor)
|
|||||||
m_cursor.MacInstall() ;
|
m_cursor.MacInstall() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUS
|
||||||
@@ -1525,7 +1526,7 @@ bool wxWindowMac::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
|
|
||||||
menu->SetInvokingWindow(NULL);
|
menu->SetInvokingWindow(NULL);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1545,7 +1546,7 @@ void wxWindowMac::DoSetToolTip(wxToolTip *tooltip)
|
|||||||
|
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
void wxWindowMac::MacInvalidateBorders()
|
void wxWindowMac::MacInvalidateBorders()
|
||||||
{
|
{
|
||||||
if ( m_peer == NULL )
|
if ( m_peer == NULL )
|
||||||
return ;
|
return ;
|
||||||
@@ -1553,18 +1554,18 @@ void wxWindowMac::MacInvalidateBorders()
|
|||||||
bool vis = MacIsReallyShown() ;
|
bool vis = MacIsReallyShown() ;
|
||||||
if ( !vis )
|
if ( !vis )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
int outerBorder = MacGetLeftBorderSize() ;
|
int outerBorder = MacGetLeftBorderSize() ;
|
||||||
if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
|
if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
|
||||||
outerBorder += 4 ;
|
outerBorder += 4 ;
|
||||||
|
|
||||||
if ( outerBorder == 0 )
|
if ( outerBorder == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
// now we know that we have something to do at all
|
// now we know that we have something to do at all
|
||||||
|
|
||||||
// as the borders are drawn on the parent we have to properly invalidate all these areas
|
// as the borders are drawn on the parent we have to properly invalidate all these areas
|
||||||
RgnHandle updateInner = NewRgn() ,
|
RgnHandle updateInner = NewRgn() ,
|
||||||
updateOuter = NewRgn() ;
|
updateOuter = NewRgn() ;
|
||||||
|
|
||||||
// this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon
|
// this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon
|
||||||
@@ -1706,7 +1707,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
|
if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))
|
||||||
actualWidth = m_maxWidth;
|
actualWidth = m_maxWidth;
|
||||||
if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
|
if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
|
||||||
actualHeight = m_maxHeight;
|
actualHeight = m_maxHeight;
|
||||||
|
|
||||||
bool doMove = false ;
|
bool doMove = false ;
|
||||||
bool doResize = false ;
|
bool doResize = false ;
|
||||||
@@ -1722,10 +1723,10 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
|
|
||||||
if ( doMove || doResize )
|
if ( doMove || doResize )
|
||||||
{
|
{
|
||||||
// as the borders are drawn outside the native control, we adjust now
|
// as the borders are drawn outside the native control, we adjust now
|
||||||
|
|
||||||
wxRect bounds( wxPoint( actualX + MacGetLeftBorderSize() ,actualY + MacGetTopBorderSize() ),
|
wxRect bounds( wxPoint( actualX + MacGetLeftBorderSize() ,actualY + MacGetTopBorderSize() ),
|
||||||
wxSize( actualWidth - (MacGetLeftBorderSize() + MacGetRightBorderSize()) ,
|
wxSize( actualWidth - (MacGetLeftBorderSize() + MacGetRightBorderSize()) ,
|
||||||
actualHeight - (MacGetTopBorderSize() + MacGetBottomBorderSize()) ) ) ;
|
actualHeight - (MacGetTopBorderSize() + MacGetBottomBorderSize()) ) ) ;
|
||||||
|
|
||||||
Rect r ;
|
Rect r ;
|
||||||
@@ -1737,10 +1738,10 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MacInvalidateBorders() ;
|
MacInvalidateBorders() ;
|
||||||
|
|
||||||
m_cachedClippedRectValid = false ;
|
m_cachedClippedRectValid = false ;
|
||||||
m_peer->SetRect( &r ) ;
|
m_peer->SetRect( &r ) ;
|
||||||
|
|
||||||
wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
|
wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
|
||||||
|
|
||||||
MacInvalidateBorders() ;
|
MacInvalidateBorders() ;
|
||||||
@@ -1783,12 +1784,12 @@ wxSize wxWindowMac::DoGetBestSize() const
|
|||||||
{
|
{
|
||||||
bestsize.bottom = 16 ;
|
bestsize.bottom = 16 ;
|
||||||
}
|
}
|
||||||
#if wxUSE_SPINBTN
|
#if wxUSE_SPINBTN
|
||||||
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||||
{
|
{
|
||||||
bestsize.bottom = 24 ;
|
bestsize.bottom = 24 ;
|
||||||
}
|
}
|
||||||
#endif // wxUSE_SPINBTN
|
#endif // wxUSE_SPINBTN
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// return wxWindowBase::DoGetBestSize() ;
|
// return wxWindowBase::DoGetBestSize() ;
|
||||||
@@ -1926,7 +1927,7 @@ bool wxWindowMac::Show(bool show)
|
|||||||
{
|
{
|
||||||
bool former = MacIsReallyShown() ;
|
bool former = MacIsReallyShown() ;
|
||||||
if ( !wxWindowBase::Show(show) )
|
if ( !wxWindowBase::Show(show) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// TODO use visibilityChanged Carbon Event for OSX
|
// TODO use visibilityChanged Carbon Event for OSX
|
||||||
if ( m_peer )
|
if ( m_peer )
|
||||||
@@ -1935,7 +1936,7 @@ bool wxWindowMac::Show(bool show)
|
|||||||
}
|
}
|
||||||
if ( former != MacIsReallyShown() )
|
if ( former != MacIsReallyShown() )
|
||||||
MacPropagateVisibilityChanged() ;
|
MacPropagateVisibilityChanged() ;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowMac::Enable(bool enable)
|
bool wxWindowMac::Enable(bool enable)
|
||||||
@@ -1943,13 +1944,13 @@ bool wxWindowMac::Enable(bool enable)
|
|||||||
wxASSERT( m_peer->Ok() ) ;
|
wxASSERT( m_peer->Ok() ) ;
|
||||||
bool former = MacIsReallyEnabled() ;
|
bool former = MacIsReallyEnabled() ;
|
||||||
if ( !wxWindowBase::Enable(enable) )
|
if ( !wxWindowBase::Enable(enable) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_peer->Enable( enable ) ;
|
m_peer->Enable( enable ) ;
|
||||||
|
|
||||||
if ( former != MacIsReallyEnabled() )
|
if ( former != MacIsReallyEnabled() )
|
||||||
MacPropagateEnabledStateChanged() ;
|
MacPropagateEnabledStateChanged() ;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2029,7 +2030,7 @@ bool wxWindowMac::MacIsReallyShown()
|
|||||||
// only under OSX the visibility of the TLW is taken into account
|
// only under OSX the visibility of the TLW is taken into account
|
||||||
if ( m_isBeingDeleted )
|
if ( m_isBeingDeleted )
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if ( m_peer && m_peer->Ok() )
|
if ( m_peer && m_peer->Ok() )
|
||||||
return m_peer->IsVisible();
|
return m_peer->IsVisible();
|
||||||
@@ -2272,7 +2273,7 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
|
|||||||
|
|
||||||
HIThemeFrameDrawInfo info ;
|
HIThemeFrameDrawInfo info ;
|
||||||
memset( &info, 0 , sizeof( info ) ) ;
|
memset( &info, 0 , sizeof( info ) ) ;
|
||||||
|
|
||||||
info.version = 0 ;
|
info.version = 0 ;
|
||||||
info.kind = 0 ;
|
info.kind = 0 ;
|
||||||
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
||||||
@@ -2280,7 +2281,7 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
|
|||||||
|
|
||||||
CGContextRef cgContext = (CGContextRef) GetParent()->MacGetCGContextRef() ;
|
CGContextRef cgContext = (CGContextRef) GetParent()->MacGetCGContextRef() ;
|
||||||
wxASSERT( cgContext ) ;
|
wxASSERT( cgContext ) ;
|
||||||
|
|
||||||
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
|
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
|
||||||
{
|
{
|
||||||
info.kind = kHIThemeFrameTextFieldSquare ;
|
info.kind = kHIThemeFrameTextFieldSquare ;
|
||||||
@@ -2295,14 +2296,14 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
|
|||||||
{
|
{
|
||||||
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
|
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_peer->GetRect( &rect ) ;
|
m_peer->GetRect( &rect ) ;
|
||||||
if ( hasBothScrollbars )
|
if ( hasBothScrollbars )
|
||||||
{
|
{
|
||||||
int size = m_hScrollBar->GetWindowVariant() == wxWINDOW_VARIANT_NORMAL ? 16 : 12 ;
|
int size = m_hScrollBar->GetWindowVariant() == wxWINDOW_VARIANT_NORMAL ? 16 : 12 ;
|
||||||
CGRect cgrect = CGRectMake( rect.right - size , rect.bottom - size , size , size ) ;
|
CGRect cgrect = CGRectMake( rect.right - size , rect.bottom - size , size , size ) ;
|
||||||
CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
|
CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
|
||||||
HIThemeGrowBoxDrawInfo info ;
|
HIThemeGrowBoxDrawInfo info ;
|
||||||
memset( &info, 0 , sizeof( info ) ) ;
|
memset( &info, 0 , sizeof( info ) ) ;
|
||||||
info.version = 0 ;
|
info.version = 0 ;
|
||||||
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
||||||
@@ -2331,7 +2332,7 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
|
|||||||
{
|
{
|
||||||
DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hasFocus )
|
if ( hasFocus )
|
||||||
{
|
{
|
||||||
DrawThemeFocusRect( &rect , true ) ;
|
DrawThemeFocusRect( &rect , true ) ;
|
||||||
@@ -2339,7 +2340,7 @@ void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
|
|||||||
|
|
||||||
if ( hasBothScrollbars )
|
if ( hasBothScrollbars )
|
||||||
{
|
{
|
||||||
// GetThemeStandaloneGrowBoxBounds
|
// GetThemeStandaloneGrowBoxBounds
|
||||||
//DrawThemeStandaloneNoGrowBox
|
//DrawThemeStandaloneNoGrowBox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2405,8 +2406,8 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
|||||||
int width , height ;
|
int width , height ;
|
||||||
GetClientSize( &width , &height ) ;
|
GetClientSize( &width , &height ) ;
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if ( 1 /* m_peer->IsCompositing() */ )
|
if ( 1 /* m_peer->IsCompositing() */ )
|
||||||
{
|
{
|
||||||
// note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
|
// note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
|
||||||
// area is scrolled, this does not occur if width and height are 2 pixels less,
|
// area is scrolled, this does not occur if width and height are 2 pixels less,
|
||||||
// TODO write optimal workaround
|
// TODO write optimal workaround
|
||||||
@@ -2443,20 +2444,20 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
|||||||
// is the better overall solution, as it does not slow down scrolling
|
// is the better overall solution, as it does not slow down scrolling
|
||||||
m_peer->SetNeedsDisplay() ;
|
m_peer->SetNeedsDisplay() ;
|
||||||
#else
|
#else
|
||||||
// this would be the preferred version for fast drawing controls
|
// this would be the preferred version for fast drawing controls
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
|
||||||
if( UMAGetSystemVersion() >= 0x1030 && m_peer->IsCompositing() )
|
if( UMAGetSystemVersion() >= 0x1030 && m_peer->IsCompositing() )
|
||||||
HIViewRender(m_peer->GetControlRef()) ;
|
HIViewRender(m_peer->GetControlRef()) ;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
Update() ;
|
Update() ;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
wxPoint pos;
|
wxPoint pos;
|
||||||
pos.x = pos.y = 0;
|
pos.x = pos.y = 0;
|
||||||
@@ -2483,7 +2484,7 @@ void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
|
|||||||
ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
|
ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
|
||||||
|
|
||||||
// now scroll the former update region as well and add the new update region
|
// now scroll the former update region as well and add the new update region
|
||||||
|
|
||||||
WindowRef rootWindow = (WindowRef) MacGetTopLevelWindowRef() ;
|
WindowRef rootWindow = (WindowRef) MacGetTopLevelWindowRef() ;
|
||||||
RgnHandle formerUpdateRgn = NewRgn() ;
|
RgnHandle formerUpdateRgn = NewRgn() ;
|
||||||
RgnHandle scrollRgn = NewRgn() ;
|
RgnHandle scrollRgn = NewRgn() ;
|
||||||
@@ -2723,19 +2724,19 @@ wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const
|
|||||||
return win ;
|
return win ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxRect& wxWindowMac::MacGetClippedClientRect() const
|
const wxRect& wxWindowMac::MacGetClippedClientRect() const
|
||||||
{
|
{
|
||||||
MacUpdateClippedRects() ;
|
MacUpdateClippedRects() ;
|
||||||
return m_cachedClippedClientRect ;
|
return m_cachedClippedClientRect ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxRect& wxWindowMac::MacGetClippedRect() const
|
const wxRect& wxWindowMac::MacGetClippedRect() const
|
||||||
{
|
{
|
||||||
MacUpdateClippedRects() ;
|
MacUpdateClippedRects() ;
|
||||||
return m_cachedClippedRect ;
|
return m_cachedClippedRect ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxRect&wxWindowMac:: MacGetClippedRectWithOuterStructure() const
|
const wxRect&wxWindowMac:: MacGetClippedRectWithOuterStructure() const
|
||||||
{
|
{
|
||||||
MacUpdateClippedRects() ;
|
MacUpdateClippedRects() ;
|
||||||
return m_cachedClippedRectWithOuterStructure ;
|
return m_cachedClippedRectWithOuterStructure ;
|
||||||
@@ -2770,7 +2771,7 @@ void wxWindowMac::MacUpdateClippedRects() const
|
|||||||
|
|
||||||
Rect r ;
|
Rect r ;
|
||||||
Rect rIncludingOuterStructures ;
|
Rect rIncludingOuterStructures ;
|
||||||
|
|
||||||
m_peer->GetRect( &r ) ;
|
m_peer->GetRect( &r ) ;
|
||||||
r.left -= MacGetLeftBorderSize() ;
|
r.left -= MacGetLeftBorderSize() ;
|
||||||
r.top -= MacGetTopBorderSize() ;
|
r.top -= MacGetTopBorderSize() ;
|
||||||
@@ -2784,10 +2785,10 @@ void wxWindowMac::MacUpdateClippedRects() const
|
|||||||
|
|
||||||
rIncludingOuterStructures = r ;
|
rIncludingOuterStructures = r ;
|
||||||
InsetRect( &rIncludingOuterStructures , -4 , -4 ) ;
|
InsetRect( &rIncludingOuterStructures , -4 , -4 ) ;
|
||||||
|
|
||||||
wxRect cl = GetClientRect() ;
|
wxRect cl = GetClientRect() ;
|
||||||
Rect rClient = { cl.y , cl.x , cl.y + cl.height , cl.x + cl.width } ;
|
Rect rClient = { cl.y , cl.x , cl.y + cl.height , cl.x + cl.width } ;
|
||||||
|
|
||||||
const wxWindow* child = this ;
|
const wxWindow* child = this ;
|
||||||
const wxWindow* parent = NULL ;
|
const wxWindow* parent = NULL ;
|
||||||
while( !child->IsTopLevel() && ( parent = child->GetParent() ) != NULL )
|
while( !child->IsTopLevel() && ( parent = child->GetParent() ) != NULL )
|
||||||
@@ -2829,19 +2830,19 @@ void wxWindowMac::MacUpdateClippedRects() const
|
|||||||
}
|
}
|
||||||
child = parent ;
|
child = parent ;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cachedClippedRect = wxRect( r.left , r.top , r.right - r.left , r.bottom - r.top ) ;
|
m_cachedClippedRect = wxRect( r.left , r.top , r.right - r.left , r.bottom - r.top ) ;
|
||||||
m_cachedClippedClientRect = wxRect( rClient.left , rClient.top ,
|
m_cachedClippedClientRect = wxRect( rClient.left , rClient.top ,
|
||||||
rClient.right - rClient.left , rClient.bottom - rClient.top ) ;
|
rClient.right - rClient.left , rClient.bottom - rClient.top ) ;
|
||||||
m_cachedClippedRectWithOuterStructure = wxRect(
|
m_cachedClippedRectWithOuterStructure = wxRect(
|
||||||
rIncludingOuterStructures.left , rIncludingOuterStructures.top ,
|
rIncludingOuterStructures.left , rIncludingOuterStructures.top ,
|
||||||
rIncludingOuterStructures.right - rIncludingOuterStructures.left ,
|
rIncludingOuterStructures.right - rIncludingOuterStructures.left ,
|
||||||
rIncludingOuterStructures.bottom - rIncludingOuterStructures.top ) ;
|
rIncludingOuterStructures.bottom - rIncludingOuterStructures.top ) ;
|
||||||
|
|
||||||
m_cachedClippedRegionWithOuterStructure = wxRegion( m_cachedClippedRectWithOuterStructure ) ;
|
m_cachedClippedRegionWithOuterStructure = wxRegion( m_cachedClippedRectWithOuterStructure ) ;
|
||||||
m_cachedClippedRegion = wxRegion( m_cachedClippedRect ) ;
|
m_cachedClippedRegion = wxRegion( m_cachedClippedRect ) ;
|
||||||
m_cachedClippedClientRegion = wxRegion( m_cachedClippedClientRect ) ;
|
m_cachedClippedClientRegion = wxRegion( m_cachedClippedClientRect ) ;
|
||||||
|
|
||||||
m_cachedClippedRectValid = true ;
|
m_cachedClippedRectValid = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2857,7 +2858,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
|||||||
|
|
||||||
// wxLogDebug(wxT("update for %s bounds %d , %d , %d , %d"),wxString(GetClassInfo()->GetClassName()).c_str(), updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
|
// wxLogDebug(wxT("update for %s bounds %d , %d , %d , %d"),wxString(GetClassInfo()->GetClassName()).c_str(), updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
|
||||||
|
|
||||||
if ( !EmptyRgn(updatergn) )
|
if ( !EmptyRgn(updatergn) )
|
||||||
{
|
{
|
||||||
RgnHandle newupdate = NewRgn() ;
|
RgnHandle newupdate = NewRgn() ;
|
||||||
wxSize point = GetClientSize() ;
|
wxSize point = GetClientSize() ;
|
||||||
@@ -2876,7 +2877,7 @@ bool wxWindowMac::MacDoRedraw( WXHRGN updatergnr , long time )
|
|||||||
dc->SetClippingRegion(wxRegion(updatergn));
|
dc->SetClippingRegion(wxRegion(updatergn));
|
||||||
else
|
else
|
||||||
dc->SetClippingRegion(wxRegion(newupdate));
|
dc->SetClippingRegion(wxRegion(newupdate));
|
||||||
|
|
||||||
wxEraseEvent eevent( GetId(), dc );
|
wxEraseEvent eevent( GetId(), dc );
|
||||||
eevent.SetEventObject( this );
|
eevent.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent( eevent );
|
GetEventHandler()->ProcessEvent( eevent );
|
||||||
@@ -3135,7 +3136,7 @@ long wxWindowMac::MacGetLeftBorderSize( ) const
|
|||||||
return 0 ;
|
return 0 ;
|
||||||
|
|
||||||
SInt32 border = 0 ;
|
SInt32 border = 0 ;
|
||||||
|
|
||||||
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
|
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
|
||||||
{
|
{
|
||||||
GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
|
GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
|
||||||
|
@@ -152,9 +152,10 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data )
|
|||||||
HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
|
HGLOBAL hDevNames = (HGLOBAL)(DWORD) m_devNames;
|
||||||
|
|
||||||
if (!hDevMode)
|
if (!hDevMode)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if ( hDevMode )
|
else
|
||||||
{
|
{
|
||||||
LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode);
|
LPDEVMODE devMode = (LPDEVMODE)GlobalLock(hDevMode);
|
||||||
|
|
||||||
@@ -221,7 +222,7 @@ bool wxWindowsPrintNativeData::TransferTo( wxPrintData &data )
|
|||||||
data.SetPaperId( wxPAPER_NONE );
|
data.SetPaperId( wxPAPER_NONE );
|
||||||
data.SetPaperSize( wxSize(0,0) );
|
data.SetPaperSize( wxSize(0,0) );
|
||||||
m_customWindowsPaperId = 0;
|
m_customWindowsPaperId = 0;
|
||||||
|
|
||||||
GlobalUnlock(hDevMode);
|
GlobalUnlock(hDevMode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user