46 #include <private/qmacinputcontext_p.h> 49 #include <private/qapplication_p.h> 50 #include <private/qkeymapper_p.h> 56 #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5) 57 # define typeRefCon typeSInt32 58 # define typeByteCount typeSInt32 62 :
QInputContext(parent), composing(false), recursionGuard(false), textDocument(0),
63 keydownEvent(0), lastFocusWid(0)
70 #ifndef QT_MAC_USE_COCOA 79 #ifndef QT_MAC_USE_COCOA 81 InterfaceTypeList itl = { kUnicodeDocument };
96 #ifndef QT_MAC_USE_COCOA 111 #if !defined QT_MAC_USE_COCOA 149 #ifndef QT_MAC_USE_COCOA 159 #ifndef QT_MAC_USE_COCOA 161 { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
162 { kEventClassTextInput, kEventTextInputOffsetToPos },
163 { kEventClassTextInput, kEventTextInputUpdateActiveInputArea }
172 #ifndef QT_MAC_USE_COCOA 185 #ifndef QT_MAC_USE_COCOA 204 ReleaseEvent(tmpEvent);
210 #ifndef QT_MAC_USE_COCOA 214 GetEventParameter(event, kEventParamTextInputSendRefCon, typeRefCon, 0,
215 sizeof(refcon), 0, &refcon);
218 bool handled_event=
true;
219 UInt32 ekind = GetEventKind(event), eclass = GetEventClass(event);
221 case kEventClassTextInput: {
222 handled_event =
false;
224 bool canCompose = widget && (!context || widget->
inputContext() == context)
229 handled_event =
false;
230 }
else if(ekind == kEventTextInputOffsetToPos) {
232 handled_event =
false;
240 pt.v = mp.y() + mr.height();
241 SetEventParameter(event, kEventParamTextInputReplyPoint, typeQDPoint,
243 handled_event =
true;
244 }
else if(ekind == kEventTextInputUpdateActiveInputArea) {
246 handled_event =
false;
253 ByteCount unilen = 0;
254 GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
256 UniChar *unicode = (UniChar*)NewPtr(unilen);
257 GetEventParameter(event, kEventParamTextInputSendText, typeUnicodeText,
258 0, unilen, 0, unicode);
260 DisposePtr((
char*)unicode);
262 ByteCount fixed_length = 0;
263 GetEventParameter(event, kEventParamTextInputSendFixLen, typeByteCount, 0,
264 sizeof(fixed_length), 0, &fixed_length);
265 if(fixed_length == ULONG_MAX || fixed_length == unilen) {
270 handled_event =
true;
273 ByteCount rngSize = 0;
274 OSStatus err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
278 err = GetEventParameter(event, kEventParamTextInputSendHiliteRng, typeTextRangeArray, 0,
279 rngSize, &rngSize, highlight.
data());
282 if(fixed_length > 0) {
283 const int qFixedLength = fixed_length /
sizeof(UniChar);
286 qFixedLength, text.
length()-qFixedLength,
290 e.setCommitString(text.
left(qFixedLength), 0, qFixedLength);
292 handled_event =
true;
306 #ifndef kConvertedText 307 #define kConvertedText 4 309 #ifndef kCaretPosition 310 #define kCaretPosition 1 314 TextRangeArray *
data = highlight.
data();
315 for (
int i = 0; i < data->fNumOfRanges; ++i) {
316 int start = data->fRange[i].fStart /
sizeof(UniChar);
317 int len = (data->fRange[i].fEnd - data->fRange[i].fStart) /
sizeof(UniChar);
337 handled_event =
true;
342 handled_event =
false;
346 qt_mac_eat_unicode_key = handled_event;
347 }
else if(ekind == kEventTextInputUnicodeForKeyEvent) {
349 GetEventParameter(event, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0,
350 sizeof(key_ev), 0, &key_ev);
352 ByteCount unilen = 0;
353 if(GetEventParameter(key_ev, kEventParamKeyUnicodes, typeUnicodeText, 0, 0, &unilen, 0) == noErr) {
354 UniChar *unicode = (UniChar*)NewPtr(unilen);
355 GetEventParameter(key_ev, kEventParamKeyUnicodes, typeUnicodeText, 0, unilen, 0, unicode);
356 text =
QString((
QChar*)unicode, unilen /
sizeof(UniChar));
357 DisposePtr((
char*)unicode);
359 unsigned char chr = 0;
360 GetEventParameter(key_ev, kEventParamKeyMacCharCodes, typeChar, 0,
sizeof(chr), 0, &chr);
375 return eventNotHandledErr;
The QVariant class acts like a union for the most common Qt data types.
virtual bool isComposing() const
This function indicates whether InputMethodStart event had been sent to the current focus widget...
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
virtual ~QMacInputContext()
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
const QChar at(int i) const
Returns the character at the given index position in the string.
void createTextDocument()
TSMDocumentID textDocument
int length() const
Returns the number of characters in this string.
static QApplicationPrivate * instance()
QWidget * focusWidget() const
Returns the widget that has an input focus for this input context.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
The QChar class provides a 16-bit Unicode character.
bool qt_mac_eat_unicode_key
static QWidget * focus_widget
QMacInputContext(QObject *parent=0)
virtual void reset()
This function can be reimplemented in a subclass to reset the state of the input method.
#define QT_BEGIN_NAMESPACE
This macro expands to.
static EventTypeSpec input_events[]
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
static EventHandlerRef input_proc_handler
The QTextFormat class provides formatting information for a QTextDocument.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *)
static const char * data(const QByteArray &arr)
void setUnderlineColor(const QColor &color)
Sets the underline color used for the characters with this format to the color specified.
EventRef lastKeydownEvent()
void setLastKeydownEvent(EventRef)
bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab)
bool qt_sendSpontaneousEvent(QObject *, QEvent *)
static QTextFormat qt_mac_compose_format()
struct OpaqueEventRef * EventRef
The QMouseEvent class contains parameters that describe a mouse event.
void mouseHandler(int pos, QMouseEvent *)
This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
void setFontUnderline(bool underline)
If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-und...
The QPoint class defines a point in the plane using integer precision.
The QRect class defines a rectangle in the plane using integer precision.
QKeyMapperPrivate * qt_keymapper_private()
struct OpaqueEventHandlerCallRef * EventHandlerCallRef
int x() const
Returns the x coordinate of this point.
static EventHandlerUPP input_proc_handlerUPP
The QInputContext class abstracts the input method dependent data and composing state.
virtual void setFocusWidget(QWidget *w)
Sets the widget that has an input focus for this input context.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
virtual QString language()
This function must be implemented in any subclasses to return a language code (e. ...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.