size-cache-invalid for editor<%>

svn: r13120
This commit is contained in:
Matthew Flatt 2009-01-14 20:29:37 +00:00
parent 074be235b4
commit cf2e98eb92
7 changed files with 145 additions and 11 deletions

View File

@ -240,6 +240,7 @@
can-save-file? can-save-file?
on-new-box on-new-box
on-new-image-snip on-new-image-snip
size-cache-invalid
invalidate-bitmap-cache invalidate-bitmap-cache
on-paint on-paint
write-footers-to-file write-footers-to-file
@ -921,6 +922,7 @@
can-save-file? can-save-file?
on-new-box on-new-box
on-new-image-snip on-new-image-snip
size-cache-invalid
invalidate-bitmap-cache invalidate-bitmap-cache
on-paint on-paint
write-footers-to-file write-footers-to-file
@ -1133,6 +1135,7 @@
can-save-file? can-save-file?
on-new-box on-new-box
on-new-image-snip on-new-image-snip
size-cache-invalid
invalidate-bitmap-cache invalidate-bitmap-cache
on-paint on-paint
write-footers-to-file write-footers-to-file

View File

@ -38,4 +38,5 @@
[(--> (in-hole e-ctxt_1 a) (in-hole e-ctxt_1 b)) [(--> (in-hole e-ctxt_1 a) (in-hole e-ctxt_1 b))
(c--> a b)])) (c--> a b)]))
(traces reductions (term (- (* (sqrt 36) (/ 1 2)) (+ 1 2)))) (traces/ps reductions (term (- (* (sqrt 36) (/ 1 2)) (+ 1 2)))
"/home/mflatt/Desktop/p.ps")

View File

@ -152,11 +152,7 @@
(dynamic-wind (dynamic-wind
void void
(λ () (λ ()
(let loop ([snip (send graph-pb find-first-snip)]) (send graph-pb size-cache-invalid)
(when snip
(send (send snip get-admin) resized snip #t)
(loop (send snip next))))
(send graph-pb invalidate-bitmap-cache)
(send graph-pb re-run-layout) (send graph-pb re-run-layout)
@ -175,7 +171,7 @@
(when snip (when snip
(send snip size-cache-invalid) (send snip size-cache-invalid)
(loop (send snip next)))) (loop (send snip next))))
(send graph-pb invalidate-bitmap-cache) (send graph-pb size-cache-invalid)
(send graph-pb re-run-layout))))) (send graph-pb re-run-layout)))))
(define printing-editor-admin% (define printing-editor-admin%
@ -208,7 +204,8 @@
(define/override (get-max-view x y w h [full? #f]) (define/override (get-max-view x y w h [full? #f])
(get-view x y w h full?)) (get-view x y w h full?))
(define/override (get-view x y w h [full? #f]) (define/override (get-view x y w h [full? #f])
(super get-view x y w h full?) (when x (set-box! x 0.0))
(when y (set-box! x 0.0))
(when (box? w) (set-box! w 500)) (when (box? w) (set-box! w 500))
(when (box? h) (set-box! h 500))) (when (box? h) (set-box! h 500)))

View File

@ -1015,7 +1015,7 @@ The default implementation triggers a redraw of the editor, either
immediately or at the end of the current edit sequence (if any) immediately or at the end of the current edit sequence (if any)
started by @method[editor<%> begin-edit-sequence]. started by @method[editor<%> begin-edit-sequence].
} See also @method[editor<%> size-cache-invalid].}
@defmethod[(is-locked?) @defmethod[(is-locked?)
@ -2322,6 +2322,20 @@ Setting the style list is disallowed when the editor is internally
} }
@defmethod[(size-cache-invalid)
void?]{
This method is called when the drawing context given to the editor by
its administrator changes in a way that makes cached size information
(such as the width of a string) invalid.
The default implementation eventually propagates the message to snips,
and, more generally, causes @tech{location} information to be
recalculated on demand.
See also @method[editor<%> invalidate-bitmap-cache].}
@defmethod[(style-has-changed [style (or/c (is-a?/c style<%>) false/c)]) @defmethod[(style-has-changed [style (or/c (is-a?/c style<%>) false/c)])
void?]{ void?]{

View File

@ -73,6 +73,7 @@
@ Z "on-paint" : void OnPaint(bool,wxDC!,double,double,double,double,double,double,SYM[caret]); : : /CHECKDCOK[1.METHODNAME("editor<%>","on-paint")] @ Z "on-paint" : void OnPaint(bool,wxDC!,double,double,double,double,double,double,SYM[caret]); : : /CHECKDCOK[1.METHODNAME("editor<%>","on-paint")]
@ Y "invalidate-bitmap-cache" : void InvalidateBitmapCache(double=0.0,double=0.0,nnfs[end]=-1.0,nnfs[end]=-1.0); @ Y "invalidate-bitmap-cache" : void InvalidateBitmapCache(double=0.0,double=0.0,nnfs[end]=-1.0,nnfs[end]=-1.0);
@ Y "size-cache-invalid" : void SizeCacheInvalid();
@ Z "on-new-image-snip" : wxImageSnip! OnNewImageSnip(nxpathname,SYM[bitmapType],bool,bool); @ Z "on-new-image-snip" : wxImageSnip! OnNewImageSnip(nxpathname,SYM[bitmapType],bool,bool);
@ Z "on-new-box" : wxSnip! OnNewBox(SYM[bufferType]); @ Z "on-new-box" : wxSnip! OnNewBox(SYM[bufferType]);

View File

@ -1015,6 +1015,7 @@ class os_wxMediaEdit : public wxMediaEdit {
Bool CanSaveFile(epathname x0, int x1); Bool CanSaveFile(epathname x0, int x1);
class wxSnip* OnNewBox(int x0); class wxSnip* OnNewBox(int x0);
class wxImageSnip* OnNewImageSnip(nxpathname x0, int x1, Bool x2, Bool x3); class wxImageSnip* OnNewImageSnip(nxpathname x0, int x1, Bool x2, Bool x3);
void SizeCacheInvalid();
void InvalidateBitmapCache(double x0 = 0.0, double x1 = 0.0, double x2 = -1.0, double x3 = -1.0); void InvalidateBitmapCache(double x0 = 0.0, double x1 = 0.0, double x2 = -1.0, double x3 = -1.0);
void OnPaint(Bool x0, class wxDC* x1, double x2, double x3, double x4, double x5, double x6, double x7, int x8); void OnPaint(Bool x0, class wxDC* x1, double x2, double x3, double x4, double x5, double x6, double x7, int x8);
Bool WriteFootersToFile(class wxMediaStreamOut* x0); Bool WriteFootersToFile(class wxMediaStreamOut* x0);
@ -2469,6 +2470,40 @@ class wxImageSnip* os_wxMediaEdit::OnNewImageSnip(nxpathname x0, int x1, Bool x2
} }
} }
static Scheme_Object *os_wxMediaEditSizeCacheInvalid(int n, Scheme_Object *p[]);
void os_wxMediaEdit::SizeCacheInvalid()
{
Scheme_Object *p[POFFSET+0] INIT_NULLED_ARRAY({ 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+0);
SET_VAR_STACK();
method = objscheme_find_method((Scheme_Object *) ASSELF __gc_external, os_wxMediaEdit_class, "size-cache-invalid", &mcache);
if (!method || OBJSCHEME_PRIM_METHOD(method, os_wxMediaEditSizeCacheInvalid)) {
SET_VAR_STACK();
READY_TO_RETURN; ASSELF wxMediaEdit::SizeCacheInvalid();
} else {
p[0] = (Scheme_Object *) ASSELF __gc_external;
v = WITH_VAR_STACK(scheme_apply(method, POFFSET+0, p));
READY_TO_RETURN;
}
}
static Scheme_Object *os_wxMediaEditInvalidateBitmapCache(int n, Scheme_Object *p[]); static Scheme_Object *os_wxMediaEditInvalidateBitmapCache(int n, Scheme_Object *p[]);
void os_wxMediaEdit::InvalidateBitmapCache(double x0, double x1, double x2, double x3) void os_wxMediaEdit::InvalidateBitmapCache(double x0, double x1, double x2, double x3)
@ -7673,6 +7708,29 @@ static Scheme_Object *os_wxMediaEditOnNewImageSnip(int n, Scheme_Object *p[])
return WITH_REMEMBERED_STACK(objscheme_bundle_wxImageSnip(r)); return WITH_REMEMBERED_STACK(objscheme_bundle_wxImageSnip(r));
} }
static Scheme_Object *os_wxMediaEditSizeCacheInvalid(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
REMEMBER_VAR_STACK();
objscheme_check_valid(os_wxMediaEdit_class, "size-cache-invalid in text%", n, p);
SETUP_VAR_STACK_REMEMBERED(1);
VAR_STACK_PUSH(0, p);
if (((Scheme_Class_Object *)p[0])->primflag)
WITH_VAR_STACK(((os_wxMediaEdit *)((Scheme_Class_Object *)p[0])->primdata)->wxMediaEdit::SizeCacheInvalid());
else
WITH_VAR_STACK(((wxMediaEdit *)((Scheme_Class_Object *)p[0])->primdata)->SizeCacheInvalid());
READY_TO_RETURN;
return scheme_void;
}
static Scheme_Object *os_wxMediaEditInvalidateBitmapCache(int n, Scheme_Object *p[]) static Scheme_Object *os_wxMediaEditInvalidateBitmapCache(int n, Scheme_Object *p[])
{ {
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p) WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
@ -8778,7 +8836,7 @@ void objscheme_setup_wxMediaEdit(Scheme_Env *env)
wxREGGLOB(os_wxMediaEdit_class); wxREGGLOB(os_wxMediaEdit_class);
os_wxMediaEdit_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "text%", "editor%", (Scheme_Method_Prim *)os_wxMediaEdit_ConstructScheme, 153)); os_wxMediaEdit_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "text%", "editor%", (Scheme_Method_Prim *)os_wxMediaEdit_ConstructScheme, 154));
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, "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)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "remove-clickback" " method", (Scheme_Method_Prim *)os_wxMediaEditRemoveClickback, 2, 2));
@ -8896,6 +8954,7 @@ void objscheme_setup_wxMediaEdit(Scheme_Env *env)
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "can-save-file?" " method", (Scheme_Method_Prim *)os_wxMediaEditCanSaveFile, 2, 2)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "can-save-file?" " method", (Scheme_Method_Prim *)os_wxMediaEditCanSaveFile, 2, 2));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "on-new-box" " method", (Scheme_Method_Prim *)os_wxMediaEditOnNewBox, 1, 1)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "on-new-box" " method", (Scheme_Method_Prim *)os_wxMediaEditOnNewBox, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "on-new-image-snip" " method", (Scheme_Method_Prim *)os_wxMediaEditOnNewImageSnip, 4, 4)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "on-new-image-snip" " method", (Scheme_Method_Prim *)os_wxMediaEditOnNewImageSnip, 4, 4));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "size-cache-invalid" " method", (Scheme_Method_Prim *)os_wxMediaEditSizeCacheInvalid, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "invalidate-bitmap-cache" " method", (Scheme_Method_Prim *)os_wxMediaEditInvalidateBitmapCache, 0, 4)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "invalidate-bitmap-cache" " method", (Scheme_Method_Prim *)os_wxMediaEditInvalidateBitmapCache, 0, 4));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "on-paint" " method", (Scheme_Method_Prim *)os_wxMediaEditOnPaint, 9, 9)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "on-paint" " method", (Scheme_Method_Prim *)os_wxMediaEditOnPaint, 9, 9));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "write-footers-to-file" " method", (Scheme_Method_Prim *)os_wxMediaEditWriteFootersToFile, 1, 1)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaEdit_class, "write-footers-to-file" " method", (Scheme_Method_Prim *)os_wxMediaEditWriteFootersToFile, 1, 1));

View File

@ -436,6 +436,7 @@ class os_wxMediaPasteboard : public wxMediaPasteboard {
Bool CanSaveFile(epathname x0, int x1); Bool CanSaveFile(epathname x0, int x1);
class wxSnip* OnNewBox(int x0); class wxSnip* OnNewBox(int x0);
class wxImageSnip* OnNewImageSnip(nxpathname x0, int x1, Bool x2, Bool x3); class wxImageSnip* OnNewImageSnip(nxpathname x0, int x1, Bool x2, Bool x3);
void SizeCacheInvalid();
void InvalidateBitmapCache(double x0 = 0.0, double x1 = 0.0, double x2 = -1.0, double x3 = -1.0); void InvalidateBitmapCache(double x0 = 0.0, double x1 = 0.0, double x2 = -1.0, double x3 = -1.0);
void OnPaint(Bool x0, class wxDC* x1, double x2, double x3, double x4, double x5, double x6, double x7, int x8); void OnPaint(Bool x0, class wxDC* x1, double x2, double x3, double x4, double x5, double x6, double x7, int x8);
Bool WriteFootersToFile(class wxMediaStreamOut* x0); Bool WriteFootersToFile(class wxMediaStreamOut* x0);
@ -2217,6 +2218,40 @@ class wxImageSnip* os_wxMediaPasteboard::OnNewImageSnip(nxpathname x0, int x1, B
} }
} }
static Scheme_Object *os_wxMediaPasteboardSizeCacheInvalid(int n, Scheme_Object *p[]);
void os_wxMediaPasteboard::SizeCacheInvalid()
{
Scheme_Object *p[POFFSET+0] INIT_NULLED_ARRAY({ 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+0);
SET_VAR_STACK();
method = objscheme_find_method((Scheme_Object *) ASSELF __gc_external, os_wxMediaPasteboard_class, "size-cache-invalid", &mcache);
if (!method || OBJSCHEME_PRIM_METHOD(method, os_wxMediaPasteboardSizeCacheInvalid)) {
SET_VAR_STACK();
READY_TO_RETURN; ASSELF wxMediaPasteboard::SizeCacheInvalid();
} else {
p[0] = (Scheme_Object *) ASSELF __gc_external;
v = WITH_VAR_STACK(scheme_apply(method, POFFSET+0, p));
READY_TO_RETURN;
}
}
static Scheme_Object *os_wxMediaPasteboardInvalidateBitmapCache(int n, Scheme_Object *p[]); static Scheme_Object *os_wxMediaPasteboardInvalidateBitmapCache(int n, Scheme_Object *p[]);
void os_wxMediaPasteboard::InvalidateBitmapCache(double x0, double x1, double x2, double x3) void os_wxMediaPasteboard::InvalidateBitmapCache(double x0, double x1, double x2, double x3)
@ -5718,6 +5753,29 @@ static Scheme_Object *os_wxMediaPasteboardOnNewImageSnip(int n, Scheme_Object *
return WITH_REMEMBERED_STACK(objscheme_bundle_wxImageSnip(r)); return WITH_REMEMBERED_STACK(objscheme_bundle_wxImageSnip(r));
} }
static Scheme_Object *os_wxMediaPasteboardSizeCacheInvalid(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
REMEMBER_VAR_STACK();
objscheme_check_valid(os_wxMediaPasteboard_class, "size-cache-invalid in pasteboard%", n, p);
SETUP_VAR_STACK_REMEMBERED(1);
VAR_STACK_PUSH(0, p);
if (((Scheme_Class_Object *)p[0])->primflag)
WITH_VAR_STACK(((os_wxMediaPasteboard *)((Scheme_Class_Object *)p[0])->primdata)->wxMediaPasteboard::SizeCacheInvalid());
else
WITH_VAR_STACK(((wxMediaPasteboard *)((Scheme_Class_Object *)p[0])->primdata)->SizeCacheInvalid());
READY_TO_RETURN;
return scheme_void;
}
static Scheme_Object *os_wxMediaPasteboardInvalidateBitmapCache(int n, Scheme_Object *p[]) static Scheme_Object *os_wxMediaPasteboardInvalidateBitmapCache(int n, Scheme_Object *p[])
{ {
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p) WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
@ -6999,7 +7057,7 @@ void objscheme_setup_wxMediaPasteboard(Scheme_Env *env)
wxREGGLOB(os_wxMediaPasteboard_class); wxREGGLOB(os_wxMediaPasteboard_class);
os_wxMediaPasteboard_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "pasteboard%", "editor%", (Scheme_Method_Prim *)os_wxMediaPasteboard_ConstructScheme, 115)); os_wxMediaPasteboard_class = WITH_VAR_STACK(objscheme_def_prim_class(env, "pasteboard%", "editor%", (Scheme_Method_Prim *)os_wxMediaPasteboard_ConstructScheme, 116));
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, "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)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "get-scroll-step" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardGetScrollStep, 0, 0));
@ -7072,6 +7130,7 @@ void objscheme_setup_wxMediaPasteboard(Scheme_Env *env)
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "can-save-file?" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardCanSaveFile, 2, 2)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "can-save-file?" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardCanSaveFile, 2, 2));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "on-new-box" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardOnNewBox, 1, 1)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "on-new-box" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardOnNewBox, 1, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "on-new-image-snip" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardOnNewImageSnip, 4, 4)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "on-new-image-snip" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardOnNewImageSnip, 4, 4));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "size-cache-invalid" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardSizeCacheInvalid, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "invalidate-bitmap-cache" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardInvalidateBitmapCache, 0, 4)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "invalidate-bitmap-cache" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardInvalidateBitmapCache, 0, 4));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "on-paint" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardOnPaint, 9, 9)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "on-paint" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardOnPaint, 9, 9));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "write-footers-to-file" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardWriteFootersToFile, 1, 1)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaPasteboard_class, "write-footers-to-file" " method", (Scheme_Method_Prim *)os_wxMediaPasteboardWriteFootersToFile, 1, 1));