add editor-scroll-to method of editor<%>

svn: r10860
This commit is contained in:
Matthew Flatt 2008-07-22 13:17:09 +00:00
parent 44440a42a7
commit 6c43d23bc4
13 changed files with 232 additions and 11 deletions

View File

@ -36,7 +36,7 @@
"MrEdIt" #f 620 450))
(define c (make-object editor-canvas% f))
(define e (make-object (class editor%
(define/override (set-modified mod?)
(define/override (set-modified mod?)
(send f modified mod?)
(super set-modified mod?))
(super-new))))

View File

@ -252,6 +252,7 @@
release-snip
on-snip-modified
set-modified
scroll-editor-to
set-snip-data
get-snip-data
needs-update
@ -928,6 +929,7 @@
release-snip
on-snip-modified
set-modified
scroll-editor-to
set-snip-data
get-snip-data
needs-update
@ -1141,6 +1143,7 @@
release-snip
on-snip-modified
set-modified
scroll-editor-to
set-snip-data
get-snip-data
needs-update

View File

@ -1988,6 +1988,30 @@ The @scheme[show-errors?] argument is no longer used.
}
@defmethod[(scroll-editor-to [localx real?]
[localy real?]
[width (and/c real? (not/c negative?))]
[height (and/c real? (not/c negative?))]
[refresh? any/c]
[bias (one-of/c 'start 'end 'none)])
boolean?]{
Causes the editor to be scrolled so that a given @techlink{location}
is visible. If the editor is scrolled, @scheme[#t] is returned,
otherwise @scheme[#f] is returned.
This method is normally called indirectly by @method[editor<%>
scroll-to] or @xmethod[text% scroll-to-position] to implement
scrolling.
The default implementation forwards the request to the
@method[editor-admin% scroll-to] method of the current administrator,
if any (see @method[editor<%> get-admin]). If the editor has no
administrator, @scheme[#f] is returned.
}
@defmethod[(scroll-line-location [pos (and/c exact? integer?)])
(and/c real? (not/c negative?))]{
@ -2010,8 +2034,13 @@ For @scheme[text%] objects: @|FCA| @|EVD|
Called (indirectly) by snips within the editor: it causes the editor
to be scrolled so that a given @techlink{location} range within a
given snip is visible. If the editor is scrolled, @scheme[#t] is
returned, otherwise @scheme[#f] is returned.
given snip is visible. If the editor is scrolled immediately,
@scheme[#t] is returned, otherwise @scheme[#f] is returned.
If refreshing is delayed (see @method[editor<%> refresh-delayed?]),
then the scroll request is saved until the delay has ended. The
scroll is performed (immediately or later) by calling
@method[editor<%> scroll-editor-to].
The @scheme[localx], @scheme[localy], @scheme[width], and @scheme[height]
arguments specify the area that needs to be visible in @scheme[snip]'s

View File

@ -1706,12 +1706,18 @@ When the specified range cannot fit in the visible area, @scheme[bias]
displayed. Otherwise, @scheme[bias] must be @scheme['none].
If the editor is scrolled, then the editor is redrawn and the return
value is @scheme[#t]; otherwise, the return value is @scheme[#f].
value is @scheme[#t]; otherwise, the return value is @scheme[#f]. If
refreshing is delayed (see @method[editor<%> refresh-delayed?]), then
the scroll request is saved until the delay has ended. The scroll is
performed (immediately or later) by calling @method[editor<%>
scroll-editor-to].
Scrolling is disallowed when the editor is internally locked for
reflowing (see also @|lockdiscuss|).
The system may scroll the editor without calling this method.
The system may scroll the editor without calling this method. For
example, a canvas displaying an editor might scroll the editor to
handle a scrollbar event.
}

View File

@ -94,6 +94,7 @@
(let ([n (command-line #:args (n) (string->number n))])
(go n '(blue red yellow))
(go n '(blue red yellow red yellow blue red yellow red blue)))
(go n '(blue red yellow red yellow blue red yellow red blue))
(newline))

View File

@ -2559,6 +2559,14 @@ void wxMediaBuffer::SetInactiveCaretThreshold(int v)
inactiveCaretThreshold = v;
}
Bool wxMediaBuffer::AdminScrollTo(double localx, double localy, double w, double h,
Bool refresh, int bias)
{
if (admin)
return admin->ScrollTo(localx, localy, w, h, refresh, bias);
else
return FALSE;
}
void wxMediaBuffer::OnPaint(Bool WXUNUSED(pre),
wxDC *WXUNUSED(dc),

View File

@ -182,6 +182,9 @@ class wxMediaBuffer : public wxObject
virtual long NumScrollLines() = 0;
virtual long FindScrollLine(double y) = 0;
virtual Bool AdminScrollTo(double localx, double localy, double w, double h,
Bool refresh = TRUE, int bias = 0);
virtual wxMediaBuffer *CopySelf(void) = 0;
virtual void CopySelfTo(wxMediaBuffer *b);
virtual double GetDescent(void) = 0;

View File

@ -1001,7 +1001,7 @@ Bool wxMediaEdit::ScrollToPosition(long start, Bool ateol, Bool refresh,
w = botx - topx;
h = boty - topy;
return admin->ScrollTo(topx, topy, w, h, refresh, bias);
return AdminScrollTo(topx, topy, w, h, refresh, bias);
}
Bool wxMediaEdit::ScrollToPosition(long start, Bool ateol, long end, int bias)
@ -4398,7 +4398,7 @@ Bool wxMediaEdit::ScrollTo(wxSnip *snip, double localx, double localy,
return FALSE;
} else
x = y = 0;
if (admin->ScrollTo(x + localx, y + localy, w, h, refresh, bias)) {
if (AdminScrollTo(x + localx, y + localy, w, h, refresh, bias)) {
if (!refresh)
refreshAll = TRUE;
return TRUE;

View File

@ -2028,7 +2028,7 @@ Bool wxMediaPasteboard::ScrollTo(wxSnip *snip,
GetSnipLocation(snip, &x, &y);
if (admin->ScrollTo(x + localx, y + localy, w, h, refresh, bias)) {
if (AdminScrollTo(x + localx, y + localy, w, h, refresh, bias)) {
if (!refresh) {
updateTop = 0;
updateLeft = 0;

View File

@ -54,6 +54,8 @@
@ Y "get-snip-data" : wxBufferData^ GetSnipData(wxSnip!); : : : : XrZERO
@ Y "set-snip-data" : void SetSnipData(wxSnip!, wxBufferData^);
@ Y "scroll-editor-to" : bool AdminScrollTo(double,double,nndouble,nndouble,bool,SYM[bias]); : : : : XrZERO
@ Z "set-modified" : void SetModified(bool);
@ Z "on-snip-modified" : void OnSnipModified(wxSnip!,bool);

View File

@ -777,6 +777,7 @@ static int unbundle_symset_Bias(Scheme_Object *v, const char *where) {
#undef l_ADDRESS
@ -1020,6 +1021,7 @@ class os_wxMediaEdit : public wxMediaEdit {
Bool ReleaseSnip(class wxSnip* x0);
void OnSnipModified(class wxSnip* x0, Bool x1);
void SetModified(Bool x0);
Bool AdminScrollTo(double x0, double x1, nndouble x2, nndouble x3, Bool x4, int x5);
void SetSnipData(class wxSnip* x0, class wxBufferData* x1);
class wxBufferData* GetSnipData(class wxSnip* x0);
void NeedsUpdate(class wxSnip* x0, double x1, double x2, nndouble x3, nndouble x4);
@ -2829,6 +2831,51 @@ void os_wxMediaEdit::SetModified(Bool x0)
}
}
static Scheme_Object *os_wxMediaEditAdminScrollTo(int n, Scheme_Object *p[]);
Bool os_wxMediaEdit::AdminScrollTo(double x0, double x1, nndouble x2, nndouble x3, Bool x4, int x5)
{
Scheme_Object *p[POFFSET+6] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT });
Scheme_Object *v;
Scheme_Object *method INIT_NULLED_OUT;
#ifdef MZ_PRECISE_GC
os_wxMediaEdit *sElF = this;
#endif
static void *mcache = 0;
SETUP_VAR_STACK(5);
VAR_STACK_PUSH(0, method);
VAR_STACK_PUSH(1, sElF);
VAR_STACK_PUSH_ARRAY(2, p, POFFSET+6);
SET_VAR_STACK();
method = objscheme_find_method((Scheme_Object *) ASSELF __gc_external, os_wxMediaEdit_class, "scroll-editor-to", &mcache);
if (!method || OBJSCHEME_PRIM_METHOD(method, os_wxMediaEditAdminScrollTo)) {
SET_VAR_STACK();
READY_TO_RETURN; return ASSELF wxMediaEdit::AdminScrollTo(x0, x1, x2, x3, x4, x5);
} else {
p[POFFSET+0] = WITH_VAR_STACK(scheme_make_double(x0));
p[POFFSET+1] = WITH_VAR_STACK(scheme_make_double(x1));
p[POFFSET+2] = WITH_VAR_STACK(scheme_make_double(x2));
p[POFFSET+3] = WITH_VAR_STACK(scheme_make_double(x3));
p[POFFSET+4] = (x4 ? scheme_true : scheme_false);
p[POFFSET+5] = WITH_VAR_STACK(bundle_symset_bias(x5));
p[0] = (Scheme_Object *) ASSELF __gc_external;
v = WITH_VAR_STACK(scheme_apply(method, POFFSET+6, p));
{
Bool resval;
resval = WITH_VAR_STACK(objscheme_unbundle_bool(v, "scroll-editor-to in text%"", extracting return value"));
READY_TO_RETURN;
return resval;
}
}
}
static Scheme_Object *os_wxMediaEditSetSnipData(int n, Scheme_Object *p[]);
void os_wxMediaEdit::SetSnipData(class wxSnip* x0, class wxBufferData* x1)
@ -7875,6 +7922,42 @@ static Scheme_Object *os_wxMediaEditSetModified(int n, Scheme_Object *p[])
return scheme_void;
}
static Scheme_Object *os_wxMediaEditAdminScrollTo(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
REMEMBER_VAR_STACK();
Bool r;
objscheme_check_valid(os_wxMediaEdit_class, "scroll-editor-to in text%", n, p);
double x0;
double x1;
nndouble x2;
nndouble x3;
Bool x4;
int x5;
SETUP_VAR_STACK_REMEMBERED(1);
VAR_STACK_PUSH(0, p);
x0 = WITH_VAR_STACK(objscheme_unbundle_double(p[POFFSET+0], "scroll-editor-to in text%"));
x1 = WITH_VAR_STACK(objscheme_unbundle_double(p[POFFSET+1], "scroll-editor-to in text%"));
x2 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_double(p[POFFSET+2], "scroll-editor-to in text%"));
x3 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_double(p[POFFSET+3], "scroll-editor-to in text%"));
x4 = WITH_VAR_STACK(objscheme_unbundle_bool(p[POFFSET+4], "scroll-editor-to in text%"));
x5 = WITH_VAR_STACK(unbundle_symset_bias(p[POFFSET+5], "scroll-editor-to in text%"));
if (((Scheme_Class_Object *)p[0])->primflag)
r = WITH_VAR_STACK(((os_wxMediaEdit *)((Scheme_Class_Object *)p[0])->primdata)->wxMediaEdit::AdminScrollTo(x0, x1, x2, x3, x4, x5));
else
r = WITH_VAR_STACK(((wxMediaEdit *)((Scheme_Class_Object *)p[0])->primdata)->AdminScrollTo(x0, x1, x2, x3, x4, x5));
READY_TO_RETURN;
return (r ? scheme_true : scheme_false);
}
static Scheme_Object *os_wxMediaEditSetSnipData(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
@ -8634,7 +8717,7 @@ void objscheme_setup_wxMediaEdit(Scheme_Env *env)
wxREGGLOB(os_wxMediaEdit_class);
os_wxMediaEdit_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "text%", "editor%", (Scheme_Method_Prim *)os_wxMediaEdit_ConstructScheme, 151));
os_wxMediaEdit_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "text%", "editor%", (Scheme_Method_Prim *)os_wxMediaEdit_ConstructScheme, 152));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "call-clickback" " method", (Scheme_Method_Prim *)os_wxMediaEditCallClickback, 2, 2));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "remove-clickback" " method", (Scheme_Method_Prim *)os_wxMediaEditRemoveClickback, 2, 2));
@ -8761,6 +8844,7 @@ void objscheme_setup_wxMediaEdit(Scheme_Env *env)
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "release-snip" " method", (Scheme_Method_Prim *)os_wxMediaEditReleaseSnip, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "on-snip-modified" " method", (Scheme_Method_Prim *)os_wxMediaEditOnSnipModified, 2, 2));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "set-modified" " method", (Scheme_Method_Prim *)os_wxMediaEditSetModified, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "scroll-editor-to" " method", (Scheme_Method_Prim *)os_wxMediaEditAdminScrollTo, 6, 6));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "set-snip-data" " method", (Scheme_Method_Prim *)os_wxMediaEditSetSnipData, 2, 2));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "get-snip-data" " method", (Scheme_Method_Prim *)os_wxMediaEditGetSnipData, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "needs-update" " method", (Scheme_Method_Prim *)os_wxMediaEditNeedsUpdate, 5, 5));

View File

@ -514,6 +514,7 @@ static Scheme_Object *bundle_symset_bitmapType(int v) {
// W are Methods not intended to be overriden by the user,

View File

@ -382,6 +382,7 @@ static Scheme_Object *bundle_symset_bitmapType(int v) {
class os_wxMediaPasteboard : public wxMediaPasteboard {
@ -443,6 +444,7 @@ class os_wxMediaPasteboard : public wxMediaPasteboard {
Bool ReleaseSnip(class wxSnip* x0);
void OnSnipModified(class wxSnip* x0, Bool x1);
void SetModified(Bool x0);
Bool AdminScrollTo(double x0, double x1, nndouble x2, nndouble x3, Bool x4, int x5);
void SetSnipData(class wxSnip* x0, class wxBufferData* x1);
class wxBufferData* GetSnipData(class wxSnip* x0);
void NeedsUpdate(class wxSnip* x0, double x1, double x2, nndouble x3, nndouble x4);
@ -2613,6 +2615,51 @@ void os_wxMediaPasteboard::SetModified(Bool x0)
}
}
static Scheme_Object *os_wxMediaPasteboardAdminScrollTo(int n, Scheme_Object *p[]);
Bool os_wxMediaPasteboard::AdminScrollTo(double x0, double x1, nndouble x2, nndouble x3, Bool x4, int x5)
{
Scheme_Object *p[POFFSET+6] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT });
Scheme_Object *v;
Scheme_Object *method INIT_NULLED_OUT;
#ifdef MZ_PRECISE_GC
os_wxMediaPasteboard *sElF = this;
#endif
static void *mcache = 0;
SETUP_VAR_STACK(5);
VAR_STACK_PUSH(0, method);
VAR_STACK_PUSH(1, sElF);
VAR_STACK_PUSH_ARRAY(2, p, POFFSET+6);
SET_VAR_STACK();
method = objscheme_find_method((Scheme_Object *) ASSELF __gc_external, os_wxMediaPasteboard_class, "scroll-editor-to", &mcache);
if (!method || OBJSCHEME_PRIM_METHOD(method, os_wxMediaPasteboardAdminScrollTo)) {
SET_VAR_STACK();
READY_TO_RETURN; return ASSELF wxMediaPasteboard::AdminScrollTo(x0, x1, x2, x3, x4, x5);
} else {
p[POFFSET+0] = WITH_VAR_STACK(scheme_make_double(x0));
p[POFFSET+1] = WITH_VAR_STACK(scheme_make_double(x1));
p[POFFSET+2] = WITH_VAR_STACK(scheme_make_double(x2));
p[POFFSET+3] = WITH_VAR_STACK(scheme_make_double(x3));
p[POFFSET+4] = (x4 ? scheme_true : scheme_false);
p[POFFSET+5] = WITH_VAR_STACK(bundle_symset_bias(x5));
p[0] = (Scheme_Object *) ASSELF __gc_external;
v = WITH_VAR_STACK(scheme_apply(method, POFFSET+6, p));
{
Bool resval;
resval = WITH_VAR_STACK(objscheme_unbundle_bool(v, "scroll-editor-to in pasteboard%"", extracting return value"));
READY_TO_RETURN;
return resval;
}
}
}
static Scheme_Object *os_wxMediaPasteboardSetSnipData(int n, Scheme_Object *p[]);
void os_wxMediaPasteboard::SetSnipData(class wxSnip* x0, class wxBufferData* x1)
@ -6032,6 +6079,42 @@ static Scheme_Object *os_wxMediaPasteboardSetModified(int n, Scheme_Object *p[]
return scheme_void;
}
static Scheme_Object *os_wxMediaPasteboardAdminScrollTo(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
REMEMBER_VAR_STACK();
Bool r;
objscheme_check_valid(os_wxMediaPasteboard_class, "scroll-editor-to in pasteboard%", n, p);
double x0;
double x1;
nndouble x2;
nndouble x3;
Bool x4;
int x5;
SETUP_VAR_STACK_REMEMBERED(1);
VAR_STACK_PUSH(0, p);
x0 = WITH_VAR_STACK(objscheme_unbundle_double(p[POFFSET+0], "scroll-editor-to in pasteboard%"));
x1 = WITH_VAR_STACK(objscheme_unbundle_double(p[POFFSET+1], "scroll-editor-to in pasteboard%"));
x2 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_double(p[POFFSET+2], "scroll-editor-to in pasteboard%"));
x3 = WITH_VAR_STACK(objscheme_unbundle_nonnegative_double(p[POFFSET+3], "scroll-editor-to in pasteboard%"));
x4 = WITH_VAR_STACK(objscheme_unbundle_bool(p[POFFSET+4], "scroll-editor-to in pasteboard%"));
x5 = WITH_VAR_STACK(unbundle_symset_bias(p[POFFSET+5], "scroll-editor-to in pasteboard%"));
if (((Scheme_Class_Object *)p[0])->primflag)
r = WITH_VAR_STACK(((os_wxMediaPasteboard *)((Scheme_Class_Object *)p[0])->primdata)->wxMediaPasteboard::AdminScrollTo(x0, x1, x2, x3, x4, x5));
else
r = WITH_VAR_STACK(((wxMediaPasteboard *)((Scheme_Class_Object *)p[0])->primdata)->AdminScrollTo(x0, x1, x2, x3, x4, x5));
READY_TO_RETURN;
return (r ? scheme_true : scheme_false);
}
static Scheme_Object *os_wxMediaPasteboardSetSnipData(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
@ -6914,7 +6997,7 @@ void objscheme_setup_wxMediaPasteboard(Scheme_Env *env)
wxREGGLOB(os_wxMediaPasteboard_class);
os_wxMediaPasteboard_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "pasteboard%", "editor%", (Scheme_Method_Prim *)os_wxMediaPasteboard_ConstructScheme, 114));
os_wxMediaPasteboard_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "pasteboard%", "editor%", (Scheme_Method_Prim *)os_wxMediaPasteboard_ConstructScheme, 115));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "set-scroll-step" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardSetScrollStep, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "get-scroll-step" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardGetScrollStep, 0, 0));
@ -6999,6 +7082,7 @@ void objscheme_setup_wxMediaPasteboard(Scheme_Env *env)
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "release-snip" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardReleaseSnip, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "on-snip-modified" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardOnSnipModified, 2, 2));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "set-modified" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardSetModified, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "scroll-editor-to" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardAdminScrollTo, 6, 6));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "set-snip-data" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardSetSnipData, 2, 2));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "get-snip-data" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardGetSnipData, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "needs-update" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardNeedsUpdate, 5, 5));