diff options
Diffstat (limited to 'lib/observer/src/observer_app_wx.erl')
-rw-r--r-- | lib/observer/src/observer_app_wx.erl | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/lib/observer/src/observer_app_wx.erl b/lib/observer/src/observer_app_wx.erl index a2b7c21993..40e117357c 100644 --- a/lib/observer/src/observer_app_wx.erl +++ b/lib/observer/src/observer_app_wx.erl @@ -29,7 +29,7 @@ -include("observer_defs.hrl"). %% Import drawing wrappers --import(observer_perf_wx, [haveGC/0, +-import(observer_perf_wx, [haveGC/0, make_gc/2, destroy_gc/1, setPen/2, setFont/3, setBrush/2, strokeLine/5, strokeLines/2, drawRoundedRectangle/6, drawText/4, getTextExtent/2]). @@ -244,28 +244,18 @@ handle_event(Event, _State) -> %%%%%%%%%% handle_sync_event(#wx{event = #wxPaint{}},_, #state{app_w=DA, app=App, sel=Sel, paint=Paint, usegc=UseGC}) -> - %% PaintDC must be created in a callback to work on windows. - IsWindows = element(1, os:type()) =:= win32, - %% Avoid Windows flickering hack - DC = if IsWindows -> wx:typeCast(wxBufferedPaintDC:new(DA), wxPaintDC); - true -> wxPaintDC:new(DA) - end, - IsWindows andalso wxDC:clear(DC), - GC = case UseGC of - true -> - GC0 = ?wxGC:create(DC), - %% Argh must handle scrolling when using ?wxGC - {Sx,Sy} = wxScrolledWindow:calcScrolledPosition(DA, {0,0}), - ?wxGC:translate(GC0, Sx,Sy), - GC0; - false -> - wxScrolledWindow:doPrepareDC(DA,DC), - DC - end, + GC = {GC0, DC} = make_gc(DA, UseGC), + case UseGC of + false -> + wxScrolledWindow:doPrepareDC(DA,DC); + true -> + %% Argh must handle scrolling when using ?wxGC + {Sx,Sy} = wxScrolledWindow:calcScrolledPosition(DA, {0,0}), + ?wxGC:translate(GC0, Sx,Sy) + end, %% Nothing is drawn until wxPaintDC is destroyed. - draw({UseGC, GC}, App, Sel, Paint), - UseGC andalso ?wxGC:destroy(GC), - wxPaintDC:destroy(DC), + draw(GC, App, Sel, Paint), + destroy_gc(GC), ok. %%%%%%%%%% handle_call(Event, From, _State) -> @@ -312,15 +302,10 @@ handle_info({delivery, _Pid, app, _Curr, {[], [], [], []}}, handle_info({delivery, Pid, app, Curr, AppData}, State = #state{panel=Panel, appmon=Pid, current=Curr, usegc=UseGC, app_w=AppWin, paint=#paint{font=Font}}) -> - GC = if UseGC -> ?wxGC:create(AppWin); - true -> wxWindowDC:new(AppWin) - end, - FontW = {UseGC, GC}, - setFont(FontW, Font, {0,0,0}), - App = build_tree(AppData, FontW), - if UseGC -> ?wxGC:destroy(GC); - true -> wxWindowDC:destroy(GC) - end, + GC = make_gc(AppWin, UseGC), + setFont(GC, Font, {0,0,0}), + App = build_tree(AppData, GC), + destroy_gc(GC), setup_scrollbar(AppWin, App), wxWindow:refresh(Panel), wxWindow:layout(Panel), |