]> git.saurik.com Git - wxWidgets.git/commitdiff
background handling
authorStefan Csomor <csomor@advancedconcepts.ch>
Tue, 20 Jul 2004 16:40:49 +0000 (16:40 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Tue, 20 Jul 2004 16:40:49 +0000 (16:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28333 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mac/carbon/private.h
include/wx/mac/carbon/textctrl.h
include/wx/mac/carbon/window.h
src/mac/carbon/textctrl.cpp
src/mac/carbon/utils.cpp
src/mac/carbon/window.cpp

index 0d84f0ee92071ca754826a9a2e11a8d9636fcdbf..1dccf0e3d69def5d821ddd872f38fddfb83ea8b0 100644 (file)
@@ -407,6 +407,7 @@ public :
     virtual void Flash( ControlPartCode part , UInt32 ticks = 8 ) ;
     virtual void VisibilityChanged( bool shown ) ;
     virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ;
+    virtual void SetBackground( const wxBrush &brush ) ;
     virtual ControlPartCode HandleKey(  SInt16 keyCode,  SInt16 charCode, EventModifiers modifiers ) ;
     void SetActionProc( ControlActionUPP   actionProc ) ;
     void SetViewSize( SInt32 viewSize ) ;
index b3bb9905e04d1ec9b81ba5a65896e2473f31d1ad..109fbf394ee9f32c8b16b8766db203a0122b8307 100644 (file)
@@ -155,6 +155,8 @@ public:
     void OnUpdatePaste(wxUpdateUIEvent& event);
     void OnUpdateUndo(wxUpdateUIEvent& event);
     void OnUpdateRedo(wxUpdateUIEvent& event);
+    
+    void OnEraseBackground(wxEraseEvent& event) ;
 
     virtual bool MacCanFocus() const { return true ; }
     virtual bool MacSetupCursor( const wxPoint& pt ) ;
index 26ec619fdbe965dfd24454da5c6882a6b0f1b7c2..01b5e495d4934bbd2c9e48d5c9fd6d7f1347df02 100644 (file)
@@ -195,7 +195,7 @@ public:
     virtual void        Update() ;
     virtual bool        MacSetupCursor( const wxPoint& pt ) ;
         
-    virtual void        MacSetBackgroundBrush( const wxBrush &brush ) { m_macBackgroundBrush = brush ; }
+    virtual void        MacSetBackgroundBrush( const wxBrush &brush ) ;
     const wxBrush&      MacGetBackgroundBrush() const { return m_macBackgroundBrush ; }
     
     // returns the visible region of this control in window ie non-client coordinates
index 73b7aa5dc07e2a774b4233715a7cb9700d93db7d..4843c777c1fded5f69842009eaecd8cea663e731 100644 (file)
@@ -204,6 +204,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 SetStyle(long start, long end, const wxTextAttr& style) ;
     virtual void Copy() ;
     virtual void Cut() ;
@@ -312,6 +313,7 @@ public :
 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
 
 BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
+    EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground )
     EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
     EVT_CHAR(wxTextCtrl::OnChar)
     EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
@@ -758,6 +760,14 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
     }
 }
 
+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...
+}
+
 void wxTextCtrl::OnChar(wxKeyEvent& event)
 {
     int key = event.GetKeyCode() ;
@@ -1252,7 +1262,7 @@ void wxMacUnicodeTextControl::WriteText(const wxString& str)
         val.Remove( start , end - start ) ;
         val.insert( start , str ) ;
         SetStringValue( val ) ;
-        SetInsertionPoint( start + str.Length() ) ;
+        SetSelection( start + str.Length() , start + str.Length() ) ;
     #endif
 }
 
@@ -1463,6 +1473,15 @@ void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, boo
     TXNSetBackground( m_txn , &tback);
 }
 
+void wxMacMLTEControl::SetBackground( const wxBrush &brush ) 
+{
+    // currently only solid background are supported
+    TXNBackground tback;
+    tback.bgType = kTXNBackgroundTypeRGB;
+    tback.bg.color = MAC_WXCOLORREF( brush.GetColour().GetPixel() );
+    TXNSetBackground( m_txn , &tback);
+}
+
 int wxMacMLTEControl::ConvertAttribute( const wxTextAttr& style , TXNTypeAttributes typeAttr[] )
 {
     Str255 fontName = "\pMonaco" ;
@@ -1492,7 +1511,6 @@ int wxMacMLTEControl::ConvertAttribute( const wxTextAttr& style , TXNTypeAttribu
         typeAttr[attrCounter+2].size = kTXNQDFontStyleAttributeSize ;
         typeAttr[attrCounter+2].data.dataValue = fontStyle ;
         attrCounter += 3 ;
-        
     }
     if ( style.HasTextColour() )
     {
@@ -1508,7 +1526,7 @@ int wxMacMLTEControl::ConvertAttribute( const wxTextAttr& style , TXNTypeAttribu
 void wxMacMLTEControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) 
 {
     EditHelper help(m_txn) ;
-    wxTextAttr style(wxNullColour,wxNullColour,font) ;
+    wxTextAttr style(foreground,wxNullColour,font) ;
     TXNTypeAttributes typeAttr[4] ;
     int attrCounter = ConvertAttribute( style , typeAttr ) ;
     if ( attrCounter > 0 )
index cc1caf7c1068ddb2f07b1619dca4397a5ccf934e..f9b1d82641fff45165a286e483e04ddbf7db09b2 100644 (file)
@@ -1597,6 +1597,12 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l
        ::SetControlFontStyle( m_controlRef , &fontStyle );
 }
 
+void wxMacControl::SetBackground( const wxBrush &WXUNUSED(brush) ) 
+{
+    // TODO 
+    // setting up a color proc is not recommended anymore
+}
+
 void wxMacControl::SetRange( SInt32 minimum , SInt32 maximum )
 {
     ::SetControl32BitMinimum( m_controlRef , minimum ) ;
index 9d20d9a04c43c1c1a4570f38984fe414570cb44b..0c6d1dbc37b05fd91baaada8893aec73e163fe2a 100644 (file)
@@ -889,11 +889,14 @@ bool wxWindowMac::SetBackgroundColour(const wxColour& col )
     }
     MacSetBackgroundBrush( brush ) ;
         
-    MacUpdateControlFont() ;
-    
     return true ;
 }
 
+void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
+{
+    m_macBackgroundBrush = brush ;
+    m_peer->SetBackground( brush ) ;
+}
 
 bool wxWindowMac::MacCanFocus() const
 {