Check-in [31ff0ed16b]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Realize the content area when it is set as well as during painting.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:31ff0ed16bcf160e3a6e9584586a2909114c5964
User & Date: stephanie.gawroriski 2019-05-17 16:17:16
Context
2019-05-17
16:20
Capability get of pointer events. check-in: b75815213e user: stephanie.gawroriski tags: trunk
16:17
Realize the content area when it is set as well as during painting. check-in: 31ff0ed16b user: stephanie.gawroriski tags: trunk
15:46
Draw command bar if there are commands. check-in: f4e7411c38 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/ActiveDisplay.java.

41
42
43
44
45
46
47






48
49
50
51
52
53
54
..
86
87
88
89
90
91
92

93



94
95
96
97
98
99
100
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

130
131
132
133
134

135
136
137
138
139
140
141


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

185



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
...
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
...
276
277
278
279
280
281
282














































































283
284
285
286
287
288
289
	private volatile boolean _invibrate;
	
	/** Vibration end time. */
	private volatile long _vibrateend;
	
	/** Vibration cycle. */
	private volatile boolean _vibratecycle;






	
	/** Width of the content area. */
	int _contentwidth;
	
	/** Height of the content area. */
	int _contentheight;
	
................................................................................
	 */
	public final void activate(Displayable __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		

		this._current = __d;



	}
	
	/**
	 * Paints whatever is in the active display.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
................................................................................
		Graphics dg = this.image.getGraphics();
		int dw = this.width,
			dh = this.height;
		
		// Current displayable to draw
		ExposedDisplayable current = (ExposedDisplayable)this._current;
		
		// Get commands that are used, this is used to figure out if the
		// command bar needs to be drawn
		Command[] commands = (current == null ? new Command[0] :
			current.getCommands());
		int numcommands = commands.length;
		
		// Is the command bar and title bar to be drawn maybe?
		boolean drawcommandbar,
			drawtitlebar;
		
		// Drawing full-screen graphics so do not draw the title bar or the
		// command bar at all. But since it is full-screen we can just draw
		// directly on the image without using a wrapper (is faster)
		// This becomes the user drawing area
		Graphics ug;

		int uw, uh;
		if (current != null && current.isFullscreen())
		{
			// Display is the whole screen
			ug = dg;

			uw = dw;
			uh = dh;
			
			// These are never drawn
			drawtitlebar = false;
			drawcommandbar = false;
		}


		
		// Otherwise, we draw the title bar and the command bar
		else
		{
			// Title bar is always drawn
			drawtitlebar = true;
			
			// The command bar is only drawn if we have actual commands
			drawcommandbar = (numcommands > 0);
			
			// Draw area is shortened in height
			uw = dw;
			uh = (dh - StandardMetrics.TITLE_BAR_HEIGHT) -
				(drawcommandbar ? StandardMetrics.COMMAND_BAR_HEIGHT : 0);
			
			// Use 
			ug = new EnforcedDrawingAreaGraphics(dg,
				0, StandardMetrics.TITLE_BAR_HEIGHT,
				uw, uh);
		}
		
		// Remember default parameters
		Font oldfont = dg.getFont();
		int oldcolor = dg.getColor();
		
		// Draw title bar
		if (drawtitlebar)
		{
			// Draw background
			dg.setColor(StandardMetrics.BACKGROUND_BAR_COLOR);
			dg.fillRect(0, 0, dw, StandardMetrics.TITLE_BAR_HEIGHT);
			
			// Set font
			dg.setFont(Font.getFont("sansserif", 0,
				StandardMetrics.TITLE_BAR_HEIGHT));
			
			// Draw title text
			String title = this._title;
			dg.setColor(StandardMetrics.FOREGROUND_BAR_COLOR);
			dg.drawString(title, 0, 0, Graphics.TOP | Graphics.LEFT);
			dg.drawString(title, 1, 0, Graphics.TOP | Graphics.LEFT);
		}
		

		// Draw the command bar?



		if (drawcommandbar)
		{
			// Base Y position
			int cy = dh - StandardMetrics.COMMAND_BAR_HEIGHT;
			
			// Draw background
			dg.setColor(StandardMetrics.BACKGROUND_BAR_COLOR);
			dg.fillRect(0, cy, dw, StandardMetrics.COMMAND_BAR_HEIGHT);
		}
		
		// Restore parameters
		dg.setFont(oldfont);
		dg.setColor(oldcolor);
		
		// Send resize to the display before drawing it?
		int oldcw = this._contentwidth,
			oldch = this._contentheight;
		if (oldcw != uw || oldch != uh)
		{

			// Set new size
			this._contentwidth = uw;
			this._contentheight = uh;
			
			// And send it now
			if (current != null)
				current.sizeChanged(uw, uh);
		}
		
		// If nothing is being shown, just show the version info
		if (current == null)
		{
			// Draw box
			ug.setColor(0x0000FF);
			ug.fillRect(0, 0, uw, uh);
................................................................................
		else
		{
			// If the displayable is transparent then, we fill in the
			// background for the application
			if (current.isTransparent())
			{
				// Use background color instead
				oldcolor = ug.getColor();
				ug.setColor(StandardMetrics.TRANSPARENT_COLOR);
				
				// Fill
				ug.fillRect(0, 0, uw, uh);
				
				// Restore
				ug.setColor(oldcolor);
................................................................................
				// Draw vibrate symbol
				dg.setColor(StandardMetrics.VIBRATE_COLOR);
				dg.drawChar('#', sx, 0, Graphics.RIGHT | Graphics.TOP);
				sx -= xa;
			}
		}
	}














































































	
	/**
	 * Vibrates the display for the given number of milliseconds.
	 *
	 * @param __ms The number of milliseconds to vibrate for.
	 * @since 2019/05/17
	 */







>
>
>
>
>
>







 







>

>
>
>







 







|
|
|
|
<

<
<
<
<
<
<
<
<
<
>
|
<
<
<
<
>
|
|
|
<
<
<
<
>
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
<
<
<













|
<
>
|
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
<
<
|
>
|
<
<
<
<
<
|
<







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
...
118
119
120
121
122
123
124
125
126
127
128

129









130
131




132
133
134
135




136
137
138




















139
140
141
142



143
144
145
146
147
148
149
150
151
152
153
154
155
156

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175




176
177
178





179

180
181
182
183
184
185
186
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
	private volatile boolean _invibrate;
	
	/** Vibration end time. */
	private volatile long _vibrateend;
	
	/** Vibration cycle. */
	private volatile boolean _vibratecycle;
	
	/** Content X Area. */
	int _contentx;
	
	/** Content Y Area. */
	int _contenty;
	
	/** Width of the content area. */
	int _contentwidth;
	
	/** Height of the content area. */
	int _contentheight;
	
................................................................................
	 */
	public final void activate(Displayable __d)
		throws NullPointerException
	{
		if (__d == null)
			throw new NullPointerException("NARG");
		
		// Set
		this._current = __d;
		
		// Realize the dimensions
		this.realize(new int[4]);
	}
	
	/**
	 * Paints whatever is in the active display.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
................................................................................
		Graphics dg = this.image.getGraphics();
		int dw = this.width,
			dh = this.height;
		
		// Current displayable to draw
		ExposedDisplayable current = (ExposedDisplayable)this._current;
		
		// Realize new content area coordinates
		int[] ua = new int[4];
		if (this.realize(ua))
			current.sizeChanged(ua[2], ua[3]);

		









		// Extract coordinates
		int ux = ua[0],




			uy = ua[1],
			uw = ua[2],
			uh = ua[3];
		




		// If not full-screen, then draw title bar and maybe the command bar
		if (uh != dh)
		{




















			// Remember default parameters
			Font oldfont = dg.getFont();
			int oldcolor = dg.getColor();
			



			// Draw background
			dg.setColor(StandardMetrics.BACKGROUND_BAR_COLOR);
			dg.fillRect(0, 0, dw, StandardMetrics.TITLE_BAR_HEIGHT);
			
			// Set font
			dg.setFont(Font.getFont("sansserif", 0,
				StandardMetrics.TITLE_BAR_HEIGHT));
			
			// Draw title text
			String title = this._title;
			dg.setColor(StandardMetrics.FOREGROUND_BAR_COLOR);
			dg.drawString(title, 0, 0, Graphics.TOP | Graphics.LEFT);
			dg.drawString(title, 1, 0, Graphics.TOP | Graphics.LEFT);
			

			// Get commands that are used, this is used to figure out if the
			// command bar needs to be drawn
			Command[] commands = (current == null ? new Command[0] :
				current.getCommands());
			int numcommands = commands.length;
			if (numcommands > 0)
			{
				// Base Y position
				int cy = dh - StandardMetrics.COMMAND_BAR_HEIGHT;
				
				// Draw background
				dg.setColor(StandardMetrics.BACKGROUND_BAR_COLOR);
				dg.fillRect(0, cy, dw, StandardMetrics.COMMAND_BAR_HEIGHT);
			}
			
			// Restore parameters
			dg.setFont(oldfont);
			dg.setColor(oldcolor);
		}




		
		// Setup enforced graphics
		Graphics ug = new EnforcedDrawingAreaGraphics(dg,





			ux, uy, uw, uh);

		
		// If nothing is being shown, just show the version info
		if (current == null)
		{
			// Draw box
			ug.setColor(0x0000FF);
			ug.fillRect(0, 0, uw, uh);
................................................................................
		else
		{
			// If the displayable is transparent then, we fill in the
			// background for the application
			if (current.isTransparent())
			{
				// Use background color instead
				int oldcolor = ug.getColor();
				ug.setColor(StandardMetrics.TRANSPARENT_COLOR);
				
				// Fill
				ug.fillRect(0, 0, uw, uh);
				
				// Restore
				ug.setColor(oldcolor);
................................................................................
				// Draw vibrate symbol
				dg.setColor(StandardMetrics.VIBRATE_COLOR);
				dg.drawChar('#', sx, 0, Graphics.RIGHT | Graphics.TOP);
				sx -= xa;
			}
		}
	}
	
	/**
	 * Realizes the size of the content area.
	 *
	 * @param __dims The output content area dimensions.
	 * @return {@code true} if the area has been resized.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	public final boolean realize(int[] __dims)
		throws NullPointerException
	{
		if (__dims == null)
			throw new NullPointerException("NARG");
		
		// Screen size
		int dw = this.width,
			dh = this.height;
		
		// User area
		int ux, uy, uw, uh;
		
		// Current displayable to draw
		ExposedDisplayable current = (ExposedDisplayable)this._current;
		
		// Full-screen uses the entire screen
		if (current != null && current.isFullscreen())
		{
			ux = 0;
			uy = 0;
			uw = dw;
			uh = dh;
		}
		
		// Otherwise, space is lost to the title bar and commands
		else
		{
			// Get commands that are used, this is used to figure out if the
			// command bar needs to be drawn
			Command[] commands = (current == null ? new Command[0] :
				current.getCommands());
			int numcommands = commands.length;
			
			// Clip dimensions
			ux = 0;
			uy = StandardMetrics.TITLE_BAR_HEIGHT;
			uw = dw;
			uh = (dh - StandardMetrics.TITLE_BAR_HEIGHT) -
				(numcommands > 0 ? StandardMetrics.COMMAND_BAR_HEIGHT : 0);
		}
		
		// Has the area changed?
		boolean rv = false;
		int oldux = this._contentx,
			olduy = this._contenty,
			olduw = this._contentwidth,
			olduh = this._contentheight;
		if (ux != oldux || uy != olduy || uw != olduw || uh != olduh)
		{
			// Did change
			rv = true;
			
			// Set new fields
			this._contentx = ux;
			this._contenty = uy;
			this._contentwidth = uw;
			this._contentheight = uh;
		}
		
		// Set output user area dimensions
		__dims[0] = ux;
		__dims[1] = uy;
		__dims[2] = uw;
		__dims[3] = uh;
		
		// Has this changed at all?
		return rv;
	}
	
	/**
	 * Vibrates the display for the given number of milliseconds.
	 *
	 * @param __ms The number of milliseconds to vibrate for.
	 * @since 2019/05/17
	 */