// event tables and other macros
// ----------------------------------------------------------------------------
-#if wxUSE_EXTENDED_RTTI
-WX_DEFINE_FLAGS( wxTextCtrlStyle )
-
-wxBEGIN_FLAGS( wxTextCtrlStyle )
- // new style border flags, we put them first to
- // use them for streaming out
- wxFLAGS_MEMBER(wxBORDER_SIMPLE)
- wxFLAGS_MEMBER(wxBORDER_SUNKEN)
- wxFLAGS_MEMBER(wxBORDER_DOUBLE)
- wxFLAGS_MEMBER(wxBORDER_RAISED)
- wxFLAGS_MEMBER(wxBORDER_STATIC)
- wxFLAGS_MEMBER(wxBORDER_NONE)
-
- // old style border flags
- wxFLAGS_MEMBER(wxSIMPLE_BORDER)
- wxFLAGS_MEMBER(wxSUNKEN_BORDER)
- wxFLAGS_MEMBER(wxDOUBLE_BORDER)
- wxFLAGS_MEMBER(wxRAISED_BORDER)
- wxFLAGS_MEMBER(wxSTATIC_BORDER)
- wxFLAGS_MEMBER(wxBORDER)
-
- // standard window styles
- wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
- wxFLAGS_MEMBER(wxCLIP_CHILDREN)
- wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
- wxFLAGS_MEMBER(wxWANTS_CHARS)
- wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
- wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
- wxFLAGS_MEMBER(wxVSCROLL)
- wxFLAGS_MEMBER(wxHSCROLL)
-
- wxFLAGS_MEMBER(wxTE_PROCESS_ENTER)
- wxFLAGS_MEMBER(wxTE_PROCESS_TAB)
- wxFLAGS_MEMBER(wxTE_MULTILINE)
- wxFLAGS_MEMBER(wxTE_PASSWORD)
- wxFLAGS_MEMBER(wxTE_READONLY)
- wxFLAGS_MEMBER(wxHSCROLL)
- wxFLAGS_MEMBER(wxTE_RICH)
- wxFLAGS_MEMBER(wxTE_RICH2)
- wxFLAGS_MEMBER(wxTE_AUTO_URL)
- wxFLAGS_MEMBER(wxTE_NOHIDESEL)
- wxFLAGS_MEMBER(wxTE_LEFT)
- wxFLAGS_MEMBER(wxTE_CENTRE)
- wxFLAGS_MEMBER(wxTE_RIGHT)
- wxFLAGS_MEMBER(wxTE_DONTWRAP)
- wxFLAGS_MEMBER(wxTE_CHARWRAP)
- wxFLAGS_MEMBER(wxTE_WORDWRAP)
-
-wxEND_FLAGS( wxTextCtrlStyle )
-
-IMPLEMENT_DYNAMIC_CLASS_XTI(wxTextCtrl, wxControl,"wx/textctrl.h")
-
-wxBEGIN_PROPERTIES_TABLE(wxTextCtrl)
- wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent )
- wxEVENT_PROPERTY( TextEnter , wxEVT_COMMAND_TEXT_ENTER , wxCommandEvent )
-
- 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 , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
-wxEND_PROPERTIES_TABLE()
-
-wxBEGIN_HANDLERS_TABLE(wxTextCtrl)
-wxEND_HANDLERS_TABLE()
-
-wxCONSTRUCTOR_6( wxTextCtrl , wxWindow* , Parent , wxWindowID , Id , wxString , Value , wxPoint , Position , wxSize , Size , long , WindowStyle)
-#else
-IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
-#endif
-
-
BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
EVT_CHAR(wxTextCtrl::OnChar)
EVT_KEY_DOWN(wxTextCtrl::OnKeyDown)
if ( !wxTextCtrlBase::SetFont(font) )
return false;
- if ( IsRich() )
+ if ( GetRichVersion() >= 4 )
{
- // Using WM_SETFONT doesn't work reliably with rich edit controls: as
- // an example, if we set a fixed width font for a richedit 4.1 control,
- // it's used for the ASCII characters but inserting any non-ASCII ones
- // switches the font to a proportional one, whether it's done
- // programmatically or not. So just use EM_SETCHARFORMAT for this too.
+ // Using WM_SETFONT is not enough with RichEdit 4.1: it does work but
+ // for ASCII characters only and inserting a non-ASCII one into it
+ // later reverts to the default font so use EM_SETCHARFORMAT to change
+ // the default font for it.
wxTextAttr attr;
attr.SetFont(font);
- SetDefaultStyle(attr);
+ SetStyle(-1, -1, attr);
}
return true;
}
#endif // wxUSE_RICHEDIT2
- // Apply the style to the selection.
- DoSetSelection(start, end, SetSel_NoScroll);
+ // Apply the style either to the selection or to the entire control.
+ WPARAM selMode;
+ if ( start != -1 || end != -1 )
+ {
+ DoSetSelection(start, end, SetSel_NoScroll);
+ selMode = SCF_SELECTION;
+ }
+ else
+ {
+ selMode = SCF_ALL;
+ }
- if ( !::SendMessage(GetHwnd(), EM_SETCHARFORMAT,
- SCF_SELECTION, (LPARAM)&cf) )
+ if ( !::SendMessage(GetHwnd(), EM_SETCHARFORMAT, selMode, (LPARAM)&cf) )
{
wxLogLastError(wxT("SendMessage(EM_SETCHARFORMAT)"));
return false;