350.4
svn: r3629
This commit is contained in:
parent
673866d972
commit
6f29e3f0c0
|
@ -220,7 +220,7 @@ int FindReady(MrEdContext *c, MSG *msg, int remove, MrEdContext **c_return)
|
|||
MSG pmsg;
|
||||
while (PeekMessage(&pmsg, NULL, 0x4000, 0xFFFF, PM_REMOVE)) {
|
||||
found_nothing = 0;
|
||||
TranslateMessage(&pmsg);
|
||||
wxTranslateMessage(&pmsg);
|
||||
DispatchMessage(&pmsg);
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ void MrEdDispatchEvent(MSG *msg)
|
|||
fflush(log);
|
||||
#endif
|
||||
|
||||
TranslateMessage(msg);
|
||||
wxTranslateMessage(msg);
|
||||
|
||||
can_trampoline_win = msg->hwnd;
|
||||
last_msg_time = msg->time;
|
||||
|
|
|
@ -702,3 +702,23 @@ wxWindow *wxLocationToWindow(int x, int y)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
int wxLocaleStringToChar(char *str, int slen)
|
||||
{
|
||||
Scheme_Object *s;
|
||||
s = scheme_make_locale_string(str);
|
||||
if (SCHEME_CHAR_STRLEN_VAL(s))
|
||||
return SCHEME_CHAR_STR_VAL(s)[0];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxUTF8StringToChar(char *str, int slen)
|
||||
{
|
||||
mzchar s[1];
|
||||
s[0] = 0;
|
||||
scheme_utf8_decode((unsigned char *)str, 0, slen,
|
||||
s, 0, 1,
|
||||
NULL, 0, '?');
|
||||
return (int)s[0];
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ class wxKeycode
|
|||
TF_Flag( metaOn );
|
||||
TF_Flag( metaOff );
|
||||
|
||||
TF_Flag( checkOther );
|
||||
|
||||
TF_Flag( fullset );
|
||||
#undef TF_Flag
|
||||
|
||||
|
@ -164,7 +166,7 @@ void wxKeymap::SetBreakSequenceCallback(wxBreakSequenceFunction f,
|
|||
fold(dataold);
|
||||
}
|
||||
|
||||
wxKeycode *wxKeymap::FindKey(long code,
|
||||
wxKeycode *wxKeymap::FindKey(long code, long other_code,
|
||||
Bool shift, Bool ctrl,
|
||||
Bool alt, Bool meta,
|
||||
wxKeycode *prefix)
|
||||
|
@ -172,33 +174,38 @@ wxKeycode *wxKeymap::FindKey(long code,
|
|||
wxKeycode *key;
|
||||
wxKeycode *bestKey = NULL;
|
||||
int bestScore = -1;
|
||||
int iter;
|
||||
|
||||
if (!keys)
|
||||
return NULL;
|
||||
|
||||
key = (wxKeycode *)keys->Get(code);
|
||||
while (key) {
|
||||
if (key->code == code
|
||||
&& ((key->shiftOn && shift)
|
||||
|| (key->shiftOff && !shift)
|
||||
|| (!key->shiftOn && !key->shiftOff))
|
||||
&& ((key->ctrlOn && ctrl)
|
||||
|| (key->ctrlOff && !ctrl)
|
||||
|| (!key->ctrlOn && !key->ctrlOff))
|
||||
&& ((key->altOn && alt)
|
||||
|| (key->altOff && !alt)
|
||||
|| (!key->altOn && !key->altOff))
|
||||
&& ((key->metaOn && meta)
|
||||
|| (key->metaOff && !meta)
|
||||
|| (!key->metaOn && !key->metaOff))
|
||||
&& key->seqprefix == prefix) {
|
||||
int score = key->score;
|
||||
if (score > bestScore) {
|
||||
bestKey = key;
|
||||
bestScore = score;
|
||||
for (iter = 0; iter < 2; iter++) {
|
||||
key = (wxKeycode *)keys->Get(iter ? other_code : code);
|
||||
while (key) {
|
||||
if (((key->code == code)
|
||||
|| (key->checkOther
|
||||
&& (key->code == other_code)))
|
||||
&& ((key->shiftOn && shift)
|
||||
|| (key->shiftOff && !shift)
|
||||
|| (!key->shiftOn && !key->shiftOff))
|
||||
&& ((key->ctrlOn && ctrl)
|
||||
|| (key->ctrlOff && !ctrl)
|
||||
|| (!key->ctrlOn && !key->ctrlOff))
|
||||
&& ((key->altOn && alt)
|
||||
|| (key->altOff && !alt)
|
||||
|| (!key->altOn && !key->altOff))
|
||||
&& ((key->metaOn && meta)
|
||||
|| (key->metaOff && !meta)
|
||||
|| (!key->metaOn && !key->metaOff))
|
||||
&& key->seqprefix == prefix) {
|
||||
int score = key->score;
|
||||
if (score > bestScore) {
|
||||
bestKey = key;
|
||||
bestScore = score;
|
||||
}
|
||||
}
|
||||
key = key->next;
|
||||
}
|
||||
key = key->next;
|
||||
}
|
||||
|
||||
return bestKey;
|
||||
|
@ -288,7 +295,7 @@ static Keybind keylist[]
|
|||
{ NULL, 0 }};
|
||||
|
||||
wxKeycode *wxKeymap::MapFunction(long code, int shift, int ctrl,
|
||||
int alt, int meta,
|
||||
int alt, int meta, int checkOther,
|
||||
char *fname, wxKeycode *prev, int type)
|
||||
{
|
||||
wxKeycode *key, *newkey;
|
||||
|
@ -305,6 +312,7 @@ wxKeycode *wxKeymap::MapFunction(long code, int shift, int ctrl,
|
|||
&& (key->altOff == (alt < 0))
|
||||
&& (key->metaOn == (meta > 0))
|
||||
&& (key->metaOff == (meta < 0))
|
||||
&& (key->checkOther == (checkOther ? 1 : 0))
|
||||
&& key->seqprefix == prev)
|
||||
break;
|
||||
key = key->next;
|
||||
|
@ -342,9 +350,9 @@ wxKeycode *wxKeymap::MapFunction(long code, int shift, int ctrl,
|
|||
}
|
||||
|
||||
if (keystr)
|
||||
sprintf(buffer, "keymap: \"%s%s\" ", modbuf, keystr);
|
||||
sprintf(buffer, "keymap: \"%s%s%s\" ", modbuf, checkOther ? "?" : "", keystr);
|
||||
else
|
||||
sprintf(buffer, "keymap: \"%s%c\" ", modbuf, (char)code);
|
||||
sprintf(buffer, "keymap: \"%s%s%c\" ", modbuf, checkOther ? "?" : "", (char)code);
|
||||
|
||||
strcat(buffer, "is already mapped as a ");
|
||||
if (!key->isprefix)
|
||||
|
@ -373,6 +381,7 @@ wxKeycode *wxKeymap::MapFunction(long code, int shift, int ctrl,
|
|||
newkey->altOff = (alt < 0);
|
||||
newkey->metaOn = (meta > 0);
|
||||
newkey->metaOff = (meta < 0);
|
||||
newkey->checkOther = (checkOther ? 1 : 0);
|
||||
newkey->score = ((newkey->shiftOn ? 1 : 0)
|
||||
+ (newkey->shiftOff ? 5 : 0)
|
||||
+ (newkey->ctrlOn ? 1 : 0)
|
||||
|
@ -380,7 +389,8 @@ wxKeycode *wxKeymap::MapFunction(long code, int shift, int ctrl,
|
|||
+ (newkey->altOn ? 1 : 0)
|
||||
+ (newkey->altOff ? 5 : 0)
|
||||
+ (newkey->metaOn ? 1 : 0)
|
||||
+ (newkey->metaOn ? 5 : 0));
|
||||
+ (newkey->metaOn ? 5 : 0)
|
||||
+ (newkey->checkOther ? 0 : 20));
|
||||
newkey->fullset = 0;
|
||||
newkey->fname = copystring(fname);
|
||||
newkey->next = NULL;
|
||||
|
@ -420,12 +430,15 @@ static long GetCode(unsigned char *keyseq, int *_kp, int *fullset)
|
|||
for (i = 1; keyseq[kp] && (keyseq[kp] != ';'); i++, kp++) {
|
||||
if (i >= MAX_BUF - 1)
|
||||
return 0;
|
||||
buffer[i] = tolower(keyseq[kp]);
|
||||
buffer[i] = keyseq[kp];
|
||||
if (buffer[i] < 128)
|
||||
buffer[i] = tolower(buffer[i]);
|
||||
}
|
||||
buffer[i] = 0;
|
||||
code = 0;
|
||||
if (buffer[1]) {
|
||||
buffer[0] = tolower(buffer[0]);
|
||||
if (buffer[0] < 128)
|
||||
buffer[0] = tolower(buffer[0]);
|
||||
for (i = 0; keylist[i].str; i++) {
|
||||
if (!strcmp((char *)buffer, keylist[i].str)) {
|
||||
code = keylist[i].code;
|
||||
|
@ -449,7 +462,7 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
char *keyseq = keys;
|
||||
int num_keys, num_new_keys, kp, start_keys;
|
||||
wxKeycode **key, **new_key;
|
||||
int shift, ctrl, alt, meta, mod;
|
||||
int shift, ctrl, alt, meta, mod, checkOther;
|
||||
int part = 1, i, j;
|
||||
long code;
|
||||
int fullset;
|
||||
|
@ -466,6 +479,7 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
shift = ctrl = alt = meta = 0;
|
||||
code = 0;
|
||||
fullset = 0;
|
||||
checkOther = 0;
|
||||
|
||||
while (keyseq[kp] && (keyseq[kp] != ';')) {
|
||||
mod = 1;
|
||||
|
@ -484,7 +498,11 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
kp++;
|
||||
} else if (keyseq[kp + 1] == ':') {
|
||||
do_mod:
|
||||
switch (tolower(keyseq[kp])) {
|
||||
unsigned char mch;
|
||||
mch = keyseq[kp];
|
||||
if (mch < 128)
|
||||
mch = tolower(mch);
|
||||
switch (mch) {
|
||||
case 's':
|
||||
shift = mod;
|
||||
break;
|
||||
|
@ -510,6 +528,14 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
case 'a':
|
||||
alt = mod;
|
||||
break;
|
||||
case '?':
|
||||
if (mod == 1) {
|
||||
checkOther = 1;
|
||||
} else {
|
||||
errstr = "cannot negate ? modifier";
|
||||
goto key_error;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errstr = "bad modifier";
|
||||
goto key_error;
|
||||
|
@ -527,10 +553,16 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
}
|
||||
|
||||
if (code) {
|
||||
if ((code > 0) && (code < 256) && isalpha(code)) {
|
||||
if (shift > 0)
|
||||
code = toupper(code);
|
||||
else if (isupper(code))
|
||||
if ((code > 0) && (code < 127) && isalpha(code)) {
|
||||
if (shift > 0) {
|
||||
#ifdef wx_mac
|
||||
if (!meta)
|
||||
#endif
|
||||
#ifdef wx_msw
|
||||
if (!ctrl || meta)
|
||||
#endif
|
||||
code = toupper(code);
|
||||
} else if (isupper(code))
|
||||
shift = TRUE;
|
||||
}
|
||||
|
||||
|
@ -539,7 +571,7 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
|
||||
for (i = 0, j = 0; i < num_keys; i++) {
|
||||
wxKeycode *mf;
|
||||
mf = MapFunction(code, shift, ctrl, alt, meta, fname, key[i],
|
||||
mf = MapFunction(code, shift, ctrl, alt, meta, checkOther, fname, key[i],
|
||||
keyseq[kp] ? wxKEY_PREFIX : wxKEY_FINAL);
|
||||
mf->fullset = fullset;
|
||||
new_key[j++] = mf;
|
||||
|
@ -570,13 +602,13 @@ void wxKeymap::MapFunction(char *keys, char *fname)
|
|||
wxsKeymapError(buffer);
|
||||
}
|
||||
|
||||
int wxKeymap::HandleEvent(long code, Bool shift, Bool ctrl,
|
||||
int wxKeymap::HandleEvent(long code, long other_code, Bool shift, Bool ctrl,
|
||||
Bool alt, Bool meta, int score,
|
||||
char **fname, int *fullset)
|
||||
{
|
||||
wxKeycode *key;
|
||||
|
||||
key = FindKey(code, shift, ctrl, alt, meta, prefix);
|
||||
key = FindKey(code, other_code, shift, ctrl, alt, meta, prefix);
|
||||
|
||||
prefix = NULL;
|
||||
|
||||
|
@ -595,13 +627,13 @@ int wxKeymap::HandleEvent(long code, Bool shift, Bool ctrl,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int wxKeymap::GetBestScore(long code, Bool shift, Bool ctrl,
|
||||
int wxKeymap::GetBestScore(long code, long other_code, Bool shift, Bool ctrl,
|
||||
Bool alt, Bool meta)
|
||||
{
|
||||
wxKeycode *key;
|
||||
int s, i;
|
||||
|
||||
key = FindKey(code, shift, ctrl, alt, meta, prefix);
|
||||
key = FindKey(code, other_code, shift, ctrl, alt, meta, prefix);
|
||||
|
||||
if (key)
|
||||
s = key->score;
|
||||
|
@ -610,7 +642,7 @@ int wxKeymap::GetBestScore(long code, Bool shift, Bool ctrl,
|
|||
|
||||
for (i = 0; i < chainCount; i++) {
|
||||
int r;
|
||||
r = chainTo[i]->GetBestScore(code, shift, ctrl, alt, meta);
|
||||
r = chainTo[i]->GetBestScore(code, other_code, shift, ctrl, alt, meta);
|
||||
if (r > s)
|
||||
s = r;
|
||||
}
|
||||
|
@ -648,6 +680,7 @@ Bool wxKeymap::HandleKeyEvent(UNKNOWN_OBJ media, wxKeyEvent *event)
|
|||
int wxKeymap::GetBestScore(wxKeyEvent *event)
|
||||
{
|
||||
return GetBestScore(event->keyCode,
|
||||
event->otherKeyCode,
|
||||
event->shiftDown,
|
||||
event->controlDown,
|
||||
event->altDown,
|
||||
|
@ -703,6 +736,7 @@ int wxKeymap::ChainHandleKeyEvent(UNKNOWN_OBJ media, wxKeyEvent *event,
|
|||
return OtherHandleKeyEvent(media, event, grab, grabData, -1, score);
|
||||
|
||||
if (HandleEvent(event->keyCode,
|
||||
event->otherKeyCode,
|
||||
event->shiftDown,
|
||||
event->controlDown,
|
||||
event->altDown,
|
||||
|
@ -795,6 +829,7 @@ int wxKeymap::GetBestScore(wxMouseEvent *event)
|
|||
}
|
||||
|
||||
return GetBestScore(code,
|
||||
-1,
|
||||
event->shiftDown,
|
||||
event->controlDown,
|
||||
event->altDown,
|
||||
|
@ -895,6 +930,7 @@ int wxKeymap::ChainHandleMouseEvent(UNKNOWN_OBJ media, wxMouseEvent *event,
|
|||
|
||||
do {
|
||||
if (HandleEvent(code,
|
||||
-1,
|
||||
event->shiftDown,
|
||||
event->controlDown,
|
||||
event->altDown,
|
||||
|
|
|
@ -62,10 +62,10 @@ class wxKeymap : public wxObject
|
|||
wxBreakSequenceFunction onBreak;
|
||||
void *onBreakData;
|
||||
|
||||
class wxKeycode *FindKey(long, Bool, Bool, Bool, Bool, class wxKeycode *);
|
||||
int HandleEvent(long code, Bool shift, Bool ctrl, Bool alt, Bool meta,
|
||||
class wxKeycode *FindKey(long, long, Bool, Bool, Bool, Bool, class wxKeycode *);
|
||||
int HandleEvent(long code, long, Bool shift, Bool ctrl, Bool alt, Bool meta,
|
||||
int score, char **fname, int *fullset);
|
||||
int GetBestScore(long code, Bool shift, Bool ctrl, Bool alt, Bool meta);
|
||||
int GetBestScore(long code, long, Bool shift, Bool ctrl, Bool alt, Bool meta);
|
||||
|
||||
Bool CycleCheck(wxKeymap *km);
|
||||
|
||||
|
@ -104,7 +104,7 @@ class wxKeymap : public wxObject
|
|||
void SetBreakSequenceCallback(wxBreakSequenceFunction f, void *data);
|
||||
|
||||
class wxKeycode *MapFunction(long code, int shift, int ctrl,
|
||||
int alt, int meta,
|
||||
int alt, int meta, int check_alt,
|
||||
char *fname, class wxKeycode *prevkey=NULL,
|
||||
int keytype = wxKEY_FINAL);
|
||||
void MapFunction(char *keyname, char *fname);
|
||||
|
|
|
@ -1458,6 +1458,10 @@ static Scheme_Object *bundle_symset_keyCode(int v) {
|
|||
}
|
||||
|
||||
|
||||
static long GetOtherKey(wxKeyEvent *k) { return k->otherKeyCode; }
|
||||
static void SetOtherKey(wxKeyEvent *k, long c) { k->otherKeyCode = c; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1494,6 +1498,50 @@ os_wxKeyEvent::~os_wxKeyEvent()
|
|||
objscheme_destroy(this, (Scheme_Object *) __gc_external);
|
||||
}
|
||||
|
||||
static Scheme_Object *os_wxKeyEventSetOtherKey(int n, Scheme_Object *p[])
|
||||
{
|
||||
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
|
||||
REMEMBER_VAR_STACK();
|
||||
objscheme_check_valid(os_wxKeyEvent_class, "set-other-shift-key-code in key-event%", n, p);
|
||||
long x0 INIT_NULLED_OUT;
|
||||
|
||||
SETUP_VAR_STACK_REMEMBERED(2);
|
||||
VAR_STACK_PUSH(0, p);
|
||||
VAR_STACK_PUSH(1, x0);
|
||||
|
||||
|
||||
x0 = (SCHEME_FALSEP(p[POFFSET+0]) ? 0 : unbundle_symset_keyCode(p[POFFSET+0], METHODNAME("key-event%","get-other-shift-key-code")));
|
||||
|
||||
|
||||
WITH_VAR_STACK(SetOtherKey(((wxKeyEvent *)((Scheme_Class_Object *)p[0])->primdata), x0));
|
||||
|
||||
|
||||
|
||||
READY_TO_RETURN;
|
||||
return scheme_void;
|
||||
}
|
||||
|
||||
static Scheme_Object *os_wxKeyEventGetOtherKey(int n, Scheme_Object *p[])
|
||||
{
|
||||
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
|
||||
REMEMBER_VAR_STACK();
|
||||
long r;
|
||||
objscheme_check_valid(os_wxKeyEvent_class, "get-other-shift-key-code in key-event%", n, p);
|
||||
|
||||
SETUP_VAR_STACK_REMEMBERED(1);
|
||||
VAR_STACK_PUSH(0, p);
|
||||
|
||||
|
||||
|
||||
|
||||
r = WITH_VAR_STACK(GetOtherKey(((wxKeyEvent *)((Scheme_Class_Object *)p[0])->primdata)));
|
||||
|
||||
|
||||
|
||||
READY_TO_RETURN;
|
||||
return (r ? bundle_symset_keyCode(r) : scheme_false);
|
||||
}
|
||||
|
||||
static Scheme_Object *objscheme_wxKeyEvent_GetkeyCode(int n, Scheme_Object *p[])
|
||||
{
|
||||
Scheme_Class_Object *cobj INIT_NULLED_OUT;
|
||||
|
@ -1842,8 +1890,10 @@ void objscheme_setup_wxKeyEvent(Scheme_Env *env)
|
|||
|
||||
wxREGGLOB(os_wxKeyEvent_class);
|
||||
|
||||
os_wxKeyEvent_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "key-event%", "event%", (Scheme_Method_Prim *)os_wxKeyEvent_ConstructScheme, 16));
|
||||
os_wxKeyEvent_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "key-event%", "event%", (Scheme_Method_Prim *)os_wxKeyEvent_ConstructScheme, 18));
|
||||
|
||||
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxKeyEvent_class, "set-other-shift-key-code" " method", (Scheme_Method_Prim *)os_wxKeyEventSetOtherKey, 1, 1));
|
||||
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxKeyEvent_class, "get-other-shift-key-code" " method", (Scheme_Method_Prim *)os_wxKeyEventGetOtherKey, 0, 0));
|
||||
|
||||
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxKeyEvent_class,"get-key-code" " method", (Scheme_Method_Prim *)objscheme_wxKeyEvent_GetkeyCode, 0, 0));
|
||||
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxKeyEvent_class,"set-key-code" " method", (Scheme_Method_Prim *)objscheme_wxKeyEvent_SetkeyCode, 1, 1));
|
||||
|
@ -1924,6 +1974,43 @@ class wxKeyEvent *objscheme_unbundle_wxKeyEvent(Scheme_Object *obj, const char *
|
|||
}
|
||||
|
||||
|
||||
static int wxKeySymbolToInteger(int v) { return v; }
|
||||
|
||||
|
||||
|
||||
static Scheme_Object *wxKeyEventGlobalwxKeySymbolToInteger(int n, Scheme_Object *p[])
|
||||
{
|
||||
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
|
||||
REMEMBER_VAR_STACK();
|
||||
int r;
|
||||
int x0;
|
||||
|
||||
SETUP_VAR_STACK_REMEMBERED(1);
|
||||
VAR_STACK_PUSH(0, p);
|
||||
|
||||
|
||||
x0 = WITH_VAR_STACK(unbundle_symset_keyCode(p[0+0], NULL));
|
||||
|
||||
|
||||
r = WITH_VAR_STACK(wxKeySymbolToInteger(x0));
|
||||
|
||||
|
||||
|
||||
READY_TO_RETURN;
|
||||
return scheme_make_integer(r);
|
||||
}
|
||||
|
||||
void objscheme_setup_wxKeyEventGlobal(Scheme_Env *env)
|
||||
{
|
||||
Scheme_Object *functmp INIT_NULLED_OUT;
|
||||
SETUP_VAR_STACK(1);
|
||||
VAR_STACK_PUSH(0, env);
|
||||
functmp = WITH_VAR_STACK(scheme_make_prim_w_arity((Scheme_Prim *)wxKeyEventGlobalwxKeySymbolToInteger, "key-symbol-to-integer", 1, 1));
|
||||
WITH_VAR_STACK(scheme_install_xc_global("key-symbol-to-integer", functmp, env));
|
||||
READY_TO_RETURN;
|
||||
}
|
||||
|
||||
|
||||
static Scheme_Object *mouseEventType_wxEVENT_TYPE_LEFT_DOWN_sym = NULL;
|
||||
static Scheme_Object *mouseEventType_wxEVENT_TYPE_LEFT_UP_sym = NULL;
|
||||
static Scheme_Object *mouseEventType_wxEVENT_TYPE_MIDDLE_DOWN_sym = NULL;
|
||||
|
|
|
@ -30,6 +30,9 @@ int objscheme_istype_wxKeyEvent(Scheme_Object *obj, const char *stop, int nullOK
|
|||
Scheme_Object *objscheme_bundle_wxKeyEvent(class wxKeyEvent *realobj);
|
||||
class wxKeyEvent *objscheme_unbundle_wxKeyEvent(Scheme_Object *obj, const char *where, int nullOK);
|
||||
#endif
|
||||
void objscheme_setup_wxKeyEventGlobal(Scheme_Env *env);
|
||||
#ifndef WXS_SETUP_ONLY
|
||||
#endif
|
||||
void objscheme_setup_wxMouseEvent(Scheme_Env *env);
|
||||
#ifndef WXS_SETUP_ONLY
|
||||
int objscheme_istype_wxMouseEvent(Scheme_Object *obj, const char *stop, int nullOK);
|
||||
|
|
|
@ -220,6 +220,11 @@ wxMouseEvent_ext::wxMouseEvent_ext(int et, int ld, int mdd, int rd, int xv, int
|
|||
@SYM "release" : WXK_RELEASE
|
||||
@ENDSYMBOLS
|
||||
|
||||
@MACRO bKeyOrFalse = ({x} ? bundle_symset_keyCode({x}) : scheme_false)
|
||||
@MACRO ubKeyOrFalse = (SCHEME_FALSEP({x}) ? 0 : unbundle_symset_keyCode({x}, METHODNAME("key-event%","get-other-shift-key-code")))
|
||||
static long GetOtherKey(wxKeyEvent *k) { return k->otherKeyCode; }
|
||||
static void SetOtherKey(wxKeyEvent *k, long c) { k->otherKeyCode = c; }
|
||||
|
||||
@CLASSBASE wxKeyEvent=wxKeyEvent_ext "key-event":"event" / nofnl
|
||||
|
||||
@CREATOR (SYM[keyCode]=0, bool=0, bool=0, bool=0, bool=0, int=0, int=0, ExactLong=0)
|
||||
|
@ -235,6 +240,17 @@ wxMouseEvent_ext::wxMouseEvent_ext(int et, int ld, int mdd, int rd, int xv, int
|
|||
@IVAR "x" : int x
|
||||
@IVAR "y" : int y
|
||||
|
||||
@ m "get-other-shift-key-code" : long/bKeyOrFalse GetOtherKey();
|
||||
@ m "set-other-shift-key-code" : void SetOtherKey(long//ubKeyOrFalse////push);
|
||||
|
||||
@END
|
||||
|
||||
static int wxKeySymbolToInteger(int v) { return v; }
|
||||
|
||||
@GLOBAL wxKeyEventGlobal
|
||||
|
||||
@ "key-symbol-to-integer" : int wxKeySymbolToInteger(SYMZ[keyCode])
|
||||
|
||||
@END
|
||||
|
||||
@BEGINSYMBOLS mouseEventType > ONE > PRED
|
||||
|
|
|
@ -3261,6 +3261,7 @@ static void wxScheme_Install(Scheme_Env *global_env)
|
|||
objscheme_setup_wxPopupEvent(global_env);
|
||||
objscheme_setup_wxScrollEvent(global_env);
|
||||
objscheme_setup_wxKeyEvent(global_env);
|
||||
objscheme_setup_wxKeyEventGlobal(global_env);
|
||||
objscheme_setup_wxMouseEvent(global_env);
|
||||
objscheme_setup_wxDC(global_env);
|
||||
objscheme_setup_wxDCGlobal(global_env);
|
||||
|
|
|
@ -735,8 +735,9 @@ typedef struct {
|
|||
typedef struct Scheme_Hash_Table
|
||||
{
|
||||
Scheme_Inclhash_Object iso;
|
||||
int size, count, step;
|
||||
Scheme_Object **keys;
|
||||
int size; /* power of 2 */
|
||||
int count;
|
||||
Scheme_Object **keys;
|
||||
Scheme_Object **vals;
|
||||
void (*make_hash_indices)(void *v, long *h1, long *h2);
|
||||
int (*compare)(void *v1, void *v2);
|
||||
|
@ -755,7 +756,8 @@ typedef struct Scheme_Bucket
|
|||
typedef struct Scheme_Bucket_Table
|
||||
{
|
||||
Scheme_Object so;
|
||||
int size, count, step;
|
||||
int size; /* power of 2 */
|
||||
int count;
|
||||
Scheme_Bucket **buckets;
|
||||
char weak, with_home;
|
||||
void (*make_hash_indices)(void *v, long *h1, long *h2);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -62,13 +62,7 @@ long PTR_TO_LONG(Scheme_Object *o)
|
|||
|
||||
#define FILL_FACTOR 1.4
|
||||
|
||||
#define MIN_HTABLE_SIZE 7
|
||||
|
||||
long scheme_hash_primes[] =
|
||||
{MIN_HTABLE_SIZE, 31, 61, 127, 257, 521, 1031, 2053, 4099, 8209, 16411,
|
||||
32779, 65543, 131101, 262147, 425329, 1048583, 2097169,
|
||||
4194319, 8388617, 16777259, 33554467, 67108879, 134217757,
|
||||
268435459, 536870923, 1073741827};
|
||||
#define MIN_HTABLE_SIZE 8
|
||||
|
||||
typedef int (*Hash_Compare_Proc)(void*, void*);
|
||||
|
||||
|
@ -131,7 +125,6 @@ Scheme_Hash_Table *scheme_make_hash_table(int type)
|
|||
|
||||
table = MALLOC_ONE_TAGGED(Scheme_Hash_Table);
|
||||
|
||||
table->step = 0;
|
||||
table->size = 0;
|
||||
|
||||
table->iso.so.type = scheme_hash_table_type;
|
||||
|
@ -156,23 +149,24 @@ static Scheme_Object *do_hash(Scheme_Hash_Table *table, Scheme_Object *key, int
|
|||
{
|
||||
Scheme_Object *tkey, **keys;
|
||||
hash_v_t h, h2, useme = 0;
|
||||
unsigned long size = table->size;
|
||||
unsigned long mask;
|
||||
|
||||
rehash_key:
|
||||
|
||||
mask = table->size - 1;
|
||||
|
||||
if (table->make_hash_indices) {
|
||||
table->make_hash_indices((void *)key, (long *)&h, (long *)&h2);
|
||||
h = h % size;
|
||||
h2 = h2 % size;
|
||||
h = h & mask;
|
||||
h2 = h2 & mask;
|
||||
} else {
|
||||
unsigned long lkey;
|
||||
lkey = (unsigned long)PTR_TO_LONG((Scheme_Object *)key);
|
||||
h = (lkey >> 2) % size;
|
||||
h2 = (lkey >> 3) % size;
|
||||
h = (lkey >> 2) & mask;
|
||||
h2 = (lkey >> 3) & mask;
|
||||
}
|
||||
|
||||
if (!h2)
|
||||
h2 = 2;
|
||||
h2 |= 1;
|
||||
|
||||
keys = table->keys;
|
||||
|
||||
|
@ -196,7 +190,7 @@ static Scheme_Object *do_hash(Scheme_Hash_Table *table, Scheme_Object *key, int
|
|||
return table->vals[h];
|
||||
}
|
||||
scheme_hash_iteration_count++;
|
||||
h = (h + h2) % size;
|
||||
h = (h + h2) & mask;
|
||||
}
|
||||
} else {
|
||||
scheme_hash_request_count++;
|
||||
|
@ -218,7 +212,7 @@ static Scheme_Object *do_hash(Scheme_Hash_Table *table, Scheme_Object *key, int
|
|||
}
|
||||
}
|
||||
scheme_hash_iteration_count++;
|
||||
h = (h + h2) % size;
|
||||
h = (h + h2) & mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,14 +221,14 @@ static Scheme_Object *do_hash(Scheme_Hash_Table *table, Scheme_Object *key, int
|
|||
|
||||
if (set == 1)
|
||||
h = useme;
|
||||
else if (table->mcount * FILL_FACTOR >= size) {
|
||||
else if (table->mcount * FILL_FACTOR >= table->size) {
|
||||
/* Rehash */
|
||||
int i, oldsize = table->size;
|
||||
int i, oldsize = table->size, size;
|
||||
Scheme_Object **oldkeys = table->keys;
|
||||
Scheme_Object **oldvals = table->vals;
|
||||
|
||||
table->size = scheme_hash_primes[++table->step];
|
||||
size = table->size;
|
||||
size = oldsize << 1;
|
||||
table->size = size;
|
||||
|
||||
{
|
||||
Scheme_Object **ba;
|
||||
|
@ -268,7 +262,7 @@ void scheme_hash_set(Scheme_Hash_Table *table, Scheme_Object *key, Scheme_Object
|
|||
if (!table->vals) {
|
||||
Scheme_Object **ba;
|
||||
|
||||
table->size = scheme_hash_primes[0];
|
||||
table->size = 8;
|
||||
|
||||
ba = MALLOC_N(Scheme_Object *, table->size);
|
||||
table->vals = ba;
|
||||
|
@ -345,16 +339,15 @@ Scheme_Hash_Table *scheme_clone_hash_table(Scheme_Hash_Table *ht)
|
|||
|
||||
void scheme_reset_hash_table(Scheme_Hash_Table *table, int *history)
|
||||
{
|
||||
if (!table->step
|
||||
|| ((table->count * FILL_FACTOR > (scheme_hash_primes[table->step - 1])))) {
|
||||
if ((table->size <= 8)
|
||||
|| (table->count * FILL_FACTOR > (table->size >> 1))) {
|
||||
/* Keep same size */
|
||||
memset(table->vals, 0, sizeof(Scheme_Object *) * table->size);
|
||||
memset(table->keys, 0, sizeof(Scheme_Object *) * table->size);
|
||||
} else {
|
||||
/* Shrink by one step */
|
||||
Scheme_Object **ba;
|
||||
--table->step;
|
||||
table->size = scheme_hash_primes[table->step];
|
||||
table->size >>= 1;
|
||||
ba = MALLOC_N(Scheme_Object *, table->size);
|
||||
memcpy(ba, table->vals, sizeof(Scheme_Object *) * table->size);
|
||||
table->vals = ba;
|
||||
|
@ -378,11 +371,10 @@ scheme_make_bucket_table (int size, int type)
|
|||
|
||||
table = MALLOC_ONE_TAGGED(Scheme_Bucket_Table);
|
||||
|
||||
table->step = 0;
|
||||
while (scheme_hash_primes[table->step] < size) {
|
||||
table->step++;
|
||||
table->size = 1;
|
||||
while (table->size < size) {
|
||||
table->size <<= 1;
|
||||
}
|
||||
table->size = scheme_hash_primes[table->step];
|
||||
|
||||
table->count = 0;
|
||||
|
||||
|
@ -409,7 +401,6 @@ Scheme_Bucket_Table *scheme_clone_bucket_table(Scheme_Bucket_Table *bt)
|
|||
table->so.type = scheme_bucket_table_type;
|
||||
table->size = bt->size;
|
||||
table->count = bt->count;
|
||||
table->step = bt->step;
|
||||
table->weak = bt->weak;
|
||||
table->with_home = 0;
|
||||
table->make_hash_indices = bt->make_hash_indices;
|
||||
|
@ -436,27 +427,24 @@ get_bucket (Scheme_Bucket_Table *table, const char *key, int add, Scheme_Bucket
|
|||
hash_v_t h, h2;
|
||||
Scheme_Bucket *bucket;
|
||||
Compare_Proc compare = table->compare;
|
||||
unsigned long size;
|
||||
unsigned long mask;
|
||||
|
||||
rehash_key:
|
||||
|
||||
size = table->size;
|
||||
mask = table->size - 1;
|
||||
|
||||
if (table->make_hash_indices) {
|
||||
table->make_hash_indices((void *)key, (long *)&h, (long *)&h2);
|
||||
h = h % size;
|
||||
h2 = h2 % size;
|
||||
h = h & mask;
|
||||
h2 = h2 & mask;
|
||||
} else {
|
||||
unsigned long lkey;
|
||||
lkey = (unsigned long)PTR_TO_LONG((Scheme_Object *)key);
|
||||
h = (lkey >> 2) % size;
|
||||
h2 = (lkey >> 3) % size;
|
||||
h = (lkey >> 2) & mask;
|
||||
h2 = (lkey >> 3) & mask;
|
||||
}
|
||||
|
||||
if (!h2)
|
||||
h2 = 2;
|
||||
else if (h2 & 0x1)
|
||||
h2++;
|
||||
h2 |= 0x1;
|
||||
|
||||
if (table->weak) {
|
||||
scheme_hash_request_count++;
|
||||
|
@ -477,7 +465,7 @@ get_bucket (Scheme_Bucket_Table *table, const char *key, int add, Scheme_Bucket
|
|||
} else if (add)
|
||||
break;
|
||||
scheme_hash_iteration_count++;
|
||||
h = (h + h2) % size;
|
||||
h = (h + h2) & mask;
|
||||
}
|
||||
} else {
|
||||
scheme_hash_request_count++;
|
||||
|
@ -487,7 +475,7 @@ get_bucket (Scheme_Bucket_Table *table, const char *key, int add, Scheme_Bucket
|
|||
else if (compare && !compare((void *)bucket->key, (void *)key))
|
||||
return bucket;
|
||||
scheme_hash_iteration_count++;
|
||||
h = (h + h2) % size;
|
||||
h = (h + h2) & mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -514,12 +502,12 @@ get_bucket (Scheme_Bucket_Table *table, const char *key, int add, Scheme_Bucket
|
|||
}
|
||||
|
||||
if (actual * FILL_FACTOR < table->count) {
|
||||
/* Decrement step so that the table won't actually grow. */
|
||||
--table->step;
|
||||
/* Decrement size so that the table won't actually grow. */
|
||||
table->size >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
table->size = scheme_hash_primes[++table->step];
|
||||
table->size <<= 1;
|
||||
|
||||
asize = (size_t)table->size * sizeof(Scheme_Bucket *);
|
||||
{
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
|
||||
#define MZSCHEME_VERSION_MAJOR 350
|
||||
#define MZSCHEME_VERSION_MINOR 3
|
||||
#define MZSCHEME_VERSION_MINOR 4
|
||||
|
||||
#define MZSCHEME_VERSION "350.3" _MZ_SPECIAL_TAG
|
||||
#define MZSCHEME_VERSION "350.4" _MZ_SPECIAL_TAG
|
||||
|
|
|
@ -803,10 +803,10 @@ static int maybe_add_chain_cache(Scheme_Stx *stx)
|
|||
/* ok to skip, but don't count toward needing a cache */
|
||||
} else if (SCHEME_HASHTP(p)) {
|
||||
/* Hack: we store the depth of the table in the chain
|
||||
in the `step' fields, at least until the table is initialized: */
|
||||
in the `size' fields, at least until the table is initialized: */
|
||||
Scheme_Hash_Table *ht2 = (Scheme_Hash_Table *)p;
|
||||
if (!ht2->count)
|
||||
pos = ht2->step;
|
||||
pos = ht2->size;
|
||||
else {
|
||||
p = scheme_hash_get(ht2, scheme_make_integer(2));
|
||||
pos = SCHEME_INT_VAL(p);
|
||||
|
@ -825,7 +825,7 @@ static int maybe_add_chain_cache(Scheme_Stx *stx)
|
|||
|
||||
ht = scheme_make_hash_table(SCHEME_hash_ptr);
|
||||
|
||||
ht->step = pos;
|
||||
ht->size = pos;
|
||||
|
||||
p = scheme_make_pair((Scheme_Object *)ht, stx->wraps);
|
||||
stx->wraps = p;
|
||||
|
@ -878,8 +878,8 @@ static void fill_chain_cache(Scheme_Object *wraps)
|
|||
|
||||
scheme_hash_set(ht, scheme_make_integer(5), NULL);
|
||||
} else {
|
||||
pos = ht->step;
|
||||
ht->step = 0;
|
||||
pos = ht->size;
|
||||
ht->size = 0;
|
||||
|
||||
wraps = SCHEME_CDR(wraps);
|
||||
|
||||
|
@ -913,11 +913,11 @@ static void fill_chain_cache(Scheme_Object *wraps)
|
|||
/* ok to skip */
|
||||
} else if (SCHEME_HASHTP(p)) {
|
||||
/* Hack: we store the depth of the table in the chain
|
||||
in the `step' fields, at least until the table is initialized: */
|
||||
in the `size' fields, at least until the table is initialized: */
|
||||
Scheme_Hash_Table *ht2 = (Scheme_Hash_Table *)p;
|
||||
int pos2;
|
||||
if (!ht2->count)
|
||||
pos2 = ht2->step;
|
||||
pos2 = ht2->size;
|
||||
else {
|
||||
p = scheme_hash_get(ht2, scheme_make_integer(2));
|
||||
pos2 = SCHEME_INT_VAL(p);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <ctype.h>
|
||||
#include "schgc.h"
|
||||
|
||||
# define HASH_TABLE_SIZE_STEP 4
|
||||
# define HASH_TABLE_INIT_SIZE 256
|
||||
#ifdef SMALL_HASH_TABLES
|
||||
# define FILL_FACTOR 1.30
|
||||
#else
|
||||
|
@ -74,8 +74,6 @@ static int gensym_counter;
|
|||
typedef unsigned long hash_v_t;
|
||||
#define HASH_SEED 0xF0E1D2C3
|
||||
|
||||
extern long scheme_hash_primes[];
|
||||
|
||||
#define SYMTAB_LOST_CELL scheme_false
|
||||
|
||||
#ifdef MZ_PRECISE_GC
|
||||
|
@ -90,11 +88,14 @@ static Scheme_Object *symbol_bucket(Scheme_Hash_Table *table,
|
|||
Scheme_Object *naya)
|
||||
{
|
||||
hash_v_t h, h2;
|
||||
unsigned long mask;
|
||||
Scheme_Object *bucket;
|
||||
|
||||
/* WARNING: key may be GC-misaligned... */
|
||||
|
||||
rehash_key:
|
||||
mask = table->size - 1;
|
||||
|
||||
{
|
||||
unsigned int i;
|
||||
i = 0;
|
||||
|
@ -110,14 +111,11 @@ static Scheme_Object *symbol_bucket(Scheme_Hash_Table *table,
|
|||
h ^= (h << 5) + (h >> 2) + 0xA0A0;
|
||||
h ^= (h << 5) + (h >> 2) + 0x0505;
|
||||
|
||||
h = h % table->size;
|
||||
h2 = h2 % table->size;
|
||||
h = h & mask;
|
||||
h2 = h2 & mask;
|
||||
}
|
||||
|
||||
if (!h2)
|
||||
h2 = 2;
|
||||
else if (h2 & 0x1)
|
||||
h2++; /* note: table size is never even, so no % needed */
|
||||
h2 |= 0x1;
|
||||
|
||||
while ((bucket = table->keys[WEAK_ARRAY_HEADSIZE + h])) {
|
||||
if (SAME_OBJ(bucket, SYMTAB_LOST_CELL)) {
|
||||
|
@ -130,7 +128,7 @@ static Scheme_Object *symbol_bucket(Scheme_Hash_Table *table,
|
|||
} else if (((int)length == SCHEME_SYM_LEN(bucket))
|
||||
&& !memcmp(key, SCHEME_SYM_VAL(bucket), length))
|
||||
return bucket;
|
||||
h = (h + h2) % table->size;
|
||||
h = (h + h2) & mask;
|
||||
}
|
||||
|
||||
/* In case it's GC-misaligned: */
|
||||
|
@ -155,9 +153,9 @@ static Scheme_Object *symbol_bucket(Scheme_Hash_Table *table,
|
|||
lostc++;
|
||||
}
|
||||
if ((lostc * 2) < table->count)
|
||||
table->step++;
|
||||
|
||||
newsize = scheme_hash_primes[table->step];
|
||||
newsize = oldsize << 1;
|
||||
else
|
||||
newsize = oldsize;
|
||||
|
||||
asize = (size_t)newsize * sizeof(Scheme_Object *);
|
||||
{
|
||||
|
@ -241,8 +239,7 @@ static Scheme_Hash_Table *init_one_symbol_table()
|
|||
|
||||
symbol_table = scheme_make_hash_table(SCHEME_hash_ptr);
|
||||
|
||||
symbol_table->step = HASH_TABLE_SIZE_STEP;
|
||||
symbol_table->size = scheme_hash_primes[symbol_table->step];
|
||||
symbol_table->size = HASH_TABLE_INIT_SIZE;
|
||||
|
||||
size = symbol_table->size * sizeof(Scheme_Object *);
|
||||
#ifdef MZ_PRECISE_GC
|
||||
|
|
|
@ -2201,7 +2201,7 @@ sub PrintBundleVar
|
|||
$var = "&$var" unless $outgoing;
|
||||
&PrintBundleObject($var, $paramtype, $wvs);
|
||||
} elsif (substr($paramtype, 0, 3) eq 'SYM') {
|
||||
$paramtype =~ /SYM\[(.*)\]/;
|
||||
$paramtype =~ /SYMZ?\[(.*)\]/;
|
||||
$symtype = $1;
|
||||
print "$wvs(bundle_symset_${symtype}($var))";
|
||||
} else {
|
||||
|
@ -2427,6 +2427,10 @@ sub PrintUnbundleVar
|
|||
substr($paramtype, -1) = '';
|
||||
print "*" if ($outgoing);
|
||||
&PrintUnbundleObject("$var", $paramtype, 0, $mname);
|
||||
} elsif (substr($paramtype, 0, 4) eq 'SYMZ') {
|
||||
$paramtype =~ /SYMZ\[(.*)\]/;
|
||||
$symtype = $1;
|
||||
print "WITH_VAR_STACK(unbundle_symset_${symtype}($var, NULL))";
|
||||
} elsif (substr($paramtype, 0, 3) eq 'SYM') {
|
||||
$paramtype =~ /SYM\[(.*)\]/;
|
||||
$symtype = $1;
|
||||
|
@ -2798,7 +2802,7 @@ sub PrintTypecheck
|
|||
substr($paramtype, -1) = '';
|
||||
&PrintTypecheckObj("$var", $paramtype, $stop);
|
||||
} elsif (substr($paramtype, 0, 3) eq 'SYM') {
|
||||
$paramtype =~ /SYM\[(.*)\]/;
|
||||
$paramtype =~ /SYMZ?\[(.*)\]/;
|
||||
$symtype = $1;
|
||||
print "WITH_REMEMBERED_STACK(istype_symset_${symtype}($var, $stop))";
|
||||
} else {
|
||||
|
|
|
@ -188,10 +188,11 @@ class wxKeyEvent: public wxEvent
|
|||
int y ;
|
||||
long keyCode;
|
||||
long keyUpCode;
|
||||
long otherKeyCode;
|
||||
Bool controlDown;
|
||||
Bool shiftDown;
|
||||
Bool altDown;
|
||||
Bool metaDown; //mflatt
|
||||
Bool metaDown;
|
||||
|
||||
wxKeyEvent(WXTYPE keyType);
|
||||
|
||||
|
|
|
@ -429,7 +429,7 @@ void wxApp::doMacMouseUp(void)
|
|||
theMouseEvent->metaDown = cCurrentEvent.modifiers & cmdKey;
|
||||
theMouseEvent->x = hitX;
|
||||
theMouseEvent->y = hitY;
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when); // mflatt
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when);
|
||||
|
||||
/* Grab is now only used for grabbing on mouse-down for canvases & panels: */
|
||||
if (wxSubType(mouseWindow->__type, wxTYPE_CANVAS)
|
||||
|
@ -472,7 +472,7 @@ void wxApp::doMacMouseUp(void)
|
|||
theMouseEvent->metaDown = cCurrentEvent.modifiers & cmdKey;
|
||||
theMouseEvent->x = hitX;
|
||||
theMouseEvent->y = hitY;
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when); // mflatt
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when);
|
||||
|
||||
macWxFrame->SeekMouseEventArea(theMouseEvent, &metal_drag_ok);
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ void wxApp::doMacMouseMotion(void)
|
|||
theMouseEvent->controlDown = FALSE;
|
||||
theMouseEvent->altDown = isAltKey;
|
||||
theMouseEvent->metaDown = cCurrentEvent.modifiers & cmdKey;
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when); // mflatt
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when);
|
||||
|
||||
if (wxWindow::gMouseWindow)
|
||||
{
|
||||
|
@ -560,7 +560,7 @@ void wxApp::doMacMouseLeave(void)
|
|||
theMouseEvent->controlDown = FALSE;
|
||||
theMouseEvent->altDown = isAltKey;
|
||||
theMouseEvent->metaDown = cCurrentEvent.modifiers & cmdKey;
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when); // mflatt
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when);
|
||||
|
||||
rc = (void *)cCurrentEvent.message;
|
||||
win = (wxWindow*)GET_SAFEREF(rc);
|
||||
|
@ -601,7 +601,7 @@ void wxApp::doMacKeyUpDown(Bool down)
|
|||
{
|
||||
wxFrame* theMacWxFrame;
|
||||
wxKeyEvent *theKeyEvent;
|
||||
int key;
|
||||
int key, otherKey = 0;
|
||||
|
||||
theMacWxFrame = findMacWxFrame(MrEdKeyWindow());
|
||||
|
||||
|
@ -742,102 +742,123 @@ void wxApp::doMacKeyUpDown(Bool down)
|
|||
break;
|
||||
default:
|
||||
{
|
||||
char cstr[3];
|
||||
int from_str = 0;
|
||||
int iter, akey, orig_key = key;
|
||||
|
||||
if (cCurrentEvent.modifiers & wxMacDisableMods) {
|
||||
/* The following code manually translates the virtual key event
|
||||
into a character. We'd use this code all the time, except
|
||||
that dead keys have already been filtered before we get here,
|
||||
which means that option-e-e doesn't produce an accented e.
|
||||
So, instead, we only use this code to find out what would
|
||||
happen if the control key weren't pressed. */
|
||||
int mods;
|
||||
OSStatus status;
|
||||
UniCharCount len;
|
||||
UniChar keys[1];
|
||||
SInt16 currentKeyLayoutID;
|
||||
static UCKeyboardLayout *key_layout;
|
||||
key = 0; /* let compiler know that key is assigned */
|
||||
for (iter = 0; iter < ((cCurrentEvent.modifiers & cmdKey) ? 2 : 1); iter++) {
|
||||
char cstr[3];
|
||||
int from_str = 0;
|
||||
|
||||
/* Remove effect of anything in wxMacDisableMods: */
|
||||
mods = cCurrentEvent.modifiers - (cCurrentEvent.modifiers & wxMacDisableMods);
|
||||
akey = orig_key;
|
||||
|
||||
currentKeyLayoutID = GetScriptVariable(GetScriptManagerVariable(smKeyScript), smScriptKeys);
|
||||
if ((!uchrHandle && !KCHRHandle) || (currentKeyLayoutID != lastKeyLayoutID)) {
|
||||
key_state = 0;
|
||||
KCHRHandle = GetResource('KCHR', currentKeyLayoutID);
|
||||
if (!KCHRHandle)
|
||||
uchrHandle = GetResource('uchr', currentKeyLayoutID);
|
||||
else
|
||||
uchrHandle = NULL;
|
||||
lastKeyLayoutID = currentKeyLayoutID;
|
||||
}
|
||||
if (cCurrentEvent.modifiers & (wxMacDisableMods | cmdKey)) {
|
||||
/* The following code manually translates the virtual key event
|
||||
into a character. We'd use this code all the time, except
|
||||
that dead keys have already been filtered before we get here,
|
||||
which means that option-e-e doesn't produce an accented e.
|
||||
So, instead, we only use this code to find out what would
|
||||
happen if the control/option key wasn't pressed. */
|
||||
int mods;
|
||||
OSStatus status;
|
||||
UniCharCount len;
|
||||
UniChar keys[1];
|
||||
SInt16 currentKeyLayoutID;
|
||||
static UCKeyboardLayout *key_layout;
|
||||
|
||||
if (!uchrHandle) {
|
||||
if (!KCHRHandle) {
|
||||
key = '?';
|
||||
mods = cCurrentEvent.modifiers;
|
||||
if (mods & cmdKey) {
|
||||
/* Strip control and option modifiers when command is pressed: */
|
||||
mods -= (mods & (optionKey | controlKey | cmdKey | shiftKey));
|
||||
/* On second iteration, set the shift key: */
|
||||
if (iter)
|
||||
mods |= shiftKey;
|
||||
} else {
|
||||
int trans;
|
||||
trans = KeyTranslate(*KCHRHandle, key | mods, &key_state);
|
||||
if (trans & 0xFF0000) {
|
||||
/* 2-byte result */
|
||||
cstr[0] = (trans & 0xFF0000) >> 16;
|
||||
cstr[1] = trans & 0xFF;
|
||||
cstr[2] = 0;
|
||||
} else {
|
||||
/* 1-byte result */
|
||||
cstr[0] = trans & 0xFF;
|
||||
cstr[1] = 0;
|
||||
}
|
||||
/* Remove effect of anything in wxMacDisableMods: */
|
||||
mods -= (mods & wxMacDisableMods);
|
||||
}
|
||||
|
||||
key = '?'; /* temporary */
|
||||
from_str = 1;
|
||||
currentKeyLayoutID = GetScriptVariable(GetScriptManagerVariable(smKeyScript), smScriptKeys);
|
||||
if ((!uchrHandle && !KCHRHandle) || (currentKeyLayoutID != lastKeyLayoutID)) {
|
||||
key_state = 0;
|
||||
KCHRHandle = GetResource('KCHR', currentKeyLayoutID);
|
||||
if (!KCHRHandle)
|
||||
uchrHandle = GetResource('uchr', currentKeyLayoutID);
|
||||
else
|
||||
uchrHandle = NULL;
|
||||
lastKeyLayoutID = currentKeyLayoutID;
|
||||
}
|
||||
|
||||
if (!uchrHandle) {
|
||||
if (!KCHRHandle) {
|
||||
akey = '?';
|
||||
} else {
|
||||
int trans;
|
||||
trans = KeyTranslate(*KCHRHandle, akey | mods, &key_state);
|
||||
if (trans & 0xFF0000) {
|
||||
/* 2-byte result */
|
||||
cstr[0] = (trans & 0xFF0000) >> 16;
|
||||
cstr[1] = trans & 0xFF;
|
||||
cstr[2] = 0;
|
||||
} else {
|
||||
/* 1-byte result */
|
||||
cstr[0] = trans & 0xFF;
|
||||
cstr[1] = 0;
|
||||
}
|
||||
|
||||
akey = '?'; /* temporary */
|
||||
from_str = 1;
|
||||
}
|
||||
} else {
|
||||
key_layout = (UCKeyboardLayout *)*uchrHandle;
|
||||
|
||||
status = UCKeyTranslate(key_layout,
|
||||
akey,
|
||||
cCurrentEvent.what - keyDown,
|
||||
mods >> 8,
|
||||
LMGetKbdType(),
|
||||
0 /* options */,
|
||||
&key_state,
|
||||
1,
|
||||
&len,
|
||||
keys);
|
||||
|
||||
if (status == noErr)
|
||||
akey = keys[0];
|
||||
else
|
||||
akey = '?';
|
||||
}
|
||||
} else {
|
||||
key_layout = (UCKeyboardLayout *)*uchrHandle;
|
||||
|
||||
status = UCKeyTranslate(key_layout,
|
||||
key,
|
||||
cCurrentEvent.what - keyDown,
|
||||
mods >> 8,
|
||||
LMGetKbdType(),
|
||||
0 /* options */,
|
||||
&key_state,
|
||||
1,
|
||||
&len,
|
||||
keys);
|
||||
|
||||
if (status == noErr)
|
||||
key = keys[0];
|
||||
else
|
||||
key = '?';
|
||||
akey = '?'; /* temporary */
|
||||
cstr[0] = cCurrentEvent.message & charCodeMask;
|
||||
cstr[1] = 0;
|
||||
from_str = 1;
|
||||
}
|
||||
} else {
|
||||
key = '?'; /* temporary */
|
||||
cstr[0] = cCurrentEvent.message & charCodeMask;
|
||||
cstr[1] = 0;
|
||||
from_str = 1;
|
||||
}
|
||||
|
||||
if (from_str) {
|
||||
CFStringRef str;
|
||||
UniChar keys[1];
|
||||
if (from_str) {
|
||||
CFStringRef str;
|
||||
UniChar keys[1];
|
||||
|
||||
str = CFStringCreateWithCStringNoCopy(NULL, cstr,
|
||||
GetScriptManagerVariable(smKeyScript),
|
||||
kCFAllocatorNull);
|
||||
if (str) {
|
||||
if (CFStringGetLength(str) > 0) {
|
||||
GC_CAN_IGNORE CFRange rng;
|
||||
rng = CFRangeMake(0, 1);
|
||||
CFStringGetCharacters(str, rng, keys);
|
||||
str = CFStringCreateWithCStringNoCopy(NULL, cstr,
|
||||
GetScriptManagerVariable(smKeyScript),
|
||||
kCFAllocatorNull);
|
||||
if (str) {
|
||||
if (CFStringGetLength(str) > 0) {
|
||||
GC_CAN_IGNORE CFRange rng;
|
||||
rng = CFRangeMake(0, 1);
|
||||
CFStringGetCharacters(str, rng, keys);
|
||||
} else
|
||||
keys[0] = '?';
|
||||
CFRelease(str);
|
||||
} else
|
||||
keys[0] = '?';
|
||||
CFRelease(str);
|
||||
} else
|
||||
keys[0] = '?';
|
||||
|
||||
key = keys[0];
|
||||
akey = keys[0];
|
||||
}
|
||||
|
||||
if (!iter)
|
||||
key = akey;
|
||||
else
|
||||
otherKey = akey;
|
||||
}
|
||||
}
|
||||
} // end switch
|
||||
|
@ -850,6 +871,7 @@ void wxApp::doMacKeyUpDown(Bool down)
|
|||
theKeyEvent->keyCode = WXK_RELEASE;
|
||||
theKeyEvent->keyUpCode = key;
|
||||
}
|
||||
theKeyEvent->otherKeyCode = otherKey;
|
||||
|
||||
{
|
||||
wxWindow *in_win;
|
||||
|
@ -1152,7 +1174,7 @@ void wxApp::doMacContentClick(wxFrame* frame)
|
|||
theMouseEvent->controlDown = FALSE;
|
||||
theMouseEvent->altDown = isAltKey;
|
||||
theMouseEvent->metaDown = cCurrentEvent.modifiers & cmdKey;
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when); // mflatt
|
||||
theMouseEvent->timeStamp = SCALE_TIMESTAMP(cCurrentEvent.when);
|
||||
|
||||
hitX = cCurrentEvent.where.h; // screen window c.s.
|
||||
hitY = cCurrentEvent.where.v; // screen window c.s.
|
||||
|
@ -1354,3 +1376,80 @@ void wxPrimDialogCleanUp()
|
|||
event.message = (long)w;
|
||||
QueueMrEdEvent(&event);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
int wxKeyCodeToVirtualKey(int wxk) {
|
||||
switch (wxk) {
|
||||
# define wxKEYF(code, wxk) case wxk: return code
|
||||
wxKEYF(122, WXK_F1);
|
||||
wxKEYF(120, WXK_F2);
|
||||
wxKEYF(99, WXK_F3);
|
||||
wxKEYF(118, WXK_F4);
|
||||
wxKEYF(96, WXK_F5);
|
||||
wxKEYF(97, WXK_F6);
|
||||
wxKEYF(98, WXK_F7);
|
||||
wxKEYF(100, WXK_F8);
|
||||
wxKEYF(101, WXK_F9);
|
||||
wxKEYF(109, WXK_F10);
|
||||
wxKEYF(103, WXK_F11);
|
||||
wxKEYF(111, WXK_F12);
|
||||
wxKEYF(105, WXK_F13);
|
||||
wxKEYF(107, WXK_F14);
|
||||
wxKEYF(113, WXK_F15);
|
||||
case WXK_UP:
|
||||
return 0x7e;
|
||||
case WXK_DOWN:
|
||||
return 0x7d;
|
||||
case WXK_LEFT:
|
||||
return 0x7b;
|
||||
case WXK_RIGHT:
|
||||
return 0x7c;
|
||||
case WXK_RETURN:
|
||||
return 0x24;
|
||||
case WXK_TAB:
|
||||
return 0x30;
|
||||
case WXK_BACK:
|
||||
return 0x33;
|
||||
case WXK_DELETE:
|
||||
return 0x75;
|
||||
case WXK_HOME:
|
||||
return 0x73;
|
||||
case WXK_END:
|
||||
return 0x77;
|
||||
case WXK_PRIOR:
|
||||
return 0x74;
|
||||
case WXK_NEXT:
|
||||
return 0x79;
|
||||
case WXK_ADD:
|
||||
return 0x45;
|
||||
case WXK_SUBTRACT:
|
||||
return 78;
|
||||
case WXK_MULTIPLY:
|
||||
return 0x43;
|
||||
case WXK_DIVIDE:
|
||||
return 0x4B;
|
||||
case WXK_SEPARATOR:
|
||||
return 71;
|
||||
case WXK_DECIMAL:
|
||||
return 65;
|
||||
case 3:
|
||||
return 76;
|
||||
case WXK_NUMPAD0:
|
||||
case WXK_NUMPAD1:
|
||||
case WXK_NUMPAD2:
|
||||
case WXK_NUMPAD3:
|
||||
case WXK_NUMPAD4:
|
||||
case WXK_NUMPAD5:
|
||||
case WXK_NUMPAD6:
|
||||
case WXK_NUMPAD7:
|
||||
return (wxk - WXK_NUMPAD0) + 82;
|
||||
case WXK_NUMPAD8:
|
||||
return 91;
|
||||
case WXK_NUMPAD9:
|
||||
return 92;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1189,7 +1189,7 @@ void wxGL::Reset(wxGLConfig *cfg, CGrafPtr gp, int offscreen, int w, int h)
|
|||
aglSetDrawable(ctx, NULL);
|
||||
aglDestroyContext(ctx);
|
||||
|
||||
gl_ctx = NULL;
|
||||
gl_ctx = 0;
|
||||
}
|
||||
|
||||
if (gp) {
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
int wxNumHelpItems;
|
||||
MenuHandle wxHelpMenu;
|
||||
|
||||
extern int wxKeyCodeToVirtualKey(int wxk);
|
||||
|
||||
void wxSetUpAppleMenu(wxMenuBar *mbar);
|
||||
|
||||
extern int wxCan_Do_Pref();
|
||||
|
@ -219,10 +221,10 @@ wxMenu::~wxMenu(void)
|
|||
// setupstr should be used with AppendItem; the result should then be used with SetMenuItemText
|
||||
// If stripCmds is TRUE, instead of replacing wxMenu string special chars,
|
||||
// we delete them. This is appropriate for the menu text of a pulldown Menu.
|
||||
char *wxBuildMacMenuString(StringPtr setupstr, char *itemName, Bool stripCmds)
|
||||
char *wxBuildMacMenuString(StringPtr setupstr, char *itemName,
|
||||
int *spc, int *modifiers, int *is_virt)
|
||||
{
|
||||
int s, d;
|
||||
char spc = '\0';
|
||||
char *showstr;
|
||||
|
||||
showstr = copystring(itemName);
|
||||
|
@ -232,9 +234,27 @@ char *wxBuildMacMenuString(StringPtr setupstr, char *itemName, Bool stripCmds)
|
|||
showstr[d++] = ' ';
|
||||
for (s = 0; itemName[s] != '\0'; ) {
|
||||
if (itemName[s] == '\t') {
|
||||
s++;
|
||||
if (strncmp("Cmd+", itemName + s, 4) == 0)
|
||||
spc = itemName[s+4];
|
||||
if (spc) {
|
||||
s++;
|
||||
if (strncmp("Cmd+", itemName + s, 4) == 0) {
|
||||
*spc = itemName[s+4];
|
||||
*modifiers = 0;
|
||||
*is_virt = 0;
|
||||
}
|
||||
if (strncmp("Cut=", itemName + s, 4) == 0) {
|
||||
/* 1 byte for modfiers, then string version of a integer: */
|
||||
int vk;
|
||||
*modifiers = itemName[s+4] - 'A';
|
||||
vk = strtol(itemName XFORM_OK_PLUS (s + 5), NULL, 10);
|
||||
*spc = vk;
|
||||
vk = wxKeyCodeToVirtualKey(*spc);
|
||||
if (vk) {
|
||||
*spc = vk;
|
||||
*is_virt = 1;
|
||||
} else
|
||||
*is_virt = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
@ -247,12 +267,7 @@ char *wxBuildMacMenuString(StringPtr setupstr, char *itemName, Bool stripCmds)
|
|||
showstr = wxItemStripLabel(showstr);
|
||||
if (setupstr) {
|
||||
setupstr[1] = 'X'; // temporary menu item name
|
||||
if (spc && !stripCmds) {
|
||||
setupstr[2] = '/';
|
||||
setupstr[3] = spc;
|
||||
setupstr[0] = 3;
|
||||
} else
|
||||
setupstr[0] = 1;
|
||||
setupstr[0] = 1;
|
||||
}
|
||||
|
||||
return showstr;
|
||||
|
@ -266,6 +281,7 @@ MenuHandle wxMenu::CreateCopy(char *title, Bool doabouthack, MenuHandle toHandle
|
|||
int helpflg;
|
||||
int hId;
|
||||
int cnt;
|
||||
int spc, modifiers, is_virt;
|
||||
wxNode* node;
|
||||
wxMenuItem* menuItem;
|
||||
|
||||
|
@ -300,6 +316,7 @@ MenuHandle wxMenu::CreateCopy(char *title, Bool doabouthack, MenuHandle toHandle
|
|||
// Try to recreate from the wxMenuItem
|
||||
menuItem = (wxMenuItem*)node->Data();
|
||||
hId = 0;
|
||||
spc = 0;
|
||||
if (menuItem->itemId == -1) {
|
||||
// Separator
|
||||
title = "-";
|
||||
|
@ -307,12 +324,12 @@ MenuHandle wxMenu::CreateCopy(char *title, Bool doabouthack, MenuHandle toHandle
|
|||
tempString[1] = '-';
|
||||
} else if (menuItem->subMenu) {
|
||||
wxMenu *subMenu;
|
||||
title = wxBuildMacMenuString(tempString, menuItem->itemName, TRUE);
|
||||
title = wxBuildMacMenuString(tempString, menuItem->itemName, NULL, NULL, NULL);
|
||||
subMenu = menuItem->subMenu;
|
||||
subMenu->wxMacInsertSubmenu();
|
||||
hId = subMenu->cMacMenuId;
|
||||
} else {
|
||||
title = wxBuildMacMenuString(tempString, menuItem->itemName, FALSE);
|
||||
title = wxBuildMacMenuString(tempString, menuItem->itemName, &spc, &modifiers, &is_virt);
|
||||
if (!i && doabouthack && helpflg && (!strncmp("About", title, 5))) {
|
||||
if (menu_bar) {
|
||||
// This is a very sad hack !
|
||||
|
@ -327,6 +344,10 @@ MenuHandle wxMenu::CreateCopy(char *title, Bool doabouthack, MenuHandle toHandle
|
|||
::SetMenuItemTextWithCFString(nmh, i + offset, ct);
|
||||
CFRelease(ct);
|
||||
}
|
||||
if (spc) {
|
||||
SetMenuItemCommandKey(nmh, i + offset, is_virt, spc);
|
||||
SetMenuItemModifiers(nmh, i + offset, modifiers);
|
||||
}
|
||||
{
|
||||
Bool v;
|
||||
v = menuItem->IsChecked();
|
||||
|
@ -809,6 +830,7 @@ void wxMenu::Append(int Id, char* Label, char* helpString, Bool checkable)
|
|||
// assert(Id >= 1);
|
||||
wxMenuItem* item;
|
||||
Str255 menusetup;
|
||||
int spc = 0, modifiers, is_virt;
|
||||
|
||||
item = new WXGC_PTRS wxMenuItem(this, checkable);
|
||||
|
||||
|
@ -818,7 +840,7 @@ void wxMenu::Append(int Id, char* Label, char* helpString, Bool checkable)
|
|||
menuItems->Append(item);
|
||||
no_items ++;
|
||||
|
||||
Label = wxBuildMacMenuString(menusetup, item->itemName, FALSE);
|
||||
Label = wxBuildMacMenuString(menusetup, item->itemName, &spc, &modifiers, &is_virt);
|
||||
wxPrepareMenuDraw();
|
||||
::AppendMenu(cMacMenu, menusetup);
|
||||
{
|
||||
|
@ -827,6 +849,10 @@ void wxMenu::Append(int Id, char* Label, char* helpString, Bool checkable)
|
|||
::SetMenuItemTextWithCFString(cMacMenu, no_items, ct);
|
||||
CFRelease(ct);
|
||||
}
|
||||
if (spc) {
|
||||
SetMenuItemCommandKey(cMacMenu, no_items, is_virt, spc);
|
||||
SetMenuItemModifiers(cMacMenu, no_items, modifiers);
|
||||
}
|
||||
wxDoneMenuDraw();
|
||||
CheckHelpHack();
|
||||
}
|
||||
|
@ -859,7 +885,7 @@ void wxMenu::Append(int Id, char* Label, wxMenu* SubMenu, char* helpString)
|
|||
menuItems->Append(item);
|
||||
no_items++;
|
||||
|
||||
Label = wxBuildMacMenuString(menusetup, item->itemName, TRUE);
|
||||
Label = wxBuildMacMenuString(menusetup, item->itemName, NULL, NULL, NULL);
|
||||
|
||||
wxPrepareMenuDraw();
|
||||
::AppendMenu(cMacMenu, menusetup);
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
#include "wx_utils.h"
|
||||
#include "wx_mac_utils.h"
|
||||
|
||||
extern char *wxBuildMacMenuString(StringPtr setupstr, char *itemName, Bool stripCmds);
|
||||
extern char *wxBuildMacMenuString(StringPtr setupstr, char *itemName,
|
||||
int *spc, int *modifiers, int *is_virt);
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Constructors
|
||||
|
@ -146,20 +147,28 @@ void wxMenuItem::SetLabel(char* label)
|
|||
Str255 tempString;
|
||||
char *s;
|
||||
MenuHandle nmh;
|
||||
int spc = 0, modifiers, is_virt;
|
||||
|
||||
nmh = parentMenu->MacMenu();
|
||||
|
||||
s = wxBuildMacMenuString(tempString, label, 0);
|
||||
s = wxBuildMacMenuString(tempString, label,
|
||||
&spc, &modifiers, &is_virt);
|
||||
|
||||
/* Add item such the command keys are set */
|
||||
/* Effectively clears shortcuts, if any: */
|
||||
::DeleteMenuItem(nmh, macMenuItem);
|
||||
::InsertMenuItem(nmh, tempString, macMenuItem - 1);
|
||||
|
||||
/* Install the real label */
|
||||
/* Install the label */
|
||||
ct = wxCFString(s);
|
||||
::SetMenuItemTextWithCFString(nmh, macMenuItem, ct);
|
||||
CFRelease(ct);
|
||||
|
||||
/* Set the command key: */
|
||||
if (spc) {
|
||||
SetMenuItemCommandKey(nmh, macMenuItem, is_virt, spc);
|
||||
SetMenuItemModifiers(nmh, macMenuItem, modifiers);
|
||||
}
|
||||
|
||||
/* restore the submenu id, if any */
|
||||
if (subMenu)
|
||||
::SetMenuItemHierarchicalID(nmh, macMenuItem, subMenu->cMacMenuId);
|
||||
|
|
|
@ -183,6 +183,7 @@ class wxKeyEvent: public wxEvent
|
|||
int y ;
|
||||
long keyCode;
|
||||
long keyUpCode;
|
||||
long otherKeyCode;
|
||||
Bool controlDown;
|
||||
Bool shiftDown;
|
||||
Bool altDown;
|
||||
|
|
|
@ -129,4 +129,8 @@ int wxCharCodeWXToMSW(int id, Bool *IsVirtual);
|
|||
int wxEventTrampoline(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam,
|
||||
LRESULT *res, WNDPROC proc);
|
||||
|
||||
extern wxKeyEvent *wxMakeCharEvent(BOOL just_check, WORD wParam, LPARAM lParam, Bool isASCII, Bool isRelease, HWND handle);
|
||||
|
||||
extern BOOL wxTranslateMessage(MSG *m);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -245,8 +245,6 @@ static int skip_next_return;
|
|||
extern int wx_start_win_event(const char *who, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, int tramp, LONG *_retval);
|
||||
extern void wx_end_win_event(const char *who, HWND hWnd, UINT message, int tramp);
|
||||
|
||||
extern wxKeyEvent *wxMakeCharEvent(WORD wParam, LPARAM lParam, Bool isASCII, Bool isRelease, HWND handle);
|
||||
|
||||
LONG wxDoItemPres(wxItem *item, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam,
|
||||
long *result, int tramp)
|
||||
{
|
||||
|
@ -426,7 +424,7 @@ LONG wxDoItemPres(wxItem *item, HWND hWnd, UINT message, WPARAM wParam, LPARAM l
|
|||
|
||||
event = new wxKeyEvent(wxEVENT_TYPE_CHAR);
|
||||
|
||||
event = wxMakeCharEvent(wParam, lParam,
|
||||
event = wxMakeCharEvent(FALSE, wParam, lParam,
|
||||
((message == WM_CHAR) || (message == WM_SYSCHAR)),
|
||||
FALSE, hWnd);
|
||||
|
||||
|
|
|
@ -1128,19 +1128,10 @@ static LONG WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, in
|
|||
wxUnhideCursor();
|
||||
retval = wnd->DefWindowProc(message, wParam, lParam);
|
||||
}
|
||||
case WM_KEYUP:
|
||||
case WM_KEYUP: /* ^^^ fallthrough */
|
||||
case WM_KEYDOWN: /* ^^^ fallthrough */
|
||||
{
|
||||
// Avoid duplicate messages to OnChar
|
||||
if ((message == WM_KEYUP)
|
||||
|| ((wParam != VK_ESCAPE)
|
||||
&& (wParam != VK_SHIFT)
|
||||
&& (wParam != VK_CONTROL)
|
||||
&& (wParam != VK_SPACE)
|
||||
&& (wParam != VK_RETURN)
|
||||
&& (wParam != VK_TAB)
|
||||
&& (wParam != VK_BACK)))
|
||||
wnd->OnChar((WORD)wParam, lParam, FALSE, message == WM_KEYUP);
|
||||
wnd->OnChar((WORD)wParam, lParam, FALSE, message == WM_KEYUP);
|
||||
break;
|
||||
}
|
||||
case WM_SYSCHAR:
|
||||
|
@ -2011,122 +2002,75 @@ static int dot_scan_code;
|
|||
|
||||
static int generic_ascii_code[256];
|
||||
|
||||
static const char *find_shift_alts = "!@#$%^&*()_+-=\\|[]{}:\";',.<>/?~`";
|
||||
static int shift_alt_key_codes[36], sakc_initialized;
|
||||
|
||||
#define THE_SCAN_CODE(lParam) ((((unsigned long)lParam) >> 16) & 0x1FF)
|
||||
|
||||
wxKeyEvent *wxMakeCharEvent(WORD wParam, LPARAM lParam, Bool isASCII, Bool isRelease, HWND handle)
|
||||
wxKeyEvent *wxMakeCharEvent(BOOL just_check, WORD wParam, LPARAM lParam, Bool isASCII, Bool isRelease, HWND handle)
|
||||
{
|
||||
int id;
|
||||
Bool tempControlDown;
|
||||
int id, other_id = 0;
|
||||
Bool tempControlDown, tempAltDown;
|
||||
|
||||
tempControlDown = (::GetKeyState(VK_CONTROL) >> 1);
|
||||
tempAltDown = ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN);
|
||||
|
||||
if (isASCII) {
|
||||
int sc;
|
||||
|
||||
// If 1 -> 26, translate to CTRL plus a letter.
|
||||
id = wParam;
|
||||
if ((id > 0) && (id < 27) && tempControlDown) {
|
||||
id = id + 96;
|
||||
}
|
||||
// Map id 28 to ctl+backslash
|
||||
if (tempControlDown) {
|
||||
switch (id) {
|
||||
case 27:
|
||||
id = '[';
|
||||
break;
|
||||
case 28:
|
||||
id = '\\';
|
||||
break;
|
||||
case 29:
|
||||
id = ']';
|
||||
break;
|
||||
case 30:
|
||||
id = '^';
|
||||
break;
|
||||
case 31:
|
||||
id = '_';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ignore character created by numpad, since it's
|
||||
already handled as WM_KEYDOWN */
|
||||
/* Remember scan codes to help with some key-release events: */
|
||||
sc = THE_SCAN_CODE(lParam);
|
||||
if (sc) {
|
||||
if ((id >= '0') && (id <= '9')) {
|
||||
if (numpad_scan_codes[id - '0'] == sc)
|
||||
id = -1;
|
||||
} else if (id == '+') {
|
||||
if (sc == plus_scan_code)
|
||||
id = -1;
|
||||
} else if (id == '-') {
|
||||
if (sc == minus_scan_code)
|
||||
id = -1;
|
||||
} else if (id == '*') {
|
||||
if (sc == times_scan_code)
|
||||
id = -1;
|
||||
} else if (id == '/') {
|
||||
if (sc == divide_scan_code)
|
||||
id = -1;
|
||||
} else if (id == '.') {
|
||||
if (sc == dot_scan_code)
|
||||
id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((id >= 0) && (id <= 255))
|
||||
generic_ascii_code[id] = sc;
|
||||
} else {
|
||||
int override_mapping = (tempControlDown && !tempAltDown);
|
||||
|
||||
if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
|
||||
if (tempControlDown) {
|
||||
int sd;
|
||||
sd = (::GetKeyState(VK_SHIFT) >> 1);
|
||||
switch(wParam) {
|
||||
case VK_OEM_1:
|
||||
id = (sd ? ':' : ';');
|
||||
break;
|
||||
case VK_OEM_2:
|
||||
id = (sd ? '|' : -1);
|
||||
break;
|
||||
case VK_OEM_3:
|
||||
id = (sd ? '~' : '`');
|
||||
break;
|
||||
case VK_OEM_7:
|
||||
id = (sd ? '"' : '\'');
|
||||
break;
|
||||
case VK_OEM_PLUS:
|
||||
id = (sd ? '+' : '=');
|
||||
break;
|
||||
case VK_OEM_MINUS:
|
||||
id = (sd ? -1 : '-');
|
||||
break;
|
||||
case VK_OEM_PERIOD:
|
||||
id = (sd ? '>' : '.');
|
||||
break;
|
||||
case VK_OEM_COMMA:
|
||||
id = (sd ? '<' : ',');
|
||||
break;
|
||||
default:
|
||||
if (override_mapping || isRelease) {
|
||||
int j;
|
||||
|
||||
id = MapVirtualKey(wParam, 2);
|
||||
id &= 0xFFFF;
|
||||
if (!id)
|
||||
id = -1;
|
||||
else if (id < 128)
|
||||
id = tolower(id);
|
||||
|
||||
/* Look for shifted alternate: */
|
||||
if (!sakc_initialized) {
|
||||
for (j = 0; find_shift_alts[j]; j++) {
|
||||
shift_alt_key_codes[j] = VkKeyScan(find_shift_alts[j]) & 0xFF;
|
||||
}
|
||||
}
|
||||
for (j = 0; find_shift_alts[j]; j++) {
|
||||
if (shift_alt_key_codes[j] == wParam) {
|
||||
if (find_shift_alts[j] != id) {
|
||||
other_id = find_shift_alts[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
id = -1;
|
||||
}
|
||||
if ((id >= WXK_NUMPAD0) && (id <= WXK_NUMPAD9)) {
|
||||
/* remember scan code so we can ignore the WM_CHAR part */
|
||||
numpad_scan_codes[id - WXK_NUMPAD0] = THE_SCAN_CODE(lParam);
|
||||
} else if (id == WXK_ADD) {
|
||||
plus_scan_code = THE_SCAN_CODE(lParam);
|
||||
} else if (id == WXK_SUBTRACT) {
|
||||
minus_scan_code = THE_SCAN_CODE(lParam);
|
||||
} else if (id == WXK_MULTIPLY) {
|
||||
times_scan_code = THE_SCAN_CODE(lParam);
|
||||
} else if (id == WXK_DIVIDE) {
|
||||
divide_scan_code = THE_SCAN_CODE(lParam);
|
||||
} else if (id == WXK_DECIMAL) {
|
||||
dot_scan_code = THE_SCAN_CODE(lParam);
|
||||
} else {
|
||||
/* Don't generat control-key down events: */
|
||||
if (!isRelease && (wParam == VK_CONTROL))
|
||||
return NULL;
|
||||
|
||||
if (!override_mapping && !isRelease) {
|
||||
/* Let these get translated to WM_CHAR or skipped
|
||||
entirely: */
|
||||
if ((wParam == VK_ESCAPE)
|
||||
|| (wParam == VK_SHIFT)
|
||||
|| (wParam == VK_CONTROL)
|
||||
|| (wParam == VK_SPACE)
|
||||
|| (wParam == VK_RETURN)
|
||||
|| (wParam == VK_TAB)
|
||||
|| (wParam == VK_BACK))
|
||||
id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (isRelease && (id < 0)) {
|
||||
|
@ -2136,10 +2080,16 @@ wxKeyEvent *wxMakeCharEvent(WORD wParam, LPARAM lParam, Bool isASCII, Bool isRel
|
|||
for (i = 0; i < 256; i++) {
|
||||
if (generic_ascii_code[i] == sc) {
|
||||
id = i;
|
||||
if (id < 127)
|
||||
id = tolower(id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (id < 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (id > -1) {
|
||||
|
@ -2147,18 +2097,22 @@ wxKeyEvent *wxMakeCharEvent(WORD wParam, LPARAM lParam, Bool isASCII, Bool isRel
|
|||
RECT rect;
|
||||
wxKeyEvent *event;
|
||||
|
||||
if (just_check)
|
||||
return (wxKeyEvent *)0x1;
|
||||
|
||||
event = new wxKeyEvent(wxEVENT_TYPE_CHAR);
|
||||
|
||||
if (::GetKeyState(VK_SHIFT) >> 1)
|
||||
event->shiftDown = TRUE;
|
||||
if (tempControlDown)
|
||||
event->controlDown = TRUE;
|
||||
if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
|
||||
if (tempAltDown)
|
||||
event->metaDown = TRUE;
|
||||
|
||||
event->keyCode = (isRelease ? WXK_RELEASE : id);
|
||||
event->keyUpCode = (isRelease ? id : WXK_PRESS);
|
||||
event->SetTimestamp(last_msg_time); /* MATTHEW: timeStamp */
|
||||
event->otherKeyCode = other_id;
|
||||
event->SetTimestamp(last_msg_time);
|
||||
|
||||
GetCursorPos(&pt);
|
||||
GetWindowRect(handle,&rect);
|
||||
|
@ -2173,11 +2127,23 @@ wxKeyEvent *wxMakeCharEvent(WORD wParam, LPARAM lParam, Bool isASCII, Bool isRel
|
|||
return NULL;
|
||||
}
|
||||
|
||||
BOOL wxTranslateMessage(MSG *m)
|
||||
{
|
||||
if ((m->message == WM_KEYDOWN) || (m->message == WM_SYSKEYDOWN)
|
||||
|| (m->message == WM_KEYUP) || (m->message == WM_SYSKEYUP))
|
||||
if (!wxMakeCharEvent(TRUE, m->wParam, m->lParam, FALSE,
|
||||
(m->message == WM_KEYUP) || (m->message == WM_SYSKEYUP),
|
||||
m->hwnd))
|
||||
return TranslateMessage(m);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxWnd::OnChar(WORD wParam, LPARAM lParam, Bool isASCII, Bool isRelease)
|
||||
{
|
||||
wxKeyEvent *event;
|
||||
|
||||
event = wxMakeCharEvent(wParam, lParam, isASCII, isRelease, handle);
|
||||
event = wxMakeCharEvent(FALSE, wParam, lParam, isASCII, isRelease, handle);
|
||||
|
||||
if (event && wx_window) {
|
||||
if (!wx_window->CallPreOnChar(wx_window->PreWindow(), event))
|
||||
|
|
|
@ -128,6 +128,7 @@ class wxKeyEvent: public wxEvent
|
|||
int y ;
|
||||
long keyCode;
|
||||
long keyUpCode;
|
||||
long otherKeyCode;
|
||||
Bool controlDown;
|
||||
Bool shiftDown;
|
||||
Bool altDown;
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
static Atom utf8_atom = 0, net_wm_name_atom, net_wm_icon_name_atom;
|
||||
|
||||
extern void wxSetSensitive(Widget, Bool enabled);
|
||||
extern int wxLocaleStringToChar(char *str, int slen);
|
||||
extern int wxUTF8StringToChar(char *str, int slen);
|
||||
|
||||
static wxWindow *grabbing_panel;
|
||||
static Time grabbing_panel_time;
|
||||
|
@ -1571,12 +1573,73 @@ extern Bool wxIsAlt(KeySym key_sym);
|
|||
static XComposeStatus compose_status;
|
||||
#ifndef NO_XMB_LOOKUP_STRING
|
||||
# define XMB_KC_STATUS(status) (status == XLookupKeySym) || (status == XLookupBoth)
|
||||
# define XMB_STR_STATUS(status) (status == XLookupChars) || (status == XLookupBoth)
|
||||
# define DEFAULT_XMB_STATUS XLookupKeySym
|
||||
# ifdef X_HAVE_UTF8_STRING
|
||||
# define X___LookupString Xutf8LookupString
|
||||
# else
|
||||
# define X___LookupString XmbLookupString
|
||||
# endif
|
||||
#else
|
||||
# define XMB_KC_STATUS(status) (status)
|
||||
# define XMB_STR_STATUS(status) 0
|
||||
# define DEFAULT_XMB_STATUS 1
|
||||
#endif
|
||||
|
||||
|
||||
Status wxWindow::LookupKey(int unshifted, Widget w, wxWindow *win, XEvent *xev, KeySym *_keysym, char *str, int *_len)
|
||||
{
|
||||
KeySym keysym;
|
||||
Status status;
|
||||
int len;
|
||||
XKeyPressedEvent evt;
|
||||
|
||||
memcpy(&evt, &(xev->xkey), sizeof(XKeyPressedEvent));
|
||||
if (unshifted) {
|
||||
if (evt.state & ShiftMask)
|
||||
evt.state -= ShiftMask;
|
||||
else
|
||||
evt.state |= ShiftMask;
|
||||
}
|
||||
|
||||
#ifndef NO_XMB_LOOKUP_STRING
|
||||
if (!the_im) {
|
||||
the_im = XOpenIM(wxAPP_DISPLAY, NULL, NULL, NULL);
|
||||
}
|
||||
if (the_im) {
|
||||
if (!win->X->ic) {
|
||||
win->X->ic = XCreateIC(the_im,
|
||||
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||
NULL);
|
||||
win->X->us_ic = XCreateIC(the_im,
|
||||
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (win->X->ic && (xev->xany.type == KeyPress)) {
|
||||
XIC ic;
|
||||
ic = unshifted ? win->X->ic : win->X->ic;
|
||||
XSetICValues(ic,
|
||||
XNClientWindow, XtWindow(w),
|
||||
XNFocusWindow, XtWindow(w),
|
||||
NULL);
|
||||
XSetICFocus(ic);
|
||||
|
||||
len = X___LookupString(ic, &evt, str, 10, &keysym, &status);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
(void)XLookupString(&evt, str, 10, &keysym, &compose_status);
|
||||
status = DEFAULT_XMB_STATUS;
|
||||
len = 0;
|
||||
}
|
||||
|
||||
*_len = len;
|
||||
*_keysym = keysym;
|
||||
return status;
|
||||
}
|
||||
|
||||
void wxWindow::WindowEventHandler(Widget w,
|
||||
wxWindow **winp,
|
||||
XEvent *xev,
|
||||
|
@ -1639,38 +1702,16 @@ void wxWindow::WindowEventHandler(Widget w,
|
|||
win->current_state = xev->xkey.state;
|
||||
{ /* ^^^ fallthrough !!!! ^^^ */
|
||||
wxKeyEvent *wxevent;
|
||||
KeySym keysym;
|
||||
long kc;
|
||||
Status status;
|
||||
char str[10];
|
||||
KeySym keysym, other_keysym;
|
||||
long kc, other_kc;
|
||||
Status status, other_status;
|
||||
char str[10], other_str[10];
|
||||
int slen, other_slen;
|
||||
|
||||
wxevent = new wxKeyEvent(wxEVENT_TYPE_CHAR);
|
||||
|
||||
#ifndef NO_XMB_LOOKUP_STRING
|
||||
if (!the_im) {
|
||||
the_im = XOpenIM(wxAPP_DISPLAY, NULL, NULL, NULL);
|
||||
}
|
||||
if (!win->X->ic) {
|
||||
if (the_im) {
|
||||
win->X->ic = XCreateIC(the_im,
|
||||
XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (win->X->ic && (xev->xany.type == KeyPress)) {
|
||||
XSetICValues(win->X->ic,
|
||||
XNClientWindow, XtWindow(w),
|
||||
XNFocusWindow, XtWindow(w),
|
||||
NULL);
|
||||
XSetICFocus(win->X->ic);
|
||||
(void)XmbLookupString(win->X->ic, &(xev->xkey), str, 10, &keysym, &status);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
(void)XLookupString(&(xev->xkey), str, 10, &keysym, &compose_status);
|
||||
status = DEFAULT_XMB_STATUS;
|
||||
}
|
||||
status = LookupKey(0, w, win, xev, &keysym, str, &slen);
|
||||
other_status = LookupKey(1, w, win, xev, &other_keysym, other_str, &other_slen);
|
||||
|
||||
if (xev->xany.type == KeyPress) {
|
||||
static int handle_alt = 0;
|
||||
|
@ -1689,15 +1730,39 @@ void wxWindow::WindowEventHandler(Widget w,
|
|||
}
|
||||
}
|
||||
|
||||
if (XMB_KC_STATUS(status))
|
||||
if (XMB_STR_STATUS(status)) {
|
||||
if (slen > 9)
|
||||
slen = 9;
|
||||
str[slen] = 0;
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
kc = wxUTF8StringToChar(str, slen);
|
||||
#else
|
||||
kc = wxLocaleStringToChar(str, slen);
|
||||
#endif
|
||||
} else if (XMB_KC_STATUS(status))
|
||||
kc = CharCodeXToWX(keysym);
|
||||
else
|
||||
kc = 0;
|
||||
|
||||
if (XMB_STR_STATUS(other_status)) {
|
||||
if (other_slen > 9)
|
||||
other_slen = 9;
|
||||
other_str[other_slen] = 0;
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
other_kc = wxUTF8StringToChar(other_str, other_slen);
|
||||
#else
|
||||
other_kc = wxLocaleStringToChar(other_str, other_slen);
|
||||
#endif
|
||||
} else if (XMB_KC_STATUS(other_status))
|
||||
other_kc = CharCodeXToWX(other_keysym);
|
||||
else
|
||||
other_kc = 0;
|
||||
|
||||
// set wxWindows event structure
|
||||
wxevent->eventHandle = (char*)xev;
|
||||
wxevent->keyCode = (xev->xany.type == KeyPress) ? kc : WXK_RELEASE;
|
||||
wxevent->keyUpCode = (xev->xany.type == KeyRelease) ? kc : WXK_PRESS;
|
||||
wxevent->otherKeyCode = other_kc;
|
||||
wxevent->x = xev->xkey.x;
|
||||
wxevent->y = xev->xkey.y;
|
||||
wxevent->altDown = /* xev->xkey.state & Mod3Mask */ FALSE;
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
unsigned int last_clickbutton; // if a double click has arrived
|
||||
#ifndef NO_XMB_LOOKUP_STRING
|
||||
XIC ic;
|
||||
XIC us_ic;
|
||||
XIM im;
|
||||
#endif
|
||||
};
|
||||
|
@ -192,6 +193,7 @@ protected:
|
|||
static void WindowEventHandler(Widget w, wxWindow **win,
|
||||
XEvent *ev, Boolean *continue_to_dispatch_return);
|
||||
static void ScrollEventHandler(Widget w, wxWindow **win, XtPointer p_XfwfScrollInfo);
|
||||
static Status wxWindow::LookupKey(int unshifted, Widget w, wxWindow *win, XEvent *xev, KeySym *_keysym, char *s, int *_len);
|
||||
void RegisterAll(Widget ww);
|
||||
# endif
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue
Block a user