]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/textentry.cpp
8b3a1291d5cd8569a0a0de410770787114e3de68
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/textentry.cpp
3 // Purpose: implementation of wxTextEntry for wxMotif
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
27 #include "wx/string.h"
28 #include "wx/window.h"
31 #include "wx/textentry.h"
34 #pragma message disable nosimpint
38 #pragma message enable nosimpint
41 // return the text widget casted to the correct type
42 #define GetText() ((Widget)this->GetTextWidget())
44 // ============================================================================
45 // wxTextEntry implementation
46 // ============================================================================
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 long wxTextEntry::GetMotifPos(long pos
) const
54 // in wx API position -1 means "last one" but for Motif position must be
55 // positive, i.e. it doesn't have this convention, so translate
56 return pos
== -1 ? GetLastPosition() : pos
;
59 // ----------------------------------------------------------------------------
60 // operations on control text
61 // ----------------------------------------------------------------------------
63 wxString
wxTextEntry::DoGetValue() const
67 char * const s
= XmTextGetString(GetText());
77 void wxTextEntry::WriteText(const wxString
& text
)
79 long pos
= GetInsertionPoint();
81 XmTextInsert(GetText(), pos
, text
.char_str());
85 XtVaSetValues(GetText(), XmNcursorPosition
, pos
, NULL
);
86 SetInsertionPoint(pos
);
87 XmTextShowPosition(GetText(), pos
);
90 void wxTextEntry::Replace(long from
, long to
, const wxString
& value
)
92 XmTextReplace(GetText(), from
, GetMotifPos(to
), value
.char_str());
95 void wxTextEntry::Remove(long from
, long to
)
97 SetSelection(from
, to
);
98 XmTextRemove(GetText());
101 // ----------------------------------------------------------------------------
102 // clipboard operations
103 // ----------------------------------------------------------------------------
105 void wxTextEntry::Copy()
107 XmTextCopy(GetText(), CurrentTime
);
110 void wxTextEntry::Cut()
112 XmTextCut(GetText(), CurrentTime
);
115 void wxTextEntry::Paste()
117 XmTextPaste(GetText());
120 // ----------------------------------------------------------------------------
121 // undo/redo (not implemented)
122 // ----------------------------------------------------------------------------
124 void wxTextEntry::Undo()
128 void wxTextEntry::Redo()
132 bool wxTextEntry::CanUndo() const
137 bool wxTextEntry::CanRedo() const
142 // ----------------------------------------------------------------------------
144 // ----------------------------------------------------------------------------
146 void wxTextEntry::SetInsertionPoint(long pos
)
148 XmTextSetInsertionPosition(GetText(), GetMotifPos(pos
));
151 long wxTextEntry::GetInsertionPoint() const
153 return XmTextGetInsertionPosition(GetText());
156 wxTextPos
wxTextEntry::GetLastPosition() const
158 return XmTextGetLastPosition(GetText());
161 // ----------------------------------------------------------------------------
163 // ----------------------------------------------------------------------------
165 void wxTextEntry::GetSelection(long* from
, long* to
) const
167 XmTextPosition left
, right
;
168 if ( !XmTextGetSelectionPosition(GetText(), &left
, &right
) )
170 // no selection, for compatibility with wxMSW return empty range at
173 right
= GetInsertionPoint();
182 void wxTextEntry::SetSelection(long from
, long to
)
184 XmTextSetSelection(GetText(), from
, GetMotifPos(to
), CurrentTime
);
188 // ----------------------------------------------------------------------------
190 // ----------------------------------------------------------------------------
192 bool wxTextEntry::IsEditable() const
194 return XmTextGetEditable(GetText()) != 0;
197 void wxTextEntry::SetEditable(bool editable
)
199 XmTextSetEditable(GetText(), (Boolean
) editable
);