combobox and textctrl fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28200 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2004-07-11 17:03:30 +00:00
parent 5ca0d8122a
commit 788e118f21
3 changed files with 38 additions and 59 deletions

View File

@@ -44,9 +44,12 @@ MenuHandle NewUniqueMenu()
// around text control. // around text control.
static const wxCoord MARGIN = 6; static const wxCoord MARGIN = 6;
static const int POPUPWIDTH = 24; static const int POPUPWIDTH = 24;
// this is the border a focus rect on OSX is needing
static const int TEXTFOCUSBORDER = 3 ;
#else #else
static const wxCoord MARGIN = 2; static const wxCoord MARGIN = 2;
static const int POPUPWIDTH = 18; static const int POPUPWIDTH = 18;
static const int TEXTFOCUSBORDER = 0 ;
#endif #endif
static const int POPUPHEIGHT = 23; static const int POPUPHEIGHT = 23;
@@ -209,21 +212,14 @@ wxSize wxComboBox::DoGetBestSize() const
if (sizeText.y > size.y) if (sizeText.y > size.y)
size.y = sizeText.y; size.y = sizeText.y;
size.x = POPUPWIDTH + sizeText.x + MARGIN; size.x = POPUPWIDTH + sizeText.x + MARGIN;
size.x += TEXTFOCUSBORDER ;
size.y += 2 * TEXTFOCUSBORDER ;
} }
return size; return size;
} }
void wxComboBox::DoMoveWindow(int x, int y, int width, int height) { void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
height = POPUPHEIGHT; wxControl::DoMoveWindow(x, y, width , height );
int origin = 0;
#if TARGET_API_MAC_OSX
// give the controls some padding so that the text ctrl's borders
// and blue highlight can appear
origin = 4;
#endif
wxControl::DoMoveWindow(x, y, width + origin, height + origin);
if ( m_text == NULL ) if ( m_text == NULL )
{ {
@@ -234,14 +230,8 @@ void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
else else
{ {
wxCoord wText = width - POPUPWIDTH - MARGIN; wxCoord wText = width - POPUPWIDTH - MARGIN;
#if TARGET_API_MAC_OSX m_text->SetSize(TEXTFOCUSBORDER, TEXTFOCUSBORDER, wText, -1 );
// also, we need to shrink the size of the wxTextCtrl a bit m_choice->SetSize(TEXTFOCUSBORDER + wText + MARGIN, TEXTFOCUSBORDER, POPUPWIDTH, -1);
// to make it appear properly on OS X.
height -= 8;
wText -= 8;
#endif
m_text->SetSize(origin, origin, wText, height);
m_choice->SetSize(origin + wText + MARGIN, 0, POPUPWIDTH, -1);
} }
} }
@@ -327,8 +317,10 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
else else
{ {
m_text = new wxComboBoxText(this); m_text = new wxComboBoxText(this);
if ( size.y == -1 ) { if ( size.y == -1 )
{
csize.y = m_text->GetSize().y ; csize.y = m_text->GetSize().y ;
csize.y += 2 * TEXTFOCUSBORDER ;
} }
} }

View File

@@ -233,6 +233,8 @@ protected :
// implementation available under OSX // implementation available under OSX
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
class wxMacMLTEHIViewControl : public wxMacMLTEControl class wxMacMLTEHIViewControl : public wxMacMLTEControl
{ {
public : public :
@@ -248,6 +250,8 @@ protected :
HIViewRef m_textView ; HIViewRef m_textView ;
} ; } ;
#endif
class wxMacUnicodeTextControl : public wxMacTextControl class wxMacUnicodeTextControl : public wxMacTextControl
{ {
public : public :
@@ -300,18 +304,6 @@ public :
#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL #define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
#if TARGET_API_MAC_OSX
#define wxMAC_USE_MLTE 1
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
#define wxMAC_USE_MLTE_HIVIEW 1
#else
#define wxMAC_USE_MLTE_HIVIEW 0
#endif
#else
// there is no unicodetextctrl on classic, and hopefully MLTE works better there
#define wxMAC_USE_MLTE 1
#define wxMAC_USE_MLTE_HIVIEW 0
#endif
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
@@ -357,19 +349,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
m_macIsUserPane = FALSE ; m_macIsUserPane = FALSE ;
m_editable = true ; m_editable = true ;
// base initialization
if ( !HasFlag(wxNO_BORDER) ) if ( !HasFlag(wxNO_BORDER) )
{
#if wxMAC_USE_MLTE
#if wxMAC_USE_MLTE_HIVIEW
style |= wxSUNKEN_BORDER ; style |= wxSUNKEN_BORDER ;
#endif
#endif
}
else
{
}
if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) ) if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) )
return FALSE; return FALSE;
@@ -386,15 +367,21 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
m_windowStyle |= wxTE_PROCESS_ENTER; m_windowStyle |= wxTE_PROCESS_ENTER;
style |= wxTE_PROCESS_ENTER ; style |= wxTE_PROCESS_ENTER ;
} }
#if wxMAC_USE_MLTE #if TARGET_API_MAC_OSX
#if wxMAC_USE_MLTE_HIVIEW #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
if ( UMAGetSystemVersion() >= 0x1030 )
{
m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ; m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ;
}
else
#endif
{
m_peer = new wxMacUnicodeTextControl( this , str , pos , size , style ) ;
}
#else #else
m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ; m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ;
#endif #endif
#else // wxMAC_USE_MLTE
m_peer = new wxMacUnicodeTextControl( this , str , pos , size , style ) ;
#endif
MacPostControlCreate(pos,size) ; MacPostControlCreate(pos,size) ;
if ( m_windowStyle & wxTE_READONLY) if ( m_windowStyle & wxTE_READONLY)
@@ -647,12 +634,8 @@ wxSize wxTextCtrl::DoGetBestSize() const
break ; break ;
} }
#if !wxMAC_USE_MLTE if ( HasFlag(wxNO_BORDER) )
// unicode text control is using client size, ie 3 pixels on every side
// TODO make this fit into normal window size concept, probably having
// to reintroduce the margin vars
hText -= 6 ; hText -= 6 ;
#endif
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
{ {

View File

@@ -2387,12 +2387,16 @@ void wxWindowMac::OnSetFocus(wxFocusEvent& event)
if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() ) if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
{ {
wxWindowDC dc(this) ; wxMacWindowStateSaver sv( this ) ;
wxMacPortSetter helper(&dc) ; // wxWindowDC dc(this) ;
// wxMacPortSetter helper(&dc) ;
int w , h ; int w , h ;
int x , y ;
x = y = 0 ;
MacWindowToRootWindow( &x , &y ) ;
GetSize( &w , &h ) ; GetSize( &w , &h ) ;
Rect rect = { dc.m_macLocalOrigin.y , dc.m_macLocalOrigin.x , h + dc.m_macLocalOrigin.y , w + dc.m_macLocalOrigin.x } ; Rect rect = {y , x , h + y , w + x } ;
if ( event.GetEventType() == wxEVT_SET_FOCUS ) if ( event.GetEventType() == wxEVT_SET_FOCUS )
DrawThemeFocusRect( &rect , true ) ; DrawThemeFocusRect( &rect , true ) ;