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()
|
// forward decl for GetSelections()
|
||||||
class wxArrayInt;
|
class wxArrayInt;
|
||||||
|
|
||||||
// forward decl for wxListWidgetImpl data type.
|
// forward decl for wxListWidgetImpl implementation type.
|
||||||
class wxListWidgetImpl;
|
class wxListWidgetImpl;
|
||||||
|
|
||||||
// List box item
|
// List box item
|
||||||
|
@ -426,7 +426,7 @@ public :
|
|||||||
virtual void SuperChangedPosition();
|
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 void SetBackgroundColour( const wxColour& col );
|
||||||
virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
|
virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
|
||||||
void SetActionProc( ControlActionUPP actionProc );
|
void SetActionProc( ControlActionUPP actionProc );
|
||||||
@ -962,8 +962,6 @@ void wxMacSetupConverters();
|
|||||||
void wxMacCleanupConverters();
|
void wxMacCleanupConverters();
|
||||||
|
|
||||||
// utils.cpp
|
// utils.cpp
|
||||||
void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , StringPtr to );
|
|
||||||
wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( ConstStringPtr from );
|
|
||||||
|
|
||||||
// filefn.cpp
|
// filefn.cpp
|
||||||
|
|
||||||
|
@ -14,64 +14,9 @@
|
|||||||
|
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
// common interface for all implementations
|
// implementation exposed, so that search control can pull it
|
||||||
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() ;
|
|
||||||
|
|
||||||
virtual bool CanFocus() const { return true; }
|
class wxMacUnicodeTextControl : public wxMacControl, public wxTextWidgetImpl
|
||||||
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) ;
|
wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) ;
|
||||||
@ -81,10 +26,6 @@ public :
|
|||||||
const wxSize& size, long style ) ;
|
const wxSize& size, long style ) ;
|
||||||
virtual ~wxMacUnicodeTextControl();
|
virtual ~wxMacUnicodeTextControl();
|
||||||
|
|
||||||
virtual bool Create( wxTextCtrl *wxPeer,
|
|
||||||
const wxString& str,
|
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size, long style ) ;
|
|
||||||
virtual void VisibilityChanged(bool shown);
|
virtual void VisibilityChanged(bool shown);
|
||||||
virtual wxString GetStringValue() const ;
|
virtual wxString GetStringValue() const ;
|
||||||
virtual void SetStringValue( const wxString &str) ;
|
virtual void SetStringValue( const wxString &str) ;
|
||||||
@ -98,13 +39,12 @@ public :
|
|||||||
virtual void WriteText(const wxString& str) ;
|
virtual void WriteText(const wxString& str) ;
|
||||||
|
|
||||||
protected :
|
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)
|
// contains the tag for the content (is different for password and non-password controls)
|
||||||
OSType m_valueTag ;
|
OSType m_valueTag ;
|
||||||
public :
|
public :
|
||||||
ControlEditTextSelectionRec m_selection ;
|
ControlEditTextSelectionRec m_selection ;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _WX_MAC_PRIVATE_MACTEXT_H_
|
#endif // _WX_MAC_PRIVATE_MACTEXT_H_
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#if wxUSE_SEARCHCTRL
|
#if wxUSE_SEARCHCTRL
|
||||||
|
|
||||||
class wxMacSearchFieldControl;
|
class wxSearchWidgetImpl;
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxSearchCtrl : public wxSearchCtrlBase
|
class WXDLLIMPEXP_CORE wxSearchCtrl : public wxSearchCtrlBase
|
||||||
{
|
{
|
||||||
@ -54,14 +54,13 @@ public:
|
|||||||
virtual bool IsCancelButtonVisible() const;
|
virtual bool IsCancelButtonVisible() const;
|
||||||
|
|
||||||
// TODO: In 2.9 these should probably be virtual, and declared in the base class...
|
// TODO: In 2.9 these should probably be virtual, and declared in the base class...
|
||||||
void SetDescriptiveText(const wxString& text);
|
void SetDescriptiveText(const wxString& text);
|
||||||
wxString GetDescriptiveText() const;
|
wxString GetDescriptiveText() const;
|
||||||
|
|
||||||
virtual wxInt32 MacSearchFieldSearchHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
|
virtual bool HandleSearchFieldSearchHit() ;
|
||||||
virtual wxInt32 MacSearchFieldCancelHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
|
virtual bool HandleSearchFieldCancelHit() ;
|
||||||
|
|
||||||
wxMacSearchFieldControl * GetPeer() const
|
wxSearchWidgetImpl * GetSearchPeer() const;
|
||||||
{ return (wxMacSearchFieldControl*) m_peer; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -69,12 +68,9 @@ protected:
|
|||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
virtual void CreatePeer(
|
|
||||||
const wxString& str,
|
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size, long style );
|
|
||||||
|
|
||||||
wxMenu *m_menu;
|
wxMenu *m_menu;
|
||||||
|
|
||||||
|
wxString m_descriptiveText;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxSearchCtrl)
|
DECLARE_DYNAMIC_CLASS(wxSearchCtrl)
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
#include "wx/control.h"
|
#include "wx/control.h"
|
||||||
#include "wx/textctrl.h"
|
#include "wx/textctrl.h"
|
||||||
|
|
||||||
class wxMacTextControl;
|
// forward decl for wxListWidgetImpl implementation type.
|
||||||
|
class WXDLLIMPEXP_FWD_CORE wxTextWidgetImpl;
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
|
class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
|
||||||
{
|
{
|
||||||
@ -170,17 +170,13 @@ public:
|
|||||||
virtual void MacSuperChangedPosition();
|
virtual void MacSuperChangedPosition();
|
||||||
virtual void MacCheckSpelling(bool check);
|
virtual void MacCheckSpelling(bool check);
|
||||||
|
|
||||||
wxMacTextControl * GetPeer() const
|
wxTextWidgetImpl * GetTextPeer() const;
|
||||||
{ return (wxMacTextControl*) m_peer; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
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);
|
virtual void DoSetValue(const wxString& value, int flags = 0);
|
||||||
|
|
||||||
bool m_editable;
|
bool m_editable;
|
||||||
|
@ -148,6 +148,8 @@ public :
|
|||||||
void PulseGauge();
|
void PulseGauge();
|
||||||
void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
|
void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
|
||||||
|
|
||||||
|
void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WXWidget m_osxView;
|
WXWidget m_osxView;
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
|
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"
|
#include "wx/osx/core/cfdataref.h"
|
||||||
|
|
||||||
#if wxOSX_USE_COCOA_OR_CARBON
|
#if wxOSX_USE_COCOA_OR_CARBON
|
||||||
|
|
||||||
WXDLLIMPEXP_BASE long UMAGetSystemVersion() ;
|
WXDLLIMPEXP_BASE long UMAGetSystemVersion() ;
|
||||||
|
|
||||||
|
void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , unsigned char * to );
|
||||||
|
wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( const unsigned char * from );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
@ -225,6 +230,8 @@ public :
|
|||||||
virtual void PulseGauge() = 0;
|
virtual void PulseGauge() = 0;
|
||||||
virtual void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) = 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
|
// is the clicked event sent AFTER the state already changed, so no additional
|
||||||
// state changing logic is required from the outside
|
// state changing logic is required from the outside
|
||||||
virtual bool ButtonClickDidStateChange() = 0;
|
virtual bool ButtonClickDidStateChange() = 0;
|
||||||
@ -293,6 +300,15 @@ public :
|
|||||||
long style,
|
long style,
|
||||||
long extraStyle) ;
|
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,
|
static wxWidgetImplType* CreateCheckBox( wxWindowMac* wxpeer,
|
||||||
wxWindowMac* parent,
|
wxWindowMac* parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
@ -475,6 +491,80 @@ public:
|
|||||||
virtual unsigned int ListGetCount() const = 0;
|
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
|
// toplevel window implementation class
|
||||||
//
|
//
|
||||||
|
@ -28,32 +28,18 @@
|
|||||||
#include "wx/osx/uma.h"
|
#include "wx/osx/uma.h"
|
||||||
#include "wx/osx/carbon/private/mactext.h"
|
#include "wx/osx/carbon/private/mactext.h"
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase)
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxMacSearchFieldControl
|
// wxMacSearchFieldControl
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static const EventTypeSpec eventList[] =
|
class wxMacSearchFieldControl : public wxMacUnicodeTextControl, public wxSearchWidgetImpl
|
||||||
{
|
|
||||||
{ kEventClassSearchField, kEventSearchFieldCancelClicked } ,
|
|
||||||
{ kEventClassSearchField, kEventSearchFieldSearchClicked } ,
|
|
||||||
};
|
|
||||||
|
|
||||||
class wxMacSearchFieldControl : public wxMacUnicodeTextControl
|
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
wxMacSearchFieldControl( wxTextCtrl *wxPeer,
|
wxMacSearchFieldControl( wxTextCtrl *wxPeer,
|
||||||
const wxString& str,
|
const wxString& str,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size, long style ) : wxMacUnicodeTextControl( wxPeer )
|
const wxSize& size, long style ) ;
|
||||||
{
|
|
||||||
Create( wxPeer, str, pos, size, style );
|
|
||||||
}
|
|
||||||
|
|
||||||
// search field options
|
// search field options
|
||||||
virtual void ShowSearchButton( bool show );
|
virtual void ShowSearchButton( bool show );
|
||||||
virtual bool IsSearchButtonVisible() const;
|
virtual bool IsSearchButtonVisible() const;
|
||||||
@ -62,35 +48,81 @@ public :
|
|||||||
virtual bool IsCancelButtonVisible() const;
|
virtual bool IsCancelButtonVisible() const;
|
||||||
|
|
||||||
virtual void SetSearchMenu( wxMenu* menu );
|
virtual void SetSearchMenu( wxMenu* menu );
|
||||||
virtual wxMenu* GetSearchMenu() const;
|
|
||||||
|
|
||||||
virtual void SetDescriptiveText(const wxString& text);
|
virtual void SetDescriptiveText(const wxString& text);
|
||||||
virtual wxString GetDescriptiveText() const;
|
|
||||||
|
|
||||||
virtual bool SetFocus();
|
virtual bool SetFocus();
|
||||||
|
|
||||||
protected :
|
|
||||||
virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef crf );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxMenu* m_menu;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer),
|
static const EventTypeSpec eventList[] =
|
||||||
const Rect* bounds,
|
|
||||||
CFStringRef WXUNUSED(crf))
|
|
||||||
{
|
{
|
||||||
|
{ 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;
|
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(
|
verify_noerr( HISearchFieldCreate(
|
||||||
&hibounds,
|
&hibounds,
|
||||||
attributes,
|
attributes,
|
||||||
0, // MenuRef
|
0, // MenuRef
|
||||||
CFSTR("Search"),
|
CFSTR(""),
|
||||||
&m_controlRef
|
&m_controlRef
|
||||||
) );
|
) );
|
||||||
HIViewSetVisible (m_controlRef, true);
|
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
|
// search field options
|
||||||
@ -140,10 +172,9 @@ bool wxMacSearchFieldControl::IsCancelButtonVisible() const
|
|||||||
|
|
||||||
void wxMacSearchFieldControl::SetSearchMenu( wxMenu* menu )
|
void wxMacSearchFieldControl::SetSearchMenu( wxMenu* menu )
|
||||||
{
|
{
|
||||||
m_menu = menu;
|
if ( menu )
|
||||||
if ( m_menu )
|
|
||||||
{
|
{
|
||||||
verify_noerr( HISearchFieldSetSearchMenu( m_controlRef, MAC_WXHMENU(m_menu->GetHMenu()) ) );
|
verify_noerr( HISearchFieldSetSearchMenu( m_controlRef, MAC_WXHMENU(menu->GetHMenu()) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -151,12 +182,6 @@ void wxMacSearchFieldControl::SetSearchMenu( wxMenu* menu )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu* wxMacSearchFieldControl::GetSearchMenu() const
|
|
||||||
{
|
|
||||||
return m_menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void wxMacSearchFieldControl::SetDescriptiveText(const wxString& text)
|
void wxMacSearchFieldControl::SetDescriptiveText(const wxString& text)
|
||||||
{
|
{
|
||||||
verify_noerr( HISearchFieldSetDescriptiveText(
|
verify_noerr( HISearchFieldSetDescriptiveText(
|
||||||
@ -164,20 +189,6 @@ void wxMacSearchFieldControl::SetDescriptiveText(const wxString& text)
|
|||||||
wxCFStringRef( text, wxFont::GetDefaultEncoding() )));
|
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()
|
bool wxMacSearchFieldControl::SetFocus()
|
||||||
{
|
{
|
||||||
// NB: We have to implement SetFocus a little differently because kControlFocusNextPart
|
// NB: We have to implement SetFocus a little differently because kControlFocusNextPart
|
||||||
@ -192,201 +203,18 @@ bool wxMacSearchFieldControl::SetFocus()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer,
|
||||||
// ============================================================================
|
wxWindowMac* parent,
|
||||||
// implementation
|
wxWindowID id,
|
||||||
// ============================================================================
|
const wxString& str,
|
||||||
|
const wxPoint& pos,
|
||||||
static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
long extraStyle)
|
||||||
{
|
{
|
||||||
OSStatus result = eventNotHandledErr ;
|
wxMacControl* peer = new wxMacSearchFieldControl( wxpeer , str , pos , size , style );
|
||||||
|
|
||||||
wxMacCarbonEvent cEvent( event ) ;
|
return peer;
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_NATIVE_SEARCH_CONTROL
|
#endif // wxUSE_NATIVE_SEARCH_CONTROL
|
||||||
|
@ -218,11 +218,11 @@ wxMacWindowClipper::~wxMacWindowClipper()
|
|||||||
|
|
||||||
// common parts for implementations based on MLTE
|
// common parts for implementations based on MLTE
|
||||||
|
|
||||||
class wxMacMLTEControl : public wxMacTextControl
|
class wxMacMLTEControl : public wxMacControl, public wxTextWidgetImpl
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
wxMacMLTEControl( wxTextCtrl *peer ) ;
|
wxMacMLTEControl( wxTextCtrl *peer ) ;
|
||||||
|
~wxMacMLTEControl() {}
|
||||||
virtual wxString GetStringValue() const ;
|
virtual wxString GetStringValue() const ;
|
||||||
virtual void SetStringValue( const wxString &str ) ;
|
virtual void SetStringValue( const wxString &str ) ;
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
|||||||
if ( UMAGetSystemVersion() >= 0x1050 )
|
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||||
forceMLTE = false;
|
forceMLTE = false;
|
||||||
|
|
||||||
wxMacTextControl* peer = NULL;
|
wxMacControl* peer = NULL;
|
||||||
|
|
||||||
if ( !forceMLTE )
|
if ( !forceMLTE )
|
||||||
{
|
{
|
||||||
@ -466,7 +466,7 @@ static pascal OSStatus wxMacUnicodeTextControlEventHandler( EventHandlerCallRef
|
|||||||
|
|
||||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler )
|
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 wxString& str,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size, long style )
|
const wxSize& size, long style )
|
||||||
: wxMacTextControl( wxPeer )
|
: wxMacControl( wxPeer )
|
||||||
{
|
|
||||||
Create( wxPeer, str, pos, size, style );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer,
|
|
||||||
const wxString& str,
|
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size, long style )
|
|
||||||
{
|
{
|
||||||
m_font = wxPeer->GetFont() ;
|
m_font = wxPeer->GetFont() ;
|
||||||
m_windowStyle = style ;
|
m_windowStyle = style ;
|
||||||
@ -491,19 +483,29 @@ bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer,
|
|||||||
wxString st = str ;
|
wxString st = str ;
|
||||||
wxMacConvertNewlines10To13( &st ) ;
|
wxMacConvertNewlines10To13( &st ) ;
|
||||||
wxCFStringRef cf(st , m_font.GetEncoding()) ;
|
wxCFStringRef cf(st , m_font.GetEncoding()) ;
|
||||||
CFStringRef cfr = cf ;
|
|
||||||
|
|
||||||
m_valueTag = kControlEditTextCFStringTag ;
|
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) )
|
if ( !(m_windowStyle & wxTE_MULTILINE) )
|
||||||
SetData<Boolean>( kControlEditTextPart , kControlEditTextSingleLineTag , true ) ;
|
SetData<Boolean>( kControlEditTextPart , kControlEditTextSingleLineTag , true ) ;
|
||||||
|
|
||||||
|
InstallEventHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxMacUnicodeTextControl::InstallEventHandlers()
|
||||||
|
{
|
||||||
::InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(),
|
::InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(),
|
||||||
GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this,
|
GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
|
wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
|
||||||
@ -555,19 +557,6 @@ void wxMacUnicodeTextControl::SetStringValue( const wxString &str )
|
|||||||
verify_noerr( SetData<CFStringRef>( 0, m_valueTag , cf ) ) ;
|
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()
|
void wxMacUnicodeTextControl::Copy()
|
||||||
{
|
{
|
||||||
SendHICommand( kHICommandCopy ) ;
|
SendHICommand( kHICommandCopy ) ;
|
||||||
@ -713,7 +702,7 @@ protected :
|
|||||||
} ;
|
} ;
|
||||||
|
|
||||||
wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer )
|
wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer )
|
||||||
: wxMacTextControl( peer )
|
: wxMacControl( peer )
|
||||||
{
|
{
|
||||||
SetNeedsFocusRect( true ) ;
|
SetNeedsFocusRect( true ) ;
|
||||||
}
|
}
|
||||||
|
@ -259,27 +259,6 @@ void wxMacNativeToPoint( const Point *n , wxPoint* wx )
|
|||||||
wx->y = n->v;
|
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
|
// 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;
|
m_font = font;
|
||||||
#if wxOSX_USE_CORE_TEXT
|
#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() );
|
HIViewSetTextFont( m_controlRef , part , (CTFontRef) font.MacGetCTFont() );
|
||||||
HIViewSetTextHorizontalFlush( m_controlRef, part, flush );
|
HIViewSetTextHorizontalFlush( m_controlRef, part, flush );
|
||||||
|
|
||||||
if ( foreground != *wxBLACK )
|
if ( foreground != *wxBLACK || ignoreBlack == false )
|
||||||
{
|
{
|
||||||
ControlFontStyleRec fontStyle;
|
ControlFontStyleRec fontStyle;
|
||||||
foreground.GetRGBColor( &fontStyle.foreColor );
|
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
|
// 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
|
// won't get grayed out by the system anymore
|
||||||
|
|
||||||
if ( foreground != *wxBLACK )
|
if ( foreground != *wxBLACK || ignoreBlack == false )
|
||||||
{
|
{
|
||||||
foreground.GetRGBColor( &fontStyle.foreColor );
|
foreground.GetRGBColor( &fontStyle.foreColor );
|
||||||
fontStyle.flags |= kControlUseForeColorMask;
|
fontStyle.flags |= kControlUseForeColorMask;
|
||||||
|
@ -304,39 +304,6 @@ bool wxGLCanvas::Create(wxWindow *parent,
|
|||||||
return true;
|
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()
|
wxGLCanvas::~wxGLCanvas()
|
||||||
{
|
{
|
||||||
if ( m_glFormat )
|
if ( m_glFormat )
|
||||||
|
@ -74,15 +74,15 @@ int wxMessageDialog::ShowModal()
|
|||||||
|
|
||||||
wxASSERT_MSG( (style & 0x3F) != wxYES, wxT("this style is not supported on Mac") );
|
wxASSERT_MSG( (style & 0x3F) != wxYES, wxT("this style is not supported on Mac") );
|
||||||
|
|
||||||
AlertType alertType = kAlertPlainAlert;
|
NSAlertStyle alertType = NSWarningAlertStyle;
|
||||||
if (style & wxICON_EXCLAMATION)
|
if (style & wxICON_EXCLAMATION)
|
||||||
alertType = kAlertCautionAlert;
|
alertType = NSCriticalAlertStyle;
|
||||||
else if (style & wxICON_HAND)
|
else if (style & wxICON_HAND)
|
||||||
alertType = kAlertStopAlert;
|
alertType = NSWarningAlertStyle;
|
||||||
else if (style & wxICON_INFORMATION)
|
else if (style & wxICON_INFORMATION)
|
||||||
alertType = kAlertNoteAlert;
|
alertType = NSInformationalAlertStyle;
|
||||||
else if (style & wxICON_QUESTION)
|
else if (style & wxICON_QUESTION)
|
||||||
alertType = kAlertNoteAlert;
|
alertType = NSInformationalAlertStyle;
|
||||||
|
|
||||||
|
|
||||||
// work out what to display
|
// work out what to display
|
||||||
@ -164,9 +164,8 @@ int wxMessageDialog::ShowModal()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
short result;
|
NSAlert* alert = [[NSAlert alloc] init];
|
||||||
|
|
||||||
AlertStdCFStringAlertParamRec param;
|
|
||||||
wxCFStringRef cfNoString( m_no.c_str(), GetFont().GetEncoding() );
|
wxCFStringRef cfNoString( m_no.c_str(), GetFont().GetEncoding() );
|
||||||
wxCFStringRef cfYesString( m_yes.c_str(), GetFont().GetEncoding() );
|
wxCFStringRef cfYesString( m_yes.c_str(), GetFont().GetEncoding() );
|
||||||
wxCFStringRef cfOKString( m_ok.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 cfTitle( msgtitle, GetFont().GetEncoding() );
|
||||||
wxCFStringRef cfText( msgtext, GetFont().GetEncoding() );
|
wxCFStringRef cfText( msgtext, GetFont().GetEncoding() );
|
||||||
|
|
||||||
param.movable = true;
|
[alert setMessageText:cfTitle.AsNSString()];
|
||||||
param.flags = 0;
|
[alert setInformativeText:cfText.AsNSString()];
|
||||||
param.version = kStdCFStringAlertVersionOne;
|
|
||||||
|
int buttonId[3] = { 0, 0, 0 };
|
||||||
bool skipDialog = false;
|
int buttonCount = 0;
|
||||||
|
|
||||||
if (style & wxYES_NO)
|
if (style & wxYES_NO)
|
||||||
{
|
{
|
||||||
if (style & wxCANCEL)
|
if ( style & wxNO_DEFAULT )
|
||||||
{
|
{
|
||||||
param.defaultText = cfYesString;
|
[alert addButtonWithTitle:cfNoString.AsNSString()];
|
||||||
param.cancelText = cfCancelString;
|
buttonId[ buttonCount++ ] = wxID_NO;
|
||||||
param.otherText = cfNoString;
|
[alert addButtonWithTitle:cfYesString.AsNSString()];
|
||||||
param.helpButton = false;
|
buttonId[ buttonCount++ ] = wxID_YES;
|
||||||
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
|
|
||||||
param.cancelButton = kAlertStdAlertCancelButton;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
param.defaultText = cfYesString;
|
[alert addButtonWithTitle:cfYesString.AsNSString()];
|
||||||
param.cancelText = NULL;
|
buttonId[ buttonCount++ ] = wxID_YES;
|
||||||
param.otherText = cfNoString;
|
[alert addButtonWithTitle:cfNoString.AsNSString()];
|
||||||
param.helpButton = false;
|
buttonId[ buttonCount++ ] = wxID_NO;
|
||||||
param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
|
}
|
||||||
param.cancelButton = 0;
|
|
||||||
|
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
|
// the MSW implementation even shows an OK button if it is not specified, we'll do the same
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
[alert addButtonWithTitle:cfOKString.AsNSString()];
|
||||||
|
buttonId[ buttonCount++ ] = wxID_OK;
|
||||||
if (style & wxCANCEL)
|
if (style & wxCANCEL)
|
||||||
{
|
{
|
||||||
// that's a cancel missing
|
[alert addButtonWithTitle:cfCancelString.AsNSString()];
|
||||||
param.defaultText = cfOKString;
|
buttonId[ buttonCount++ ] = wxID_CANCEL;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
param.position = kWindowDefaultPosition;
|
int button = [alert runModal];
|
||||||
if ( !skipDialog )
|
|
||||||
{
|
[alert release];
|
||||||
DialogRef alertRef;
|
|
||||||
CreateStandardAlert( alertType, cfTitle, cfText, ¶m, &alertRef );
|
if ( button < NSAlertFirstButtonReturn )
|
||||||
RunStandardAlert( alertRef, NULL, &result );
|
resultbutton = wxID_CANCEL;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return wxID_CANCEL;
|
if ( button - NSAlertFirstButtonReturn < buttonCount )
|
||||||
}
|
resultbutton = buttonId[ button - NSAlertFirstButtonReturn ];
|
||||||
|
else
|
||||||
if (style & wxOK)
|
resultbutton = wxID_CANCEL;
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,368 +25,165 @@
|
|||||||
|
|
||||||
#if wxUSE_NATIVE_SEARCH_CONTROL
|
#if wxUSE_NATIVE_SEARCH_CONTROL
|
||||||
|
|
||||||
#include "wx/osx/uma.h"
|
#include "wx/osx/private.h"
|
||||||
#include "wx/osx/carbon/private/mactext.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
|
// wxMacSearchFieldControl
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
static const EventTypeSpec eventList[] =
|
class wxNSSearchFieldControl : public wxNSTextFieldControl, public wxSearchWidgetImpl
|
||||||
{
|
|
||||||
{ kEventClassSearchField, kEventSearchFieldCancelClicked } ,
|
|
||||||
{ kEventClassSearchField, kEventSearchFieldSearchClicked } ,
|
|
||||||
};
|
|
||||||
|
|
||||||
class wxMacSearchFieldControl : public wxMacUnicodeTextControl
|
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
wxMacSearchFieldControl( wxTextCtrl *wxPeer,
|
wxNSSearchFieldControl( wxTextCtrl *wxPeer, wxNSSearchField* w ) : wxNSTextFieldControl(wxPeer, w)
|
||||||
const wxString& str,
|
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size, long style ) : wxMacUnicodeTextControl( wxPeer )
|
|
||||||
{
|
{
|
||||||
Create( wxPeer, str, pos, size, style );
|
m_searchFieldCell = [w cell];
|
||||||
|
m_searchField = w;
|
||||||
}
|
}
|
||||||
|
~wxNSSearchFieldControl();
|
||||||
|
|
||||||
// search field options
|
// search field options
|
||||||
virtual void ShowSearchButton( bool show );
|
virtual void ShowSearchButton( bool show )
|
||||||
virtual bool IsSearchButtonVisible() const;
|
{
|
||||||
|
if ( show )
|
||||||
virtual void ShowCancelButton( bool show );
|
[m_searchFieldCell resetSearchButtonCell];
|
||||||
virtual bool IsCancelButtonVisible() const;
|
else
|
||||||
|
[m_searchFieldCell setSearchButtonCell:nil];
|
||||||
virtual void SetSearchMenu( wxMenu* menu );
|
[m_searchField setNeedsDisplay:YES];
|
||||||
virtual wxMenu* GetSearchMenu() const;
|
}
|
||||||
|
|
||||||
virtual void SetDescriptiveText(const wxString& text);
|
|
||||||
virtual wxString GetDescriptiveText() const;
|
|
||||||
|
|
||||||
virtual bool SetFocus();
|
virtual bool IsSearchButtonVisible() const
|
||||||
|
{
|
||||||
|
return [m_searchFieldCell searchButtonCell] != nil;
|
||||||
|
}
|
||||||
|
|
||||||
protected :
|
virtual void ShowCancelButton( bool show )
|
||||||
virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef crf );
|
{
|
||||||
|
if ( show )
|
||||||
|
[m_searchFieldCell resetCancelButtonCell];
|
||||||
|
else
|
||||||
|
[m_searchFieldCell setCancelButtonCell:nil];
|
||||||
|
[m_searchField setNeedsDisplay:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool IsCancelButtonVisible() const
|
||||||
|
{
|
||||||
|
return [m_searchFieldCell cancelButtonCell] != nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void SetSearchMenu( wxMenu* menu )
|
||||||
|
{
|
||||||
|
if ( menu )
|
||||||
|
[m_searchFieldCell setSearchMenuTemplate:menu->GetHMenu()];
|
||||||
|
else
|
||||||
|
[m_searchFieldCell setSearchMenuTemplate:nil];
|
||||||
|
[m_searchField setNeedsDisplay:YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void SetDescriptiveText(const wxString& text)
|
||||||
|
{
|
||||||
|
[m_searchFieldCell setPlaceholderString:
|
||||||
|
wxCFStringRef( text , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool SetFocus()
|
||||||
|
{
|
||||||
|
return wxNSTextFieldControl::SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxMenu* m_menu;
|
wxNSSearchField* m_searchField;
|
||||||
|
NSSearchFieldCell* m_searchFieldCell;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
void wxMacSearchFieldControl::CreateControl(wxTextCtrl* WXUNUSED(peer),
|
wxNSSearchFieldControl::~wxNSSearchFieldControl()
|
||||||
const Rect* bounds,
|
|
||||||
CFStringRef WXUNUSED(crf))
|
|
||||||
{
|
{
|
||||||
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
|
wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer,
|
||||||
void wxMacSearchFieldControl::ShowSearchButton( bool show )
|
wxWindowMac* parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& str,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
long extraStyle)
|
||||||
{
|
{
|
||||||
OptionBits set = 0;
|
NSView* sv = (wxpeer->GetParent()->GetHandle() );
|
||||||
OptionBits clear = 0;
|
|
||||||
if ( show )
|
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
||||||
{
|
wxNSSearchField* v = [[wxNSSearchField alloc] initWithFrame:r];
|
||||||
set |= kHISearchFieldAttributesSearchIcon;
|
[sv addSubview:v];
|
||||||
}
|
[[v cell] setSendsWholeSearchString:YES];
|
||||||
else
|
// per wx default cancel is not shown
|
||||||
{
|
[[v cell] setCancelButtonCell:nil];
|
||||||
clear |= kHISearchFieldAttributesSearchIcon;
|
|
||||||
}
|
|
||||||
HISearchFieldChangeAttributes( m_controlRef, set, clear );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxMacSearchFieldControl::IsSearchButtonVisible() const
|
wxNSSearchFieldControl* c = new wxNSSearchFieldControl( wxpeer, v );
|
||||||
{
|
c->SetStringValue( str );
|
||||||
OptionBits attributes = 0;
|
[v setImplementation:c];
|
||||||
verify_noerr( HISearchFieldGetAttributes( m_controlRef, &attributes ) );
|
return c;
|
||||||
return ( attributes & kHISearchFieldAttributesSearchIcon ) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_NATIVE_SEARCH_CONTROL
|
#endif // wxUSE_NATIVE_SEARCH_CONTROL
|
||||||
|
@ -47,8 +47,7 @@
|
|||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
#include "wx/osx/carbon/private/mactext.h"
|
#include "wx/osx/cocoa/private/textimpl.h"
|
||||||
|
|
||||||
|
|
||||||
@implementation wxNSTextField
|
@implementation wxNSTextField
|
||||||
|
|
||||||
@ -75,40 +74,58 @@
|
|||||||
|
|
||||||
@end
|
@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){}
|
wxNSTextFieldControl::~wxNSTextFieldControl()
|
||||||
virtual wxString GetStringValue() const
|
{
|
||||||
{
|
}
|
||||||
wxCFStringRef cf( (CFStringRef) [[(wxNSTextField*) m_osxView stringValue] retain] );
|
|
||||||
return cf.AsString(m_wxPeer->GetFont().GetEncoding());
|
wxString wxNSTextFieldControl::GetStringValue() const
|
||||||
}
|
{
|
||||||
virtual void SetStringValue( const wxString &str)
|
wxCFStringRef cf( (CFStringRef) [[(wxNSTextField*) m_osxView stringValue] retain] );
|
||||||
{
|
return cf.AsString(m_wxPeer->GetFont().GetEncoding());
|
||||||
[(wxNSTextField*) m_osxView setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
}
|
||||||
}
|
void wxNSTextFieldControl::SetStringValue( const wxString &str)
|
||||||
virtual void Copy() {}
|
{
|
||||||
virtual void Cut() {}
|
[(wxNSTextField*) m_osxView setStringValue: wxCFStringRef( str , m_wxPeer->GetFont().GetEncoding() ).AsNSString()];
|
||||||
virtual void Paste() {}
|
}
|
||||||
virtual bool CanPaste() const { return false;}
|
void wxNSTextFieldControl::Copy()
|
||||||
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)
|
void wxNSTextFieldControl::Cut()
|
||||||
{
|
{
|
||||||
// temp hack to get logging working early
|
}
|
||||||
wxString former = GetStringValue();
|
|
||||||
SetStringValue( former + str );
|
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,
|
wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
|
||||||
wxWindowMac* parent,
|
wxWindowMac* parent,
|
||||||
|
@ -708,6 +708,11 @@ void wxWidgetCocoaImpl::SetControlSize( wxWindowVariant variant )
|
|||||||
[m_osxView setControlSize:size];
|
[m_osxView setControlSize:size];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxWidgetCocoaImpl::SetFont(wxFont const&, wxColour const&, long, bool)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Factory methods
|
// Factory methods
|
||||||
//
|
//
|
||||||
|
@ -25,8 +25,195 @@
|
|||||||
|
|
||||||
#if wxUSE_NATIVE_SEARCH_CONTROL
|
#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
|
#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
|
#endif // wxUSE_SEARCHCTRL
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
#include "wx/osx/carbon/private/mactext.h"
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
|
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
|
||||||
|
|
||||||
@ -116,9 +115,8 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
|||||||
style |= wxTE_PROCESS_ENTER ;
|
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) ;
|
MacPostControlCreate(pos, size) ;
|
||||||
|
|
||||||
@ -134,11 +132,9 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::CreatePeer(
|
wxTextWidgetImpl* wxTextCtrl::GetTextPeer() const
|
||||||
const wxString& str,
|
|
||||||
const wxPoint& pos,
|
|
||||||
const wxSize& size, long style )
|
|
||||||
{
|
{
|
||||||
|
return dynamic_cast<wxTextWidgetImpl*> (m_peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::MacSuperChangedPosition()
|
void wxTextCtrl::MacSuperChangedPosition()
|
||||||
@ -158,17 +154,17 @@ void wxTextCtrl::MacVisibilityChanged()
|
|||||||
|
|
||||||
void wxTextCtrl::MacCheckSpelling(bool check)
|
void wxTextCtrl::MacCheckSpelling(bool check)
|
||||||
{
|
{
|
||||||
GetPeer()->CheckSpelling(check);
|
GetTextPeer()->CheckSpelling(check);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxTextCtrl::GetValue() const
|
wxString wxTextCtrl::GetValue() const
|
||||||
{
|
{
|
||||||
return GetPeer()->GetStringValue() ;
|
return GetTextPeer()->GetStringValue() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::GetSelection(long* from, long* to) const
|
void wxTextCtrl::GetSelection(long* from, long* to) const
|
||||||
{
|
{
|
||||||
GetPeer()->GetSelection( from , to ) ;
|
GetTextPeer()->GetSelection( from , to ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::DoSetValue(const wxString& str, int flags)
|
void wxTextCtrl::DoSetValue(const wxString& str, int flags)
|
||||||
@ -177,7 +173,7 @@ void wxTextCtrl::DoSetValue(const wxString& str, int flags)
|
|||||||
if ( GetValue() == str )
|
if ( GetValue() == str )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GetPeer()->SetStringValue( str ) ;
|
GetTextPeer()->SetStringValue( str ) ;
|
||||||
|
|
||||||
if ( (flags & SetValue_SendEvent) && m_triggerOnSetValue )
|
if ( (flags & SetValue_SendEvent) && m_triggerOnSetValue )
|
||||||
{
|
{
|
||||||
@ -195,14 +191,14 @@ bool wxTextCtrl::SetFont( const wxFont& font )
|
|||||||
if ( !wxTextCtrlBase::SetFont( font ) )
|
if ( !wxTextCtrlBase::SetFont( font ) )
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
GetPeer()->SetFont( font , GetForegroundColour() , GetWindowStyle() ) ;
|
GetPeer()->SetFont( font , GetForegroundColour() , GetWindowStyle(), false /* dont ignore black */ ) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
|
bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
|
||||||
{
|
{
|
||||||
GetPeer()->SetStyle( start , end , style ) ;
|
GetTextPeer()->SetStyle( start , end , style ) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@ -220,14 +216,14 @@ bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style)
|
|||||||
void wxTextCtrl::Copy()
|
void wxTextCtrl::Copy()
|
||||||
{
|
{
|
||||||
if (CanCopy())
|
if (CanCopy())
|
||||||
GetPeer()->Copy() ;
|
GetTextPeer()->Copy() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Cut()
|
void wxTextCtrl::Cut()
|
||||||
{
|
{
|
||||||
if (CanCut())
|
if (CanCut())
|
||||||
{
|
{
|
||||||
GetPeer()->Cut() ;
|
GetTextPeer()->Cut() ;
|
||||||
|
|
||||||
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
|
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
|
||||||
event.SetEventObject( this );
|
event.SetEventObject( this );
|
||||||
@ -239,7 +235,7 @@ void wxTextCtrl::Paste()
|
|||||||
{
|
{
|
||||||
if (CanPaste())
|
if (CanPaste())
|
||||||
{
|
{
|
||||||
GetPeer()->Paste() ;
|
GetTextPeer()->Paste() ;
|
||||||
|
|
||||||
// TODO: eventually we should add setting the default style again
|
// TODO: eventually we should add setting the default style again
|
||||||
|
|
||||||
@ -275,7 +271,7 @@ bool wxTextCtrl::CanPaste() const
|
|||||||
if (!IsEditable())
|
if (!IsEditable())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return GetPeer()->CanPaste() ;
|
return GetTextPeer()->CanPaste() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::SetEditable(bool editable)
|
void wxTextCtrl::SetEditable(bool editable)
|
||||||
@ -283,7 +279,7 @@ void wxTextCtrl::SetEditable(bool editable)
|
|||||||
if ( editable != m_editable )
|
if ( editable != m_editable )
|
||||||
{
|
{
|
||||||
m_editable = editable ;
|
m_editable = editable ;
|
||||||
GetPeer()->SetEditable( editable ) ;
|
GetTextPeer()->SetEditable( editable ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,27 +304,27 @@ long wxTextCtrl::GetInsertionPoint() const
|
|||||||
|
|
||||||
wxTextPos wxTextCtrl::GetLastPosition() const
|
wxTextPos wxTextCtrl::GetLastPosition() const
|
||||||
{
|
{
|
||||||
return GetPeer()->GetLastPosition() ;
|
return GetTextPeer()->GetLastPosition() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Replace(long from, long to, const wxString& str)
|
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)
|
void wxTextCtrl::Remove(long from, long to)
|
||||||
{
|
{
|
||||||
GetPeer()->Remove( from , to ) ;
|
GetTextPeer()->Remove( from , to ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::SetSelection(long from, long to)
|
void wxTextCtrl::SetSelection(long from, long to)
|
||||||
{
|
{
|
||||||
GetPeer()->SetSelection( from , to ) ;
|
GetTextPeer()->SetSelection( from , to ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::WriteText(const wxString& str)
|
void wxTextCtrl::WriteText(const wxString& str)
|
||||||
{
|
{
|
||||||
GetPeer()->WriteText( str ) ;
|
GetTextPeer()->WriteText( str ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::AppendText(const wxString& text)
|
void wxTextCtrl::AppendText(const wxString& text)
|
||||||
@ -339,7 +335,7 @@ void wxTextCtrl::AppendText(const wxString& text)
|
|||||||
|
|
||||||
void wxTextCtrl::Clear()
|
void wxTextCtrl::Clear()
|
||||||
{
|
{
|
||||||
GetPeer()->Clear() ;
|
GetTextPeer()->Clear() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::IsModified() const
|
bool wxTextCtrl::IsModified() const
|
||||||
@ -403,13 +399,13 @@ wxSize wxTextCtrl::DoGetBestSize() const
|
|||||||
void wxTextCtrl::Undo()
|
void wxTextCtrl::Undo()
|
||||||
{
|
{
|
||||||
if (CanUndo())
|
if (CanUndo())
|
||||||
GetPeer()->Undo() ;
|
GetTextPeer()->Undo() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Redo()
|
void wxTextCtrl::Redo()
|
||||||
{
|
{
|
||||||
if (CanRedo())
|
if (CanRedo())
|
||||||
GetPeer()->Redo() ;
|
GetTextPeer()->Redo() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::CanUndo() const
|
bool wxTextCtrl::CanUndo() const
|
||||||
@ -417,7 +413,7 @@ bool wxTextCtrl::CanUndo() const
|
|||||||
if ( !IsEditable() )
|
if ( !IsEditable() )
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
return GetPeer()->CanUndo() ;
|
return GetTextPeer()->CanUndo() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::CanRedo() const
|
bool wxTextCtrl::CanRedo() const
|
||||||
@ -425,7 +421,7 @@ bool wxTextCtrl::CanRedo() const
|
|||||||
if ( !IsEditable() )
|
if ( !IsEditable() )
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
return GetPeer()->CanRedo() ;
|
return GetTextPeer()->CanRedo() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::MarkDirty()
|
void wxTextCtrl::MarkDirty()
|
||||||
@ -440,32 +436,32 @@ void wxTextCtrl::DiscardEdits()
|
|||||||
|
|
||||||
int wxTextCtrl::GetNumberOfLines() const
|
int wxTextCtrl::GetNumberOfLines() const
|
||||||
{
|
{
|
||||||
return GetPeer()->GetNumberOfLines() ;
|
return GetTextPeer()->GetNumberOfLines() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
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
|
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)
|
void wxTextCtrl::ShowPosition(long pos)
|
||||||
{
|
{
|
||||||
return GetPeer()->ShowPosition(pos) ;
|
return GetTextPeer()->ShowPosition(pos) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxTextCtrl::GetLineLength(long lineNo) const
|
int wxTextCtrl::GetLineLength(long lineNo) const
|
||||||
{
|
{
|
||||||
return GetPeer()->GetLineLength(lineNo) ;
|
return GetTextPeer()->GetLineLength(lineNo) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxTextCtrl::GetLineText(long lineNo) const
|
wxString wxTextCtrl::GetLineText(long lineNo) const
|
||||||
{
|
{
|
||||||
return GetPeer()->GetLineText(lineNo) ;
|
return GetTextPeer()->GetLineText(lineNo) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::Command(wxCommandEvent & event)
|
void wxTextCtrl::Command(wxCommandEvent & event)
|
||||||
@ -706,7 +702,7 @@ void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event)
|
|||||||
|
|
||||||
void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event)
|
void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event)
|
||||||
{
|
{
|
||||||
if ( GetPeer()->HasOwnContextMenu() )
|
if ( GetTextPeer()->HasOwnContextMenu() )
|
||||||
{
|
{
|
||||||
event.Skip() ;
|
event.Skip() ;
|
||||||
return ;
|
return ;
|
||||||
@ -734,7 +730,7 @@ void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event)
|
|||||||
|
|
||||||
bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
||||||
{
|
{
|
||||||
if ( !GetPeer()->SetupCursor( pt ) )
|
if ( !GetTextPeer()->SetupCursor( pt ) )
|
||||||
return wxWindow::MacSetupCursor( pt ) ;
|
return wxWindow::MacSetupCursor( pt ) ;
|
||||||
else
|
else
|
||||||
return true ;
|
return true ;
|
||||||
@ -744,104 +740,90 @@ bool wxTextCtrl::MacSetupCursor( const wxPoint& pt )
|
|||||||
// implementation base class
|
// implementation base class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if wxOSX_USE_CARBON
|
void wxTextWidgetImpl::SetStyle(long WXUNUSED(start),
|
||||||
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),
|
|
||||||
long WXUNUSED(end),
|
long WXUNUSED(end),
|
||||||
const wxTextAttr& WXUNUSED(style))
|
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 ;
|
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() ;
|
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 ) ;
|
SetSelection( from , to ) ;
|
||||||
WriteText( val ) ;
|
WriteText( val ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacTextControl::Remove( long from , long to )
|
void wxTextWidgetImpl::Remove( long from , long to )
|
||||||
{
|
{
|
||||||
SetSelection( from , to ) ;
|
SetSelection( from , to ) ;
|
||||||
WriteText( wxEmptyString) ;
|
WriteText( wxEmptyString) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacTextControl::Clear()
|
void wxTextWidgetImpl::Clear()
|
||||||
{
|
{
|
||||||
SetStringValue( wxEmptyString ) ;
|
SetStringValue( wxEmptyString ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMacTextControl::CanUndo() const
|
bool wxTextWidgetImpl::CanUndo() const
|
||||||
{
|
{
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacTextControl::Undo()
|
void wxTextWidgetImpl::Undo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMacTextControl::CanRedo() const
|
bool wxTextWidgetImpl::CanRedo() const
|
||||||
{
|
{
|
||||||
return false ;
|
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 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxMacTextControl::PositionToXY(long WXUNUSED(pos),
|
bool wxTextWidgetImpl::PositionToXY(long WXUNUSED(pos),
|
||||||
long *WXUNUSED(x),
|
long *WXUNUSED(x),
|
||||||
long *WXUNUSED(y)) const
|
long *WXUNUSED(y)) const
|
||||||
{
|
{
|
||||||
return false ;
|
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 ;
|
ItemCount lines = 0 ;
|
||||||
wxString content = GetStringValue() ;
|
wxString content = GetStringValue() ;
|
||||||
@ -856,7 +838,7 @@ int wxMacTextControl::GetNumberOfLines() const
|
|||||||
return lines ;
|
return lines ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxMacTextControl::GetLineText(long lineNo) const
|
wxString wxTextWidgetImpl::GetLineText(long lineNo) const
|
||||||
{
|
{
|
||||||
// TODO: change this if possible to reflect real lines
|
// TODO: change this if possible to reflect real lines
|
||||||
wxString content = GetStringValue() ;
|
wxString content = GetStringValue() ;
|
||||||
@ -888,7 +870,7 @@ wxString wxMacTextControl::GetLineText(long lineNo) const
|
|||||||
return wxEmptyString ;
|
return wxEmptyString ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxMacTextControl::GetLineLength(long lineNo) const
|
int wxTextWidgetImpl::GetLineLength(long lineNo) const
|
||||||
{
|
{
|
||||||
// TODO: change this if possible to reflect real lines
|
// TODO: change this if possible to reflect real lines
|
||||||
wxString content = GetStringValue() ;
|
wxString content = GetStringValue() ;
|
||||||
@ -918,22 +900,4 @@ int wxMacTextControl::GetLineLength(long lineNo) const
|
|||||||
return 0 ;
|
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
|
#endif // wxUSE_TEXTCTRL
|
||||||
|
@ -156,4 +156,24 @@ CGColorRef wxMacCreateCGColorFromHITheme( ThemeBrush brush )
|
|||||||
return color;
|
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
|
#endif // wxOSX_USE_COCOA_OR_CARBON
|
||||||
|
@ -384,9 +384,9 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
|
|||||||
|
|
||||||
void wxWindowMac::MacUpdateControlFont()
|
void wxWindowMac::MacUpdateControlFont()
|
||||||
{
|
{
|
||||||
#if wxOSX_USE_CARBON
|
|
||||||
m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
|
m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ;
|
||||||
#endif
|
|
||||||
// do not trigger refreshes upon invisible and possible partly created objects
|
// do not trigger refreshes upon invisible and possible partly created objects
|
||||||
if ( IsShownOnScreen() )
|
if ( IsShownOnScreen() )
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
|
Loading…
Reference in New Issue
Block a user