#include "wx/menu.h"
#include "wx/math.h"
#include "wx/module.h"
+ #include "wx/wxcrtvararg.h"
#endif
#include "wx/sysopt.h"
delete m_privateContextMenu;
}
-bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
+bool wxTextCtrl::Create(wxWindow *parent,
+ wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return false;
+ if ( !MSWCreateText(value, pos, size) )
+ return false;
+
+ return true;
+}
+
+bool wxTextCtrl::MSWCreateText(const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size)
+{
// translate wxWin style flags to MSW ones
WXDWORD msStyle = MSWGetCreateWindowFlags();
#if defined(__POCKETPC__) || defined(__SMARTPHONE__)
// A control that capitalizes the first letter
- if (style & wxTE_CAPITALIZE)
+ if ( HasFlag(wxTE_CAPITALIZE) )
windowClass = wxT("CAPEDIT");
#endif
// Windows XP, so if we're sure it works correctly under other
// systems we could do this only for XP
SetSize(-1, 1); // 1 is small enough to force vert scrollbar
- SetSize(size);
+ SetInitialSize(size);
}
else if ( m_windowStyle & wxTE_AUTO_URL )
{
void wxTextCtrl::SetWindowStyleFlag(long style)
{
+ // changing the alignment of the control dynamically works under Win2003
+ // (but not older Windows version: it seems to work under some versions of
+ // XP but not other ones, and we have no way to determine it so be
+ // conservative here) and only for plain EDIT controls (not RICH ones) and
+ // we have to recreate the control to make it always work
+ if ( IsRich() || wxGetWinVersion() < wxWinVersion_2003 )
+ {
+ const long alignMask = wxTE_LEFT | wxTE_CENTRE | wxTE_RIGHT;
+ if ( (style & alignMask) != (GetWindowStyle() & alignMask) )
+ {
+ const wxString value = GetValue();
+ const wxPoint pos = GetPosition();
+ const wxSize size = GetSize();
+
+ // delete the old window
+ HWND hwnd = GetHwnd();
+ DissociateHandle();
+ ::DestroyWindow(hwnd);
+
+ // create the new one with the updated flags
+ m_windowStyle = style;
+ MSWCreateText(value, pos, size);
+
+ // and make sure it has the same attributes as before
+ if ( m_hasFont )
+ {
+ // calling SetFont(m_font) would do nothing as the code would
+ // notice that the font didn't change, so force it to believe
+ // that it did
+ wxFont font = m_font;
+ m_font = wxNullFont;
+ SetFont(font);
+ }
+
+ if ( m_hasFgCol )
+ {
+ wxColour colFg = m_foregroundColour;
+ m_foregroundColour = wxNullColour;
+ SetForegroundColour(colFg);
+ }
+
+ if ( m_hasBgCol )
+ {
+ wxColour colBg = m_backgroundColour;
+ m_backgroundColour = wxNullColour;
+ SetBackgroundColour(colBg);
+ }
+
+ // note that text styles are lost but this is probably not a big
+ // problem: if you use styles, you probably don't use nor change
+ // alignment flags anyhow
+
+ return;
+ }
+ }
+
#if wxUSE_RICHEDIT
// we have to deal with some styles separately because they can't be
// changed by simply calling SetWindowLong(GWL_STYLE) but can be changed
::SendMessage(GetHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
// EM_REPLACESEL takes 1 to indicate the operation should be redoable
- selectionOnly ? 1 : 0, (LPARAM)valueDos.c_str());
+ selectionOnly ? 1 : 0, (LPARAM)valueDos.wx_str());
if ( !ucf.GotUpdate() && (flags & SetValue_SendEvent) )
{