cleanup
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50326 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -9,80 +9,4 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/dc.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/log.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/region.h"
|
||||
#endif
|
||||
|
||||
#include "wx/mac/uma.h"
|
||||
|
||||
#ifdef __MSL__
|
||||
#if __MSL__ >= 0x6000
|
||||
#include "math.h"
|
||||
// in case our functions were defined outside std, we make it known all the same
|
||||
namespace std { }
|
||||
using namespace std ;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "wx/mac/private.h"
|
||||
|
||||
#ifndef __LP64__
|
||||
|
||||
// TODO: update
|
||||
// The textctrl implementation still needs that (needs what?) for the non-HIView implementation
|
||||
//
|
||||
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) :
|
||||
wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) )
|
||||
{
|
||||
m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ;
|
||||
m_formerClip = NewRgn() ;
|
||||
m_newClip = NewRgn() ;
|
||||
GetClip( m_formerClip ) ;
|
||||
|
||||
if ( win )
|
||||
{
|
||||
// guard against half constructed objects, this just leads to a empty clip
|
||||
if ( win->GetPeer() )
|
||||
{
|
||||
int x = 0 , y = 0;
|
||||
win->MacWindowToRootWindow( &x, &y ) ;
|
||||
|
||||
// get area including focus rect
|
||||
HIShapeGetAsQDRgn( ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip );
|
||||
if ( !EmptyRgn( m_newClip ) )
|
||||
OffsetRgn( m_newClip , x , y ) ;
|
||||
}
|
||||
|
||||
SetClip( m_newClip ) ;
|
||||
}
|
||||
}
|
||||
|
||||
wxMacWindowClipper::~wxMacWindowClipper()
|
||||
{
|
||||
SetPort( m_newPort ) ;
|
||||
SetClip( m_formerClip ) ;
|
||||
DisposeRgn( m_newClip ) ;
|
||||
DisposeRgn( m_formerClip ) ;
|
||||
}
|
||||
|
||||
wxMacWindowStateSaver::wxMacWindowStateSaver( const wxWindow* win ) :
|
||||
wxMacWindowClipper( win )
|
||||
{
|
||||
// the port is already set at this point
|
||||
m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ;
|
||||
GetThemeDrawingState( &m_themeDrawingState ) ;
|
||||
}
|
||||
|
||||
wxMacWindowStateSaver::~wxMacWindowStateSaver()
|
||||
{
|
||||
SetPort( m_newPort ) ;
|
||||
SetThemeDrawingState( m_themeDrawingState , true ) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
// TODO REMOVE
|
@@ -141,6 +141,34 @@ void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( con
|
||||
return result ;
|
||||
}
|
||||
|
||||
class WXDLLEXPORT wxMacPortSaver
|
||||
{
|
||||
DECLARE_NO_COPY_CLASS(wxMacPortSaver)
|
||||
|
||||
public:
|
||||
wxMacPortSaver( GrafPtr port );
|
||||
~wxMacPortSaver();
|
||||
private :
|
||||
GrafPtr m_port;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Clips to the visible region of a control within the current port
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
|
||||
{
|
||||
DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
|
||||
|
||||
public:
|
||||
wxMacWindowClipper( const wxWindow* win );
|
||||
~wxMacWindowClipper();
|
||||
private:
|
||||
GrafPtr m_newPort;
|
||||
RgnHandle m_formerClip;
|
||||
RgnHandle m_newClip;
|
||||
};
|
||||
|
||||
// common parts for implementations based on MLTE
|
||||
|
||||
@@ -157,7 +185,7 @@ public :
|
||||
void AdjustCreationAttributes( const wxColour& background, bool visible ) ;
|
||||
|
||||
virtual void SetFont( const wxFont & font, const wxColour& foreground, long windowStyle ) ;
|
||||
virtual void SetBackground( const wxBrush &brush ) ;
|
||||
virtual void SetBackgroundColour(const wxColour& col );
|
||||
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
|
||||
virtual void Copy() ;
|
||||
virtual void Cut() ;
|
||||
@@ -218,7 +246,7 @@ public :
|
||||
|
||||
virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
|
||||
virtual bool HasFocus() const ;
|
||||
virtual void SetBackground( const wxBrush &brush) ;
|
||||
virtual void SetBackgroundColour(const wxColour& col ) ;
|
||||
|
||||
protected :
|
||||
HIViewRef m_scrollView ;
|
||||
@@ -287,7 +315,6 @@ private :
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
|
||||
EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground )
|
||||
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
|
||||
EVT_CHAR(wxTextCtrl::OnChar)
|
||||
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
|
||||
@@ -751,15 +778,6 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
|
||||
LoadFile( event.GetFiles()[0] );
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
// all erasing should be done by the real mac control implementation
|
||||
// while this is true for MLTE under classic, the HITextView is somehow
|
||||
// transparent but background erase is not working correctly, so intercept
|
||||
// things while we can...
|
||||
event.Skip() ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
int key = event.GetKeyCode() ;
|
||||
@@ -1720,13 +1738,11 @@ void wxMacMLTEControl::AdjustCreationAttributes(const wxColour &background,
|
||||
}
|
||||
}
|
||||
|
||||
void wxMacMLTEControl::SetBackground( const wxBrush &brush )
|
||||
void wxMacMLTEControl::SetBackgroundColour(const wxColour& col )
|
||||
{
|
||||
// currently only solid background are supported
|
||||
TXNBackground tback;
|
||||
|
||||
tback.bgType = kTXNBackgroundTypeRGB;
|
||||
brush.GetColour().GetRGBColor(&tback.bg.color);
|
||||
col.GetRGBColor(&tback.bg.color);
|
||||
TXNSetBackground( m_txn , &tback );
|
||||
}
|
||||
|
||||
@@ -2241,6 +2257,40 @@ int wxMacMLTEControl::GetLineLength(long lineNo) const
|
||||
// while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is
|
||||
// no way out, therefore we are using our own implementation and our own scrollbars ....
|
||||
|
||||
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) :
|
||||
wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) )
|
||||
{
|
||||
m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ;
|
||||
m_formerClip = NewRgn() ;
|
||||
m_newClip = NewRgn() ;
|
||||
GetClip( m_formerClip ) ;
|
||||
|
||||
if ( win )
|
||||
{
|
||||
// guard against half constructed objects, this just leads to a empty clip
|
||||
if ( win->GetPeer() )
|
||||
{
|
||||
int x = 0 , y = 0;
|
||||
win->MacWindowToRootWindow( &x, &y ) ;
|
||||
|
||||
// get area including focus rect
|
||||
HIShapeGetAsQDRgn( ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip );
|
||||
if ( !EmptyRgn( m_newClip ) )
|
||||
OffsetRgn( m_newClip , x , y ) ;
|
||||
}
|
||||
|
||||
SetClip( m_newClip ) ;
|
||||
}
|
||||
}
|
||||
|
||||
wxMacWindowClipper::~wxMacWindowClipper()
|
||||
{
|
||||
SetPort( m_newPort ) ;
|
||||
SetClip( m_formerClip ) ;
|
||||
DisposeRgn( m_newClip ) ;
|
||||
DisposeRgn( m_formerClip ) ;
|
||||
}
|
||||
|
||||
TXNScrollInfoUPP gTXNScrollInfoProc = NULL ;
|
||||
ControlActionUPP gTXNScrollActionProc = NULL ;
|
||||
|
||||
@@ -3037,25 +3087,9 @@ bool wxMacMLTEHIViewControl::HasFocus() const
|
||||
return control == m_textView ;
|
||||
}
|
||||
|
||||
void wxMacMLTEHIViewControl::SetBackground( const wxBrush &brush )
|
||||
void wxMacMLTEHIViewControl::SetBackgroundColour(const wxColour& col )
|
||||
{
|
||||
wxMacMLTEControl::SetBackground( brush ) ;
|
||||
|
||||
#if 0
|
||||
CGColorSpaceRef rgbSpace = CGColorSpaceCreateDeviceRGB();
|
||||
RGBColor col;
|
||||
brush.GetColour().GetRGBColor(&col) ;
|
||||
|
||||
float component[4] ;
|
||||
component[0] = col.red / 65536.0 ;
|
||||
component[1] = col.green / 65536.0 ;
|
||||
component[2] = col.blue / 65536.0 ;
|
||||
component[3] = 1.0 ; // alpha
|
||||
|
||||
CGColorRef color = CGColorCreate( rgbSpace , component );
|
||||
HITextViewSetBackgroundColor( m_textView , color );
|
||||
CGColorSpaceRelease( rgbSpace );
|
||||
#endif
|
||||
HITextViewSetBackgroundColor( m_textView, col.GetPixel() );
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
@@ -699,8 +699,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l
|
||||
|
||||
void wxMacControl::SetBackgroundColour( const wxColour &WXUNUSED(col) )
|
||||
{
|
||||
// TODO
|
||||
// setting up a color proc is not recommended anymore
|
||||
// HITextViewSetBackgroundColor( m_textView , color );
|
||||
}
|
||||
|
||||
void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum )
|
||||
|
@@ -78,8 +78,6 @@ BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
|
||||
EVT_NC_PAINT(wxWindowMac::OnNcPaint)
|
||||
EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
|
||||
EVT_PAINT(wxWindowMac::OnPaint)
|
||||
EVT_SET_FOCUS(wxWindowMac::OnSetFocus)
|
||||
EVT_KILL_FOCUS(wxWindowMac::OnSetFocus)
|
||||
EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@@ -312,6 +310,12 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl
|
||||
{
|
||||
ControlPartCode previousControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlPreviousPart , typeControlPartCode );
|
||||
ControlPartCode currentControlPart = cEvent.GetParameter<ControlPartCode>(kEventParamControlCurrentPart , typeControlPartCode );
|
||||
|
||||
if ( thisWindow->MacGetTopLevelWindow() && thisWindow->GetPeer()->NeedsFocusRect() )
|
||||
{
|
||||
thisWindow->MacInvalidateBorders();
|
||||
}
|
||||
|
||||
if ( currentControlPart == 0 )
|
||||
{
|
||||
// kill focus
|
||||
@@ -1675,7 +1679,7 @@ void wxWindowMac::MacInvalidateBorders()
|
||||
return ;
|
||||
|
||||
int outerBorder = MacGetLeftBorderSize() ;
|
||||
if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )
|
||||
if ( m_peer->NeedsFocusRect() /* && m_peer->HasFocus() */ )
|
||||
outerBorder += 4 ;
|
||||
|
||||
if ( outerBorder == 0 )
|
||||
@@ -2508,54 +2512,6 @@ wxWindowMac *wxWindowBase::DoFindFocus()
|
||||
return wxFindControlFromMacControl( control ) ;
|
||||
}
|
||||
|
||||
void wxWindowMac::OnSetFocus( wxFocusEvent& event )
|
||||
{
|
||||
// panel wants to track the window which was the last to have focus in it,
|
||||
// so we want to set ourselves as the window which last had focus
|
||||
//
|
||||
// notice that it's also important to do it upwards the tree because
|
||||
// otherwise when the top level panel gets focus, it won't set it back to
|
||||
// us, but to some other sibling
|
||||
|
||||
// CS: don't know if this is still needed:
|
||||
//wxChildFocusEvent eventFocus(this);
|
||||
//(void)GetEventHandler()->ProcessEvent(eventFocus);
|
||||
|
||||
if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
|
||||
{
|
||||
GetParent()->Refresh() ;
|
||||
wxMacWindowStateSaver sv( this ) ;
|
||||
Rect rect ;
|
||||
|
||||
m_peer->GetRect( &rect ) ;
|
||||
// on the surrounding frame
|
||||
InsetRect( &rect, -1 , -1 ) ;
|
||||
|
||||
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
|
||||
if ( top )
|
||||
{
|
||||
wxPoint pt(0, 0) ;
|
||||
wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ;
|
||||
rect.left += pt.x ;
|
||||
rect.right += pt.x ;
|
||||
rect.top += pt.y ;
|
||||
rect.bottom += pt.y ;
|
||||
}
|
||||
|
||||
bool bIsFocusEvent = (event.GetEventType() == wxEVT_SET_FOCUS);
|
||||
DrawThemeFocusRect( &rect , bIsFocusEvent ) ;
|
||||
if ( !bIsFocusEvent )
|
||||
{
|
||||
// as this erases part of the frame we have to redraw borders
|
||||
// and because our z-ordering is not always correct (staticboxes)
|
||||
// we have to invalidate things, we cannot simple redraw
|
||||
MacInvalidateBorders() ;
|
||||
}
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxWindowMac::OnInternalIdle()
|
||||
{
|
||||
// This calls the UI-update mechanism (querying windows for
|
||||
|
Reference in New Issue
Block a user