///////////////////////////////////////////////////////////////////////////////
// Name: src/msw/wince/textctrlce.cpp
-// Purpose: wxTextCtrl implementation for Smartphones
+// Purpose: wxTextCtrl implementation for smart phones driven by WinCE
// Author: Wlodzimierz ABX Skiba
// Modified by:
// Created: 30.08.2004
// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-
// ============================================================================
// declarations
// ============================================================================
// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "textctrlce.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#pragma hdrstop
#endif
+#if wxUSE_TEXTCTRL && defined(__SMARTPHONE__) && defined(__WXWINCE__)
+
+#include "wx/textctrl.h"
+
#ifndef WX_PRECOMP
- #include "wx/textctrl.h"
+ #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
#endif
#include "wx/spinbutt.h"
#include "wx/textfile.h"
-#include <commctrl.h>
-#include "wx/msw/missing.h"
-#include "wx/msw/winundef.h"
-
-#if wxUSE_TEXTCTRL && defined(__SMARTPHONE__)
-
#define GetBuddyHwnd() (HWND)(m_hwndBuddy)
#define IsVertical(wxStyle) (true)
WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
wxSize sizeText(size), sizeBtn(size);
- sizeBtn.x = GetBestSpinerSize(IsVertical(style)).x / 2;
+ sizeBtn.x = GetBestSpinnerSize(IsVertical(style)).x / 2;
if ( sizeText.x == wxDefaultCoord )
{
WXDWORD spiner_style = WS_VISIBLE |
UDS_ALIGNRIGHT |
UDS_EXPANDABLE |
- UDS_NOSCROLL;
+ UDS_NOSCROLL;
if ( !IsVertical(style) )
spiner_style |= UDS_HORZ;
sizeText.y = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
}
- SetBestSize(size);
+ SetInitialSize(size);
(void)::ShowWindow(GetBuddyHwnd(), SW_SHOW);
return str;
}
-void wxTextCtrl::SetValue(const wxString& value)
+void wxTextCtrl::DoSetValue(const wxString& value, int flags)
{
// if the text is long enough, it's faster to just set it instead of first
// comparing it with the old one (chances are that it will be different
// edit controls mostly)
if ( (value.length() > 0x400) || (value != GetValue()) )
{
- DoWriteText(value, false);
-
+ DoWriteText(value, flags);
+
// for compatibility, don't move the cursor when doing SetValue()
SetInsertionPoint(0);
}
else // same text
{
// still send an event for consistency
- SendUpdateEvent();
+ if ( flags & SetValue_SendEvent )
+ SendUpdateEvent();
}
// we should reset the modified flag even if the value didn't really change
DoWriteText(value);
}
-void wxTextCtrl::DoWriteText(const wxString& value, bool selectionOnly)
+void wxTextCtrl::DoWriteText(const wxString& value, int flags)
{
+ bool selectionOnly = (flags & SetValue_SelectionOnly) != 0;
wxString valueDos;
if ( m_windowStyle & wxTE_MULTILINE )
valueDos = wxTextFile::Translate(value, wxTextFileType_Dos);
// call below which is confusing for the client code and so should be
// avoided
//
- if ( ( selectionOnly && HasSelection() ) )
+ if ( selectionOnly && HasSelection() )
{
m_suppressNextUpdate = true;
}
::SendMessage(GetBuddyHwnd(), selectionOnly ? EM_REPLACESEL : WM_SETTEXT,
0, (LPARAM)valueDos.c_str());
- if ( !selectionOnly )
+ if ( !selectionOnly && !( flags & SetValue_SendEvent ) )
{
// Windows already sends an update event for single-line
// controls.
void wxTextCtrl::SetEditable(bool editable)
{
- SendMessage(GetBuddyHwnd(), EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
+ ::SendMessage(GetBuddyHwnd(), EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
}
void wxTextCtrl::SetInsertionPoint(long pos)
return Pos & 0xFFFF;
}
-long wxTextCtrl::GetLastPosition() const
+wxTextPos wxTextCtrl::GetLastPosition() const
{
int numLines = GetNumberOfLines();
long posStartLastLine = XYToPosition(0, numLines - 1);
// Set selection and remove it
DoSetSelection(from, to, false);
- DoWriteText(value, true);
+ DoWriteText(value, SetValue_SelectionOnly);
}
void wxTextCtrl::Remove(long from, long to)
// double check that we really are where it pretends
POINTL ptReal;
- LRESULT lRc = SendMessage(GetBuddyHwnd(), EM_POSFROMCHAR, pos, 0);
+ LRESULT lRc = ::SendMessage(GetBuddyHwnd(), EM_POSFROMCHAR, pos, 0);
- if ( lRc == -1 )
+ if ( lRc == -1 )
{
// this is apparently returned when pos corresponds to the last
// position
int linesToScroll = specifiedLineLineNo - currentLineLineNo;
if (linesToScroll != 0)
- (void)::SendMessage(GetBuddyHwnd(), EM_LINESCROLL, 0, (LPARAM)linesToScroll);
+ (void)::SendMessage(GetBuddyHwnd(), EM_LINESCROLL, 0, (LPARAM)linesToScroll);
}
long wxTextCtrl::GetLengthOfLineContainingPos(long pos) const
return true;
}
-WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED(nCtlColor),
-#if wxUSE_CTL3D
- WXUINT message,
- WXWPARAM wParam,
- WXLPARAM lParam
-#else
- WXUINT WXUNUSED(message),
- WXWPARAM WXUNUSED(wParam),
- WXLPARAM WXUNUSED(lParam)
-#endif
- )
-{
-#if wxUSE_CTL3D
- if ( m_useCtl3D )
- {
- HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
- return (WXHBRUSH) hbrush;
- }
-#endif // wxUSE_CTL3D
-
- HDC hdc = (HDC)pDC;
- wxColour colBack = GetBackgroundColour();
-
- if (!IsEnabled() && (GetWindowStyle() & wxTE_MULTILINE) == 0)
- colBack = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
-
- ::SetBkColor(hdc, wxColourToRGB(colBack));
- ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
-
- wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
-
- return (WXHBRUSH)brush->GetResourceHandle();
-}
-
bool wxTextCtrl::AdjustSpaceLimit()
{
unsigned int limit = ::SendMessage(GetBuddyHwnd(), EM_GETLIMITTEXT, 0, 0);
void wxTextCtrl::DoMoveWindow(int x, int y, int width, int height)
{
- int widthBtn = GetBestSpinerSize(IsVertical(GetWindowStyle())).x / 2;
+ int widthBtn = GetBestSpinnerSize(IsVertical(GetWindowStyle())).x / 2;
int widthText = width - widthBtn - MARGIN_BETWEEN;
if ( widthText <= 0 )
{
}
}
-#endif // wxUSE_TEXTCTRL && __SMARTPHONE__
+#endif // wxUSE_TEXTCTRL && __SMARTPHONE__ && __WXWINCE__