41 #include <wx/dcclient.h>
42 #include <wx/txtstrm.h>
49 if (!event.GetSkipped())
52 if (event.Moving() || event.Dragging())
54 else if (event.LeftDown())
56 else if (event.LeftUp())
58 else if (event.LeftDClick())
68 int textX, textY, caretX, caretY;
72 panel->SetCursor(wxCursor(wxCURSOR_IBEAM));
77 panel->SetCursor(wxCursor(wxCURSOR_IBEAM));
88 if (!event.HasAnyModifiers())
89 context->SelectItem(0,
false,
false);
91 int textX, textY, caretX, caretY;
108 int textX, textY, caretX, caretY;
112 panel->
SetCaretPos(pos.x + caretX, pos.y + caretY);
118 static bool IsAlpha(
char ch)
120 return (ch >=
'0' && ch <=
'9') || (ch >=
'A' && ch <=
'Z') || (ch >=
'a' && ch <=
'z') || ch ==
'_';
129 wxClientDC dc(panel);
132 dc.GetCharHeight(),
context->GetIndentWidth(), event.m_x, event.m_y);
135 int textX, textY, caretX, caretY;
142 if (textX >= line.length())
143 textX =
static_cast<int>(line.length() - 1);
145 int selStart = textX, selEnd = textX + 1;
146 if (line[selStart] ==
' ') {
147 while (selStart > 0 && line[selStart - 1] ==
' ')
149 while (selEnd < line.length() && line[selEnd] ==
' ')
152 else if (IsAlpha(line[selStart])) {
153 while (selStart > 0 && IsAlpha(line[selStart - 1]))
155 while (selEnd < line.length() && IsAlpha(line[selEnd]))
164 dc.GetCharHeight(),
context->GetIndentWidth(),
169 panel->
SetCaretPos(pos.x + caretX, pos.y + caretY);
174 int& textX,
int& textY,
175 int& caretX,
int& caretY)
178 wxClientDC dc(textPanel);
181 dc.GetCharHeight(),
context->GetIndentWidth(), x, y);
186 dc.GetCharHeight(),
context->GetIndentWidth(),
203 CCopyText(wxTextOutputStream& os,
204 int startRow,
int startCol,
205 int endRow,
int endCol) :
207 m_StartRow(startRow), m_StartCol(startCol),
208 m_EndRow(endRow), m_EndCol(endCol), m_CurRow(0),
209 m_CurrentLineLength(0) {}
211 virtual StreamHint GetHint()
const {
return kCopyText; }
212 virtual wxTextOutputStream* GetTextStream()
const {
return &m_OS; }
213 virtual bool IsVisible()
const;
214 virtual void UpdatePosition(
int shift) { m_CurrentLineLength += shift; }
218 virtual int CurrentRowLength()
const {
return m_CurrentLineLength; }
221 virtual void SetDefaultStyle() {}
222 virtual void Indent (
size_t steps);
226 wxTextOutputStream& m_OS;
232 int m_CurrentLineLength;
235 bool CCopyText::IsVisible()
const
237 if (m_CurRow > m_StartRow && m_CurRow < m_EndRow)
240 if (m_CurRow == m_StartRow) {
241 if (m_CurrentLineLength < m_StartCol)
243 if (m_CurRow == m_EndRow)
244 return m_CurrentLineLength < m_EndCol;
248 if (m_CurRow == m_EndRow)
249 return m_CurrentLineLength < m_EndCol;
262 void CCopyText::NewLine()
264 if (m_CurRow >= m_StartRow && m_CurRow < m_EndRow)
268 m_CurrentLineLength = 0;
273 int length =
static_cast<int>(
text.length());
274 int selStart = length, selEnd = length;
276 if (m_CurRow == m_EndRow) {
278 selEnd = m_EndCol-m_CurrentLineLength;
280 if (m_CurRow == m_StartRow)
281 selStart = m_StartCol-m_CurrentLineLength;
283 if (m_CurRow > m_StartRow && m_CurRow < m_EndRow) {
288 if (selEnd < selStart)
289 swap(selStart, selEnd);
291 if (selStart < selEnd && selStart < length && selEnd > 0) {
292 selStart =
max(selStart, 0);
293 selEnd =
min(selEnd, length);
297 m_CurrentLineLength += length;
309 CCopyText ostream(os,
b.GetStart().GetRow(),
b.GetStart().GetCol(),
310 b.GetEnd().GetRow(),
b.GetEnd().GetCol());
static void Indent(FILE *output_stream, int indent_depth, const char *indent)
void GetCaretPos(int &caretPosX, int &caretPosY) const
void GetTextPos(int &textPosX, int &textPosY) const
void SelStart(int row, int col, bool shift)
CTextPanelContext * GetContext()
void SetCaretPos(int x, int y)
void SelMove(int row, int col)
void SelEnd(int row, int col)
virtual wxPoint GetPosition() const
virtual int GetStartLine() const
virtual void TextPosToExpanded(CTextPosition &WXUNUSED(pos), CTextPanelContext *WXUNUSED(context)) const
virtual void x_RenderText(CStyledTextOStream &WXUNUSED(ostream), CTextPanelContext *WXUNUSED(context)) const
virtual void MouseEvent(wxMouseEvent &event, CTextPanelContext &context)
virtual void GetText(wxTextOutputStream &os, const CTextBlock &block, CTextPanelContext *context)
virtual void x_CalcTextPos(CTextPanelContext *context, int x, int y, int &textX, int &textY, int &caretX, int &caretY)
void MouseMove(wxMouseEvent &event)
void MouseLeftUp(wxMouseEvent &event)
void MouseLeftDown(wxMouseEvent &event)
void MouseLeftDClick(wxMouseEvent &event)
virtual void MouseEvent(wxMouseEvent &event, CTextPanelContext &context)
CNcbiOstream & operator<<(CNcbiOstream &out, const CEquivRange &range)
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static void text(MDB_val *v)
static CS_CONTEXT * context
wxString ToWxString(const string &s)