52 |
{ |
{ |
53 |
public QtComponentPeer curr; |
public QtComponentPeer curr; |
54 |
public RepaintComponent next; |
public RepaintComponent next; |
55 |
|
public boolean paintAll; |
56 |
|
public int x, y, w, h; |
57 |
|
|
58 |
public RepaintComponent(QtComponentPeer p) |
public RepaintComponent(QtComponentPeer p) |
59 |
{ |
{ |
60 |
curr = p; |
curr = p; |
61 |
next = null; |
next = null; |
62 |
|
paintAll = true; |
63 |
|
} |
64 |
|
|
65 |
|
public RepaintComponent(QtComponentPeer p, int x, int y, int w, int h) |
66 |
|
{ |
67 |
|
this(p); |
68 |
|
paintAll = false; |
69 |
|
this.x = x; |
70 |
|
this.y = y; |
71 |
|
this.w = w; |
72 |
|
this.h = h; |
73 |
} |
} |
74 |
} |
} |
75 |
|
|
89 |
{ |
{ |
90 |
busy = false; |
busy = false; |
91 |
// Wait for a repaint |
// Wait for a repaint |
92 |
sleep(1000); |
sleep(100); |
93 |
|
busy = true; |
94 |
} |
} |
95 |
catch (InterruptedException ie) |
catch (InterruptedException ie) |
96 |
{ |
{ |
|
// peform the repaint. No interruptions please. |
|
|
busy = true; |
|
97 |
while( component != null ) |
while( component != null ) |
98 |
{ |
{ |
99 |
component.curr.paintBackBuffer(); // update the back-buffer. |
try |
100 |
component.curr.QtUpdate(); // trigger a native repaint event |
{ |
101 |
|
if( component.paintAll ) |
102 |
|
{ |
103 |
|
// update the back-buffer. |
104 |
|
component.curr.paintBackBuffer(); |
105 |
|
component.curr.QtUpdate(); // trigger a native repaint event |
106 |
|
} |
107 |
|
else |
108 |
|
{ |
109 |
|
component.curr.paintBackBuffer(component.x, component.y, |
110 |
|
component.w, component.h); |
111 |
|
component.curr.QtUpdateArea(component.x, component.y, |
112 |
|
component.w, component.h); |
113 |
|
} |
114 |
|
} |
115 |
|
catch (InterruptedException e) |
116 |
|
{ |
117 |
|
} |
118 |
component = component.next; |
component = component.next; |
119 |
} |
} |
120 |
} |
} |
|
catch (Throwable x) |
|
|
{ |
|
|
System.err.println("Exception in paint thread:"); |
|
|
x.printStackTrace(System.err); |
|
|
} |
|
121 |
} |
} |
122 |
} |
} |
123 |
|
|
134 |
while( r.next != null ) r = r.next; |
while( r.next != null ) r = r.next; |
135 |
r.next = new RepaintComponent(p); |
r.next = new RepaintComponent(p); |
136 |
} |
} |
137 |
if( !busy ) |
interrupt(); |
138 |
interrupt(); |
} |
139 |
|
|
140 |
|
/** |
141 |
|
* Enqueue a component for repainting. |
142 |
|
*/ |
143 |
|
public synchronized void queueComponent(QtComponentPeer p, int x, int y, |
144 |
|
int w, int h) |
145 |
|
{ |
146 |
|
if( component == null ) |
147 |
|
component = new RepaintComponent(p, x, y, w, h); |
148 |
|
else |
149 |
|
{ |
150 |
|
RepaintComponent r = component; |
151 |
|
while( r.next != null ) r = r.next; |
152 |
|
r.next = new RepaintComponent(p, x, y, w, h); |
153 |
|
} |
154 |
|
interrupt(); |
155 |
} |
} |
156 |
} |
} |