Check-in [7e8eb4865c]

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

Overview
Comment:Base for drawing display things.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7e8eb4865c30a13599856b94ef0171a0bac32699
User & Date: stephanie.gawroriski 2019-05-16 23:33:58
Context
2019-05-17
07:02
Backup developer notes. check-in: 8eecd20a07 user: squirreljme tags: trunk
2019-05-16
23:33
Base for drawing display things. check-in: 7e8eb4865c user: stephanie.gawroriski tags: trunk
18:40
Base drawing of active display, nothing actually drawn yet. check-in: 4b0cab57c8 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.

5
6
7
8
9
10
11

12
13
14
15
16
17
18
..
25
26
27
28
29
30
31












32
33
34
35
36
37
38
..
40
41
42
43
44
45
46





















47
48
49
50
51
52
53
..
58
59
60
61
62
63
64




65
66
67
68
69
70
71
72
73


74
75


// ---------------------------------------------------------------------------
// 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.Graphics;
import javax.microedition.lcdui.Image;
import java.util.Arrays;

/**
 * This contains the display display along with the internal image buffer.
 *
................................................................................
	
	/** The height of the display. */
	protected final int height;
	
	/** The backing buffer image. */
	protected final Image image;
	












	/**
	 * Initializes the active display.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
................................................................................
	{
		// Set sizes
		this.width = __w;
		this.height = __h;
		
		// Setup buffer
		this.image = Image.createImage(__w, __h);





















	}
	
	/**
	 * Paints whatever is in the active display.
	 *
	 * @param __x The X coordinate.
	 * @param __y The Y coordinate.
................................................................................
	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;
		




		// 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);
	}


}










>







 







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







 







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







 







>
>
>
>
|
|
|
|
|
|
|
|
|
>
>
|
|
>
>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
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
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
..
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.
 *
................................................................................
	
	/** The height of the display. */
	protected final int height;
	
	/** The backing buffer image. */
	protected final Image image;
	
	/** The displayable to draw. */
	private volatile Displayable _current;
	
	/** Width of the content area. */
	int _contentwidth;
	
	/** Height of the content area. */
	int _contentheight;
	
	/** The title to use. */
	String _title;
	
	/**
	 * Initializes the active display.
	 *
	 * @param __w The width.
	 * @param __h The height.
	 * @since 2019/05/16
	 */
................................................................................
	{
		// Set sizes
		this.width = __w;
		this.height = __h;
		
		// Setup buffer
		this.image = Image.createImage(__w, __h);
		
		// Default content area size
		this._contentwidth = __w;
		this._contentheight = __h - (StandardMetrics.TITLE_BAR_HEIGHT +
			StandardMetrics.COMMAND_BAR_HEIGHT);
	}
	
	/**
	 * Activates the display.
	 *
	 * @param __d The displayable to be drawn when requested.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	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.
................................................................................
	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;
		}
	}
}

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

19
20
21
22
23
24
25

26
27
28
29
30
31
32
 */
public interface PhoneDisplayBackend
{
	/**
	 * Activates the display.
	 *
	 * @param __ad The active display to draw into.

	 * @since 2019/05/16
	 */
	public abstract void activate(ActiveDisplay __ad)
		throws NullPointerException;
	
	/**
	 * Returns if the display is upside-down, this is used for orientation







>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 */
public interface PhoneDisplayBackend
{
	/**
	 * Activates the display.
	 *
	 * @param __ad The active display to draw into.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
	public abstract void activate(ActiveDisplay __ad)
		throws NullPointerException;
	
	/**
	 * Returns if the display is upside-down, this is used for orientation

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

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
..
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
158
159
160
161
162
163
164


165
166
167
168
169
170
171
172
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
	
	/** The buffer which represents the display itself. */
	protected final Image buffer;
	
	/** The current displayable to show. */
	private Displayable _current;
	
	/** The title to use. */
	private String _title;
	
	/** Should the display be repainted? */
	private volatile boolean _repaint;
	
	/** Width of the content area. */
	private int _contentwidth;
	
	/** Height of the content area. */
	private int _contentheight;
	
	/**
	 * Initializes the base UI using the default screen size.
	 *
	 * @param __b The display backend to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
................................................................................
		
		// Set active display
		ActiveDisplay activedisplay = new ActiveDisplay(__sw, __sh);
		this.activedisplay = activedisplay;
		
		// All screen operations are done on a secondary buffer
		this.buffer = activedisplay.image;
		
		// Default content area size
		this._contentwidth = __sw;
		this._contentheight = __sh - (StandardMetrics.TITLE_BAR_HEIGHT +
			StandardMetrics.COMMAND_BAR_HEIGHT);
	}
	
	/**
	 * Returns the height of the content area.
	 *
	 * @return The content area height.
	 * @since 2019/05/16
	 */
	public final int contentHeight()
	{
		return this._contentheight;
	}
	
	/**
	 * Returns the width of the content area.
	 *
	 * @return The content area width.
	 * @since 2019/05/16
	 */
	public final int contentWidth()
	{
		return this._contentwidth;
	}
	
	/**
	 * Signals that the display should be repainted.
	 *
	 * @since 2019/05/16
	 */
................................................................................
	 */
	public final void setCurrent(Displayable __d)
	{
		// Set
		this._current = __d;
		
		// Activate the display


		this.backend.activate(this.activedisplay);
		
		// Repaint
		this.repaint();
	}
	
	/**
	 * Sets the title of what is displayed on the screen.
................................................................................
	public final void setTitle(String __t)
	{
		// Default title?
		if (__t == null)
			__t = "SquirrelJME";
		
		// Set
		this._title = __t;
		
		// Repaint
		if (this._current != null)
			this.repaint();
	}
}








<
<
<



<
<
<
<
<
<







 







<
<
<
<
<










|










|







 







>
>
|







 







|







43
44
45
46
47
48
49



50
51
52






53
54
55
56
57
58
59
..
84
85
86
87
88
89
90





91
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
118
119
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
	
	/** The buffer which represents the display itself. */
	protected final Image buffer;
	
	/** The current displayable to show. */
	private Displayable _current;
	



	/** Should the display be repainted? */
	private volatile boolean _repaint;
	






	/**
	 * Initializes the base UI using the default screen size.
	 *
	 * @param __b The display backend to use.
	 * @throws NullPointerException On null arguments.
	 * @since 2019/05/16
	 */
................................................................................
		
		// Set active display
		ActiveDisplay activedisplay = new ActiveDisplay(__sw, __sh);
		this.activedisplay = activedisplay;
		
		// All screen operations are done on a secondary buffer
		this.buffer = activedisplay.image;





	}
	
	/**
	 * Returns the height of the content area.
	 *
	 * @return The content area height.
	 * @since 2019/05/16
	 */
	public final int contentHeight()
	{
		return this.activedisplay._contentheight;
	}
	
	/**
	 * Returns the width of the content area.
	 *
	 * @return The content area width.
	 * @since 2019/05/16
	 */
	public final int contentWidth()
	{
		return this.activedisplay._contentwidth;
	}
	
	/**
	 * Signals that the display should be repainted.
	 *
	 * @since 2019/05/16
	 */
................................................................................
	 */
	public final void setCurrent(Displayable __d)
	{
		// Set
		this._current = __d;
		
		// Activate the display
		ActiveDisplay ad = this.activedisplay;
		ad.activate(__d);
		this.backend.activate(ad);
		
		// Repaint
		this.repaint();
	}
	
	/**
	 * Sets the title of what is displayed on the screen.
................................................................................
	public final void setTitle(String __t)
	{
		// Default title?
		if (__t == null)
			__t = "SquirrelJME";
		
		// Set
		this.activedisplay._title = __t;
		
		// Repaint
		if (this._current != null)
			this.repaint();
	}
}