Compare commits
117 Commits
CPPUNIT_1_
...
BEFORE_LIN
Author | SHA1 | Date | |
---|---|---|---|
|
f05fb3ea61 | ||
|
8c27f612e5 | ||
|
be18e65726 | ||
|
10644bd0bd | ||
|
528a112b2c | ||
|
20b45caa12 | ||
|
eafd9d4f24 | ||
|
6378b5268d | ||
|
17516c205e | ||
|
55b9ea2484 | ||
|
d96fbfa52a | ||
|
45911360b2 | ||
|
8637e11695 | ||
|
a00fd3e544 | ||
|
c0bd235861 | ||
|
a79c455963 | ||
|
8190b05419 | ||
|
472b41175a | ||
|
7ad39665fa | ||
|
409299535d | ||
|
99eb9f350e | ||
|
f6c8b8f53d | ||
|
9686c81605 | ||
|
36830fc59e | ||
|
d131b63b6d | ||
|
1f720ce54b | ||
|
f104f965eb | ||
|
d55d0aa0f5 | ||
|
bef37c03db | ||
|
e2f369c206 | ||
|
3b56ef075a | ||
|
85df8658e0 | ||
|
8ea58028dc | ||
|
facdb39467 | ||
|
7e29723b0f | ||
|
c80b9af4d7 | ||
|
6dbe10e7a6 | ||
|
649850e16c | ||
|
b16e3fb5e8 | ||
|
b7cdbb0e4c | ||
|
5abcba0bef | ||
|
a978bcef22 | ||
|
ca818da556 | ||
|
a3a13581dd | ||
|
943240b264 | ||
|
ea8259f286 | ||
|
b28342f733 | ||
|
62b93fefcf | ||
|
f03ccf7b5b | ||
|
8dd0bb9ab7 | ||
|
bf4014c8de | ||
|
3ab62a0f7f | ||
|
f0b67b1c57 | ||
|
db086a01fa | ||
|
dd27aca4ee | ||
|
b5366def43 | ||
|
025f9ba319 | ||
|
634b9eb4e4 | ||
|
c7a0b9e59e | ||
|
8c1e69867c | ||
|
e65ebedd36 | ||
|
ebd161b6c8 | ||
|
07e9834fca | ||
|
4c81b707a5 | ||
|
0ddd59282b | ||
|
6e6616f755 | ||
|
e45a8e8b4e | ||
|
35fd96a83a | ||
|
6e78473c26 | ||
|
1ca6cc68e0 | ||
|
5b1d0de44a | ||
|
bc2dad04e7 | ||
|
a02336b2bb | ||
|
0399bce91f | ||
|
f40a103306 | ||
|
a10069108f | ||
|
925f7f2250 | ||
|
e90a2986c7 | ||
|
d0b9653f6c | ||
|
f85b3ee981 | ||
|
8d400a3a23 | ||
|
4d437f4b2b | ||
|
afcd76dae8 | ||
|
7ba00152a6 | ||
|
5096d88d2f | ||
|
06be91840a | ||
|
2026a23167 | ||
|
e4ced7154b | ||
|
dac7332cc2 | ||
|
bd9218ba08 | ||
|
c21be757d6 | ||
|
90909d6032 | ||
|
e24eca174c | ||
|
1a1edfc0ca | ||
|
325443b96b | ||
|
a360b8503e | ||
|
89196a1dab | ||
|
46f2baf74e | ||
|
2c0eba5f88 | ||
|
efe51556de | ||
|
53cec79bbc | ||
|
bc60c3d699 | ||
|
ddee3ee64d | ||
|
8f2ea39e1d | ||
|
4dc12a1a28 | ||
|
3b2555e2d0 | ||
|
be1f93ab87 | ||
|
4d3c4c2f94 | ||
|
9df4cddfa8 | ||
|
255792efdb | ||
|
c9278366ee | ||
|
04e2f7e395 | ||
|
f84d752df6 | ||
|
eeb2c17a67 | ||
|
65ab4b2f93 | ||
|
38824a7bf7 | ||
|
d020d746c4 |
@@ -1,80 +0,0 @@
|
||||
dnl
|
||||
dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
||||
dnl
|
||||
AC_DEFUN(AM_PATH_CPPUNIT,
|
||||
[
|
||||
|
||||
AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)],
|
||||
cppunit_config_prefix="$withval", cppunit_config_prefix="")
|
||||
AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)],
|
||||
cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
|
||||
|
||||
if test x$cppunit_config_exec_prefix != x ; then
|
||||
cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
|
||||
if test x${CPPUNIT_CONFIG+set} != xset ; then
|
||||
CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
|
||||
fi
|
||||
fi
|
||||
if test x$cppunit_config_prefix != x ; then
|
||||
cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
|
||||
if test x${CPPUNIT_CONFIG+set} != xset ; then
|
||||
CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
|
||||
cppunit_version_min=$1
|
||||
|
||||
AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
|
||||
no_cppunit=""
|
||||
if test "$CPPUNIT_CONFIG" = "no" ; then
|
||||
no_cppunit=yes
|
||||
else
|
||||
CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags`
|
||||
CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
|
||||
cppunit_version=`$CPPUNIT_CONFIG --version`
|
||||
|
||||
cppunit_major_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
cppunit_minor_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
cppunit_micro_version=`echo $cppunit_version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
|
||||
cppunit_major_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
cppunit_minor_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
cppunit_micro_min=`echo $cppunit_version_min | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
|
||||
cppunit_version_proper=`expr \
|
||||
$cppunit_major_version \> $cppunit_major_min \| \
|
||||
$cppunit_major_version \= $cppunit_major_min \& \
|
||||
$cppunit_minor_version \> $cppunit_minor_min \| \
|
||||
$cppunit_major_version \= $cppunit_major_min \& \
|
||||
$cppunit_minor_version \= $cppunit_minor_min \& \
|
||||
$cppunit_micro_version \>= $cppunit_micro_min `
|
||||
|
||||
if test "$cppunit_version_proper" = "1" ; then
|
||||
AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
no_cppunit=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$no_cppunit" = x ; then
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
CPPUNIT_CFLAGS=""
|
||||
CPPUNIT_LIBS=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
|
||||
AC_SUBST(CPPUNIT_CFLAGS)
|
||||
AC_SUBST(CPPUNIT_LIBS)
|
||||
])
|
||||
|
||||
|
||||
|
514
include/wx/univ/textctrl.h
Normal file
514
include/wx/univ/textctrl.h
Normal file
@@ -0,0 +1,514 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/univ/textctrl.h
|
||||
// Purpose: wxTextCtrl class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 15.09.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIV_TEXTCTRL_H_
|
||||
#define _WX_UNIV_TEXTCTRL_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "univtextctrl.h"
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxCaret;
|
||||
class WXDLLEXPORT wxTextCtrlCommandProcessor;
|
||||
|
||||
#include "wx/scrolwin.h" // for wxScrollHelper
|
||||
|
||||
#include "wx/univ/inphand.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextCtrl actions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// cursor movement and also selection and delete operations
|
||||
#define wxACTION_TEXT_GOTO _T("goto") // to pos in numArg
|
||||
#define wxACTION_TEXT_FIRST _T("first") // go to pos 0
|
||||
#define wxACTION_TEXT_LAST _T("last") // go to last pos
|
||||
#define wxACTION_TEXT_HOME _T("home")
|
||||
#define wxACTION_TEXT_END _T("end")
|
||||
#define wxACTION_TEXT_LEFT _T("left")
|
||||
#define wxACTION_TEXT_RIGHT _T("right")
|
||||
#define wxACTION_TEXT_UP _T("up")
|
||||
#define wxACTION_TEXT_DOWN _T("down")
|
||||
#define wxACTION_TEXT_WORD_LEFT _T("wordleft")
|
||||
#define wxACTION_TEXT_WORD_RIGHT _T("wordright")
|
||||
#define wxACTION_TEXT_PAGE_UP _T("pageup")
|
||||
#define wxACTION_TEXT_PAGE_DOWN _T("pagedown")
|
||||
|
||||
// clipboard operations
|
||||
#define wxACTION_TEXT_COPY _T("copy")
|
||||
#define wxACTION_TEXT_CUT _T("cut")
|
||||
#define wxACTION_TEXT_PASTE _T("paste")
|
||||
|
||||
// insert text at the cursor position: the text is in strArg of PerformAction
|
||||
#define wxACTION_TEXT_INSERT _T("insert")
|
||||
|
||||
// if the action starts with either of these prefixes and the rest of the
|
||||
// string is one of the movement commands, it means to select/delete text from
|
||||
// the current cursor position to the new one
|
||||
#define wxACTION_TEXT_PREFIX_SEL _T("sel")
|
||||
#define wxACTION_TEXT_PREFIX_DEL _T("del")
|
||||
|
||||
// mouse selection
|
||||
#define wxACTION_TEXT_ANCHOR_SEL _T("anchorsel")
|
||||
#define wxACTION_TEXT_EXTEND_SEL _T("extendsel")
|
||||
#define wxACTION_TEXT_SEL_WORD _T("wordsel")
|
||||
#define wxACTION_TEXT_SEL_LINE _T("linesel")
|
||||
|
||||
// undo or redo
|
||||
#define wxACTION_TEXT_UNDO _T("undo")
|
||||
#define wxACTION_TEXT_REDO _T("redo")
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextCtrl types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// wxTextPos is the position in the text
|
||||
typedef long wxTextPos;
|
||||
|
||||
// wxTextCoord is the line or row number (which should have been unsigned but
|
||||
// is long for backwards compatibility)
|
||||
typedef long wxTextCoord;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextCtrl::HitTest return values
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the point asked is ...
|
||||
enum wxTextCtrlHitTestResult
|
||||
{
|
||||
wxTE_HT_BEFORE = -1, // either to the left or upper
|
||||
wxTE_HT_ON_TEXT, // directly on
|
||||
wxTE_HT_BELOW, // below [the last line]
|
||||
wxTE_HT_BEYOND // after [the end of line]
|
||||
};
|
||||
// ... the character returned
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase, public wxScrollHelper
|
||||
{
|
||||
public:
|
||||
// creation
|
||||
// --------
|
||||
|
||||
wxTextCtrl() { Init(); }
|
||||
|
||||
wxTextCtrl(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, id, value, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr);
|
||||
|
||||
virtual ~wxTextCtrl();
|
||||
|
||||
// implement base class pure virtuals
|
||||
// ----------------------------------
|
||||
|
||||
virtual wxString GetValue() const;
|
||||
virtual void SetValue(const wxString& value);
|
||||
|
||||
virtual int GetLineLength(wxTextCoord lineNo) const;
|
||||
virtual wxString GetLineText(wxTextCoord lineNo) const;
|
||||
virtual int GetNumberOfLines() const;
|
||||
|
||||
virtual bool IsModified() const;
|
||||
virtual bool IsEditable() const;
|
||||
|
||||
// If the return values from and to are the same, there is no selection.
|
||||
virtual void GetSelection(wxTextPos* from, wxTextPos* to) const;
|
||||
|
||||
// operations
|
||||
// ----------
|
||||
|
||||
// editing
|
||||
virtual void Clear();
|
||||
virtual void Replace(wxTextPos from, wxTextPos to, const wxString& value);
|
||||
virtual void Remove(wxTextPos from, wxTextPos to);
|
||||
|
||||
// clears the dirty flag
|
||||
virtual void DiscardEdits();
|
||||
|
||||
// writing text inserts it at the current position, appending always
|
||||
// inserts it at the end
|
||||
virtual void WriteText(const wxString& text);
|
||||
virtual void AppendText(const wxString& text);
|
||||
|
||||
// translate between the position (which is just an index in the text ctrl
|
||||
// considering all its contents as a single strings) and (x, y) coordinates
|
||||
// which represent (logical, i.e. unwrapped) column and line.
|
||||
virtual wxTextPos XYToPosition(wxTextCoord x, wxTextCoord y) const;
|
||||
virtual bool PositionToXY(wxTextPos pos,
|
||||
wxTextCoord *x, wxTextCoord *y) const;
|
||||
|
||||
// wxUniv-specific: find a screen position (in client coordinates) of the
|
||||
// given text position or of the caret
|
||||
bool PositionToLogicalXY(wxTextPos pos, wxCoord *x, wxCoord *y) const;
|
||||
bool PositionToDeviceXY(wxTextPos pos, wxCoord *x, wxCoord *y) const;
|
||||
wxPoint GetCaretPosition() const;
|
||||
|
||||
virtual void ShowPosition(wxTextPos pos);
|
||||
|
||||
// Clipboard operations
|
||||
virtual void Copy();
|
||||
virtual void Cut();
|
||||
virtual void Paste();
|
||||
|
||||
// Undo/redo
|
||||
virtual void Undo();
|
||||
virtual void Redo();
|
||||
|
||||
virtual bool CanUndo() const;
|
||||
virtual bool CanRedo() const;
|
||||
|
||||
// Insertion point
|
||||
virtual void SetInsertionPoint(wxTextPos pos);
|
||||
virtual void SetInsertionPointEnd();
|
||||
virtual wxTextPos GetInsertionPoint() const;
|
||||
virtual wxTextPos GetLastPosition() const;
|
||||
|
||||
virtual void SetSelection(wxTextPos from, wxTextPos to);
|
||||
virtual void SetEditable(bool editable);
|
||||
|
||||
// wxUniv-specific methods
|
||||
// -----------------------
|
||||
|
||||
// caret stuff
|
||||
virtual void ShowCaret(bool show = TRUE);
|
||||
void HideCaret() { ShowCaret(FALSE); }
|
||||
void CreateCaret(); // for the current font size
|
||||
|
||||
// helpers for cursor movement
|
||||
wxTextPos GetWordStart() const;
|
||||
wxTextPos GetWordEnd() const;
|
||||
|
||||
// selection helpers
|
||||
bool HasSelection() const
|
||||
{ return m_selStart != -1 && m_selEnd > m_selStart; }
|
||||
void ClearSelection();
|
||||
void RemoveSelection();
|
||||
wxString GetSelectionText() const;
|
||||
|
||||
// find the character at this position, return 0 if the character is
|
||||
// really there, -1 if the point is before the beginning of the text/line
|
||||
// and the returned character is the first one to follow it or +1 if it the
|
||||
// position is beyond the end of line/text and the returned character is
|
||||
// the last one
|
||||
//
|
||||
// NB: pt is in device coords (not adjusted for the client area origin nor
|
||||
// for the scrolling)
|
||||
wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
|
||||
wxTextCoord *col, wxTextCoord *row) const;
|
||||
|
||||
// find the character at this position in the given line, return value as
|
||||
// for HitTest()
|
||||
//
|
||||
// NB: x is the logical coord (client and unscrolled)
|
||||
wxTextCtrlHitTestResult HitTestLine(const wxString& line,
|
||||
wxCoord x,
|
||||
wxTextCoord *colOut) const;
|
||||
|
||||
// bring the given position into view
|
||||
void ShowHorzPosition(wxCoord pos);
|
||||
|
||||
// scroll the window horizontally so that the first character shown is in
|
||||
// position pos
|
||||
void ScrollText(wxTextCoord col);
|
||||
|
||||
// adjust the DC for horz text control scrolling too
|
||||
virtual void DoPrepareDC(wxDC& dc);
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// override this to take into account our scrollbar-less scrolling
|
||||
virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
|
||||
|
||||
// set the right colours and border
|
||||
virtual bool IsContainerWindow() const { return TRUE; }
|
||||
virtual wxBorder GetDefaultBorder() const { return wxBORDER_SUNKEN; }
|
||||
|
||||
// perform an action
|
||||
virtual bool PerformAction(const wxControlAction& action,
|
||||
long numArg = -1,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
|
||||
// override these methods to handle the caret
|
||||
virtual bool SetFont(const wxFont &font);
|
||||
virtual bool Enable(bool enable = TRUE);
|
||||
|
||||
protected:
|
||||
// draw the text
|
||||
void DrawTextLine(wxDC& dc, const wxRect& rect,
|
||||
const wxString& text,
|
||||
wxTextPos selStart, wxTextPos selEnd);
|
||||
|
||||
void DoDrawTextInRect(wxDC& dc, const wxRect& rectUpdate);
|
||||
|
||||
// override base class methods
|
||||
virtual void DoDrawBorder(wxDC& dc, const wxRect& rect);
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
// calc the size from the text extent
|
||||
virtual wxSize DoGetBestClientSize() const;
|
||||
|
||||
// input support
|
||||
virtual wxString GetInputHandlerType() const;
|
||||
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// more readable flag testing methods
|
||||
bool IsSingleLine() const { return !(GetWindowStyle() & wxTE_MULTILINE); }
|
||||
bool IsPassword() const { return (GetWindowStyle() & wxTE_PASSWORD) != 0; }
|
||||
bool WrapLines() const
|
||||
{ return !IsSingleLine() && !(GetWindowStyle() & wxHSCROLL); }
|
||||
|
||||
// get the extent (width) of the text
|
||||
wxCoord GetTextWidth(const wxString& text) const;
|
||||
|
||||
// get the logical text width (accounting for scrolling)
|
||||
wxCoord GetTotalWidth() const;
|
||||
|
||||
// find the number of rows in this line (only if WrapLines())
|
||||
wxTextCoord GetRowsPerLine(wxTextCoord line) const;
|
||||
|
||||
// get total number of rows before the given line
|
||||
wxTextCoord GetNumberOfRowsBefore(wxTextCoord line) const;
|
||||
|
||||
// the text area is the part of the window in which the text can be
|
||||
// displayed, i.e. part of it inside the margins and the real text area is
|
||||
// the area in which the text *is* currently displayed: for example, in the
|
||||
// multiline control case the text area can have extra space at the bottom
|
||||
// which is not tall enough for another line and which is then not included
|
||||
// into the real text area
|
||||
wxRect GetRealTextArea() const;
|
||||
|
||||
// refresh the text in the given (in logical coords) rect
|
||||
void RefreshTextRect(const wxRect& rect);
|
||||
|
||||
// refresh the text in the given range (in logical coords) of this line, if
|
||||
// width is 0, refresh to the end of line
|
||||
void RefreshPixelRange(wxTextCoord line, wxCoord start, wxCoord width);
|
||||
|
||||
// refresh the text in the given range (in text coords) in this line
|
||||
void RefreshColRange(wxTextCoord line, wxTextPos start, size_t count);
|
||||
|
||||
// refresh the text from in the given line range (inclusive)
|
||||
void RefreshLineRange(wxTextCoord lineFirst, wxTextCoord lineLast);
|
||||
|
||||
// refresh the text in the given range which can span multiple lines
|
||||
// (this method accepts arguments in any order)
|
||||
void RefreshTextRange(wxTextPos start, wxTextPos end);
|
||||
|
||||
// get the text to show: either the text itself or the text replaced with
|
||||
// starts for wxTE_PASSWORD control
|
||||
wxString GetTextToShow(const wxString& text) const;
|
||||
|
||||
// find the number of characters of a line before it wraps
|
||||
// (and optionally also the real width of the line)
|
||||
size_t GetPartOfWrappedLine(const wxChar* text,
|
||||
wxCoord *widthReal = NULL) const;
|
||||
|
||||
// get the start and end of the selection for this line: if the line is
|
||||
// outside the selection, both will be -1 and FALSE will be returned
|
||||
bool GetSelectedPartOfLine(wxTextCoord line,
|
||||
wxTextPos *start, wxTextPos *end) const;
|
||||
|
||||
// update the text rect: the zone inside our client rect (its coords are
|
||||
// client coords) which contains the text
|
||||
void UpdateTextRect();
|
||||
|
||||
// calculate the last visible position
|
||||
void UpdateLastVisible();
|
||||
|
||||
// move caret to the given position unconditionally
|
||||
// (SetInsertionPoint() does nothing if the position didn't change)
|
||||
void DoSetInsertionPoint(wxTextPos pos);
|
||||
|
||||
// set the caret to its initial (default) position
|
||||
void InitInsertionPoint();
|
||||
|
||||
// get the width of the longest line in pixels
|
||||
wxCoord GetMaxWidth() const;
|
||||
|
||||
// force recalculation of the max line width
|
||||
void RecalcMaxWidth();
|
||||
|
||||
// update the max width after the given line was modified
|
||||
void UpdateMaxWidth(wxTextCoord line);
|
||||
|
||||
// HitTest2() is more efficient than 2 consecutive HitTest()s with the same
|
||||
// line (i.e. y) and it also returns the offset of the starting position in
|
||||
// pixels
|
||||
//
|
||||
// as the last hack, this function accepts either logical or device (by
|
||||
// default) coords depending on devCoords flag
|
||||
wxTextCtrlHitTestResult HitTest2(wxCoord y,
|
||||
wxCoord x1,
|
||||
wxCoord x2,
|
||||
wxTextCoord *row,
|
||||
wxTextCoord *colStart,
|
||||
wxTextCoord *colEnd,
|
||||
wxTextCoord *colRowStart,
|
||||
bool devCoords = TRUE) const;
|
||||
|
||||
// HitTest() version which takes the logical text coordinates and not the
|
||||
// device ones
|
||||
wxTextCtrlHitTestResult HitTestLogical(const wxPoint& pos,
|
||||
wxTextCoord *col,
|
||||
wxTextCoord *row) const;
|
||||
|
||||
// get the height of one line (the same for all lines)
|
||||
wxCoord GetLineHeight() const
|
||||
{
|
||||
// this one should be already precalculated
|
||||
wxASSERT_MSG( m_heightLine != -1, _T("should have line height") );
|
||||
|
||||
return m_heightLine;
|
||||
}
|
||||
|
||||
// get the average char width
|
||||
wxCoord GetAverageWidth() const { return m_widthAvg; }
|
||||
|
||||
// recalc the line height and char width (to call when the font changes)
|
||||
void RecalcFontMetrics();
|
||||
|
||||
// event handlers
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
|
||||
// return the struct containing control-type dependent data
|
||||
struct wxTextSingleLineData& SData() { return *m_data.sdata; }
|
||||
struct wxTextMultiLineData& MData() { return *m_data.mdata; }
|
||||
const wxTextSingleLineData& SData() const { return *m_data.sdata; }
|
||||
const wxTextMultiLineData& MData() const { return *m_data.mdata; }
|
||||
|
||||
// accessors for derived classes (SL stands for single line)
|
||||
const wxString& GetSLValue() const
|
||||
{
|
||||
wxASSERT_MSG( IsSingleLine(), _T("only for single line controls") );
|
||||
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void SetSLValue(const wxString& value)
|
||||
{
|
||||
wxASSERT_MSG( IsSingleLine(), _T("only for single line controls") );
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
// clipboard operations (unlike the versions without Do prefix, they have a
|
||||
// return code)
|
||||
bool DoCut();
|
||||
bool DoPaste();
|
||||
|
||||
private:
|
||||
// update the scrollbars (only called from OnIdle)
|
||||
void UpdateScrollbars();
|
||||
|
||||
// the initially specified control size
|
||||
wxSize m_sizeInitial;
|
||||
|
||||
// the control text (only used for single line controls)
|
||||
wxString m_value;
|
||||
|
||||
// current position
|
||||
wxTextPos m_curPos;
|
||||
wxTextCoord m_curCol,
|
||||
m_curRow;
|
||||
|
||||
// last position (only used by GetLastPosition())
|
||||
wxTextPos m_posLast;
|
||||
|
||||
// selection
|
||||
wxTextPos m_selAnchor,
|
||||
m_selStart,
|
||||
m_selEnd;
|
||||
|
||||
// flags
|
||||
bool m_isModified:1,
|
||||
m_isEditable:1,
|
||||
m_hasCaret:1;
|
||||
|
||||
// the rectangle (in client coordinates) to draw text inside
|
||||
wxRect m_rectText;
|
||||
|
||||
// the height of one line (cached value of GetCharHeight)
|
||||
wxCoord m_heightLine;
|
||||
|
||||
// and the average char width (cached value of GetCharWidth)
|
||||
wxCoord m_widthAvg;
|
||||
|
||||
// we have some data which depends on the kind of control (single or multi
|
||||
// line)
|
||||
union
|
||||
{
|
||||
wxTextSingleLineData *sdata;
|
||||
wxTextMultiLineData *mdata;
|
||||
void *data;
|
||||
} m_data;
|
||||
|
||||
// the object to which we delegate our undo/redo implementation
|
||||
wxTextCtrlCommandProcessor *m_cmdProcessor;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStdTextCtrlInputHandler: this control handles only the mouse/kbd actions
|
||||
// common to Win32 and GTK, platform-specific things are implemented elsewhere
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxStdTextCtrlInputHandler : public wxStdInputHandler
|
||||
{
|
||||
public:
|
||||
wxStdTextCtrlInputHandler(wxInputHandler *inphand);
|
||||
|
||||
virtual bool HandleKey(wxControl *control,
|
||||
const wxKeyEvent& event,
|
||||
bool pressed);
|
||||
virtual bool HandleMouse(wxControl *control,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleMouseMove(wxControl *control,
|
||||
const wxMouseEvent& event);
|
||||
virtual bool HandleFocus(wxControl *control, const wxFocusEvent& event);
|
||||
|
||||
protected:
|
||||
// get the position of the mouse click
|
||||
static wxTextPos HitTest(const wxTextCtrl *text, const wxPoint& pos);
|
||||
|
||||
// capture data
|
||||
wxTextCtrl *m_winCapture;
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_TEXTCTRL_H_
|
||||
|
3881
src/univ/textctrl.cpp
Normal file
3881
src/univ/textctrl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user