Check-in [dc04d0d8f3]

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

Overview
Comment:Drawing of canvases.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:dc04d0d8f36d8c603c5df7a269b21bb79dffcadd
User & Date: stephanie.gawroriski 2019-05-17 14:00:09
Context
2019-05-17
14:53
Handle vibration; Add vibration symbol; If the display is vibrating, show a symbol that it is; Implement anchoring for text. check-in: 0083862360 user: stephanie.gawroriski tags: trunk
14:00
Drawing of canvases. check-in: dc04d0d8f3 user: stephanie.gawroriski tags: trunk
07:02
Backup developer notes. check-in: 8eecd20a07 user: squirreljme tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

5
6
7
8
9
10
11



12

13
14
15
16
17
18
19
..
92
93
94
95
96
97
98
99
100























































































101
102
103
104
105
106
107
108
109
110





111












112
113








114
115
116
117
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;




import javax.microedition.lcdui.Displayable;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import java.util.Arrays;

/**
 * This contains the display display along with the internal image buffer.
 *
................................................................................
	public final void paint(int __x, int __y, int __w, int __h)
	{
		// Get display details
		Graphics dg = this.image.getGraphics();
		int dw = this.width,
			dh = this.height;
		
		// If there is no displayable then draw a blank screen
		Displayable current = this._current;























































































		if (current == null)
		{
			// Draw box
			dg.setColor(0x0000FF);
			dg.fillRect(0, 0, dw, dh);
			
			// Draw an X
			dg.setColor(0xFFFF00);
			dg.drawLine(0, 0, dw, dh);
			dg.drawLine(0, dh, dw, 0);





			












			// Stop
			return;








		}
	}
}








>
>
>

>







 







|

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



|
|

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




5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
96
97
98
99
100
101
102
103
104
105
106
107
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
220
221
222
223
224
225
226
227
228
229
230
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import java.util.Arrays;

/**
 * This contains the display display along with the internal image buffer.
 *
................................................................................
	public final void paint(int __x, int __y, int __w, int __h)
	{
		// Get display details
		Graphics dg = this.image.getGraphics();
		int dw = this.width,
			dh = this.height;
		
		// Current displayable to draw
		Displayable current = 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);
		
		// If nothing is being shown, just show the version info
		if (current == null)
		{
			// Draw box
			ug.setColor(0x0000FF);
			ug.fillRect(0, 0, uw, uh);
			
			// Draw some layout text
			ug.setColor(0xFFFF00);


			ug.setFont(Font.getFont("sansserif", 0, 16));
			ug.drawString("SquirrelJME " + SquirrelJME.RUNTIME_VERSION + "\n" +
				"(C) Stephanie Gawroriski\n" +
				"https://squirreljme.cc/\nLicensed w/ the GPLv3!", 0, 0, 0);
			ug.drawString("SquirrelJME", 1, 0, 0);
		}
		
		// Normal painting
		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);
			}
			
			// Paint
			current.paint(ug);
		}
	}
}

Added runt/apis/midp-lcdui/cc/squirreljme/runtime/lcdui/phoneui/ExposedDisplayable.java.



















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.runtime.lcdui.phoneui;

import cc.squirreljme.runtime.lcdui.SerializedEvent;
import javax.microedition.lcdui.Graphics;

/**
 * This is a base class for items which need to be exposed action wise and
 * such. All methods here by default do nothing.
 *
 * @since 2019/05/17
 */
public abstract class ExposedDisplayable
{
	/**
	 * Is this widget a full-screen one?
	 *
	 * @return If this is full-screen or not.
	 * @since 2019/05/17
	 */
	protected boolean isFullscreen()
	{
		return false;
	}
	
	/**
	 * Is this display transparent?
	 *
	 * @return If the display is transparent.
	 * @since 2019/05/17
	 */
	protected boolean isTransparent()
	{
		return true;
	}
	
	/**
	 * This is called when the displayable needs to be painted onto the
	 * screen.
	 *
	 * @param __g The graphics to draw into.
	 * @since 2019/05/17
	 */
	@SerializedEvent
	protected void paint(Graphics __g)
	{
	}
}

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

19
20
21
22
23
24
25












26
27
28
29
30
31
32
33
34
35
36
	/** Height of the title bar. */
	public static final int TITLE_BAR_HEIGHT =
		12;
	
	/** Height of the command bar. */
	public static final int COMMAND_BAR_HEIGHT =
		12;












	
	/**
	 * Not used.
	 *
	 * @since 2019/05/16
	 */
	private StandardMetrics()
	{
	}
}








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











19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	/** Height of the title bar. */
	public static final int TITLE_BAR_HEIGHT =
		12;
	
	/** Height of the command bar. */
	public static final int COMMAND_BAR_HEIGHT =
		12;
	
	/** The background bar color. */
	public static final int BACKGROUND_BAR_COLOR =
		0x000000;
	
	/** The foreground bar color. */
	public static final int FOREGROUND_BAR_COLOR =
		0xFFFFFF;
	
	/** Transparent background color. */
	public static final int TRANSPARENT_COLOR =
		0xFFFFFF;
	
	/**
	 * Not used.
	 *
	 * @since 2019/05/16
	 */
	private StandardMetrics()
	{
	}
}

Changes to runt/apis/midp-lcdui/javax/microedition/lcdui/Canvas.java.

6
7
8
9
10
11
12

13
14
15
16
17
18
19
...
327
328
329
330
331
332
333
























334
335
336
337
338
339
340
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;


import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.event.EventTranslate;
import cc.squirreljme.runtime.lcdui.event.KeyNames;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
................................................................................
	 * @return {@code true}.
	 * @since 2017/05/13
	 */
	public boolean isDoubleBuffered()
	{
		return true;
	}
























	
	/**
	 * This is called when a key has been pressed.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2017/02/12
	 */







>







 







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







6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.annotation.ImplementationNote;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.cldc.asm.NativeDisplayEventCallback;
import cc.squirreljme.runtime.lcdui.common.CommonColors;
import cc.squirreljme.runtime.lcdui.event.EventTranslate;
import cc.squirreljme.runtime.lcdui.event.KeyNames;
import cc.squirreljme.runtime.lcdui.event.NonStandardKey;
import cc.squirreljme.runtime.lcdui.gfx.EnforcedDrawingAreaGraphics;
................................................................................
	 * @return {@code true}.
	 * @since 2017/05/13
	 */
	public boolean isDoubleBuffered()
	{
		return true;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	@ImplementationNote("This is in SquirrelJME only and is used to provide " +
		"access to this flag.")
	protected boolean isFullscreen()
	{
		return this._isfullscreen;
	}
	
	/**
	 * {@inheritDoc}
	 * @since 2019/05/17
	 */
	@Override
	@ImplementationNote("This is in SquirrelJME only and is used to provide " +
		"access to this flag.")
	protected boolean isTransparent()
	{
		return this._transparent;
	}
	
	/**
	 * This is called when a key has been pressed.
	 *
	 * @param __code The key code, the character is not modified by modifiers.
	 * @since 2017/02/12
	 */

Changes to runt/apis/midp-lcdui/javax/microedition/lcdui/Displayable.java.

7
8
9
10
11
12
13

14
15
16
17
18
19
20
..
21
22
23
24
25
26
27

28
29
30
31
32
33
34
...
116
117
118
119
120
121
122






123
124
125

126
127
128
129
130
131
132
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;

import cc.squirreljme.runtime.lcdui.SerializedEvent;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import javax.microedition.midlet.MIDlet;

/**
................................................................................
 * A displayable is a primary container such as a form or a canvas that can be
 * set on a display. A display may only have a single displayable associated
 * with it and a displayable may only be associated with a single display.
 *
 * @since 2016/10/08
 */
public abstract class Displayable

{
	/** Commands which have been added to the displayable. */
	final __VolatileList__<Command> _commands =
		new __VolatileList__<>();
	
	/** The display this is attached to, if any. */
	volatile Display _display;
................................................................................
	}
	
	public CommandLayoutPolicy getCommandLayoutPolicy()
	{
		throw new todo.TODO();
	}
	






	public Command[] getCommands()
	{
		throw new todo.TODO();

	}
	
	/**
	 * Returns the display that is associated with this displayable.
	 *
	 * @return The owning display or {@code null} if not found.
	 * @since 2016/10/08







>







 







>







 







>
>
>
>
>
>


<
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
140
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package javax.microedition.lcdui;

import cc.squirreljme.runtime.cldc.asm.NativeDisplayAccess;
import cc.squirreljme.runtime.lcdui.phoneui.ExposedDisplayable;
import cc.squirreljme.runtime.lcdui.SerializedEvent;
import cc.squirreljme.runtime.midlet.ActiveMidlet;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import javax.microedition.midlet.MIDlet;

/**
................................................................................
 * A displayable is a primary container such as a form or a canvas that can be
 * set on a display. A display may only have a single displayable associated
 * with it and a displayable may only be associated with a single display.
 *
 * @since 2016/10/08
 */
public abstract class Displayable
	extends ExposedDisplayable
{
	/** Commands which have been added to the displayable. */
	final __VolatileList__<Command> _commands =
		new __VolatileList__<>();
	
	/** The display this is attached to, if any. */
	volatile Display _display;
................................................................................
	}
	
	public CommandLayoutPolicy getCommandLayoutPolicy()
	{
		throw new todo.TODO();
	}
	
	/**
	 * Gets the commands which are available to use.
	 *
	 * @return The available commands.
	 * @since 2019/05/17
	 */
	public Command[] getCommands()
	{

		return this._commands.toArray(new Command[0]);
	}
	
	/**
	 * Returns the display that is associated with this displayable.
	 *
	 * @return The owning display or {@code null} if not found.
	 * @since 2016/10/08

Changes to runt/apis/midp-lcdui/javax/microedition/lcdui/Text.java.

1101
1102
1103
1104
1105
1106
1107



1108
1109
1110
1111
1112
1113
1114
					i--;
				
				// The new start index
				linedxstart = i + 1;
				
				// Set the previously calculated Y position
				y = nexty;



			}
		}
		
		// Update other needed parameters
		// The required height is our nexty because either at the end or
		// a newline this will always be set
		this._requiredheight = nexty;







>
>
>







1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
					i--;
				
				// The new start index
				linedxstart = i + 1;
				
				// Set the previously calculated Y position
				y = nexty;
				
				// Move X back
				x = startx;
			}
		}
		
		// Update other needed parameters
		// The required height is our nexty because either at the end or
		// a newline this will always be set
		this._requiredheight = nexty;

Changes to runt/apis/midp-lcdui/javax/microedition/lcdui/__VolatileList__.java.

170
171
172
173
174
175
176
































177
178
179
180
181
182
183
	 * @return The number of values stored.
	 * @since 2018/11/18
	 */
	public final int size()
	{
		return this._values.length;
	}
































	
	/**
	 * Returns the values in the list.
	 *
	 * @return The list values.
	 * @since 2018/11/18
	 */







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







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
	 * @return The number of values stored.
	 * @since 2018/11/18
	 */
	public final int size()
	{
		return this._values.length;
	}
	
	/**
	 * Converts the values to an array of the specific type.
	 *
	 * @param __ov The output array.
	 * @return The output array, may be recreated if too small.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/17
	 */
	@SuppressWarnings({"unchecked"})
	public final T[] toArray(T[] __ov)
		throws NullPointerException
	{
		if (__ov == null)
			throw new NullPointerException("NARG");
		
		// Get input values
		Object[] iv = this._values;
		int in = iv.length;
		
		// Too short of an array? Grow it
		int on = __ov.length;
		if (on < in)
			__ov = Arrays.<T>copyOf(__ov, in);
		
		// Copy values
		for (int i = 0; i < in; i++)
			__ov[i] = (T)iv[i];
		
		// And use the passed or recreated array
		return __ov;
	}
	
	/**
	 * Returns the values in the list.
	 *
	 * @return The list values.
	 * @since 2018/11/18
	 */