Boolean MCEPS::mup(uint2 which) { if (!(state & CS_MFOCUSED)) return False; state &= ~CS_MFOCUSED; switch (which) { case Button1: switch (getstack()->gettool(this)) { case T_BROWSE: if (MCU_point_in_rect(rect, mx, my)) message_with_args(MCM_mouse_up, "1"); break; case T_POINTER: end(); break; case T_HELP: help(); break; default: return False; } break; case Button2: case Button3: if (MCU_point_in_rect(rect, mx, my)) message_with_args(MCM_mouse_up, which); break; } return True; }
Boolean MCEPS::mdown(uint2 which) { if (state & CS_MFOCUSED) return False; state |= CS_MFOCUSED; switch (which) { case Button1: switch (getstack()->gettool(this)) { case T_BROWSE: message_with_args(MCM_mouse_down, "1"); break; case T_POINTER: start(True); break; case T_HELP: break; default: return False; } break; case Button2: case Button3: message_with_args(MCM_mouse_down, which); break; } return True; }
Boolean MCColors::mup(uint2 which, bool p_release) { if (!(state & CS_MFOCUSED)) return False; state &= ~CS_MFOCUSED; switch (which) { case Button1: switch (getstack()->gettool(this)) { case T_BROWSE: message_with_valueref_args(MCM_mouse_up, MCSTR("1")); break; case T_POINTER: end(true, p_release); break; default: return False; } break; case Button2: case Button3: message_with_args(MCM_mouse_up, which); break; } return True; }
Boolean MCPlayer::mup(uint2 which, bool p_release) //mouse up { if (!(state & CS_MFOCUSED)) return False; if (state & CS_MENU_ATTACHED) return MCObject::mup(which, p_release); state &= ~CS_MFOCUSED; if (state & CS_GRAB) { ungrab(which); return True; } switch (which) { case Button1: switch (getstack()->gettool(this)) { case T_BROWSE: if (!p_release && MCU_point_in_rect(rect, mx, my)) message_with_valueref_args(MCM_mouse_up, MCSTR("1")); else message_with_valueref_args(MCM_mouse_release, MCSTR("1")); break; case T_PLAYER: case T_POINTER: end(true, p_release); //stop dragging or moving the movie object, will change controller size break; case T_HELP: help(); break; default: return False; } break; case Button2: case Button3: if (!p_release && MCU_point_in_rect(rect, mx, my)) message_with_args(MCM_mouse_up, which); else message_with_args(MCM_mouse_release, which); break; } return True; }
Boolean MCScrollbar::kdown(const char *string, KeySym key) { if (!(state & CS_NO_MESSAGES)) if (MCObject::kdown(string, key)) return True; Boolean done = False; switch (key) { case XK_Home: update(0.0, MCM_scrollbar_line_inc); done = True; break; case XK_End: update(endvalue, MCM_scrollbar_end); done = True; break; case XK_Right: case XK_Down: update(thumbpos + lineinc, MCM_scrollbar_line_inc); done = True; break; case XK_Left: case XK_Up: update(thumbpos - lineinc, MCM_scrollbar_line_dec); done = True; break; case XK_Prior: update(thumbpos - pageinc, MCM_scrollbar_page_dec); done = True; break; case XK_Next: update(thumbpos + pageinc, MCM_scrollbar_page_inc); done = True; break; default: break; } if (done) message_with_args(MCM_mouse_up, "1"); return done; }
Boolean MCColors::mdown(uint2 which) { if (state & CS_MFOCUSED) return False; state |= CS_MFOCUSED; MCColor color; switch (which) { case Button1: switch (getstack()->gettool(this)) { case T_BROWSE: uint2 xcells; uint2 ycells; getcells(xcells, ycells); MCscreen->getpaletteentry((my - rect.y) * ycells / rect.height * xcells + (mx - rect.x) * xcells / rect.width, color); selectedcolor = color.pixel; // MW-2011-08-18: [[ Layers ]] Invalidate the whole object. layer_redrawall(); message_with_valueref_args(MCM_mouse_down, MCSTR("1")); break; case T_POINTER: start(True); break; default: return False; } break; case Button2: case Button3: message_with_args(MCM_mouse_down, which); break; } return True; }
Boolean MCScrollbar::mdown(uint2 which) { if (state & CS_MFOCUSED) return False; if (state & CS_MENU_ATTACHED) return MCObject::mdown(which); state |= CS_MFOCUSED; if (!IsMacEmulatedLF() && flags & F_TRAVERSAL_ON && !(state & CS_KFOCUSED)) getstack()->kfocusset(this); uint2 margin; MCRectangle brect = compute_bar(); if (flags & F_SCALE) margin = 0; else if (getstyleint(flags) == F_VERTICAL) margin = brect.width - 1; else margin = brect.height - 1; Tool tool = state & CS_NO_MESSAGES ? T_BROWSE : getstack()->gettool(this); MCWidgetInfo winfo; winfo.type = (Widget_Type)getwidgetthemetype(); switch (which) { case Button1: switch (tool) { case T_BROWSE: message_with_args(MCM_mouse_down, "1"); if (flags & F_PROGRESS) //progress bar does not respond to mouse down event return False; if (MCcurtheme && MCcurtheme->iswidgetsupported(winfo.type)) { getwidgetthemeinfo(winfo); Widget_Part wpart = MCcurtheme->hittest(winfo,mx,my,rect); // scrollbar needs to check first if mouse-down occured in arrows switch (wpart) { case WTHEME_PART_ARROW_DEC: if (MCmodifierstate & MS_SHIFT) mode = SM_BEGINNING; else mode = SM_LINEDEC; break; case WTHEME_PART_ARROW_INC: if (MCmodifierstate & MS_SHIFT) mode = SM_END; else mode = SM_LINEINC; break; case WTHEME_PART_TRACK_DEC: mode = SM_PAGEDEC; break; case WTHEME_PART_TRACK_INC: mode = SM_PAGEINC; break; } } else { //Non-theme appearence stuff: for vertical scrollbar or scale if (getstyleint(flags) == F_VERTICAL) { uint2 height; if (brect.height <= margin << 1) height = 1; else height = brect.height - (margin << 1); markpos = (my - (brect.y + margin)) * fabs(endvalue - startvalue) / height; if (my < brect.y + margin) if (MCmodifierstate & MS_SHIFT) mode = SM_BEGINNING; else mode = SM_LINEDEC; else if (my > brect.y + brect.height - margin) if (MCmodifierstate & MS_SHIFT) mode = SM_END; else mode = SM_LINEINC; else { MCRectangle thumb = compute_thumb(thumbpos); if (my < thumb.y) mode = SM_PAGEDEC; else if (my > thumb.y + thumb.height) mode = SM_PAGEINC; } } else { //for Horizontal scrollbar or scale uint2 width; if (brect.width <= (margin << 1)) width = 1; else width = brect.width - (margin << 1); markpos = (mx - (brect.x + margin)) * fabs(endvalue - startvalue) / width; if (mx < brect.x + margin) if (MCmodifierstate & MS_SHIFT) mode = SM_BEGINNING; else mode = SM_LINEDEC; else if (mx > brect.x + brect.width - margin) if (MCmodifierstate & MS_SHIFT) mode = SM_END; else mode = SM_LINEINC; else { MCRectangle thumb = compute_thumb(thumbpos); if (mx < thumb.x) mode = SM_PAGEDEC; else if (mx > thumb.x + thumb.width) mode = SM_PAGEINC; } } } //end of Non-MAC-Appearance Manager stuff switch (mode) { case SM_BEGINNING: update(0, MCM_scrollbar_beginning); break; case SM_END: update(endvalue, MCM_scrollbar_end); break; case SM_LINEDEC: case SM_LINEINC: timer(MCM_internal, NULL); redrawarrow(mode); break; case SM_PAGEDEC: case SM_PAGEINC: timer(MCM_internal, NULL); break; default: state |= CS_SCROLL; markpos = thumbpos; if (IsMacEmulatedLF()) movethumb(thumbpos--); else if (MCcurtheme) { // MW-2011-08-18: [[ Layers ]] Invalidate the whole object. redrawall(); } } break; case T_POINTER: case T_SCROLLBAR: start(True); break; case T_HELP: break; default: return False; } break; case Button2: if (message_with_args(MCM_mouse_down, "2") == ES_NORMAL) return True; state |= CS_SCROLL; { real8 newpos; real8 range = endvalue - startvalue; real8 offset = startvalue; if (flags & F_SCALE) margin = MOTIF_SCALE_THUMB_SIZE >> 1; else if (MCproportionalthumbs) if (startvalue > endvalue) offset += thumbsize / 2.0; else offset -= thumbsize / 2.0; else margin = FIXED_THUMB_SIZE >> 1; if (getstyleint(flags) == F_VERTICAL) newpos = (my - brect.y - margin) * range / (brect.height - (margin << 1)) + offset; else newpos = (mx - brect.x - margin) * range / (brect.width - (margin << 1)) + offset; update(newpos, MCM_scrollbar_drag); markpos = thumbpos; } break; case Button3: message_with_args(MCM_mouse_down, "3"); break; }