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:
@@ -21,7 +21,7 @@
|
||||
// forward decl for GetSelections()
|
||||
class wxArrayInt;
|
||||
|
||||
// forward decl for wxListWidgetImpl data type.
|
||||
// forward decl for wxListWidgetImpl implementation type.
|
||||
class wxListWidgetImpl;
|
||||
|
||||
// List box item
|
||||
|
@@ -426,7 +426,7 @@ public :
|
||||
virtual void SuperChangedPosition();
|
||||
|
||||
|
||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle );
|
||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
|
||||
virtual void SetBackgroundColour( const wxColour& col );
|
||||
virtual ControlPartCode HandleKey( SInt16 keyCode, SInt16 charCode, EventModifiers modifiers );
|
||||
void SetActionProc( ControlActionUPP actionProc );
|
||||
@@ -962,8 +962,6 @@ void wxMacSetupConverters();
|
||||
void wxMacCleanupConverters();
|
||||
|
||||
// utils.cpp
|
||||
void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , StringPtr to );
|
||||
wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( ConstStringPtr from );
|
||||
|
||||
// filefn.cpp
|
||||
|
||||
|
@@ -14,64 +14,9 @@
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
// common interface for all implementations
|
||||
class wxMacTextControl :
|
||||
#if wxOSX_USE_CARBON
|
||||
public wxMacControl
|
||||
#else
|
||||
public wxWidgetCocoaImpl
|
||||
#endif
|
||||
{
|
||||
public :
|
||||
#if wxOSX_USE_CARBON
|
||||
wxMacTextControl( wxTextCtrl *peer ) ;
|
||||
#else
|
||||
wxMacTextControl::wxMacTextControl(wxTextCtrl* peer, WXWidget w) ;
|
||||
#endif
|
||||
virtual ~wxMacTextControl() ;
|
||||
// implementation exposed, so that search control can pull it
|
||||
|
||||
virtual bool CanFocus() const { return true; }
|
||||
|
||||
virtual wxString GetStringValue() const = 0 ;
|
||||
virtual void SetStringValue( const wxString &val ) = 0 ;
|
||||
virtual void SetSelection( long from, long to ) = 0 ;
|
||||
virtual void GetSelection( long* from, long* to ) const = 0 ;
|
||||
virtual void WriteText( const wxString& str ) = 0 ;
|
||||
|
||||
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
|
||||
virtual void Copy() ;
|
||||
virtual void Cut() ;
|
||||
virtual void Paste() ;
|
||||
virtual bool CanPaste() const ;
|
||||
virtual void SetEditable( bool editable ) ;
|
||||
virtual wxTextPos GetLastPosition() const ;
|
||||
virtual void Replace( long from, long to, const wxString &str ) ;
|
||||
virtual void Remove( long from, long to ) ;
|
||||
|
||||
|
||||
virtual bool HasOwnContextMenu() const
|
||||
{ return false ; }
|
||||
|
||||
virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) )
|
||||
{ return false ; }
|
||||
|
||||
virtual void Clear() ;
|
||||
virtual bool CanUndo() const;
|
||||
virtual void Undo() ;
|
||||
virtual bool CanRedo() const;
|
||||
virtual void Redo() ;
|
||||
virtual int GetNumberOfLines() const ;
|
||||
virtual long XYToPosition(long x, long y) const;
|
||||
virtual bool PositionToXY(long pos, long *x, long *y) const ;
|
||||
virtual void ShowPosition(long WXUNUSED(pos)) ;
|
||||
virtual int GetLineLength(long lineNo) const ;
|
||||
virtual wxString GetLineText(long lineNo) const ;
|
||||
virtual void CheckSpelling(bool WXUNUSED(check)) { }
|
||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle );
|
||||
};
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
class wxMacUnicodeTextControl : public wxMacTextControl
|
||||
class wxMacUnicodeTextControl : public wxMacControl, public wxTextWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) ;
|
||||
@@ -81,10 +26,6 @@ public :
|
||||
const wxSize& size, long style ) ;
|
||||
virtual ~wxMacUnicodeTextControl();
|
||||
|
||||
virtual bool Create( wxTextCtrl *wxPeer,
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style ) ;
|
||||
virtual void VisibilityChanged(bool shown);
|
||||
virtual wxString GetStringValue() const ;
|
||||
virtual void SetStringValue( const wxString &str) ;
|
||||
@@ -98,13 +39,12 @@ public :
|
||||
virtual void WriteText(const wxString& str) ;
|
||||
|
||||
protected :
|
||||
virtual void CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef cfr );
|
||||
void InstallEventHandlers();
|
||||
|
||||
// contains the tag for the content (is different for password and non-password controls)
|
||||
OSType m_valueTag ;
|
||||
public :
|
||||
ControlEditTextSelectionRec m_selection ;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // _WX_MAC_PRIVATE_MACTEXT_H_
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
#if wxUSE_SEARCHCTRL
|
||||
|
||||
class wxMacSearchFieldControl;
|
||||
class wxSearchWidgetImpl;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxSearchCtrl : public wxSearchCtrlBase
|
||||
{
|
||||
@@ -54,14 +54,13 @@ public:
|
||||
virtual bool IsCancelButtonVisible() const;
|
||||
|
||||
// TODO: In 2.9 these should probably be virtual, and declared in the base class...
|
||||
void SetDescriptiveText(const wxString& text);
|
||||
wxString GetDescriptiveText() const;
|
||||
void SetDescriptiveText(const wxString& text);
|
||||
wxString GetDescriptiveText() const;
|
||||
|
||||
virtual wxInt32 MacSearchFieldSearchHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
|
||||
virtual wxInt32 MacSearchFieldCancelHit( WXEVENTHANDLERREF handler , WXEVENTREF event ) ;
|
||||
virtual bool HandleSearchFieldSearchHit() ;
|
||||
virtual bool HandleSearchFieldCancelHit() ;
|
||||
|
||||
wxMacSearchFieldControl * GetPeer() const
|
||||
{ return (wxMacSearchFieldControl*) m_peer; }
|
||||
wxSearchWidgetImpl * GetSearchPeer() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -69,12 +68,9 @@ protected:
|
||||
|
||||
void Init();
|
||||
|
||||
virtual void CreatePeer(
|
||||
const wxString& str,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style );
|
||||
|
||||
wxMenu *m_menu;
|
||||
|
||||
wxString m_descriptiveText;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSearchCtrl)
|
||||
|
@@ -26,8 +26,8 @@
|
||||
#include "wx/control.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
class wxMacTextControl;
|
||||
|
||||
// forward decl for wxListWidgetImpl implementation type.
|
||||
class WXDLLIMPEXP_FWD_CORE wxTextWidgetImpl;
|
||||
|
||||
class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
|
||||
{
|
||||
@@ -170,17 +170,13 @@ public:
|
||||
virtual void MacSuperChangedPosition();
|
||||
virtual void MacCheckSpelling(bool check);
|
||||
|
||||
wxMacTextControl * GetPeer() const
|
||||
{ return (wxMacTextControl*) m_peer; }
|
||||
|
||||
wxTextWidgetImpl * GetTextPeer() const;
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
virtual void CreatePeer(const wxString& str, const wxPoint& pos, const wxSize& size, long style );
|
||||
|
||||
virtual void DoSetValue(const wxString& value, int flags = 0);
|
||||
|
||||
bool m_editable;
|
||||
|
@@ -148,6 +148,8 @@ public :
|
||||
void PulseGauge();
|
||||
void SetScrollThumb( wxInt32 value, wxInt32 thumbSize );
|
||||
|
||||
void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true );
|
||||
|
||||
protected:
|
||||
WXWidget m_osxView;
|
||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxWidgetCocoaImpl)
|
||||
|
37
include/wx/osx/cocoa/private/textimpl.h
Normal file
37
include/wx/osx/cocoa/private/textimpl.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: textimpl.h
|
||||
// Purpose: textcontrol implementation classes that have to be exposed
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 03/02/99
|
||||
// RCS-ID: $Id:
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
||||
#define _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
// implementation exposed, so that search control can pull it
|
||||
|
||||
class wxNSTextFieldControl : public wxWidgetCocoaImpl, public wxTextWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w );
|
||||
virtual ~wxNSTextFieldControl();
|
||||
|
||||
virtual wxString GetStringValue() const ;
|
||||
virtual void SetStringValue( const wxString &str) ;
|
||||
virtual void Copy() ;
|
||||
virtual void Cut() ;
|
||||
virtual void Paste() ;
|
||||
virtual bool CanPaste() const ;
|
||||
virtual void SetEditable(bool editable) ;
|
||||
virtual void GetSelection( long* from, long* to) const ;
|
||||
virtual void SetSelection( long from , long to );
|
||||
virtual void WriteText(const wxString& str) ;
|
||||
};
|
||||
|
||||
#endif // _WX_OSX_COCOA_PRIVATE_TEXTIMPL_H_
|
@@ -22,7 +22,12 @@
|
||||
#include "wx/osx/core/cfdataref.h"
|
||||
|
||||
#if wxOSX_USE_COCOA_OR_CARBON
|
||||
|
||||
WXDLLIMPEXP_BASE long UMAGetSystemVersion() ;
|
||||
|
||||
void WXDLLIMPEXP_CORE wxMacStringToPascal( const wxString&from , unsigned char * to );
|
||||
wxString WXDLLIMPEXP_CORE wxMacMakeStringFromPascal( const unsigned char * from );
|
||||
|
||||
#endif
|
||||
|
||||
#if wxUSE_GUI
|
||||
@@ -225,6 +230,8 @@ public :
|
||||
virtual void PulseGauge() = 0;
|
||||
virtual void SetScrollThumb( wxInt32 value, wxInt32 thumbSize ) = 0;
|
||||
|
||||
virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle, bool ignoreBlack = true ) = 0;
|
||||
|
||||
// is the clicked event sent AFTER the state already changed, so no additional
|
||||
// state changing logic is required from the outside
|
||||
virtual bool ButtonClickDidStateChange() = 0;
|
||||
@@ -293,6 +300,15 @@ public :
|
||||
long style,
|
||||
long extraStyle) ;
|
||||
|
||||
static wxWidgetImplType* CreateSearchControl( wxTextCtrl* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
const wxString& content,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
long extraStyle) ;
|
||||
|
||||
static wxWidgetImplType* CreateCheckBox( wxWindowMac* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
@@ -475,6 +491,80 @@ public:
|
||||
virtual unsigned int ListGetCount() const = 0;
|
||||
};
|
||||
|
||||
//
|
||||
// interface to be implemented by a textcontrol
|
||||
//
|
||||
|
||||
// common interface for all implementations
|
||||
class WXDLLIMPEXP_CORE wxTextWidgetImpl
|
||||
|
||||
{
|
||||
public :
|
||||
wxTextWidgetImpl() {}
|
||||
|
||||
virtual ~wxTextWidgetImpl() {}
|
||||
|
||||
virtual bool CanFocus() const { return true; }
|
||||
|
||||
virtual wxString GetStringValue() const = 0 ;
|
||||
virtual void SetStringValue( const wxString &val ) = 0 ;
|
||||
virtual void SetSelection( long from, long to ) = 0 ;
|
||||
virtual void GetSelection( long* from, long* to ) const = 0 ;
|
||||
virtual void WriteText( const wxString& str ) = 0 ;
|
||||
|
||||
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
|
||||
virtual void Copy() ;
|
||||
virtual void Cut() ;
|
||||
virtual void Paste() ;
|
||||
virtual bool CanPaste() const ;
|
||||
virtual void SetEditable( bool editable ) ;
|
||||
virtual wxTextPos GetLastPosition() const ;
|
||||
virtual void Replace( long from, long to, const wxString &str ) ;
|
||||
virtual void Remove( long from, long to ) ;
|
||||
|
||||
|
||||
virtual bool HasOwnContextMenu() const
|
||||
{ return false ; }
|
||||
|
||||
virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) )
|
||||
{ return false ; }
|
||||
|
||||
virtual void Clear() ;
|
||||
virtual bool CanUndo() const;
|
||||
virtual void Undo() ;
|
||||
virtual bool CanRedo() const;
|
||||
virtual void Redo() ;
|
||||
virtual int GetNumberOfLines() const ;
|
||||
virtual long XYToPosition(long x, long y) const;
|
||||
virtual bool PositionToXY(long pos, long *x, long *y) const ;
|
||||
virtual void ShowPosition(long WXUNUSED(pos)) ;
|
||||
virtual int GetLineLength(long lineNo) const ;
|
||||
virtual wxString GetLineText(long lineNo) const ;
|
||||
virtual void CheckSpelling(bool WXUNUSED(check)) { }
|
||||
};
|
||||
|
||||
//
|
||||
// common interface for search controls
|
||||
//
|
||||
|
||||
class wxSearchWidgetImpl
|
||||
{
|
||||
public :
|
||||
wxSearchWidgetImpl(){}
|
||||
virtual ~wxSearchWidgetImpl(){}
|
||||
|
||||
// search field options
|
||||
virtual void ShowSearchButton( bool show ) = 0;
|
||||
virtual bool IsSearchButtonVisible() const = 0;
|
||||
|
||||
virtual void ShowCancelButton( bool show ) = 0;
|
||||
virtual bool IsCancelButtonVisible() const = 0;
|
||||
|
||||
virtual void SetSearchMenu( wxMenu* menu ) = 0;
|
||||
|
||||
virtual void SetDescriptiveText(const wxString& text) = 0;
|
||||
} ;
|
||||
|
||||
//
|
||||
// toplevel window implementation class
|
||||
//
|
||||
|
Reference in New Issue
Block a user