/////////////////////////////////////////////////////////////////////////////
-// Name: windows.cpp
+// Name: src/mac/classic/window.cpp
// Purpose: wxWindowMac
// Author: Stefan Csomor
// Modified by:
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation "window.h"
-#endif
+#include "wx/wxprec.h"
-#include "wx/setup.h"
-#include "wx/menu.h"
#include "wx/window.h"
-#include "wx/dc.h"
-#include "wx/dcclient.h"
-#include "wx/utils.h"
-#include "wx/app.h"
-#include "wx/panel.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/log.h"
+ #include "wx/app.h"
+ #include "wx/utils.h"
+ #include "wx/panel.h"
+ #include "wx/frame.h"
+ #include "wx/dc.h"
+ #include "wx/dcclient.h"
+ #include "wx/button.h"
+ #include "wx/menu.h"
+#endif
+
#include "wx/layout.h"
#include "wx/dialog.h"
#include "wx/listbox.h"
#include "wx/scrolbar.h"
#include "wx/statbox.h"
-#include "wx/button.h"
#include "wx/settings.h"
#include "wx/msgdlg.h"
-#include "wx/frame.h"
#include "wx/notebook.h"
#include "wx/tabctrl.h"
#include "wx/tooltip.h"
#include "wx/statusbr.h"
#include "wx/menuitem.h"
#include "wx/spinctrl.h"
-#include "wx/log.h"
#include "wx/geometry.h"
#if wxUSE_CARET
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
#endif // __WXUNIVERSAL__/__WXMAC__
-#if !USE_SHARED_LIBRARY
-
BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
EVT_NC_PAINT(wxWindowMac::OnNcPaint)
EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
END_EVENT_TABLE()
-#endif
-
#define wxMAC_DEBUG_REDRAW 0
#ifndef wxMAC_DEBUG_REDRAW
#define wxMAC_DEBUG_REDRAW 0
void wxWindowMac::Init()
{
- m_backgroundTransparent = FALSE;
+ m_backgroundTransparent = false;
// as all windows are created with WS_VISIBLE style...
- m_isShown = TRUE;
+ m_isShown = true;
m_x = 0;
m_y = 0 ;
}
}
- m_isBeingDeleted = TRUE;
+ m_isBeingDeleted = true;
#ifndef __WXUNIVERSAL__
// VS: make sure there's no wxFrame with last focus set to us:
long style,
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 wxUSE_STATBOX
// wxGTK doesn't allow to create controls with static box as the parent so
#endif // wxUSE_STATBOX
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
- return FALSE;
+ return false;
parent->AddChild(this);
wxWindowCreateEvent event(this);
GetEventHandler()->AddPendingEvent(event);
- return TRUE;
+ return true;
}
void wxWindowMac::SetFocus()
bool wxWindowMac::Enable(bool enable)
{
if ( !wxWindowBase::Enable(enable) )
- return FALSE;
+ return false;
MacSuperEnabled( enable ) ;
- return TRUE;
+ return true;
}
void wxWindowMac::DoCaptureMouse()
{
menu->SetInvokingWindow(this);
menu->UpdateUI();
-
+
if ( x == -1 && y == -1 )
{
wxPoint mouse = wxGetMousePosition();
menu->SetInvokingWindow(NULL);
- return TRUE;
+ return true;
}
#endif
bool wxWindowMac::SetCursor(const wxCursor& cursor)
{
if (m_cursor == cursor)
- return FALSE;
+ return false;
if (wxNullCursor == cursor)
{
if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) )
- return FALSE ;
+ return false ;
}
else
{
if ( ! wxWindowBase::SetCursor( cursor ) )
- return FALSE ;
+ return false ;
}
wxASSERT_MSG( m_cursor.Ok(),
}
}
- return TRUE ;
+ return true ;
}
oldRgn = NewRgn() ;
newRgn = NewRgn() ;
diffRgn = NewRgn() ;
-
+
// invalidate the differences between the old and the new area
-
+
SetRectRgn(oldRgn , oldPos.x , oldPos.y , oldPos.x + m_width , oldPos.y + m_height ) ;
SetRectRgn(newRgn , newPos.x , newPos.y , newPos.x + actualWidth , newPos.y + actualHeight ) ;
DiffRgn( newRgn , oldRgn , diffRgn ) ;
InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
DiffRgn( oldRgn , newRgn , diffRgn ) ;
InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
-
+
// we also must invalidate the border areas, someone might optimize this one day to invalidate only the really
// changing pixels...
-
- if ( MacGetLeftBorderSize() != 0 || MacGetRightBorderSize() != 0 ||
- MacGetTopBorderSize() != 0 || MacGetBottomBorderSize() != 0 )
+
+ if ( MacGetLeftBorderSize() != 0 || MacGetRightBorderSize() != 0 ||
+ MacGetTopBorderSize() != 0 || MacGetBottomBorderSize() != 0 )
{
- RgnHandle innerOldRgn, innerNewRgn ;
- innerOldRgn = NewRgn() ;
- innerNewRgn = NewRgn() ;
-
- SetRectRgn(innerOldRgn , oldPos.x + MacGetLeftBorderSize() , oldPos.y + MacGetTopBorderSize() ,
- oldPos.x + m_width - MacGetRightBorderSize() , oldPos.y + m_height - MacGetBottomBorderSize() ) ;
- DiffRgn( oldRgn , innerOldRgn , diffRgn ) ;
- InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
-
- SetRectRgn(innerNewRgn , newPos.x + MacGetLeftBorderSize() , newPos.y + MacGetTopBorderSize() ,
- newPos.x + actualWidth - MacGetRightBorderSize() , newPos.y + actualHeight - MacGetBottomBorderSize() ) ;
- DiffRgn( newRgn , innerNewRgn , diffRgn ) ;
- InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
-
- DisposeRgn( innerOldRgn ) ;
- DisposeRgn( innerNewRgn ) ;
+ RgnHandle innerOldRgn, innerNewRgn ;
+ innerOldRgn = NewRgn() ;
+ innerNewRgn = NewRgn() ;
+
+ SetRectRgn(innerOldRgn , oldPos.x + MacGetLeftBorderSize() , oldPos.y + MacGetTopBorderSize() ,
+ oldPos.x + m_width - MacGetRightBorderSize() , oldPos.y + m_height - MacGetBottomBorderSize() ) ;
+ DiffRgn( oldRgn , innerOldRgn , diffRgn ) ;
+ InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
+
+ SetRectRgn(innerNewRgn , newPos.x + MacGetLeftBorderSize() , newPos.y + MacGetTopBorderSize() ,
+ newPos.x + actualWidth - MacGetRightBorderSize() , newPos.y + actualHeight - MacGetBottomBorderSize() ) ;
+ DiffRgn( newRgn , innerNewRgn , diffRgn ) ;
+ InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
+
+ DisposeRgn( innerOldRgn ) ;
+ DisposeRgn( innerNewRgn ) ;
}
-
+
DisposeRgn(oldRgn) ;
DisposeRgn(newRgn) ;
DisposeRgn(diffRgn) ;
return wxPoint(MacGetLeftBorderSize( ) , MacGetTopBorderSize( ) );
}
-void wxWindowMac::SetTitle(const wxString& title)
+void wxWindowMac::SetLabel(const wxString& label)
{
- m_label = title ;
+ m_label = label ;
}
-wxString wxWindowMac::GetTitle() const
+wxString wxWindowMac::GetLabel() const
{
return m_label ;
}
bool wxWindowMac::Show(bool show)
{
if ( !wxWindowBase::Show(show) )
- return FALSE;
+ return false;
MacSuperShown( show ) ;
Refresh() ;
- return TRUE;
+ return true;
}
void wxWindowMac::MacSuperShown( bool show )
return ;
if ( !MacIsReallyShown() )
- return ;
-
+ return ;
+
wxPoint client = GetClientAreaOrigin();
int x1 = -client.x;
int y1 = -client.y;
{
if( IsTopLevel() )
return ;
-
+
int major,minor;
wxGetOsVersion( &major, &minor );
RGBColor white = { 0xFFFF, 0xFFFF , 0xFFFF } ;
RGBColor face = { 0xDDDD, 0xDDDD , 0xDDDD } ;
-
+
RGBColor darkShadow = { 0x0000, 0x0000 , 0x0000 } ;
RGBColor lightShadow = { 0x4444, 0x4444 , 0x4444 } ;
// OS X has lighter border edges than classic:
- if (major >= 10)
- {
- darkShadow.red = 0x8E8E;
- darkShadow.green = 0x8E8E;
- darkShadow.blue = 0x8E8E;
- lightShadow.red = 0xBDBD;
- lightShadow.green = 0xBDBD;
- lightShadow.blue = 0xBDBD;
- }
-
+ if (major >= 10)
+ {
+ darkShadow.red = 0x8E8E;
+ darkShadow.green = 0x8E8E;
+ darkShadow.blue = 0x8E8E;
+ lightShadow.red = 0xBDBD;
+ lightShadow.green = 0xBDBD;
+ lightShadow.blue = 0xBDBD;
+ }
+
PenNormal() ;
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
{
if( dx == 0 && dy ==0 )
return ;
-
+
{
wxClientDC dc(this) ;
SectRect( &scrollrect , &r , &scrollrect ) ;
}
ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
- // we also have to scroll the update rgn in this rectangle
+ // we also have to scroll the update rgn in this rectangle
// in order not to loose updates
WindowRef rootWindow = (WindowRef) MacGetRootWindow() ;
RgnHandle formerUpdateRgn = NewRgn() ;
}
else
{
- child->SetSize( x+dx, y+dy, w, h );
- }
+ child->SetSize( x+dx, y+dy, w, h );
+ }
}
-
+
Update() ;
}
void wxWindowMac::MacOnScroll(wxScrollEvent &event )
{
- if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar )
+ if ( event.GetEventObject() == m_vScrollBar || event.GetEventObject() == m_hScrollBar )
{
wxScrollWinEvent wevent;
wevent.SetPosition(event.GetPosition());
wevent.SetOrientation(event.GetOrientation());
- wevent.m_eventObject = this;
-
- if (event.m_eventType == wxEVT_SCROLL_TOP)
- wevent.m_eventType = wxEVT_SCROLLWIN_TOP;
- else if (event.m_eventType == wxEVT_SCROLL_BOTTOM)
- wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM;
- else if (event.m_eventType == wxEVT_SCROLL_LINEUP)
- wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
- else if (event.m_eventType == wxEVT_SCROLL_LINEDOWN)
- wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
- else if (event.m_eventType == wxEVT_SCROLL_PAGEUP)
- wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
- else if (event.m_eventType == wxEVT_SCROLL_PAGEDOWN)
- wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
- else if (event.m_eventType == wxEVT_SCROLL_THUMBTRACK)
- wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
- else if (event.m_eventType == wxEVT_SCROLL_THUMBRELEASE)
- wevent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE;
+ wevent.SetEventObject(this);
+
+ if (event.GetEventType() == wxEVT_SCROLL_TOP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_TOP );
+ else if (event.GetEventType() == wxEVT_SCROLL_BOTTOM)
+ wevent.SetEventType( wxEVT_SCROLLWIN_BOTTOM );
+ else if (event.GetEventType() == wxEVT_SCROLL_LINEUP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_LINEUP );
+ else if (event.GetEventType() == wxEVT_SCROLL_LINEDOWN)
+ wevent.SetEventType( wxEVT_SCROLLWIN_LINEDOWN );
+ else if (event.GetEventType() == wxEVT_SCROLL_PAGEUP)
+ wevent.SetEventType( wxEVT_SCROLLWIN_PAGEUP );
+ else if (event.GetEventType() == wxEVT_SCROLL_PAGEDOWN)
+ wevent.SetEventType( wxEVT_SCROLLWIN_PAGEDOWN );
+ else if (event.GetEventType() == wxEVT_SCROLL_THUMBTRACK)
+ wevent.SetEventType( wxEVT_SCROLLWIN_THUMBTRACK );
+ else if (event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE)
+ wevent.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE );
GetEventHandler()->ProcessEvent(wevent);
}
}
// Get the window with the focus
-wxWindowMac *wxWindowBase::FindFocus()
+wxWindowMac *wxWindowBase::DoFindFocus()
{
return gFocusWindow ;
}
{
if ((point.x < 0) || (point.y < 0) ||
(point.x > (m_width)) || (point.y > (m_height)))
- return FALSE;
+ return false;
}
else
{
if ((point.x < m_x) || (point.y < m_y) ||
(point.x > (m_x + m_width)) || (point.y > (m_y + m_height)))
- return FALSE;
+ return false;
}
WindowRef window = (WindowRef) MacGetRootWindow() ;
if ( child->MacGetRootWindow() == (WXWindow) window && child->m_isShown )
{
if (child->MacGetWindowFromPointSub(newPoint , outWin ))
- return TRUE;
+ return true;
}
}
*outWin = this ;
- return TRUE;
+ return true;
}
bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMac** outWin )
return win->MacGetWindowFromPointSub( point , outWin ) ;
}
}
- return FALSE ;
+ return false ;
}
static wxWindow *gs_lastWhich = NULL;
}
bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
-{
+{
if ((event.m_x < m_x) || (event.m_y < m_y) ||
(event.m_x > (m_x + m_width)) || (event.m_y > (m_y + m_height)))
- return FALSE;
+ return false;
if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) /* || IsKindOf( CLASSINFO( wxSpinCtrl ) ) */)
- return FALSE ;
+ return false ;
WindowRef window = (WindowRef) MacGetRootWindow() ;
if ( child->MacGetRootWindow() == (WXWindow) window && child->IsShown() && child->IsEnabled() )
{
if (child->MacDispatchMouseEvent(event))
- return TRUE;
+ return true;
}
}
// Same for mouse up events
if (event.GetEventType() == wxEVT_LEFT_UP)
- return TRUE;
+ return true;
if (event.GetEventType() == wxEVT_RIGHT_UP)
- return TRUE;
+ return true;
}
GetEventHandler()->ProcessEvent( event ) ;
- return TRUE;
+ return true;
}
wxString wxWindowMac::MacGetToolTipString( wxPoint &pt )
int top = 0 , left = 0 ;
MacWindowToRootWindow( &left , &top ) ;
WindowRef rootWindow = (WindowRef) MacGetRootWindow() ;
- RgnHandle updateRgn = NewRgn() ;
+ RgnHandle updateRgn = NewRgn() ;
// getting the update region in macos local coordinates
GetWindowUpdateRgn( rootWindow , updateRgn ) ;
GrafPtr port ;
int borderOther = 4 ;
if ( UMAGetSystemVersion() >= 0x1030 )
borderTop += 2 ;
-
+
SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ;
DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ;
}
hiddenWindows.Append( child ) ;
}
}
-
+
wxPaintEvent event;
- event.m_timeStamp = time ;
+ event.SetTimestamp(time);
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
-
+
for (wxWindowListNode *node = hiddenWindows.GetFirst(); node; node = node->GetNext())
{
wxControl *child = wxDynamicCast( ( wxWindow*)node->GetData() , wxControl ) ;
void wxWindowMac::OnMouseEvent( wxMouseEvent &event )
{
- if ( event.GetEventType() == wxEVT_RIGHT_DOWN )
- {
- // copied from wxGTK : CS
+ if ( event.GetEventType() == wxEVT_RIGHT_DOWN )
+ {
+ // copied from wxGTK : CS
// generate a "context menu" event: this is similar to wxEVT_RIGHT_DOWN
// except that:
//
this->ClientToScreen(event.GetPosition()));
if ( ! GetEventHandler()->ProcessEvent(evtCtx) )
event.Skip() ;
- }
- else
- {
- event.Skip() ;
- }
+ }
+ else
+ {
+ event.Skip() ;
+ }
}
-