Commit 5f9ff3c5 authored by Claes Sjofors's avatar Claes Sjofors

Java android app work

parent e01bb94c
......@@ -4,6 +4,7 @@ import android.graphics.Bitmap;
public class AGraphInfo {
public Bitmap bpm;
public Bitmap bpmInverted;
public String graph;
public String text;
public int iconX;
......@@ -12,4 +13,5 @@ public class AGraphInfo {
public int iconHeight;
public int textX;
public int textY;
public boolean inverted = false;
}
......@@ -11,6 +11,8 @@ public class AXttItemAttrObject extends AXttItemBase {
String name;
int flags;
int type;
PwrtAttrRef aref;
AXttItemAttrObject(AXtt axtt, PwrtObjid objid, String name, String fullName, int flags, int type,
PlowNode destination, int destCode) {
......@@ -20,9 +22,24 @@ public class AXttItemAttrObject extends AXttItemBase {
this.flags = flags;
this.type = type;
CdhrAttrRef ar = axtt.gdh.nameToAttrRef( fullName);
if ( ar.evenSts()) return;
aref = ar.aref;
CdhrTypeId cr = axtt.gdh.getAttrRefTid( ar.aref);
if ( cr.evenSts()) return;
CdhrObjid coidret = axtt.gdh.classIdToObjid(cr.typeId);
if ( coidret.evenSts()) return;
CdhrString cnameret = axtt.gdh.objidToName(coidret.objid, Cdh.mName_object);
if ( cnameret.evenSts()) return;
node = new PlowNode(axtt.cmn, 0, 0, axtt.ncObject);
node.setAnnotPixmap(0, axtt.iconObject);
node.setAnnotation(0, name, 22);
node.setAnnotation(1, cnameret.str, 22);
axtt.cmn.insertNode(node, destination, destCode);
node.setUserData(this);
......@@ -89,4 +106,8 @@ public class AXttItemAttrObject extends AXttItemBase {
}
axtt.cmn.configure();
}
public PwrtAttrRef getAttrRef() {
return aref;
}
}
......@@ -126,14 +126,14 @@ public class FlowCmn implements PlowCmnIfc {
public void scroll( int x, int y) {
offset_y += y;
offset_x += x;
if ( offset_x < x_left * zoom_factor - scrollOffset)
offset_x = (int)(x_left * zoom_factor) - scrollOffset;
if ( offset_x > x_right * zoom_factor - canvasWidth + scrollOffset)
offset_x = (int)(x_right * zoom_factor - canvasWidth) + scrollOffset;
if ( offset_y < y_low * zoom_factor - scrollOffset)
offset_y = (int)(y_low * zoom_factor) - scrollOffset;
if ( offset_x < x_left * zoom_factor - scrollOffset)
offset_x = (int)(x_left * zoom_factor) - scrollOffset;
if ( offset_y > y_high * zoom_factor - canvasHeight + 80 + scrollOffset)
offset_y = (int)(y_high * zoom_factor - canvasHeight + 80) + scrollOffset;
if ( offset_y < y_low * zoom_factor - scrollOffset)
offset_y = (int)(y_low * zoom_factor) - scrollOffset;
}
@Override
public void pageUp() {
......@@ -155,8 +155,11 @@ public class FlowCmn implements PlowCmnIfc {
int type;
switch( action) {
case MotionEvent.ACTION_UP:
type = PlowEvent.TYPE_CLICK;
case PlowCmnIfc.ACTION_CLICK:
type = PlowEvent.TYPE_CLICK;
break;
case PlowCmnIfc.ACTION_LONG_CLICK:
type = PlowEvent.TYPE_LONG_CLICK;
break;
default:
return;
......
......@@ -227,8 +227,8 @@ public class FlowCon implements FlowArrayElem {
public void draw( FlowPoint p0, String[] annotv, boolean highlight) {
// Adjust pos to javabean koordinates
FlowPoint p = new FlowPoint(cmn);
p.x = x_left / cmn.zoom_factor;
p.y = y_low / cmn.zoom_factor;
p.x = 0;
p.y = 0;
if ( temporary_ref != 0 || cc.con_type == Flow.eConType_Reference)
ref_a.draw( p, null, highlight);
else {
......
......@@ -131,7 +131,7 @@ public class FlowNode implements FlowArrayElem {
break;
case Flow.eSave_Node_n_name:
if ( token.hasMoreTokens())
n_name = token.nextToken();
n_name = token.nextToken();
else
n_name = new String();
break;
......@@ -178,7 +178,7 @@ public class FlowNode implements FlowArrayElem {
else
break;
}
buf.append(c); // TODO convert to UTF-8
buf.append(c);
c_old = c;
}
annotv[i] = new String( buf);
......
......@@ -139,4 +139,11 @@ public class GraphCmn implements PlowCmnIfc {
public void resetNodraw() {
graph.ctx.cmn.resetNodraw();
}
public int getAppMotion() {
return graph.cmn.getAppMotion();
}
public boolean getSliderActive() {
return graph.ctx.getSliderActive();
}
}
......@@ -6,6 +6,7 @@ import jpwr.pwrxtt.MainActivity;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.MotionEvent;
public class OpwinCmn implements PlowCmnIfc {
Object userData;
......@@ -17,10 +18,15 @@ public class OpwinCmn implements PlowCmnIfc {
int canvasWidth;
int offsetY = 0;
int borderY = 0;
AGraphInfo currentGraph = null;
double downX;
double downY;
float density;
public OpwinCmn( MainActivity appl, Vector<AGraphInfo> graphList) {
public OpwinCmn( MainActivity appl, Vector<AGraphInfo> graphList, float density) {
this.graphList = graphList;
this.appl = appl;
this.density = density;
}
public int type() {
return TYPE_OPWIN;
......@@ -41,10 +47,10 @@ public class OpwinCmn implements PlowCmnIfc {
if (graph.iconHeight > iconHeightMax)
iconHeightMax = graph.iconHeight;
}
int offsetX = 100;
int offsetY = 100;
int distX = iconWidthMax + 50;
int distY = iconHeightMax + 70;
int offsetX = (int)(density * 100);
int offsetY = (int)(density * 100);
int distX = iconWidthMax + (int)(density * 50);
int distY = iconHeightMax + (int)(density * 70);
int x = offsetX;
int y = offsetY;
for ( int i = 0; i < graphList.size(); i++) {
......@@ -52,7 +58,7 @@ public class OpwinCmn implements PlowCmnIfc {
graph.iconX = x;
graph.iconY = y;
graph.textX = graph.iconX + graph.iconWidth/2;
graph.textY = graph.iconY + graph.iconHeight + 15;
graph.textY = graph.iconY + graph.iconHeight + (int)(density * 15);
borderY = graph.textY + 100;
......@@ -78,7 +84,12 @@ public class OpwinCmn implements PlowCmnIfc {
for ( int i = 0; i < graphList.size(); i++) {
AGraphInfo graph = graphList.get(i);
canvas.drawBitmap(graph.bpm, graph.iconX, graph.iconY - offsetY, p);
if ( graph.inverted)
canvas.drawBitmap(graph.bpmInverted, graph.iconX, graph.iconY - offsetY, p);
else
canvas.drawBitmap(graph.bpm, graph.iconX, graph.iconY - offsetY, p);
p.setTextSize( density * 15);
int textWidth = (int) p.measureText(graph.text);
canvas.drawText(graph.text, graph.textX - textWidth/2, graph.textY - offsetY, p);
}
......@@ -100,14 +111,23 @@ public class OpwinCmn implements PlowCmnIfc {
public void pageDown() {}
public void eventHandler(int action, double fx, double fy) {
switch (action) {
case PlowEvent.TYPE_CLICK:
System.out.println("Opwin click " + fx + " " + fy);
case PlowCmnIfc.ACTION_UP:
if ( currentGraph != null) {
String cmd = "open graph " + currentGraph.graph;
if ( Math.abs(fx - downX) < 10 && Math.abs(fy - downY) < 10)
appl.command(cmd);
currentGraph.inverted = false;
currentGraph = null;
}
break;
case PlowCmnIfc.ACTION_DOWN:
for ( int i = 0; i < graphList.size(); i++) {
if ( fx > graphList.get(i).iconX && fx <= graphList.get(i).iconX + graphList.get(i).iconWidth &&
fy > graphList.get(i).iconY - offsetY && fy <= graphList.get(i).iconY + graphList.get(i).iconHeight - offsetY) {
System.out.println("Hit in icon");
String cmd = "open graph " + graphList.get(i).graph;
appl.command(cmd);
currentGraph = graphList.get(i);
currentGraph.inverted = true;
downX = fx;
downY = fy;
}
}
break;
......
......@@ -77,11 +77,16 @@ public class PlowCmn implements PlowCmnIfc {
double x = (fx + offset_x) / zoom_factor;
double y = (fy + offset_y) / zoom_factor;
int type;
boolean long_click = false;
switch( action) {
case MotionEvent.ACTION_UP:
case PlowCmnIfc.ACTION_CLICK:
type = PlowEvent.TYPE_CLICK;
break;
case PlowCmnIfc.ACTION_LONG_CLICK:
type = PlowEvent.TYPE_CLICK;
long_click = true;
break;
default:
return;
}
......@@ -92,6 +97,8 @@ public class PlowCmn implements PlowCmnIfc {
currentNode = null;
a.eventHandler(e);
if ( long_click)
e.type = PlowEvent.TYPE_LONG_CLICK;
appl.eventHandler(e);
switch (e.type) {
......
......@@ -8,6 +8,11 @@ public interface PlowCmnIfc {
public static final int TYPE_GRAPH = 3;
public static final int TYPE_EV = 4;
public static final int TYPE_OPWIN = 5;
public static final int ACTION_CLICK = 0;
public static final int ACTION_LONG_CLICK = 1;
public static final int ACTION_DOWN = 2;
public static final int ACTION_UP = 3;
public int type();
public Object getUserData();
......
......@@ -10,6 +10,7 @@ import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Rect;
import android.graphics.Typeface;
public class PlowDraw implements PlowDrawIfc {
......@@ -26,12 +27,14 @@ public class PlowDraw implements PlowDrawIfc {
Typeface[] fonts = new Typeface[6];
int canvasWidth;
int canvasHeight;
float textDensity = 1;
float lineDensity = 1;
static float[] inv = { -1f, 0f, 0f, 1f, 1f,
0f,-1f, 0f, 1f, 1f,
0f, 0f,-1f, 1f, 1f,
0f, 0f, 0f, 1f, 0f};
public PlowDraw(Activity activity) {
public PlowDraw(Activity activity) {
this.activity = activity;
paint = new Paint();
......@@ -61,7 +64,7 @@ public class PlowDraw implements PlowDrawIfc {
if ( border) {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
paint.setStrokeWidth(lineDensity < 1 ? 1 : lineDensity);
canvas.drawRect(x1, y1, x2, y2, paint);
}
else {
......@@ -78,7 +81,7 @@ public class PlowDraw implements PlowDrawIfc {
if ( border) {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
paint.setStrokeWidth(lineDensity < 1 ? 1 : lineDensity);
canvas.drawArc(new RectF(x1, y1, x2, y2), 360-angel1, -angel2, false, paint);
}
else {
......@@ -93,7 +96,7 @@ public class PlowDraw implements PlowDrawIfc {
paint.setColor(getColor(color));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1);
paint.setStrokeWidth(lineDensity < 1 ? 1 : lineDensity);
canvas.drawLine(x1, y1, x2, y2, paint);
}
......@@ -114,16 +117,33 @@ public class PlowDraw implements PlowDrawIfc {
@Override
public void drawText( String text, int textColor, int textSize, int font, float x, float y) {
paint.setTextSize(textSize);
paint.setTypeface(fonts[font]);
paint.setTextSize(textDensity * textSize);
paint.setTypeface(fonts[font]);
paint.setColor(getColor(textColor));
paint.setStyle(Paint.Style.FILL);
canvas.drawText( text, x, y, paint);
int idx;
if ( (idx = text.indexOf('\n')) != -1) {
Rect tsize = new Rect();
paint.getTextBounds("A", 0, 1, tsize);
String row = text.substring(0,idx);
String rest = text.substring(idx+1);
canvas.drawText( row, x, y, paint);
while ( (idx = rest.indexOf('\n')) != -1) {
row = rest.substring(0,idx);
rest = rest.substring(idx+1);
y += tsize.height() * 1.65;
canvas.drawText( row, x, y, paint);
}
}
else
canvas.drawText( text, x, y, paint);
}
@Override
public float measureText( String text, int textSize, int font) {
paint.setTextSize(textSize);
paint.setTextSize(textDensity * textSize);
paint.setTypeface(null);
return paint.measureText(text);
......@@ -170,4 +190,9 @@ public class PlowDraw implements PlowDrawIfc {
return Color.BLACK;
}
}
public void setDensity( float textDensity, float lineDensity) {
this.textDensity = textDensity;
this.lineDensity = lineDensity;
}
}
......@@ -13,5 +13,5 @@ public interface PlowDrawIfc {
public int getCanvasWidth();
public int getCanvasHeight();
public void setCanvas(Canvas canvas);
public void setDensity(float textDensity, float lineDensity);
}
......@@ -3,6 +3,7 @@ package jpwr.app;
public class PlowEvent {
public static final int TYPE_CLICK = 1;
public static final int TYPE_OBJECT_DELETED = 2;
public static final int TYPE_LONG_CLICK = 3;
public int type;
public double x;
......
......@@ -126,7 +126,7 @@ public class PlowNode implements PlowComponent, PlowArrayElem, PlowNodeIfc {
if ( invert == this.invert)
return;
this.invert = invert;
draw();
// draw();
}
public void configure(PlowNode previous) {
......
......@@ -69,7 +69,6 @@ public class GlowDraw implements GlowDrawIfc {
public GlowDraw() {
paint = new Paint();
}
public void setActivity(Activity activity) {
......
......@@ -38,174 +38,16 @@
package jpwr.jopg;
import jpwr.rt.*;
import java.io.*;
//import java.awt.*;
//import java.awt.font.*;
import java.net.*;
public class GrowFrame implements GraphApplIfc {
/*
JScrollPane scrollPane;
JPanel contentPane;
BorderLayout borderLayout1 = new BorderLayout();
Dimension size;
Object root;
Graph graph;
Timer timer;
LocalPanel localPanel = new LocalPanel();
int scanTime = 1000;
int scanCount = 0;
JDialog confirmDia = null;
JLabel confirmLabel;
Object confirmDyn;
Object confirmObject;
*/
String instance;
GrowFrameApplIfc appl;
public GrowFrame( String file, Gdh gdh, String instance, GrowFrameApplIfc appl) {
/*
root = (Object) this;
this.instance = instance;
this.appl = appl;
init( file, gdh);
*/
}
private void init( String file, Gdh gdh) {
/*
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
contentPane.add(localPanel, BorderLayout.CENTER);
contentPane.setOpaque(true);
localPanel.setLayout(null);
localPanel.setOpaque(true);
localPanel.setBackground( Color.white);
this.setTitle("GrowFrame");
size = new Dimension( 1100, 900);
setSize( size);
String filename;
BufferedReader reader = null;
String fname = file;
if ( root != null && root instanceof JApplet) {
try {
URL current = ((JApplet) root).getCodeBase();
String current_str = current.toString();
int idx1 = current_str.lastIndexOf('/');
int idx2 = current_str.lastIndexOf(':');
int idx = idx1;
if ( idx2 > idx)
idx = idx2;
String path = current_str.substring(0,idx + 1);
filename = path + fname;
System.out.println( "Opening file " + filename);
URL fileURL = new URL( filename);
InputStream in = fileURL.openStream();
// in = new BufferedInputStream(in);
InputStreamReader r2 = new InputStreamReader(in);
reader = new BufferedReader( r2);
}
catch ( Exception e) {
System.out.println( "Unable to open file");
}
}
else {
if ( fname.lastIndexOf('/') == -1)
filename = "$pwrp_exe/" + fname;
else
filename = fname;
filename = Gdh.translateFilename( filename);
System.out.println( "Fname: " + filename);
try {
reader = new BufferedReader(new FileReader(filename));
}
catch ( Exception e) {
System.out.println( "Unable to open file " + filename);
return;
}
// Read size info
String line;
int defaultWidth = 0;
int defaultHeight = 0;
try {
for ( int i = 0; i < 2; i++) {
line = reader.readLine();
if ( line == null || !line.startsWith("0! "))
break;
if ( line.substring(3, 15).equals("DefaultWidth"))
defaultWidth = new Integer(line.substring(16)).intValue();
else if ( line.substring(3, 16).equals("DefaultHeight"))
defaultHeight = new Integer(line.substring(17)).intValue();
}
} catch ( Exception e) {
System.out.println( "IOException GlowFrame");
}
System.out.println("GraphFrame size " + defaultWidth + " " + defaultHeight);
if ( defaultWidth != 0 && defaultHeight != 0) {
size = new Dimension( defaultWidth + 5, defaultHeight + 40);
setSize( size);
}
}
if ( gdh == null)
gdh = new Gdh(this);
graph = new Graph(this, gdh);
graph.open(reader);
setSize();
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
setDefaultCloseOperation( DISPOSE_ON_CLOSE);
MouseAdapter adapter = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Click;
graph.ctx.eventHandler( event);
}
public void mousePressed(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Down;
graph.ctx.eventHandler( event);
}
public void mouseReleased(MouseEvent e) {
System.out.println("MouseListener");
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_MB1Up;
graph.ctx.eventHandler( event);
}
public void mouseMoved(MouseEvent e) {
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_CursorMotion;
graph.ctx.eventHandler( event);
}
public void mouseDragged(MouseEvent e) {
GlowEvent event = new GlowEvent();
event.x = (e.getX() + graph.ctx.cmn.mw.offset_x) / graph.ctx.cmn.mw.zoom_factor_x;
event.y = (e.getY() + graph.ctx.cmn.mw.offset_y) / graph.ctx.cmn.mw.zoom_factor_y;
event.event = Glow.eEvent_ButtonMotion;
graph.ctx.eventHandler( event);
}
};
localPanel.addMouseListener(adapter);
localPanel.addMouseMotionListener(adapter);
timer = new Timer( scanTime, this);
timer.start();
*/
}
......@@ -218,111 +60,23 @@ public class GrowFrame implements GraphApplIfc {
return 100;
}
/*
public void actionPerformed( ActionEvent e) {
scanCount++;
if ( scanCount == 1)
graph.gdh.getObjectRefInfoAll();
graph.ctx.traceScan();
localPanel.repaint();
}
*/
void setSize() {
/*
size = new Dimension( (int)((graph.ctx.cmn.x_right - graph.ctx.cmn.x_left) * graph.ctx.cmn.mw.zoom_factor_x) + Glow.DRAWOFFSET * 2,
(int)((graph.ctx.cmn.y_high - graph.ctx.cmn.y_low) * graph.ctx.cmn.mw.zoom_factor_y) + Glow.DRAWOFFSET * 2);
localPanel.setPreferredSize( size);
localPanel.revalidate();
*/
}
/*
class LocalPanel extends JPanel {
public LocalPanel() {}
public Dimension getPreferredSize() { return size;}
public Dimension getMinimumSize() { return size;}
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setPaint(graph.ctx.cmn.gdraw.getColor(graph.ctx.cmn.background_color));
g2.fill(new Rectangle2D.Double(0,0,getWidth(),getHeight()));
graph.gdraw.setGraphics(g2);
graph.ctx.draw();
}
}
*/
public void closeGrow() {
}
public int command(String cmd) {
System.out.println("Ge command : " + cmd);
if ( appl != null)
return appl.command(cmd);
return 0;
}
public void confirmNo() {}
public void confirmYes() {
// ((Dyn)confirmDyn).confirmedAction( Glow.eEvent_MB1Click, confirmObject);
}
public void openConfirmDialog( Object dyn, String text, Object object) {
/*
JLabel label = null;
public void confirmYes() {}
public void openConfirmDialog( Object dyn, String text, Object object) {}
confirmDyn = dyn;
confirmObject = object;
if ( confirmDia == null) {
confirmDia = new JDialog();
confirmDia.setTitle("Confirm");
confirmDia.setResizable(false);
confirmDia.setDefaultCloseOperation( JDialog.DO_NOTHING_ON_CLOSE);
confirmDia.setSize( 400, 150);
confirmLabel = new JLabel( text, JLabel.CENTER);
confirmDia.getContentPane().setLayout( new BorderLayout());
confirmDia.getContentPane().add( confirmLabel, BorderLayout.CENTER);
JButton buttonYes = new JButton("Yes");
buttonYes.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ev) {
confirmYes();
confirmDia.dispose();
}
});
JButton buttonNo = new JButton("No");
buttonNo.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ev) {
confirmNo();
confirmDia.dispose();
}
});
JButton buttonCancel = new JButton("Cancel");
buttonCancel.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent ev) {
confirmNo();
confirmDia.dispose();
}
});
JPanel panel = new JPanel();
panel.add( buttonYes);
panel.add( buttonNo);
panel.add( buttonCancel);
confirmDia.getContentPane().add( panel, BorderLayout.SOUTH);
// confirmDia.setLocationRelativeTo( par);
confirmDia.setVisible( true);
}
else {
// confirmDia.setLocationRelativeTo( par);
confirmLabel.setText( text);
confirmDia.setVisible( true);
}
*/
}
public void openValueInputDialog( Object dyn, String text, Object object) {
}
public void openValueInputDialog( Object dyn, String text, Object object) {}
public String getObject() {
return instance;
}
......@@ -330,6 +84,9 @@ public class GrowFrame implements GraphApplIfc {
return null;
}
public void closeGraph() {}
public boolean isAuthorized(int access) {
return false;
}
}
......
This diff is collapsed.
......@@ -591,7 +591,7 @@ public class Dyn {
public static final int ePwrStatus_Error = 3;
public static final int ePwrStatus_Fatal = 4;
public static final boolean debug = false;
public static final boolean debug = true;
Vector<DynElem> elements = new Vector<DynElem>();
GraphIfc graph;
......@@ -3174,6 +3174,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Click:
dyn.object = object;
......@@ -6361,6 +6364,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -6447,6 +6453,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -6533,14 +6542,19 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
dyn.repaintNow = true;
dyn.graph.setClickActive(1);
break;
case Glow.eEvent_MB1Up:
object.setColorInverse( 0);
dyn.repaintNow = true;
dyn.graph.setClickActive( 0);
break;
case Glow.eEvent_MB1Click:
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) != 0)
......@@ -6613,6 +6627,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down: {
object.setColorInverse( 1);
......@@ -6632,7 +6649,7 @@ public class Dyn {
break;
}
if ( sts.evenSts())
System.out.println( "SetDig: " + pname.name);
System.out.println( "StoDig: " + pname.name);
break;
}
case Glow.eEvent_MB1Up: {
......@@ -6710,6 +6727,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -6783,6 +6803,9 @@ public class Dyn {
}
public int action( GlowArrayElem object, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -6858,6 +6881,9 @@ public class Dyn {
if ( (dyn.action_type1 & Dyn.mActionType1_Confirm) == 0)
return 1;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
break;
......@@ -6926,6 +6952,10 @@ public class Dyn {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -7119,6 +7149,10 @@ public class Dyn {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -7374,6 +7408,9 @@ public class Dyn {
}
public int action( GlowArrayElem o, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
o.setColorInverse( 1);
......@@ -7466,6 +7503,9 @@ public class Dyn {
}
public int action( GlowArrayElem o, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Down:
......@@ -7602,7 +7642,9 @@ public class Dyn {
}
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Down:
object.setColorInverse( 1);
......@@ -8223,6 +8265,9 @@ public class Dyn {
}
public int action( GlowArrayElem o, GlowEvent e) {
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
GrowNode object = (GrowNode)o;
switch ( e.event) {
case Glow.eEvent_MB1Click:
......@@ -8859,6 +8904,10 @@ public class Dyn {
public int action( GlowArrayElem o, GlowEvent e) {
GrowNode object = (GrowNode)o;
if ( !dyn.graph.isAuthorized( dyn.access))
return 1;
switch ( e.event) {
case Glow.eEvent_MB1Click:
if ( menu_object != null) {
......
......@@ -73,6 +73,7 @@ public class Glow {
public static final int eType_AnnotType = 21;
public static final int eType_DynType2 = 22;
public static final int eType_ActionType2 = 23;
public static final int eType_AppMotion = 24;
public static final int eCtxType_Glow = 0;
public static final int eCtxType_Brow = 1;
......@@ -243,6 +244,10 @@ public class Glow {
public static final int eHotIndication_DarkColor = 2;
public static final int eHotIndication_LightColor = 3;
public static final int eAppMotion_Scroll = 0;
public static final int eAppMotion_Slider = 1;
public static final int eAppMotion_Both = 2;
public static final int eDrawType_Line = 0;
public static final int eDrawType_LineRed = 1;
public static final int eDrawType_LineGray = 2;
......@@ -772,6 +777,7 @@ public class Glow {
public static final int eSave_Ctx_version = 137;
public static final int eSave_Ctx_hot_indication = 138;
public static final int eSave_Ctx_tiptext_size = 139;
public static final int eSave_Ctx_app_motion = 140;
public static final int eSave_Ctx_comment = 199;
public static final int eSave_Array_a = 200;
public static final int eSave_NodeClass_nc_name = 300;
......
......@@ -53,6 +53,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
public double scan_time = 1;
GrowCmn[] cmnStack = new GrowCmn[10];
int cmnStackCnt = 0;
int clickActive = 0;
public Graph(GraphApplIfc appl, Gdh gdh) {
this.appl = appl;
......@@ -504,7 +505,7 @@ public class Graph implements GraphIfc, GrowApplIfc {
}
public boolean isAuthorized(int access) {
return true;
return appl.isAuthorized(access);
}
public double getScanTime() {
......@@ -538,4 +539,12 @@ public class Graph implements GraphIfc, GrowApplIfc {
ctx = (GrowCtx)cmn.ctx;
}
}
public void setClickActive(int active) {
clickActive = active;
}
public int getClickActive() {
return clickActive;
}
}
......@@ -45,4 +45,5 @@ public interface GraphApplIfc {
public String getObject();
public Object loadGrowCtx( String file);
public void closeGraph();
public boolean isAuthorized(int access);
}
......@@ -63,4 +63,5 @@ public interface GraphIfc {
public boolean isAuthorized(int access);
public double getScanTime();
public String getCommand(String cmd);
public void setClickActive(int active);
}
......@@ -99,6 +99,7 @@ public class GrowCmn {
int translate_on;
int input_focus_mark;
int hot_indication;
int app_motion = Glow.eAppMotion_Both;
Object userdata;
GlowArrayElem callback_object;
int callback_object_type;
......@@ -119,7 +120,7 @@ public class GrowCmn {
public GrowCmn( GrowCtxIfc ctx, GrowApplIfc appl) {
this.ctx = ctx;
this.appl = appl;
this.debug = false;
this.debug = true;
this.antiAliasing = true;
mw.window_width = getWidth();
mw.window_height = getHeight();
......@@ -148,4 +149,7 @@ public class GrowCmn {
public String getOwner() {
return owner;
}
public int getAppMotion() {
return app_motion;
}
}
......@@ -140,6 +140,9 @@ public class GrowCtx implements GrowCtxIfc {
break;
case Glow.eSave_Ctx_tiptext_size:
break;
case Glow.eSave_Ctx_app_motion:
cmn.app_motion = Integer.valueOf(token.nextToken());
break;
case Glow.eSave_Ctx_grow:
open_grow( reader);
grow_loaded = true;
......@@ -826,6 +829,14 @@ public class GrowCtx implements GrowCtxIfc {
e.setSource( source, owner);
}
public boolean getSliderActive() {
return sliderActive;
}
public void setSliderActive( boolean active) {
sliderActive = active;
}
}
......
......@@ -66,4 +66,5 @@ public interface GrowCtxIfc {
public void traceScan();
public boolean traceStarted();
public void setSubwindowSource( String name, String source, String owner);
public void setSliderActive( boolean active);
}
......@@ -198,6 +198,7 @@ public class GrowScrollBar extends GrowRect {
start_pos = fy;
start_value = bar_value;
movement_active = 1;
cmn.ctx.setSliderActive(true);
}
break;
case Glow.eDir_Horizontal:
......@@ -206,12 +207,14 @@ public class GrowScrollBar extends GrowRect {
start_pos = fx;
start_value = bar_value;
movement_active = 1;
cmn.ctx.setSliderActive(true);
}
break;
}
break;
case Glow.eEvent_MB1Up:
movement_active = 0;
cmn.ctx.setSliderActive(false);
break;
case Glow.eEvent_ButtonMotion:
if ( movement_active != 0) {
......
......@@ -442,9 +442,13 @@ public class GrowWindow extends GrowRect implements GrowScrollBarIfc {
}
v_scrollbar.set_shadow( shadow);
}
else {
if ( windowCmn != null)
else if ( v_scrollbar != null) {
if ( windowCmn != null) {
v_scrollbar.set_range( wctx_y0 * windowCmn.mw.subwindow_scale, wctx_y1 * window_scale);
v_scrollbar.set_value( wctx_y0 * windowCmn.mw.subwindow_scale, y_high -
(y_low + y_low_offs) - scrollbar_width * horizontal_scrollbar);
v_value = wctx_y0 * windowCmn.mw.subwindow_scale;
}
}
if ( horizontal_scrollbar != 0 && h_scrollbar == null) {
......@@ -467,9 +471,13 @@ public class GrowWindow extends GrowRect implements GrowScrollBarIfc {
}
h_scrollbar.set_shadow( shadow);
}
else {
if ( windowCmn != null)
else if ( h_scrollbar != null) {
if ( windowCmn != null) {
h_scrollbar.set_range( wctx_x0 * windowCmn.mw.subwindow_scale, wctx_x1 * windowCmn.mw.subwindow_scale);
h_scrollbar.set_value( wctx_x0 * windowCmn.mw.subwindow_scale,
x_right - x_left - scrollbar_width * vertical_scrollbar);
h_value = wctx_x0 * windowCmn.mw.subwindow_scale;
}
}
}
......
......@@ -30,6 +30,7 @@ copy :
lib :
exe : $(bld_dir)/control_pwrrt $(bld_dir)/control_pwr $(bld_dir)/control_pwrdemo $(bld_dir)/control_pwrsev
rpi : $(bld_dir)/control_pwrrpi
clean :
......@@ -60,5 +61,10 @@ $(bld_dir)/control_pwrsev : ../../../pwrsev/control
@ ../../../pwrsev/build.sh
@ cp $(source) $(target)
$(bld_dir)/control_pwrrpi : ../../../pwrrpi/control
@ echo "build $(target)"
@ ../../../pwrrpi/build.sh
@ cp $(source) $(target)
......@@ -329,6 +329,15 @@ SObject pwrb:Class
Attr Flags = 0
EndBody
EndObject
!/**
! If AppUseWebDir is set all files used by the Android application is
! read from pwrp_web.
!*/
Object AppUseWebDir $Attribute 42
Body SysBody
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
EndObject
!
! Template for WebHandler
......
......@@ -862,6 +862,12 @@ static attrnav_sEnumElement elem_hot_indication[] = {
{ (int) glow_eHotIndication_LightColor, "LightColor"},
{ 0, ""}};
static attrnav_sEnumElement elem_app_motion[] = {
{ (int) glow_eAppMotion_Scroll, "Scroll"},
{ (int) glow_eAppMotion_Slider, "Slider"},
{ (int) glow_eAppMotion_Both, "Both"},
{ 0, ""}};
static attrnav_sEnumElement elem_annot_type[] = {
{ (int) glow_eAnnotType_OneLine, "OneLine"},
{ (int) glow_eAnnotType_MultiLine, "MultiLine"},
......@@ -995,6 +1001,7 @@ static attrnav_sEnum enum_types[] = {
{ (int) ge_eAttrType_CurveDataType, (attrnav_sEnumElement *) &elem_curve_datatype},
{ (int) glow_eType_Gradient, (attrnav_sEnumElement *) &elem_gradient},
{ (int) glow_eType_HotIndication, (attrnav_sEnumElement *) &elem_hot_indication},
{ (int) glow_eType_AppMotion, (attrnav_sEnumElement *) &elem_app_motion},
{ (int) glow_eType_AnnotType, (attrnav_sEnumElement *) &elem_annot_type},
{ (int) ge_eAttrType_OptionMenuType, (attrnav_sEnumElement *) &elem_optionmenu_type},
{ 0, NULL}};
......@@ -1063,6 +1070,7 @@ int attrnav_attr_string_to_value( int type_id, char *value_str,
case glow_eType_TextSize:
case glow_eType_Gradient:
case glow_eType_HotIndication:
case glow_eType_AppMotion:
case ge_eAttrType_DynType1:
case ge_eAttrType_DynType2:
case ge_eAttrType_DynTypeTone:
......@@ -1150,6 +1158,7 @@ void attrnav_attrvalue_to_string( int type_id, void *value_ptr,
case glow_eType_TextSize:
case glow_eType_Gradient:
case glow_eType_HotIndication:
case glow_eType_AppMotion:
case ge_eAttrType_AnimSequence:
case ge_eAttrType_LimitType:
case ge_eAttrType_ScaleType:
......@@ -2235,6 +2244,7 @@ ItemLocal::ItemLocal( AttrNav *attrnav, const char *item_name, const char *attr,
case glow_eType_TextSize:
case glow_eType_Gradient:
case glow_eType_HotIndication:
case glow_eType_AppMotion:
case ge_eAttrType_DynType1:
case ge_eAttrType_DynType2:
case ge_eAttrType_DynTypeTone:
......
......@@ -101,7 +101,8 @@ typedef enum {
glow_eType_HotIndication, //!< Type is glow_eHotIndication
glow_eType_AnnotType, //!< Type is glow_eAnnotType
glow_eType_DynType2, //!< Type of dynamics mask 2
glow_eType_ActionType2 //!< Type of action mask 2
glow_eType_ActionType2, //!< Type of action mask 2
glow_eType_AppMotion //!< Type is glow_eAppMotion
} glow_eType;
//! Type of Ctx class
......@@ -409,6 +410,13 @@ typedef enum {
glow_eHotIndication_LightColor //!< Lighter color for hot objects
} glow_eHotIndication;
//! Action for app motion event
typedef enum {
glow_eAppMotion_Scroll, //!< Scrolling
glow_eAppMotion_Slider, //!< Slider
glow_eAppMotion_Both //!< Both slider and scrolling
} glow_eAppMotion;
//! Color index for a color
/*! The drawtype is index in an array that contains the gc for colors in the color palette.
......@@ -1128,6 +1136,7 @@ typedef enum {
glow_eSave_Ctx_version = 137,
glow_eSave_Ctx_hot_indication = 138,
glow_eSave_Ctx_tiptext_size = 139,
glow_eSave_Ctx_app_motion = 140,
glow_eSave_Ctx_comment = 199,
glow_eSave_Array_a = 200,
glow_eSave_NodeClass_nc_name = 300,
......
......@@ -98,7 +98,8 @@ GlowCtx::GlowCtx( const char *ctx_name, double zoom_fact, int offs_x, int offs_y
default_hot_mode(glow_eHotMode_SingleObject), hot_found(0),
userdata_save_callback(0), userdata_open_callback(0), userdata_copy_callback(0),
version(GLOW_VERSION), inputfocus_object(0), is_component(0), comment(0),
hot_indication(glow_eHotIndication_LightColor), tiptext_size(2), eventlog_callback(0)
hot_indication(glow_eHotIndication_LightColor), tiptext_size(2), app_motion(glow_eAppMotion_Both),
eventlog_callback(0)
{
strcpy(name, ctx_name);
memset( (void *)event_callback, 0, sizeof(event_callback));
......@@ -214,6 +215,7 @@ int GlowCtx::save( char *filename, glow_eSaveMode mode)
fp << int(glow_eSave_Ctx_version) << FSPACE << version << endl;
fp << int(glow_eSave_Ctx_hot_indication) << FSPACE << hot_indication << endl;
fp << int(glow_eSave_Ctx_tiptext_size) << FSPACE << tiptext_size << endl;
fp << int(glow_eSave_Ctx_app_motion) << FSPACE << app_motion << endl;
if ( ctx_type == glow_eCtxType_Grow)
{
fp << int(glow_eSave_Ctx_grow) << endl;
......@@ -361,6 +363,7 @@ int GlowCtx::open( char *filename, glow_eSaveMode mode)
case glow_eSave_Ctx_version: fp >> version; break;
case glow_eSave_Ctx_hot_indication: fp >> tmp; hot_indication = (glow_eHotIndication)tmp; break;
case glow_eSave_Ctx_tiptext_size: fp >> tiptext_size; break;
case glow_eSave_Ctx_app_motion: fp >> tmp; app_motion = (glow_eAppMotion)tmp; break;
case glow_eSave_Ctx_grow:
((GrowCtx *)this)->open_grow( fp);
grow_loaded = 1;
......
......@@ -847,6 +847,7 @@ class GlowCtx {
CtxComment *comment;
glow_eHotIndication hot_indication; //!< Specification of how hots object should be drawn.
int tiptext_size; //!< Size of tooltip text
glow_eAppMotion app_motion; //!< Action for app motion event.
glow_tEventLogCb eventlog_callback; //!< Callback function to log events.
static int eventlog_enabled; //!< Event logging enabled.
......
......@@ -3261,6 +3261,11 @@ int grow_GetGraphAttrInfo( grow_tCtx ctx, grow_sAttrInfo **info,
attrinfo[i].type = glow_eType_TextSize;
attrinfo[i++].size = sizeof( ctx->tiptext_size);
strcpy( attrinfo[i].name, "AppMotion");
attrinfo[i].value_p = &ctx->app_motion;
attrinfo[i].type = glow_eType_AppMotion;
attrinfo[i++].size = sizeof( ctx->app_motion);
attrinfo[i].info_type = grow_eInfoType_End;
*attr_cnt = i;
*info = attrinfo;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment