simplify native textcontrol creations, adding search control for cocoa
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55476 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
23e00c551b
commit
1e181c7a2c
@ -21,7 +21,7 @@
|
||||
// forward decl for GetSelections()
|
||||
class wxArrayInt;
|
||||
|
||||
// forward decl for wxListWidgetImpl data type.
|
||||
// forward decl for wxListWidgetImpl implementation type.
|
||||
class wxListWidgetImpl;
|
||||
|
||||
// List box item
|
||||
|
@ -426,7 +426,7 @@ public :
|
||||
virtual void SuperChangedPosition();
|
||||
|
||||
|
||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle );
|
||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
|
||||
virtual void SetBackgroundColour( const wxColour& col );
|
||||
virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
|
||||
void SetActionProc( ControlActionUPP actionProc );
|
||||
@ -962,8 +962,6 @@ void wxMacSetupConverters();
|
||||
void wxMacCleanupConverters();
|
||||
|
||||
// utils.cpp
|
||||
void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , StringPtr to );
|
||||
wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( ConstStringPtr from );
|
||||
|
||||
// filefn.cpp
|
||||
|
||||
|
@ -14,64 +14,9 @@
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
// common interface for all implementations
|
||||
class wxMacTextControl :
|
||||
#if wxOSX_USE_CARBON
|
||||
public wxMacControl
|
||||
#else
|
||||
public wxWidgetCocoaImpl
|
||||
#endif
|
||||
{
|
||||
public :
|
||||
#if wxOSX_USE_CARBON
|
||||
wxMacTextControl( wxTextCtrl *peer ) ;
|
||||
#else
|
||||
wxMacTextControl::wxMacTextControl(wxTextCtrl* peer, WXWidget w) ;
|
||||
#endif
|
||||
virtual ~wxMacTextControl() ;
|
||||
// implementation exposed, so that search control can pull it
|
||||
|
||||
virtual bool CanFocus() const { return true; }
|
||||
|
||||
virtual wxString GetStringValue() const = 0 ;
|
||||
virtual void SetStringValue( const wxString &val ) = 0 ;
|
||||
virtual void SetSelection( long from, long to ) = 0 ;
|
||||
virtual void GetSelection( long* from, long* to ) const = 0 ;
|
||||
virtual void WriteText( const wxString& str ) = 0 ;
|
||||
|
||||
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
|
||||
virtual void Copy() ;
|
||||
virtual void Cut() ;
|
||||
virtual void Paste() ;
|
||||
virtual bool CanPaste() const ;
|
||||
virtual void SetEditable( bool editable ) ;
|
||||
virtual wxTextPos GetLastPosition() const ;
|
||||
virtual void Replace( long from, long to, const wxString &str ) ;
|
||||
virtual void Remove( long from, long to ) ;
|
||||
|
||||
|
||||
virtual bool HasOwnContextMenu() const
|
||||
{ return false ; }
|
||||
|
||||
virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) )
|
||||
{ return false ; }
|
||||
|
||||
virtual void Clear() ;
|
||||
virtual bool CanUndo() const;
|
||||
virtual void Undo() ;
|
||||
virtual bool CanRedo() const;
|
||||
virtual void Redo() ;
|
||||
virtual int GetNumberOfLines() const ;
|
||||
virtual long XYToPosition(long x, long y) const;
|
||||
virtual bool PositionToXY(long pos, long *x, long *y) const ;
|
||||
virtual void ShowPosition(long WXUNUSED(pos)) ;
|
||||
virtual int GetLineLength(long lineNo) const ;
|
||||
virtual wxString GetLineText(long lineNo) const ;
|
||||
virtual void CheckSpelling(bool WXUNUSED(check)) { }
|
||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle );
|
||||
};
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
class wxMacUnicodeTextControl : public wxMacTextControl
|
||||
class wxMacUnicodeTextControl : public wxMacControl, public wxTextWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) ;
|
||||
@ -81,10 +26,6 @@ public :
|
||||
const wxSize& size, long style ) ;
|
||||
virtual ~wxMacUnicodeTextControl();
|
||||
|
||||
virtual bool Create( wxTextCtrl *wxPeer,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style ) ;
|
||||
virtual void VisibilityChanged(bool shown);
|
||||
virtual wxString GetStringValue() const ;
|
||||
virtual void SetStringValue( const wxString &str) ;
|
||||
@ -98,13 +39,12 @@ public :
|
||||
virtual void WriteText(const wxString& str) ;
|
||||
|
||||
protected :
|
||||
virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef cfr );
|
||||
void InstallEventHandlers();
|
||||
|
||||
// contains the tag for the content (is different for password and non-password controls)
|
||||
OSType m_valueTag ;
|
||||
public :
|
||||
ControlEditTextSelectionRec m_selection ;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // _WX_MAC_PRIVATE_MACTEXT_H_
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#if wxUSE_SEARCHCTRL
|
||||
|
||||
class wxMacSearchFieldControl;
|
||||
class wxSearchWidgetImpl;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxSearchCtrl : public wxSearchCtrlBase
|
||||
{
|
||||
@ -54,14 +54,13 @@ public:
|
||||
virtual bool IsCancelButtonVisible() const;
|
||||
|
||||
// TODO: In 2.9 these should probably be virtual, and declared in the base class...
|
||||
void SetDescriptiveText(const wxString& text);
|
||||
wxString GetDescriptiveText() const;
|
||||
void SetDescriptiveText(const wxString& text);
|
||||
wxString GetDescriptiveText() const;
|
||||
|
||||
virtual wxInt32 MacSearchFieldSearchHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
|
||||
virtual wxInt32 MacSearchFieldCancelHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
|
||||
virtual bool HandleSearchFieldSearchHit() ;
|
||||
virtual bool HandleSearchFieldCancelHit() ;
|
||||
|
||||
wxMacSearchFieldControl * GetPeer() const
|
||||
{ return (wxMacSearchFieldControl*) m_peer; }
|
||||
wxSearchWidgetImpl * GetSearchPeer() const;
|
||||
|
||||
protected:
|
||||
|
||||
@ -69,13 +68,10 @@ protected:
|
||||
|
||||
void Init();
|
||||
|
||||
virtual void CreatePeer(
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style );
|
||||
|
||||
wxMenu *m_menu;
|
||||
|
||||
wxString m_descriptiveText;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSearchCtrl)
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "wx/control.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
class wxMacTextControl;
|
||||
|
||||
// forward decl for wxListWidgetImpl implementation type.
|
||||
class WXDLLIMPEXP_FWD_CORE wxTextWidgetImpl;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
|
||||
{
|
||||
@ -170,17 +170,13 @@ public:
|
||||
virtual void MacSuperChangedPosition();
|
||||
virtual void MacCheckSpelling(bool check);
|
||||
|
||||
wxMacTextControl * GetPeer() const
|
||||
{ return (wxMacTextControl*) m_peer; }
|
||||
|
||||
wxTextWidgetImpl * GetTextPeer() const;
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
virtual void CreatePeer(const wxString& str, const wxPoint& pos, const wxSize& size, long style );
|
||||
|
||||
virtual void DoSetValue(const wxString& value, int flags = 0);
|
||||
|
||||
bool m_editable;
|
||||
|
@ -148,6 +148,8 @@ public :
|
||||
void PulseGauge();
|
||||
void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
|
||||
|
||||
void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
|
||||
|
||||
protected:
|
||||
WXWidget m_osxView;
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
|
||||
|
37
include/wx/osx/cocoa/private/textimpl.h
Normal file
37
include/wx/osx/cocoa/private/textimpl.h
Normal file
@ -0,0 +1,37 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: textimpl.h
|
||||
// Purpose: textcontrol implementation classes that have to be exposed
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 03/02/99
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
||||
#define _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
// implementation exposed, so that search control can pull it
|
||||
|
||||
class wxNSTextFieldControl : public wxWidgetCocoaImpl, public wxTextWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w );
|
||||
virtual ~wxNSTextFieldControl();
|
||||
|
||||
virtual wxString GetStringValue() const ;
|
||||
virtual void SetStringValue( const wxString &str) ;
|
||||
virtual void Copy() ;
|
||||
virtual void Cut() ;
|
||||
virtual void Paste() ;
|
||||
virtual bool CanPaste() const ;
|
||||
virtual void SetEditable(bool editable) ;
|
||||
virtual void GetSelection( long* from, long* to) const ;
|
||||
virtual void SetSelection( long from , long to );
|
||||
virtual void WriteText(const wxString& str) ;
|
||||
};
|
||||
|
||||
#endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
@ -22,7 +22,12 @@
|
||||
#include "wx/osx/core/cfdataref.h"
|
||||
|
||||
#if wxOSX_USE_COCOA_OR_CARBON
|
||||
|
||||
WXDLLIMPEXP_BASE long UMAGetSystemVersion() ;
|
||||
|
||||
void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , unsigned char * to );
|
||||
wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( const unsigned char * from );
|
||||
|
||||
#endif
|
||||
|
||||
#if wxUSE_GUI
|
||||
@ -225,6 +230,8 @@ public :
|
||||
virtual void PulseGauge() = 0;
|
||||
virtual void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) = 0;
|
||||
|
||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ) = 0;
|
||||
|
||||
// is the clicked event sent AFTER the state already changed, so no additional
|
||||
// state changing logic is required from the outside
|
||||
virtual bool ButtonClickDidStateChange() = 0;
|
||||
@ -293,6 +300,15 @@ public :
|
||||
long style,
|
||||
long extraStyle) ;
|
||||
|
||||
static wxWidgetImplType* CreateSearchControl( wxTextCtrl* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
const wxString& content,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
long extraStyle) ;
|
||||
|
||||
static wxWidgetImplType* CreateCheckBox( wxWindowMac* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
@ -475,6 +491,80 @@ public:
|
||||
virtual unsigned int ListGetCount() const = 0;
|
||||
};
|
||||
|
||||
//
|
||||
// interface to be implemented by a textcontrol
|
||||
//
|
||||
|
||||
// common interface for all implementations
|
||||
class WXDLLIMPEXP_CORE wxTextWidgetImpl
|
||||
|
||||
{
|
||||
public :
|
||||
wxTextWidgetImpl() {}
|
||||
|
||||
virtual ~wxTextWidgetImpl() {}
|
||||
|
||||
virtual bool CanFocus() const { return true; }
|
||||
|
||||
virtual wxString GetStringValue() const = 0 ;
|
||||
virtual void SetStringValue( const wxString &val ) = 0 ;
|
||||
virtual void SetSelection( long from, long to ) = 0 ;
|
||||
virtual void GetSelection( long* from, long* to ) const = 0 ;
|
||||
virtual void WriteText( const wxString& str ) = 0 ;
|
||||
|
||||
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
|
||||
virtual void Copy() ;
|
||||
virtual void Cut() ;
|
||||
virtual void Paste() ;
|
||||
virtual bool CanPaste() const ;
|
||||
virtual void SetEditable( bool editable ) ;
|
||||
virtual wxTextPos GetLastPosition() const ;
|
||||
virtual void Replace( long from, long to, const wxString &str ) ;
|
||||
virtual void Remove( long from, long to ) ;
|
||||
|
||||
|
||||
virtual bool HasOwnContextMenu() const
|
||||
{ return false ; }
|
||||
|
||||
virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) )
|
||||
{ return false ; }
|
||||
|
||||
virtual void Clear() ;
|
||||
virtual bool CanUndo() const;
|
||||
virtual void Undo() ;
|
||||
virtual bool CanRedo() const;
|
||||
virtual void Redo() ;
|
||||
virtual int GetNumberOfLines() const ;
|
||||
virtual long XYToPosition(long x, long y) const;
|
||||
virtual bool PositionToXY(long pos, long *x, long *y) const ;
|
||||
virtual void ShowPosition(long WXUNUSED(pos)) ;
|
||||
virtual int GetLineLength(long lineNo) const ;
|
||||
virtual wxString GetLineText(long lineNo) const ;
|
||||
virtual void CheckSpelling(bool WXUNUSED(check)) { }
|
||||
};
|
||||
|
||||
//
|
||||
// common interface for search controls
|
||||
//
|
||||
|
||||
class wxSearchWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxSearchWidgetImpl(){}
|
||||
virtual ~wxSearchWidgetImpl(){}
|
||||
|
||||
// search field options
|
||||
virtual void ShowSearchButton( bool show ) = 0;
|
||||
virtual bool IsSearchButtonVisible() const = 0;
|
||||
|
||||
virtual void ShowCancelButton( bool show ) = 0;
|
||||
virtual bool IsCancelButtonVisible() const = 0;
|
||||
|
||||
virtual void SetSearchMenu( wxMenu* menu ) = 0;
|
||||
|
||||
virtual void SetDescriptiveText(const wxString& text) = 0;
|
||||
} ;
|
||||
|
||||
//
|
||||
// toplevel window implementation class
|
||||
//
|
||||
|
@ -28,31 +28,17 @@
|
||||
#include "wx/osx/uma.h"
|
||||
#include "wx/osx/carbon/private/mactext.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase)
|
||||
|
||||
// ============================================================================
|
||||
// wxMacSearchFieldControl
|
||||
// ============================================================================
|
||||
|
||||
static const EventTypeSpec eventList[] =
|
||||
{
|
||||
{ kEventClassSearchField, kEventSearchFieldCancelClicked } ,
|
||||
{ kEventClassSearchField, kEventSearchFieldSearchClicked } ,
|
||||
};
|
||||
|
||||
class wxMacSearchFieldControl : public wxMacUnicodeTextControl
|
||||
class wxMacSearchFieldControl : public wxMacUnicodeTextControl, public wxSearchWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxMacSearchFieldControl( wxTextCtrl *wxPeer,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style ) : wxMacUnicodeTextControl( wxPeer )
|
||||
{
|
||||
Create( wxPeer, str, pos, size, style );
|
||||
}
|
||||
const wxSize& size, long style ) ;
|
||||
|
||||
// search field options
|
||||
virtual void ShowSearchButton( bool show );
|
||||
@ -62,35 +48,81 @@ public :
|
||||
virtual bool IsCancelButtonVisible() const;
|
||||
|
||||
virtual void SetSearchMenu( wxMenu* menu );
|
||||
virtual wxMenu* GetSearchMenu() const;
|
||||
|
||||
virtual void SetDescriptiveText(const wxString& text);
|
||||
virtual wxString GetDescriptiveText() const;
|
||||
|
||||
virtual bool SetFocus();
|
||||
|
||||
protected :
|
||||
virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef crf );
|
||||
|
||||
private:
|
||||
wxMenu* m_menu;
|
||||
} ;
|
||||
|
||||
void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer),
|
||||
const Rect* bounds,
|
||||
CFStringRef WXUNUSED(crf))
|
||||
static const EventTypeSpec eventList[] =
|
||||
{
|
||||
{ kEventClassSearchField, kEventSearchFieldCancelClicked } ,
|
||||
{ kEventClassSearchField, kEventSearchFieldSearchClicked } ,
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||
{
|
||||
OSStatus result = eventNotHandledErr ;
|
||||
|
||||
wxMacCarbonEvent cEvent( event ) ;
|
||||
|
||||
ControlRef controlRef ;
|
||||
wxSearchCtrl* thisWindow = (wxSearchCtrl*) data ;
|
||||
cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
|
||||
|
||||
switch( GetEventKind( event ) )
|
||||
{
|
||||
case kEventSearchFieldCancelClicked :
|
||||
thisWindow->HandleSearchFieldCancelHit() ;
|
||||
break ;
|
||||
case kEventSearchFieldSearchClicked :
|
||||
thisWindow->HandleSearchFieldSearchHit() ;
|
||||
break ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacSearchControlEventHandler )
|
||||
|
||||
wxMacSearchFieldControl::wxMacSearchFieldControl( wxTextCtrl *wxPeer,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style ) : wxMacUnicodeTextControl( wxPeer )
|
||||
{
|
||||
m_font = wxPeer->GetFont() ;
|
||||
m_windowStyle = style ;
|
||||
m_selection.selStart = m_selection.selEnd = 0;
|
||||
Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
|
||||
wxString st = str ;
|
||||
wxMacConvertNewlines10To13( &st ) ;
|
||||
wxCFStringRef cf(st , m_font.GetEncoding()) ;
|
||||
|
||||
m_valueTag = kControlEditTextCFStringTag ;
|
||||
|
||||
OptionBits attributes = kHISearchFieldAttributesSearchIcon;
|
||||
|
||||
HIRect hibounds = { { bounds->left, bounds->top }, { bounds->right-bounds->left, bounds->bottom-bounds->top } };
|
||||
HIRect hibounds = { { bounds.left, bounds.top }, { bounds.right-bounds.left, bounds.bottom-bounds.top } };
|
||||
verify_noerr( HISearchFieldCreate(
|
||||
&hibounds,
|
||||
attributes,
|
||||
0, // MenuRef
|
||||
CFSTR("Search"),
|
||||
CFSTR(""),
|
||||
&m_controlRef
|
||||
) );
|
||||
HIViewSetVisible (m_controlRef, true);
|
||||
|
||||
verify_noerr( SetData<CFStringRef>( 0, kControlEditTextCFStringTag , cf ) ) ;
|
||||
|
||||
::InstallControlEventHandler( m_controlRef, GetwxMacSearchControlEventHandlerUPP(),
|
||||
GetEventTypeCount(eventList), eventList, wxPeer, NULL);
|
||||
wxMacUnicodeTextControl::InstallEventHandlers();
|
||||
}
|
||||
|
||||
// search field options
|
||||
@ -140,10 +172,9 @@ bool wxMacSearchFieldControl::IsCancelButtonVisible() const
|
||||
|
||||
void wxMacSearchFieldControl::SetSearchMenu( wxMenu* menu )
|
||||
{
|
||||
m_menu = menu;
|
||||
if ( m_menu )
|
||||
if ( menu )
|
||||
{
|
||||
verify_noerr( HISearchFieldSetSearchMenu( m_controlRef, MAC_WXHMENU(m_menu->GetHMenu()) ) );
|
||||
verify_noerr( HISearchFieldSetSearchMenu( m_controlRef, MAC_WXHMENU(menu->GetHMenu()) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -151,12 +182,6 @@ void wxMacSearchFieldControl::SetSearchMenu( wxMenu* menu )
|
||||
}
|
||||
}
|
||||
|
||||
wxMenu* wxMacSearchFieldControl::GetSearchMenu() const
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
|
||||
void wxMacSearchFieldControl::SetDescriptiveText(const wxString& text)
|
||||
{
|
||||
verify_noerr( HISearchFieldSetDescriptiveText(
|
||||
@ -164,20 +189,6 @@ void wxMacSearchFieldControl::SetDescriptiveText(const wxString& text)
|
||||
wxCFStringRef( text, wxFont::GetDefaultEncoding() )));
|
||||
}
|
||||
|
||||
wxString wxMacSearchFieldControl::GetDescriptiveText() const
|
||||
{
|
||||
CFStringRef cfStr;
|
||||
verify_noerr( HISearchFieldCopyDescriptiveText( m_controlRef, &cfStr ));
|
||||
if ( cfStr )
|
||||
{
|
||||
return wxCFStringRef(cfStr).AsString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxMacSearchFieldControl::SetFocus()
|
||||
{
|
||||
// NB: We have to implement SetFocus a little differently because kControlFocusNextPart
|
||||
@ -192,201 +203,18 @@ bool wxMacSearchFieldControl::SetFocus()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||
wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
long extraStyle)
|
||||
{
|
||||
OSStatus result = eventNotHandledErr ;
|
||||
wxMacControl* peer = new wxMacSearchFieldControl( wxpeer , str , pos , size , style );
|
||||
|
||||
wxMacCarbonEvent cEvent( event ) ;
|
||||
|
||||
ControlRef controlRef ;
|
||||
wxSearchCtrl* thisWindow = (wxSearchCtrl*) data ;
|
||||
cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
|
||||
|
||||
switch( GetEventKind( event ) )
|
||||
{
|
||||
case kEventSearchFieldCancelClicked :
|
||||
thisWindow->MacSearchFieldCancelHit( handler , event ) ;
|
||||
break ;
|
||||
case kEventSearchFieldSearchClicked :
|
||||
thisWindow->MacSearchFieldSearchHit( handler , event ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacSearchControlEventHandler )
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxSearchCtrl creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// creation
|
||||
// --------
|
||||
|
||||
wxSearchCtrl::wxSearchCtrl()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
wxSearchCtrl::wxSearchCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, value, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
void wxSearchCtrl::Init()
|
||||
{
|
||||
m_menu = 0;
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !wxTextCtrl::Create(parent, id, wxEmptyString, pos, size, wxBORDER_NONE | style, validator, name) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EventHandlerRef searchEventHandler;
|
||||
InstallControlEventHandler( m_peer->GetControlRef(), GetwxMacSearchControlEventHandlerUPP(),
|
||||
GetEventTypeCount(eventList), eventList, this,
|
||||
(EventHandlerRef *)&searchEventHandler);
|
||||
|
||||
SetValue(value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxSearchCtrl::~wxSearchCtrl()
|
||||
{
|
||||
delete m_menu;
|
||||
}
|
||||
|
||||
wxSize wxSearchCtrl::DoGetBestSize() const
|
||||
{
|
||||
wxSize size = wxWindow::DoGetBestSize();
|
||||
// it seems to return a default width of about 16, which is way too small here.
|
||||
if (size.GetWidth() < 100)
|
||||
size.SetWidth(100);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
// search control specific interfaces
|
||||
// wxSearchCtrl owns menu after this call
|
||||
void wxSearchCtrl::SetMenu( wxMenu* menu )
|
||||
{
|
||||
if ( menu == m_menu )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_menu )
|
||||
{
|
||||
m_menu->SetInvokingWindow( 0 );
|
||||
}
|
||||
|
||||
delete m_menu;
|
||||
m_menu = menu;
|
||||
|
||||
if ( m_menu )
|
||||
{
|
||||
m_menu->SetInvokingWindow( this );
|
||||
}
|
||||
|
||||
GetPeer()->SetSearchMenu( m_menu );
|
||||
}
|
||||
|
||||
wxMenu* wxSearchCtrl::GetMenu()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
void wxSearchCtrl::ShowSearchButton( bool show )
|
||||
{
|
||||
if ( IsSearchButtonVisible() == show )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
GetPeer()->ShowSearchButton( show );
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::IsSearchButtonVisible() const
|
||||
{
|
||||
return GetPeer()->IsSearchButtonVisible();
|
||||
}
|
||||
|
||||
|
||||
void wxSearchCtrl::ShowCancelButton( bool show )
|
||||
{
|
||||
if ( IsCancelButtonVisible() == show )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
GetPeer()->ShowCancelButton( show );
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::IsCancelButtonVisible() const
|
||||
{
|
||||
return GetPeer()->IsCancelButtonVisible();
|
||||
}
|
||||
|
||||
void wxSearchCtrl::SetDescriptiveText(const wxString& text)
|
||||
{
|
||||
GetPeer()->SetDescriptiveText(text);
|
||||
}
|
||||
|
||||
wxString wxSearchCtrl::GetDescriptiveText() const
|
||||
{
|
||||
return GetPeer()->GetDescriptiveText();
|
||||
}
|
||||
|
||||
wxInt32 wxSearchCtrl::MacSearchFieldSearchHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, m_windowId );
|
||||
event.SetEventObject(this);
|
||||
ProcessCommand(event);
|
||||
return eventNotHandledErr ;
|
||||
}
|
||||
|
||||
wxInt32 wxSearchCtrl::MacSearchFieldCancelHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, m_windowId );
|
||||
event.SetEventObject(this);
|
||||
ProcessCommand(event);
|
||||
return eventNotHandledErr ;
|
||||
}
|
||||
|
||||
|
||||
void wxSearchCtrl::CreatePeer(
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style )
|
||||
{
|
||||
m_peer = new wxMacSearchFieldControl( this , str , pos , size , style );
|
||||
return peer;
|
||||
}
|
||||
|
||||
#endif // wxUSE_NATIVE_SEARCH_CONTROL
|
||||
|
@ -218,11 +218,11 @@ wxMacWindowClipper::~wxMacWindowClipper()
|
||||
|
||||
// common parts for implementations based on MLTE
|
||||
|
||||
class wxMacMLTEControl : public wxMacTextControl
|
||||
class wxMacMLTEControl : public wxMacControl, public wxTextWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxMacMLTEControl( wxTextCtrl *peer ) ;
|
||||
|
||||
~wxMacMLTEControl() {}
|
||||
virtual wxString GetStringValue() const ;
|
||||
virtual void SetStringValue( const wxString &str ) ;
|
||||
|
||||
@ -378,7 +378,7 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
||||
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||
forceMLTE = false;
|
||||
|
||||
wxMacTextControl* peer = NULL;
|
||||
wxMacControl* peer = NULL;
|
||||
|
||||
if ( !forceMLTE )
|
||||
{
|
||||
@ -466,7 +466,7 @@ static pascal OSStatus wxMacUnicodeTextControlEventHandler( EventHandlerCallRef
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler )
|
||||
|
||||
wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) : wxMacTextControl( wxPeer )
|
||||
wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) : wxMacControl( wxPeer )
|
||||
{
|
||||
}
|
||||
|
||||
@ -474,15 +474,7 @@ wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style )
|
||||
: wxMacTextControl( wxPeer )
|
||||
{
|
||||
Create( wxPeer, str, pos, size, style );
|
||||
}
|
||||
|
||||
bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style )
|
||||
: wxMacControl( wxPeer )
|
||||
{
|
||||
m_font = wxPeer->GetFont() ;
|
||||
m_windowStyle = style ;
|
||||
@ -491,19 +483,29 @@ bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer,
|
||||
wxString st = str ;
|
||||
wxMacConvertNewlines10To13( &st ) ;
|
||||
wxCFStringRef cf(st , m_font.GetEncoding()) ;
|
||||
CFStringRef cfr = cf ;
|
||||
|
||||
m_valueTag = kControlEditTextCFStringTag ;
|
||||
CreateControl( wxPeer, &bounds, cfr );
|
||||
Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ;
|
||||
if ( isPassword )
|
||||
{
|
||||
m_valueTag = kControlEditTextPasswordCFStringTag ;
|
||||
}
|
||||
OSStatus err = CreateEditUnicodeTextControl(
|
||||
MAC_WXHWND(wxPeer->MacGetTopLevelWindowRef()), &bounds , cf ,
|
||||
isPassword , NULL , &m_controlRef ) ;
|
||||
verify_noerr( err );
|
||||
|
||||
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||
SetData<Boolean>( kControlEditTextPart , kControlEditTextSingleLineTag , true ) ;
|
||||
|
||||
InstallEventHandlers();
|
||||
}
|
||||
|
||||
void wxMacUnicodeTextControl::InstallEventHandlers()
|
||||
{
|
||||
::InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(),
|
||||
GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this,
|
||||
NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
|
||||
@ -555,19 +557,6 @@ void wxMacUnicodeTextControl::SetStringValue( const wxString &str )
|
||||
verify_noerr( SetData<CFStringRef>( 0, m_valueTag , cf ) ) ;
|
||||
}
|
||||
|
||||
void wxMacUnicodeTextControl::CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef cfr )
|
||||
{
|
||||
Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ;
|
||||
if ( isPassword )
|
||||
{
|
||||
m_valueTag = kControlEditTextPasswordCFStringTag ;
|
||||
}
|
||||
OSStatus err = CreateEditUnicodeTextControl(
|
||||
MAC_WXHWND(peer->MacGetTopLevelWindowRef()), bounds , cfr ,
|
||||
isPassword , NULL , &m_controlRef ) ;
|
||||
verify_noerr( err );
|
||||
}
|
||||
|
||||
void wxMacUnicodeTextControl::Copy()
|
||||
{
|
||||
SendHICommand( kHICommandCopy ) ;
|
||||
@ -713,7 +702,7 @@ protected :
|
||||
} ;
|
||||
|
||||
wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer )
|
||||
: wxMacTextControl( peer )
|
||||
: wxMacControl( peer )
|
||||
{
|
||||
SetNeedsFocusRect( true ) ;
|
||||
}
|
||||
|
@ -259,27 +259,6 @@ void wxMacNativeToPoint( const Point *n , wxPoint* wx )
|
||||
wx->y = n->v;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// wxMac Specific string utility functions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void wxMacStringToPascal( const wxString&from , StringPtr to )
|
||||
{
|
||||
wxCharBuffer buf = from.mb_str( wxConvLocal );
|
||||
int len = strlen(buf);
|
||||
|
||||
if ( len > 255 )
|
||||
len = 255;
|
||||
to[0] = len;
|
||||
memcpy( (char*) &to[1] , buf , len );
|
||||
}
|
||||
|
||||
wxString wxMacMakeStringFromPascal( ConstStringPtr from )
|
||||
{
|
||||
return wxString( (char*) &from[1] , wxConvLocal , from[0] );
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Carbon Event Support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -1184,7 +1184,7 @@ void wxMacControl::SuperChangedPosition()
|
||||
{
|
||||
}
|
||||
|
||||
void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle )
|
||||
void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack )
|
||||
{
|
||||
m_font = font;
|
||||
#if wxOSX_USE_CORE_TEXT
|
||||
@ -1199,7 +1199,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l
|
||||
HIViewSetTextFont( m_controlRef , part , (CTFontRef) font.MacGetCTFont() );
|
||||
HIViewSetTextHorizontalFlush( m_controlRef, part, flush );
|
||||
|
||||
if ( foreground != *wxBLACK )
|
||||
if ( foreground != *wxBLACK || ignoreBlack == false )
|
||||
{
|
||||
ControlFontStyleRec fontStyle;
|
||||
foreground.GetRGBColor( &fontStyle.foreColor );
|
||||
@ -1252,7 +1252,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l
|
||||
// we only should do this in case of a non-standard color, as otherwise 'disabled' controls
|
||||
// won't get grayed out by the system anymore
|
||||
|
||||
if ( foreground != *wxBLACK )
|
||||
if ( foreground != *wxBLACK || ignoreBlack == false )
|
||||
{
|
||||
foreground.GetRGBColor( &fontStyle.foreColor );
|
||||
fontStyle.flags |= kControlUseForeColorMask;
|
||||
|
@ -304,39 +304,6 @@ bool wxGLCanvas::Create(wxWindow *parent,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxGLCanvas::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const int *attribList,
|
||||
const wxPalette& WXUNUSED(palette))
|
||||
{
|
||||
m_needsUpdate = false;
|
||||
m_macCanvasIsShown = false;
|
||||
|
||||
m_glFormat = WXGLChoosePixelFormat(attribList);
|
||||
if ( !m_glFormat )
|
||||
return false;
|
||||
|
||||
if ( !wxWindow::Create(parent, id, pos, size, style, name) )
|
||||
return false;
|
||||
|
||||
m_dummyContext = WXGLCreateContext(m_glFormat, NULL);
|
||||
|
||||
static GLint gCurrentBufferName = 1;
|
||||
m_bufferName = gCurrentBufferName++;
|
||||
aglSetInteger (m_dummyContext, AGL_BUFFER_NAME, &m_bufferName);
|
||||
|
||||
AGLDrawable drawable = (AGLDrawable)GetWindowPort(MAC_WXHWND(MacGetTopLevelWindowRef()));
|
||||
aglSetDrawable(m_dummyContext, drawable);
|
||||
|
||||
m_macCanvasIsShown = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxGLCanvas::~wxGLCanvas()
|
||||
{
|
||||
if ( m_glFormat )
|
||||
|
@ -74,15 +74,15 @@ int wxMessageDialog::ShowModal()
|
||||
|
||||
wxASSERT_MSG( (style & 0x3F) != wxYES, wxT("this style is not supported on Mac") );
|
||||
|
||||
AlertType alertType = kAlertPlainAlert;
|
||||
NSAlertStyle alertType = NSWarningAlertStyle;
|
||||
if (style & wxICON_EXCLAMATION)
|
||||
alertType = kAlertCautionAlert;
|
||||
alertType = NSCriticalAlertStyle;
|
||||
else if (style & wxICON_HAND)
|
||||
alertType = kAlertStopAlert;
|
||||
alertType = NSWarningAlertStyle;
|
||||
else if (style & wxICON_INFORMATION)
|
||||
alertType = kAlertNoteAlert;
|
||||
alertType = NSInformationalAlertStyle;
|
||||
else if (style & wxICON_QUESTION)
|
||||
alertType = kAlertNoteAlert;
|
||||
alertType = NSInformationalAlertStyle;
|
||||
|
||||
|
||||
// work out what to display
|
||||
@ -164,9 +164,8 @@ int wxMessageDialog::ShowModal()
|
||||
}
|
||||
else
|
||||
{
|
||||
short result;
|
||||
NSAlert* alert = [[NSAlert alloc] init];
|
||||
|
||||
AlertStdCFStringAlertParamRec param;
|
||||
wxCFStringRef cfNoString( m_no.c_str(), GetFont().GetEncoding() );
|
||||
wxCFStringRef cfYesString( m_yes.c_str(), GetFont().GetEncoding() );
|
||||
wxCFStringRef cfOKString( m_ok.c_str(), GetFont().GetEncoding() );
|
||||
@ -175,108 +174,59 @@ int wxMessageDialog::ShowModal()
|
||||
wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() );
|
||||
wxCFStringRef cfText( msgtext, GetFont().GetEncoding() );
|
||||
|
||||
param.movable = true;
|
||||
param.flags = 0;
|
||||
param.version = kStdCFStringAlertVersionOne;
|
||||
[alert setMessageText:cfTitle.AsNSString()];
|
||||
[alert setInformativeText:cfText.AsNSString()];
|
||||
|
||||
bool skipDialog = false;
|
||||
int buttonId[3] = { 0, 0, 0 };
|
||||
int buttonCount = 0;
|
||||
|
||||
if (style & wxYES_NO)
|
||||
{
|
||||
if (style & wxCANCEL)
|
||||
if ( style & wxNO_DEFAULT )
|
||||
{
|
||||
param.defaultText = cfYesString;
|
||||
param.cancelText = cfCancelString;
|
||||
param.otherText = cfNoString;
|
||||
param.helpButton = false;
|
||||
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
|
||||
param.cancelButton = kAlertStdAlertCancelButton;
|
||||
[alert addButtonWithTitle:cfNoString.AsNSString()];
|
||||
buttonId[ buttonCount++ ] = wxID_NO;
|
||||
[alert addButtonWithTitle:cfYesString.AsNSString()];
|
||||
buttonId[ buttonCount++ ] = wxID_YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
param.defaultText = cfYesString;
|
||||
param.cancelText = NULL;
|
||||
param.otherText = cfNoString;
|
||||
param.helpButton = false;
|
||||
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
|
||||
param.cancelButton = 0;
|
||||
[alert addButtonWithTitle:cfYesString.AsNSString()];
|
||||
buttonId[ buttonCount++ ] = wxID_YES;
|
||||
[alert addButtonWithTitle:cfNoString.AsNSString()];
|
||||
buttonId[ buttonCount++ ] = wxID_NO;
|
||||
}
|
||||
|
||||
if (style & wxCANCEL)
|
||||
{
|
||||
[alert addButtonWithTitle:cfCancelString.AsNSString()];
|
||||
buttonId[ buttonCount++ ] = wxID_CANCEL;
|
||||
}
|
||||
}
|
||||
// the MSW implementation even shows an OK button if it is not specified, we'll do the same
|
||||
else
|
||||
{
|
||||
[alert addButtonWithTitle:cfOKString.AsNSString()];
|
||||
buttonId[ buttonCount++ ] = wxID_OK;
|
||||
if (style & wxCANCEL)
|
||||
{
|
||||
// that's a cancel missing
|
||||
param.defaultText = cfOKString;
|
||||
param.cancelText = cfCancelString;
|
||||
param.otherText = NULL;
|
||||
param.helpButton = false;
|
||||
param.defaultButton = kAlertStdAlertOKButton;
|
||||
param.cancelButton = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
param.defaultText = cfOKString;
|
||||
param.cancelText = NULL;
|
||||
param.otherText = NULL;
|
||||
param.helpButton = false;
|
||||
param.defaultButton = kAlertStdAlertOKButton;
|
||||
param.cancelButton = 0;
|
||||
[alert addButtonWithTitle:cfCancelString.AsNSString()];
|
||||
buttonId[ buttonCount++ ] = wxID_CANCEL;
|
||||
}
|
||||
}
|
||||
|
||||
param.position = kWindowDefaultPosition;
|
||||
if ( !skipDialog )
|
||||
{
|
||||
DialogRef alertRef;
|
||||
CreateStandardAlert( alertType, cfTitle, cfText, ¶m, &alertRef );
|
||||
RunStandardAlert( alertRef, NULL, &result );
|
||||
}
|
||||
int button = [alert runModal];
|
||||
|
||||
[alert release];
|
||||
|
||||
if ( button < NSAlertFirstButtonReturn )
|
||||
resultbutton = wxID_CANCEL;
|
||||
else
|
||||
{
|
||||
return wxID_CANCEL;
|
||||
}
|
||||
|
||||
if (style & wxOK)
|
||||
{
|
||||
switch ( result )
|
||||
{
|
||||
case 1:
|
||||
resultbutton = wxID_OK;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// TODO: add Cancel button
|
||||
// if (style & wxCANCEL)
|
||||
// resultbutton = wxID_CANCEL;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (style & wxYES_NO)
|
||||
{
|
||||
switch ( result )
|
||||
{
|
||||
case 1:
|
||||
resultbutton = wxID_YES;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (!(style & wxCANCEL))
|
||||
resultbutton = wxID_CANCEL;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
resultbutton = wxID_NO;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( button - NSAlertFirstButtonReturn < buttonCount )
|
||||
resultbutton = buttonId[ button - NSAlertFirstButtonReturn ];
|
||||
else
|
||||
resultbutton = wxID_CANCEL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,368 +25,165 @@
|
||||
|
||||
#if wxUSE_NATIVE_SEARCH_CONTROL
|
||||
|
||||
#include "wx/osx/uma.h"
|
||||
#include "wx/osx/carbon/private/mactext.h"
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/cocoa/private/textimpl.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase)
|
||||
@interface wxNSSearchField : NSSearchField
|
||||
{
|
||||
wxWidgetImpl* impl;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation wxNSSearchField
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
[super initWithFrame:frame];
|
||||
impl = NULL;
|
||||
[self setTarget: self];
|
||||
[self setAction: @selector(searchAction:)];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setImplementation: (wxWidgetImpl *) theImplementation
|
||||
{
|
||||
impl = theImplementation;
|
||||
}
|
||||
|
||||
- (wxWidgetImpl*) implementation
|
||||
{
|
||||
return impl;
|
||||
}
|
||||
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
// use our common calls
|
||||
- (void) setTitle:(NSString *) title
|
||||
{
|
||||
[self setStringValue: title];
|
||||
}
|
||||
|
||||
- (void) searchAction: (id) sender
|
||||
{
|
||||
if ( impl )
|
||||
{
|
||||
wxSearchCtrl* wxpeer = dynamic_cast<wxSearchCtrl*>( impl->GetWXPeer() );
|
||||
if ( wxpeer )
|
||||
{
|
||||
NSString *searchString = [self stringValue];
|
||||
if ( searchString == nil )
|
||||
{
|
||||
wxpeer->HandleSearchFieldCancelHit();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxpeer->HandleSearchFieldSearchHit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// ============================================================================
|
||||
// wxMacSearchFieldControl
|
||||
// ============================================================================
|
||||
|
||||
static const EventTypeSpec eventList[] =
|
||||
{
|
||||
{ kEventClassSearchField, kEventSearchFieldCancelClicked } ,
|
||||
{ kEventClassSearchField, kEventSearchFieldSearchClicked } ,
|
||||
};
|
||||
|
||||
class wxMacSearchFieldControl : public wxMacUnicodeTextControl
|
||||
class wxNSSearchFieldControl : public wxNSTextFieldControl, public wxSearchWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxMacSearchFieldControl( wxTextCtrl *wxPeer,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style ) : wxMacUnicodeTextControl( wxPeer )
|
||||
wxNSSearchFieldControl( wxTextCtrl *wxPeer, wxNSSearchField* w ) : wxNSTextFieldControl(wxPeer, w)
|
||||
{
|
||||
Create( wxPeer, str, pos, size, style );
|
||||
m_searchFieldCell = [w cell];
|
||||
m_searchField = w;
|
||||
}
|
||||
~wxNSSearchFieldControl();
|
||||
|
||||
// search field options
|
||||
virtual void ShowSearchButton( bool show );
|
||||
virtual bool IsSearchButtonVisible() const;
|
||||
virtual void ShowSearchButton( bool show )
|
||||
{
|
||||
if ( show )
|
||||
[m_searchFieldCell resetSearchButtonCell];
|
||||
else
|
||||
[m_searchFieldCell setSearchButtonCell:nil];
|
||||
[m_searchField setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
virtual void ShowCancelButton( bool show );
|
||||
virtual bool IsCancelButtonVisible() const;
|
||||
virtual bool IsSearchButtonVisible() const
|
||||
{
|
||||
return [m_searchFieldCell searchButtonCell] != nil;
|
||||
}
|
||||
|
||||
virtual void SetSearchMenu( wxMenu* menu );
|
||||
virtual wxMenu* GetSearchMenu() const;
|
||||
virtual void ShowCancelButton( bool show )
|
||||
{
|
||||
if ( show )
|
||||
[m_searchFieldCell resetCancelButtonCell];
|
||||
else
|
||||
[m_searchFieldCell setCancelButtonCell:nil];
|
||||
[m_searchField setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
virtual void SetDescriptiveText(const wxString& text);
|
||||
virtual wxString GetDescriptiveText() const;
|
||||
virtual bool IsCancelButtonVisible() const
|
||||
{
|
||||
return [m_searchFieldCell cancelButtonCell] != nil;
|
||||
}
|
||||
|
||||
virtual bool SetFocus();
|
||||
virtual void SetSearchMenu( wxMenu* menu )
|
||||
{
|
||||
if ( menu )
|
||||
[m_searchFieldCell setSearchMenuTemplate:menu->GetHMenu()];
|
||||
else
|
||||
[m_searchFieldCell setSearchMenuTemplate:nil];
|
||||
[m_searchField setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
protected :
|
||||
virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef crf );
|
||||
virtual void SetDescriptiveText(const wxString& text)
|
||||
{
|
||||
[m_searchFieldCell setPlaceholderString:
|
||||
wxCFStringRef( text , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||
}
|
||||
|
||||
virtual bool SetFocus()
|
||||
{
|
||||
return wxNSTextFieldControl::SetFocus();
|
||||
}
|
||||
|
||||
private:
|
||||
wxMenu* m_menu;
|
||||
wxNSSearchField* m_searchField;
|
||||
NSSearchFieldCell* m_searchFieldCell;
|
||||
} ;
|
||||
|
||||
void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer),
|
||||
const Rect* bounds,
|
||||
CFStringRef WXUNUSED(crf))
|
||||
wxNSSearchFieldControl::~wxNSSearchFieldControl()
|
||||
{
|
||||
OptionBits attributes = kHISearchFieldAttributesSearchIcon;
|
||||
|
||||
HIRect hibounds = { { bounds->left, bounds->top }, { bounds->right-bounds->left, bounds->bottom-bounds->top } };
|
||||
verify_noerr( HISearchFieldCreate(
|
||||
&hibounds,
|
||||
attributes,
|
||||
0, // MenuRef
|
||||
CFSTR("Search"),
|
||||
&m_controlRef
|
||||
) );
|
||||
HIViewSetVisible (m_controlRef, true);
|
||||
}
|
||||
|
||||
// search field options
|
||||
void wxMacSearchFieldControl::ShowSearchButton( bool show )
|
||||
wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
long extraStyle)
|
||||
{
|
||||
OptionBits set = 0;
|
||||
OptionBits clear = 0;
|
||||
if ( show )
|
||||
{
|
||||
set |= kHISearchFieldAttributesSearchIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
clear |= kHISearchFieldAttributesSearchIcon;
|
||||
}
|
||||
HISearchFieldChangeAttributes( m_controlRef, set, clear );
|
||||
}
|
||||
NSView* sv = (wxpeer->GetParent()->GetHandle() );
|
||||
|
||||
bool wxMacSearchFieldControl::IsSearchButtonVisible() const
|
||||
{
|
||||
OptionBits attributes = 0;
|
||||
verify_noerr( HISearchFieldGetAttributes( m_controlRef, &attributes ) );
|
||||
return ( attributes & kHISearchFieldAttributesSearchIcon ) != 0;
|
||||
}
|
||||
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
||||
wxNSSearchField* v = [[wxNSSearchField alloc] initWithFrame:r];
|
||||
[sv addSubview:v];
|
||||
[[v cell] setSendsWholeSearchString:YES];
|
||||
// per wx default cancel is not shown
|
||||
[[v cell] setCancelButtonCell:nil];
|
||||
|
||||
void wxMacSearchFieldControl::ShowCancelButton( bool show )
|
||||
{
|
||||
OptionBits set = 0;
|
||||
OptionBits clear = 0;
|
||||
if ( show )
|
||||
{
|
||||
set |= kHISearchFieldAttributesCancel;
|
||||
}
|
||||
else
|
||||
{
|
||||
clear |= kHISearchFieldAttributesCancel;
|
||||
}
|
||||
HISearchFieldChangeAttributes( m_controlRef, set, clear );
|
||||
}
|
||||
|
||||
bool wxMacSearchFieldControl::IsCancelButtonVisible() const
|
||||
{
|
||||
OptionBits attributes = 0;
|
||||
verify_noerr( HISearchFieldGetAttributes( m_controlRef, &attributes ) );
|
||||
return ( attributes & kHISearchFieldAttributesCancel ) != 0;
|
||||
}
|
||||
|
||||
void wxMacSearchFieldControl::SetSearchMenu( wxMenu* menu )
|
||||
{
|
||||
m_menu = menu;
|
||||
if ( m_menu )
|
||||
{
|
||||
verify_noerr( HISearchFieldSetSearchMenu( m_controlRef, MAC_WXHMENU(m_menu->GetHMenu()) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
verify_noerr( HISearchFieldSetSearchMenu( m_controlRef, 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
wxMenu* wxMacSearchFieldControl::GetSearchMenu() const
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
|
||||
void wxMacSearchFieldControl::SetDescriptiveText(const wxString& text)
|
||||
{
|
||||
verify_noerr( HISearchFieldSetDescriptiveText(
|
||||
m_controlRef,
|
||||
wxCFStringRef( text, wxFont::GetDefaultEncoding() )));
|
||||
}
|
||||
|
||||
wxString wxMacSearchFieldControl::GetDescriptiveText() const
|
||||
{
|
||||
CFStringRef cfStr;
|
||||
verify_noerr( HISearchFieldCopyDescriptiveText( m_controlRef, &cfStr ));
|
||||
if ( cfStr )
|
||||
{
|
||||
return wxCFStringRef(cfStr).AsString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxMacSearchFieldControl::SetFocus()
|
||||
{
|
||||
// NB: We have to implement SetFocus a little differently because kControlFocusNextPart
|
||||
// leads to setting the focus on the search icon rather than the text area.
|
||||
// We get around this by explicitly telling the control to set focus to the
|
||||
// text area.
|
||||
|
||||
OSStatus err = SetKeyboardFocus( GetControlOwner( m_controlRef ), m_controlRef, kControlEditTextPart );
|
||||
if ( err == errCouldntSetFocus )
|
||||
return false ;
|
||||
SetUserFocusWindow(GetControlOwner( m_controlRef ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||
{
|
||||
OSStatus result = eventNotHandledErr ;
|
||||
|
||||
wxMacCarbonEvent cEvent( event ) ;
|
||||
|
||||
ControlRef controlRef ;
|
||||
wxSearchCtrl* thisWindow = (wxSearchCtrl*) data ;
|
||||
cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
|
||||
|
||||
switch( GetEventKind( event ) )
|
||||
{
|
||||
case kEventSearchFieldCancelClicked :
|
||||
thisWindow->MacSearchFieldCancelHit( handler , event ) ;
|
||||
break ;
|
||||
case kEventSearchFieldSearchClicked :
|
||||
thisWindow->MacSearchFieldSearchHit( handler , event ) ;
|
||||
break ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacSearchControlEventHandler )
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxSearchCtrl creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// creation
|
||||
// --------
|
||||
|
||||
wxSearchCtrl::wxSearchCtrl()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
wxSearchCtrl::wxSearchCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, value, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
void wxSearchCtrl::Init()
|
||||
{
|
||||
m_menu = 0;
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
if ( !wxTextCtrl::Create(parent, id, wxEmptyString, pos, size, wxBORDER_NONE | style, validator, name) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EventHandlerRef searchEventHandler;
|
||||
InstallControlEventHandler( m_peer->GetControlRef(), GetwxMacSearchControlEventHandlerUPP(),
|
||||
GetEventTypeCount(eventList), eventList, this,
|
||||
(EventHandlerRef *)&searchEventHandler);
|
||||
|
||||
SetValue(value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxSearchCtrl::~wxSearchCtrl()
|
||||
{
|
||||
delete m_menu;
|
||||
}
|
||||
|
||||
wxSize wxSearchCtrl::DoGetBestSize() const
|
||||
{
|
||||
wxSize size = wxWindow::DoGetBestSize();
|
||||
// it seems to return a default width of about 16, which is way too small here.
|
||||
if (size.GetWidth() < 100)
|
||||
size.SetWidth(100);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
// search control specific interfaces
|
||||
// wxSearchCtrl owns menu after this call
|
||||
void wxSearchCtrl::SetMenu( wxMenu* menu )
|
||||
{
|
||||
if ( menu == m_menu )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_menu )
|
||||
{
|
||||
m_menu->SetInvokingWindow( 0 );
|
||||
}
|
||||
|
||||
delete m_menu;
|
||||
m_menu = menu;
|
||||
|
||||
if ( m_menu )
|
||||
{
|
||||
m_menu->SetInvokingWindow( this );
|
||||
}
|
||||
|
||||
GetPeer()->SetSearchMenu( m_menu );
|
||||
}
|
||||
|
||||
wxMenu* wxSearchCtrl::GetMenu()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
void wxSearchCtrl::ShowSearchButton( bool show )
|
||||
{
|
||||
if ( IsSearchButtonVisible() == show )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
GetPeer()->ShowSearchButton( show );
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::IsSearchButtonVisible() const
|
||||
{
|
||||
return GetPeer()->IsSearchButtonVisible();
|
||||
}
|
||||
|
||||
|
||||
void wxSearchCtrl::ShowCancelButton( bool show )
|
||||
{
|
||||
if ( IsCancelButtonVisible() == show )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
GetPeer()->ShowCancelButton( show );
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::IsCancelButtonVisible() const
|
||||
{
|
||||
return GetPeer()->IsCancelButtonVisible();
|
||||
}
|
||||
|
||||
void wxSearchCtrl::SetDescriptiveText(const wxString& text)
|
||||
{
|
||||
GetPeer()->SetDescriptiveText(text);
|
||||
}
|
||||
|
||||
wxString wxSearchCtrl::GetDescriptiveText() const
|
||||
{
|
||||
return GetPeer()->GetDescriptiveText();
|
||||
}
|
||||
|
||||
wxInt32 wxSearchCtrl::MacSearchFieldSearchHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, m_windowId );
|
||||
event.SetEventObject(this);
|
||||
ProcessCommand(event);
|
||||
return eventNotHandledErr ;
|
||||
}
|
||||
|
||||
wxInt32 wxSearchCtrl::MacSearchFieldCancelHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, m_windowId );
|
||||
event.SetEventObject(this);
|
||||
ProcessCommand(event);
|
||||
return eventNotHandledErr ;
|
||||
}
|
||||
|
||||
|
||||
void wxSearchCtrl::CreatePeer(
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style )
|
||||
{
|
||||
m_peer = new wxMacSearchFieldControl( this , str , pos , size , style );
|
||||
wxNSSearchFieldControl* c = new wxNSSearchFieldControl( wxpeer, v );
|
||||
c->SetStringValue( str );
|
||||
[v setImplementation:c];
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif // wxUSE_NATIVE_SEARCH_CONTROL
|
||||
|
@ -47,8 +47,7 @@
|
||||
#include "wx/thread.h"
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/carbon/private/mactext.h"
|
||||
|
||||
#include "wx/osx/cocoa/private/textimpl.h"
|
||||
|
||||
@implementation wxNSTextField
|
||||
|
||||
@ -75,40 +74,58 @@
|
||||
|
||||
@end
|
||||
|
||||
class wxNSTextFieldControl : public wxMacTextControl
|
||||
wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w)
|
||||
{
|
||||
public :
|
||||
wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxMacTextControl(wxPeer, w)
|
||||
{
|
||||
}
|
||||
virtual ~wxNSTextFieldControl()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
virtual void VisibilityChanged(bool shown){}
|
||||
virtual wxString GetStringValue() const
|
||||
{
|
||||
wxCFStringRef cf( (CFStringRef) [[(wxNSTextField*) m_osxView stringValue] retain] );
|
||||
return cf.AsString(m_wxPeer->GetFont().GetEncoding());
|
||||
}
|
||||
virtual void SetStringValue( const wxString &str)
|
||||
{
|
||||
[(wxNSTextField*) m_osxView setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||
}
|
||||
virtual void Copy() {}
|
||||
virtual void Cut() {}
|
||||
virtual void Paste() {}
|
||||
virtual bool CanPaste() const { return false;}
|
||||
virtual void SetEditable(bool editable) {}
|
||||
virtual void GetSelection( long* from, long* to) const {}
|
||||
virtual void SetSelection( long from , long to ){}
|
||||
virtual void WriteText(const wxString& str)
|
||||
{
|
||||
// temp hack to get logging working early
|
||||
wxString former = GetStringValue();
|
||||
SetStringValue( former + str );
|
||||
}
|
||||
};
|
||||
wxNSTextFieldControl::~wxNSTextFieldControl()
|
||||
{
|
||||
}
|
||||
|
||||
wxString wxNSTextFieldControl::GetStringValue() const
|
||||
{
|
||||
wxCFStringRef cf( (CFStringRef) [[(wxNSTextField*) m_osxView stringValue] retain] );
|
||||
return cf.AsString(m_wxPeer->GetFont().GetEncoding());
|
||||
}
|
||||
void wxNSTextFieldControl::SetStringValue( const wxString &str)
|
||||
{
|
||||
[(wxNSTextField*) m_osxView setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||
}
|
||||
void wxNSTextFieldControl::Copy()
|
||||
{
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::Cut()
|
||||
{
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::Paste()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxNSTextFieldControl::CanPaste() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::SetEditable(bool editable)
|
||||
{
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::GetSelection( long* from, long* to) const
|
||||
{
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::SetSelection( long from , long to )
|
||||
{
|
||||
}
|
||||
|
||||
void wxNSTextFieldControl::WriteText(const wxString& str)
|
||||
{
|
||||
// temp hack to get logging working early
|
||||
wxString former = GetStringValue();
|
||||
SetStringValue( former + str );
|
||||
}
|
||||
|
||||
wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
|
@ -708,6 +708,11 @@ void wxWidgetCocoaImpl::SetControlSize( wxWindowVariant variant )
|
||||
[m_osxView setControlSize:size];
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::SetFont(wxFont const&, wxColour const&, long, bool)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
//
|
||||
// Factory methods
|
||||
//
|
||||
|
@ -25,8 +25,195 @@
|
||||
|
||||
#if wxUSE_NATIVE_SEARCH_CONTROL
|
||||
|
||||
// no common code yet, only here as placeholder
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase)
|
||||
|
||||
|
||||
#endif // wxUSE_NATIVE_SEARCH_CONTROL
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxSearchCtrl creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// creation
|
||||
// --------
|
||||
|
||||
wxSearchCtrl::wxSearchCtrl()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
wxSearchCtrl::wxSearchCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, value, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
void wxSearchCtrl::Init()
|
||||
{
|
||||
m_menu = 0;
|
||||
}
|
||||
|
||||
wxSearchWidgetImpl* wxSearchCtrl::GetSearchPeer() const
|
||||
{
|
||||
return dynamic_cast<wxSearchWidgetImpl*> (m_peer);
|
||||
}
|
||||
|
||||
wxSearchCtrl::~wxSearchCtrl()
|
||||
{
|
||||
delete m_menu;
|
||||
}
|
||||
|
||||
wxSize wxSearchCtrl::DoGetBestSize() const
|
||||
{
|
||||
wxSize size = wxWindow::DoGetBestSize();
|
||||
// it seems to return a default width of about 16, which is way too small here.
|
||||
if (size.GetWidth() < 100)
|
||||
size.SetWidth(100);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
// search control specific interfaces
|
||||
// wxSearchCtrl owns menu after this call
|
||||
void wxSearchCtrl::SetMenu( wxMenu* menu )
|
||||
{
|
||||
if ( menu == m_menu )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_menu )
|
||||
{
|
||||
m_menu->SetInvokingWindow( 0 );
|
||||
}
|
||||
|
||||
delete m_menu;
|
||||
m_menu = menu;
|
||||
|
||||
if ( m_menu )
|
||||
{
|
||||
m_menu->SetInvokingWindow( this );
|
||||
}
|
||||
|
||||
GetSearchPeer()->SetSearchMenu( m_menu );
|
||||
}
|
||||
|
||||
wxMenu* wxSearchCtrl::GetMenu()
|
||||
{
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
void wxSearchCtrl::ShowSearchButton( bool show )
|
||||
{
|
||||
if ( IsSearchButtonVisible() == show )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
GetSearchPeer()->ShowSearchButton( show );
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::IsSearchButtonVisible() const
|
||||
{
|
||||
return GetSearchPeer()->IsSearchButtonVisible();
|
||||
}
|
||||
|
||||
|
||||
void wxSearchCtrl::ShowCancelButton( bool show )
|
||||
{
|
||||
if ( IsCancelButtonVisible() == show )
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
GetSearchPeer()->ShowCancelButton( show );
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::IsCancelButtonVisible() const
|
||||
{
|
||||
return GetSearchPeer()->IsCancelButtonVisible();
|
||||
}
|
||||
|
||||
void wxSearchCtrl::SetDescriptiveText(const wxString& text)
|
||||
{
|
||||
m_descriptiveText = text;
|
||||
GetSearchPeer()->SetDescriptiveText(text);
|
||||
}
|
||||
|
||||
wxString wxSearchCtrl::GetDescriptiveText() const
|
||||
{
|
||||
return m_descriptiveText;
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_macIsUserPane = false ;
|
||||
m_editable = true ;
|
||||
|
||||
if ( ! (style & wxNO_BORDER) )
|
||||
style = (style & ~wxBORDER_MASK) | wxSUNKEN_BORDER ;
|
||||
|
||||
if ( !wxTextCtrlBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
|
||||
return false;
|
||||
|
||||
if ( m_windowStyle & wxTE_MULTILINE )
|
||||
{
|
||||
// always turn on this style for multi-line controls
|
||||
m_windowStyle |= wxTE_PROCESS_ENTER;
|
||||
style |= wxTE_PROCESS_ENTER ;
|
||||
}
|
||||
|
||||
|
||||
m_peer = wxWidgetImpl::CreateSearchControl( this, GetParent(), GetId(), value, pos, size, style, GetExtraStyle() );
|
||||
|
||||
MacPostControlCreate(pos, size) ;
|
||||
|
||||
// only now the embedding is correct and we can do a positioning update
|
||||
|
||||
MacSuperChangedPosition() ;
|
||||
|
||||
if ( m_windowStyle & wxTE_READONLY)
|
||||
SetEditable( false ) ;
|
||||
|
||||
SetCursor( wxCursor( wxCURSOR_IBEAM ) ) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::HandleSearchFieldSearchHit()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, m_windowId );
|
||||
event.SetEventObject(this);
|
||||
return ProcessCommand(event);
|
||||
}
|
||||
|
||||
bool wxSearchCtrl::HandleSearchFieldCancelHit()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, m_windowId );
|
||||
event.SetEventObject(this);
|
||||
return ProcessCommand(event);
|
||||
}
|
||||
|
||||
|
||||
#endif // wxUSE_SEARCHCTRL
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "wx/thread.h"
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/carbon/private/mactext.h"
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
|
||||
|
||||
@ -116,9 +115,8 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
||||
style |= wxTE_PROCESS_ENTER ;
|
||||
}
|
||||
|
||||
m_peer = wxWidgetImpl::CreateTextControl( this, parent, id, str, pos, size, style, GetExtraStyle() );
|
||||
|
||||
// CreatePeer( str, pos, size, style );
|
||||
m_peer = wxWidgetImpl::CreateTextControl( this, GetParent(), GetId(), str, pos, size, style, GetExtraStyle() );
|
||||
|
||||
MacPostControlCreate(pos, size) ;
|
||||
|
||||
@ -134,11 +132,9 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxTextCtrl::CreatePeer(
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style )
|
||||
wxTextWidgetImpl* wxTextCtrl::GetTextPeer() const
|
||||
{
|
||||
return dynamic_cast<wxTextWidgetImpl*> (m_peer);
|
||||
}
|
||||
|
||||
void wxTextCtrl::MacSuperChangedPosition()
|
||||
@ -158,17 +154,17 @@ void wxTextCtrl::MacVisibilityChanged()
|
||||
|
||||
void wxTextCtrl::MacCheckSpelling(bool check)
|
||||
{
|
||||
GetPeer()->CheckSpelling(check);
|
||||
GetTextPeer()->CheckSpelling(check);
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetValue() const
|
||||
{
|
||||
return GetPeer()->GetStringValue() ;
|
||||
return GetTextPeer()->GetStringValue() ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::GetSelection(long* from, long* to) const
|
||||
{
|
||||
GetPeer()->GetSelection( from , to ) ;
|
||||
GetTextPeer()->GetSelection( from , to ) ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::DoSetValue(const wxString& str, int flags)
|
||||
@ -177,7 +173,7 @@ void wxTextCtrl::DoSetValue(const wxString& str, int flags)
|
||||
if ( GetValue() == str )
|
||||
return;
|
||||
|
||||
GetPeer()->SetStringValue( str ) ;
|
||||
GetTextPeer()->SetStringValue( str ) ;
|
||||
|
||||
if ( (flags & SetValue_SendEvent) && m_triggerOnSetValue )
|
||||
{
|
||||
@ -195,14 +191,14 @@ bool wxTextCtrl::SetFont( const wxFont& font )
|
||||
if ( !wxTextCtrlBase::SetFont( font ) )
|
||||
return false ;
|
||||
|
||||
GetPeer()->SetFont( font , GetForegroundColour() , GetWindowStyle() ) ;
|
||||
GetPeer()->SetFont( font , GetForegroundColour() , GetWindowStyle(), false /* dont ignore black */ ) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
|
||||
{
|
||||
GetPeer()->SetStyle( start , end , style ) ;
|
||||
GetTextPeer()->SetStyle( start , end , style ) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@ -220,14 +216,14 @@ bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style)
|
||||
void wxTextCtrl::Copy()
|
||||
{
|
||||
if (CanCopy())
|
||||
GetPeer()->Copy() ;
|
||||
GetTextPeer()->Copy() ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::Cut()
|
||||
{
|
||||
if (CanCut())
|
||||
{
|
||||
GetPeer()->Cut() ;
|
||||
GetTextPeer()->Cut() ;
|
||||
|
||||
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
|
||||
event.SetEventObject( this );
|
||||
@ -239,7 +235,7 @@ void wxTextCtrl::Paste()
|
||||
{
|
||||
if (CanPaste())
|
||||
{
|
||||
GetPeer()->Paste() ;
|
||||
GetTextPeer()->Paste() ;
|
||||
|
||||
// TODO: eventually we should add setting the default style again
|
||||
|
||||
@ -275,7 +271,7 @@ bool wxTextCtrl::CanPaste() const
|
||||
if (!IsEditable())
|
||||
return false;
|
||||
|
||||
return GetPeer()->CanPaste() ;
|
||||
return GetTextPeer()->CanPaste() ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetEditable(bool editable)
|
||||
@ -283,7 +279,7 @@ void wxTextCtrl::SetEditable(bool editable)
|
||||
if ( editable != m_editable )
|
||||
{
|
||||
m_editable = editable ;
|
||||
GetPeer()->SetEditable( editable ) ;
|
||||
GetTextPeer()->SetEditable( editable ) ;
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,27 +304,27 @@ long wxTextCtrl::GetInsertionPoint() const
|
||||
|
||||
wxTextPos wxTextCtrl::GetLastPosition() const
|
||||
{
|
||||
return GetPeer()->GetLastPosition() ;
|
||||
return GetTextPeer()->GetLastPosition() ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::Replace(long from, long to, const wxString& str)
|
||||
{
|
||||
GetPeer()->Replace( from , to , str ) ;
|
||||
GetTextPeer()->Replace( from , to , str ) ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::Remove(long from, long to)
|
||||
{
|
||||
GetPeer()->Remove( from , to ) ;
|
||||
GetTextPeer()->Remove( from , to ) ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetSelection(long from, long to)
|
||||
{
|
||||
GetPeer()->SetSelection( from , to ) ;
|
||||
GetTextPeer()->SetSelection( from , to ) ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::WriteText(const wxString& str)
|
||||
{
|
||||
GetPeer()->WriteText( str ) ;
|
||||
GetTextPeer()->WriteText( str ) ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::AppendText(const wxString& text)
|
||||
@ -339,7 +335,7 @@ void wxTextCtrl::AppendText(const wxString& text)
|
||||
|
||||
void wxTextCtrl::Clear()
|
||||
{
|
||||
GetPeer()->Clear() ;
|
||||
GetTextPeer()->Clear() ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::IsModified() const
|
||||
@ -403,13 +399,13 @@ wxSize wxTextCtrl::DoGetBestSize() const
|
||||
void wxTextCtrl::Undo()
|
||||
{
|
||||
if (CanUndo())
|
||||
GetPeer()->Undo() ;
|
||||
GetTextPeer()->Undo() ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::Redo()
|
||||
{
|
||||
if (CanRedo())
|
||||
GetPeer()->Redo() ;
|
||||
GetTextPeer()->Redo() ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanUndo() const
|
||||
@ -417,7 +413,7 @@ bool wxTextCtrl::CanUndo() const
|
||||
if ( !IsEditable() )
|
||||
return false ;
|
||||
|
||||
return GetPeer()->CanUndo() ;
|
||||
return GetTextPeer()->CanUndo() ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanRedo() const
|
||||
@ -425,7 +421,7 @@ bool wxTextCtrl::CanRedo() const
|
||||
if ( !IsEditable() )
|
||||
return false ;
|
||||
|
||||
return GetPeer()->CanRedo() ;
|
||||
return GetTextPeer()->CanRedo() ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::MarkDirty()
|
||||
@ -440,32 +436,32 @@ void wxTextCtrl::DiscardEdits()
|
||||
|
||||
int wxTextCtrl::GetNumberOfLines() const
|
||||
{
|
||||
return GetPeer()->GetNumberOfLines() ;
|
||||
return GetTextPeer()->GetNumberOfLines() ;
|
||||
}
|
||||
|
||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||
{
|
||||
return GetPeer()->XYToPosition( x , y ) ;
|
||||
return GetTextPeer()->XYToPosition( x , y ) ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
|
||||
{
|
||||
return GetPeer()->PositionToXY( pos , x , y ) ;
|
||||
return GetTextPeer()->PositionToXY( pos , x , y ) ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::ShowPosition(long pos)
|
||||
{
|
||||
return GetPeer()->ShowPosition(pos) ;
|
||||
return GetTextPeer()->ShowPosition(pos) ;
|
||||
}
|
||||
|
||||
int wxTextCtrl::GetLineLength(long lineNo) const
|
||||
{
|
||||
return GetPeer()->GetLineLength(lineNo) ;
|
||||
return GetTextPeer()->GetLineLength(lineNo) ;
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetLineText(long lineNo) const
|
||||
{
|
||||
return GetPeer()->GetLineText(lineNo) ;
|
||||
return GetTextPeer()->GetLineText(lineNo) ;
|
||||
}
|
||||
|
||||
void wxTextCtrl::Command(wxCommandEvent & event)
|
||||
@ -706,7 +702,7 @@ void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
|
||||
|
||||
void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event)
|
||||
{
|
||||
if ( GetPeer()->HasOwnContextMenu() )
|
||||
if ( GetTextPeer()->HasOwnContextMenu() )
|
||||
{
|
||||
event.Skip() ;
|
||||
return ;
|
||||
@ -734,7 +730,7 @@ void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event)
|
||||
|
||||
bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
||||
{
|
||||
if ( !GetPeer()->SetupCursor( pt ) )
|
||||
if ( !GetTextPeer()->SetupCursor( pt ) )
|
||||
return wxWindow::MacSetupCursor( pt ) ;
|
||||
else
|
||||
return true ;
|
||||
@ -744,104 +740,90 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
||||
// implementation base class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
wxMacTextControl::wxMacTextControl(wxTextCtrl* peer) :
|
||||
wxMacControl( peer )
|
||||
#else
|
||||
wxMacTextControl::wxMacTextControl(wxTextCtrl* peer, WXWidget w) :
|
||||
wxWidgetCocoaImpl( peer, w )
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
wxMacTextControl::~wxMacTextControl()
|
||||
{
|
||||
}
|
||||
|
||||
void wxMacTextControl::SetStyle(long WXUNUSED(start),
|
||||
void wxTextWidgetImpl::SetStyle(long WXUNUSED(start),
|
||||
long WXUNUSED(end),
|
||||
const wxTextAttr& WXUNUSED(style))
|
||||
{
|
||||
}
|
||||
|
||||
void wxMacTextControl::Copy()
|
||||
void wxTextWidgetImpl::Copy()
|
||||
{
|
||||
}
|
||||
|
||||
void wxMacTextControl::Cut()
|
||||
void wxTextWidgetImpl::Cut()
|
||||
{
|
||||
}
|
||||
|
||||
void wxMacTextControl::Paste()
|
||||
void wxTextWidgetImpl::Paste()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxMacTextControl::CanPaste() const
|
||||
bool wxTextWidgetImpl::CanPaste() const
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
void wxMacTextControl::SetEditable(bool WXUNUSED(editable))
|
||||
void wxTextWidgetImpl::SetEditable(bool WXUNUSED(editable))
|
||||
{
|
||||
}
|
||||
|
||||
wxTextPos wxMacTextControl::GetLastPosition() const
|
||||
wxTextPos wxTextWidgetImpl::GetLastPosition() const
|
||||
{
|
||||
return GetStringValue().length() ;
|
||||
}
|
||||
|
||||
void wxMacTextControl::Replace( long from , long to , const wxString &val )
|
||||
void wxTextWidgetImpl::Replace( long from , long to , const wxString &val )
|
||||
{
|
||||
SetSelection( from , to ) ;
|
||||
WriteText( val ) ;
|
||||
}
|
||||
|
||||
void wxMacTextControl::Remove( long from , long to )
|
||||
void wxTextWidgetImpl::Remove( long from , long to )
|
||||
{
|
||||
SetSelection( from , to ) ;
|
||||
WriteText( wxEmptyString) ;
|
||||
}
|
||||
|
||||
void wxMacTextControl::Clear()
|
||||
void wxTextWidgetImpl::Clear()
|
||||
{
|
||||
SetStringValue( wxEmptyString ) ;
|
||||
}
|
||||
|
||||
bool wxMacTextControl::CanUndo() const
|
||||
bool wxTextWidgetImpl::CanUndo() const
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
void wxMacTextControl::Undo()
|
||||
void wxTextWidgetImpl::Undo()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxMacTextControl::CanRedo() const
|
||||
bool wxTextWidgetImpl::CanRedo() const
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
void wxMacTextControl::Redo()
|
||||
void wxTextWidgetImpl::Redo()
|
||||
{
|
||||
}
|
||||
|
||||
long wxMacTextControl::XYToPosition(long WXUNUSED(x), long WXUNUSED(y)) const
|
||||
long wxTextWidgetImpl::XYToPosition(long WXUNUSED(x), long WXUNUSED(y)) const
|
||||
{
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
bool wxMacTextControl::PositionToXY(long WXUNUSED(pos),
|
||||
bool wxTextWidgetImpl::PositionToXY(long WXUNUSED(pos),
|
||||
long *WXUNUSED(x),
|
||||
long *WXUNUSED(y)) const
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
|
||||
void wxMacTextControl::ShowPosition( long WXUNUSED(pos) )
|
||||
void wxTextWidgetImpl::ShowPosition( long WXUNUSED(pos) )
|
||||
{
|
||||
}
|
||||
|
||||
int wxMacTextControl::GetNumberOfLines() const
|
||||
int wxTextWidgetImpl::GetNumberOfLines() const
|
||||
{
|
||||
ItemCount lines = 0 ;
|
||||
wxString content = GetStringValue() ;
|
||||
@ -856,7 +838,7 @@ int wxMacTextControl::GetNumberOfLines() const
|
||||
return lines ;
|
||||
}
|
||||
|
||||
wxString wxMacTextControl::GetLineText(long lineNo) const
|
||||
wxString wxTextWidgetImpl::GetLineText(long lineNo) const
|
||||
{
|
||||
// TODO: change this if possible to reflect real lines
|
||||
wxString content = GetStringValue() ;
|
||||
@ -888,7 +870,7 @@ wxString wxMacTextControl::GetLineText(long lineNo) const
|
||||
return wxEmptyString ;
|
||||
}
|
||||
|
||||
int wxMacTextControl::GetLineLength(long lineNo) const
|
||||
int wxTextWidgetImpl::GetLineLength(long lineNo) const
|
||||
{
|
||||
// TODO: change this if possible to reflect real lines
|
||||
wxString content = GetStringValue() ;
|
||||
@ -918,22 +900,4 @@ int wxMacTextControl::GetLineLength(long lineNo) const
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
void wxMacTextControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle )
|
||||
{
|
||||
#if wxOSX_USE_CARBON
|
||||
wxMacControl::SetFont(font, foreground, windowStyle );
|
||||
|
||||
// overrule the barrier in wxMacControl for supporting disabled controls, in order to support
|
||||
// setting the color to eg red and back to black by controllers
|
||||
|
||||
if ( foreground == *wxBLACK )
|
||||
{
|
||||
ControlFontStyleRec fontStyle;
|
||||
fontStyle.foreColor.red = fontStyle.foreColor.green = fontStyle.foreColor.blue = 0;
|
||||
fontStyle.flags = kControlUseForeColorMask;
|
||||
::SetControlFontStyle( m_controlRef , &fontStyle );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
@ -156,4 +156,24 @@ CGColorRef wxMacCreateCGColorFromHITheme( ThemeBrush brush )
|
||||
return color;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Mac Specific string utility functions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void wxMacStringToPascal( const wxString&from , unsigned char * to )
|
||||
{
|
||||
wxCharBuffer buf = from.mb_str( wxConvLocal );
|
||||
int len = strlen(buf);
|
||||
|
||||
if ( len > 255 )
|
||||
len = 255;
|
||||
to[0] = len;
|
||||
memcpy( (char*) &to[1] , buf , len );
|
||||
}
|
||||
|
||||
wxString wxMacMakeStringFromPascal( const unsigned char * from )
|
||||
{
|
||||
return wxString( (char*) &from[1] , wxConvLocal , from[0] );
|
||||
}
|
||||
|
||||
#endif // wxOSX_USE_COCOA_OR_CARBON
|
||||
|
@ -384,9 +384,9 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
|
||||
|
||||
void wxWindowMac::MacUpdateControlFont()
|
||||
{
|
||||
#if wxOSX_USE_CARBON
|
||||
|
||||
m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
|
||||
#endif
|
||||
|
||||
// do not trigger refreshes upon invisible and possible partly created objects
|
||||
if ( IsShownOnScreen() )
|
||||
Refresh() ;
|
||||
|
Loading…
Reference in New Issue
Block a user