wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent )
wxEVENT_PROPERTY( TextEnter , wxEVT_COMMAND_TEXT_ENTER , wxCommandEvent )
- wxPROPERTY( Font , wxFont , SetFont , GetFont ,, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
+ wxPROPERTY( Font , wxFont , SetFont , GetFont , EMPTY_MACROVALUE, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
wxPROPERTY( Value , wxString , SetValue, GetValue, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
- wxPROPERTY_FLAGS( WindowStyle , wxTextCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+ wxPROPERTY_FLAGS( WindowStyle , wxTextCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
wxEND_PROPERTIES_TABLE()
wxBEGIN_HANDLERS_TABLE(wxTextCtrl)
const wxValidator& validator,
const wxString& name)
{
+#ifdef __WXWINCE__
+ if ((style & wxBORDER_MASK) == 0)
+ style |= wxBORDER_SIMPLE;
+#endif
+
// base initialization
- if ( !CreateBase(parent, id, pos, size, style, validator, name) )
+ if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return FALSE;
- if ( parent )
- parent->AddChild(this);
-
// translate wxWin style flags to MSW ones
WXDWORD msStyle = MSWGetCreateWindowFlags();
if ( style & wxTE_DONTWRAP )
{
// automatically scroll the control horizontally as necessary
- msStyle |= WS_HSCROLL;
+ //
+ // NB: ES_AUTOHSCROLL is needed for richedit controls or they don't
+ // show horz scrollbar at all, even in spite of WS_HSCROLL, and as
+ // it doesn't seem to do any harm for plain edit controls, add it
+ // always
+ msStyle |= WS_HSCROLL | ES_AUTOHSCROLL;
}
if ( style & wxTE_READONLY )
void wxTextCtrl::SetSelection(long from, long to)
{
- // if from and to are both -1, it means (in wxWindows) that all text should
+ // if from and to are both -1, it means (in wxWidgets) that all text should
// be selected - translate into Windows convention
if ( (from == -1) && (to == -1) )
{
}
wxTextCtrlHitTestResult
-wxTextCtrl::HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const
+wxTextCtrl::HitTest(const wxPoint& pt, long *posOut) const
{
// first get the position from Windows
LPARAM lParam;
else
rc = wxTE_HT_ON_TEXT;
- // finally translate to column/row
- if ( !PositionToXY(pos, col, row) )
- {
- wxFAIL_MSG( _T("PositionToXY() not expected to fail in HitTest()") );
- }
+ if ( posOut )
+ *posOut = pos;
return rc;
}
void wxTextCtrl::SetMaxLength(unsigned long len)
{
+#if wxUSE_RICHEDIT
+ if (IsRich())
+ ::SendMessage(GetHwnd(), EM_EXLIMITTEXT, 0, (LPARAM) (DWORD) len);
+ else
+#endif
::SendMessage(GetHwnd(), EM_LIMITTEXT, len, 0);
}
{
if (CanRedo())
{
+#if wxUSE_RICHEDIT
+ if (GetRichVersion() > 1)
+ ::SendMessage(GetHwnd(), EM_REDO, 0, 0);
+ else
+#endif
// Same as Undo, since Undo undoes the undo, i.e. a redo.
::SendMessage(GetHwnd(), EM_UNDO, 0, 0);
}
bool wxTextCtrl::CanRedo() const
{
+#if wxUSE_RICHEDIT
+ if (GetRichVersion() > 1)
+ return ::SendMessage(GetHwnd(), EM_CANREDO, 0, 0) != 0;
+ else
+#endif
return ::SendMessage(GetHwnd(), EM_CANUNDO, 0, 0) != 0;
}
break;
case WXK_TAB:
- // always produce navigation event -- even if we process TAB
- // ourselves the fact that we got here means that the user code
- // decided to skip processing of this TAB -- probably to let it
- // do its default job.
-
// ok, so this is getting absolutely ridiculous but I don't see
// any other way to fix this bug: when a multiline text control is
// inside a wxFrame, we need to generate the navigation event as
// the right thing to do would, of course, be to understand what
// the hell is IsDialogMessage() doing but this is beyond my feeble
// forces at the moment unfortunately
- if ( FindFocus() == this )
+ if ( !(m_windowStyle & wxTE_PROCESS_TAB))
{
- wxNavigationKeyEvent eventNav;
- eventNav.SetDirection(!event.ShiftDown());
- eventNav.SetWindowChange(event.ControlDown());
- eventNav.SetEventObject(this);
-
- if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
- return;
+ if ( FindFocus() == this )
+ {
+ int flags = 0;
+ if (!event.ShiftDown())
+ flags |= wxNavigationKeyEvent::IsForward ;
+ if (event.ControlDown())
+ flags |= wxNavigationKeyEvent::WinChange ;
+ if (Navigate(flags))
+ return;
+ }
+ }
+ else
+ {
+ // Insert tab since calling the default Windows handler
+ // doesn't seem to do it
+ WriteText(wxT("\t"));
}
break;
}
wxSize wxTextCtrl::DoGetBestSize() const
{
int cx, cy;
- wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
+ wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
int wText = DEFAULT_ITEM_WIDTH;
cf.dwEffects |= CFE_UNDERLINE;
}
- // strikeout fonts are not supported by wxWindows
+ // strikeout fonts are not supported by wxWidgets
}
if ( style.HasTextColour() )
if (style.HasLeftIndent())
{
- pf.dwMask |= PFM_STARTINDENT;
+ pf.dwMask |= PFM_STARTINDENT | PFM_OFFSET;
// Convert from 1/10 mm to TWIPS
pf.dxStartIndent = (int) (((double) style.GetLeftIndent()) * mm2twips / 10.0) ;
-
- // TODO: do we need to specify dxOffset?
+ pf.dxOffset = (int) (((double) style.GetLeftSubIndent()) * mm2twips / 10.0) ;
}
if (style.HasRightIndent())
// do format the selection
(void) ::SendMessage(GetHwnd(), EM_GETPARAFORMAT, 0, (LPARAM) &pf) ;
- style.SetLeftIndent( (int) ((double) pf.dxStartIndent * twips2mm * 10.0) );
+ style.SetLeftIndent( (int) ((double) pf.dxStartIndent * twips2mm * 10.0), (int) ((double) pf.dxOffset * twips2mm * 10.0) );
style.SetRightIndent( (int) ((double) pf.dxRightIndent * twips2mm * 10.0) );
if (pf.wAlignment == PFA_CENTER)
size_t i;
for (i = 0; i < (size_t) pf.cTabCount; i++)
{
- tabStops[i] = (int) ((double) (pf.rgxTabs[i] & 0xFFFF) * twips2mm * 10.0) ;
+ tabStops.Add( (int) ((double) (pf.rgxTabs[i] & 0xFFFF) * twips2mm * 10.0) );
}
if ( changeSel )