View topic - Urgent: 5000 Euro Reward

Urgent: 5000 Euro Reward

Read-only archive of qnx.gui (Creating graphical applications within a GUI environment, such as Photon or PhAB) at inn.qnx.com

Re: Switching keyboard layouts with ALT-SHIFT

Postby Wojtek Lerch » Fri Sep 17, 2004 2:29 pm

Karsten P. Hoffmann wrote:
Does this mean, the 'bug-feature' is going to be removed
or will it get a UI :-)

Get a UI. I can't promise you when though.
Wojtek Lerch
 

Re: Switching keyboard layouts with ALT-SHIFT

Postby oklapek » Tue Sep 21, 2004 9:43 pm

Hallo Karsten,

Information about international keyboard is readed from file
/etc/system/trap/.KEYBOARD.host_name when start inputtrap ( devi-hirun
have some option like 'filter keyboard -k kbd_file' )

If you want use more keyboard layouts after start up, modify this file
(add names of keyboard files ).

Example for 3 keyboard layouts:
en_US_101.kbd
sk_SK_102.kbd
de_DE_102.kbd

Disadvantage - phlocale utility modify this file after you change
Language, Keyboard or Timezone setting. ( You can check this file when
start computer )

My be it can help to you.

Regards
Marian.
oklapek
Active Member
 
Posts: 21
Joined: Thu May 06, 2004 11:16 am

Re: Switching keyboard layouts with ALT-SHIFT

Postby Karsten P. Hoffmann » Wed Sep 22, 2004 6:43 am

Marian Oklapek wrote:
If you want use more keyboard layouts after start up, modify this file
(add names of keyboard files ).

Example for 3 keyboard layouts:
en_US_101.kbd
sk_SK_102.kbd
de_DE_102.kbd

That's exactly the UI, we need :-)))

Disadvantage - phlocale utility modify this file after you change
Language, Keyboard or Timezone setting. ( You can check this file when
start computer )

No problems, since we don't use phlocale for our customer's machine setups.

I hope, this 'undocumented feature' will persist the ongoing change and will
be available in QNX6.3, too.

Thanks a lot!


Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

MBS GmbH
Karsten Hoffmann

--
MBS GmbH E-Mail: karsten.hoffmann@mbs-software.de
Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de Mobil: +49 / 172 / 38 12 373
Karsten P. Hoffmann
 

Re: Photon & J9 JNI

Postby Sergiy Uvarov » Wed Sep 21, 2005 8:20 am

Rodney Dowdall wrote:
Can you please post the code where you added the extra widget? You have
to make sure that the mapping in the Display class is correct. If it is
off it will cause this problem.

I added widgets as this article recommends:

http://www.eclipse.org/articles/Article ... Widget.htm

By the way I moved all native calls for printing in separate library
so that I don't need to recompile SWT native but printing also doesn't
work. At first photon call (PpCreatePC) j9 throws unhandeled exception.

This is the widget class:
package org.eclipse.swt.widgets;

import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.photon.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;

/**
* Wrapper around Photon PtTrend widget
*/
public class Trend extends Composite {
int handleTrend;
private static final int Pt_ARG_TREND_FLAGS = 0x11D2F;
private static final int Pt_ARG_TREND_GRID_COLOR = 0x11D30;
private static final int Pt_ARG_TREND_GRID_X = 0x11D29;
private static final int Pt_ARG_TREND_GRID_Y = 0x11D2A;
private static final int Pt_ARG_TREND_COUNT = 0x11D2B;
private static final int Pt_ARG_TREND_COLOR_LIST = 0x11D31;
private static final int Pt_ARG_TREND_ATTRIBUTES = 0x11D32;
private static final int Pt_ARG_TREND_DATA = 0x11D28;
private static final int Pt_ARG_TREND_MAX = 0x11D2C;
private static final int Pt_ARG_TREND_MIN = 0x11D2D;

private static final int Pt_GRID = 2;
private static final int Pt_GRID_IS_TRANSLUCENT = 0x400;
private static final int Pt_GRID_FORCE = 0x800;
private static final int Pt_RESULT_GRID = (Pt_GRID |
Pt_GRID_IS_TRANSLUCENT | Pt_GRID_FORCE);

private double min = 0,max = 100;
private short trendMin, trendMax;
private int [] handles = new int[2];

static { System.loadLibrary("jinf"); }

public Trend(Composite parent, int style) {
// create parent composite
super(parent,style);

// create native widget
// PtOSContainer -> handles[0]
// PtTrend -> handles[1]
createControl(handle,handles);
handleTrend = handles[1];
if(handleTrend==0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.PtSetResource(handleTrend,Pt_ARG_TREND_COUNT,1,0);
addControlListener(new ControlAdapter(){
public void controlResized(ControlEvent e) {
Rectangle rect = getClientArea();
resizeControl(handles[0], rect.x, rect.y, rect.width, rect.height);
}
});

addFocusListener( new FocusAdapter() {
public void focusGained(FocusEvent e) {
setFocus(handles[0]);
}
});

/* Get min/mx biunds from trend */
int [] args = new int[] {Pt_ARG_TREND_MIN,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMin = (short) args[1];

args = new int[] {Pt_ARG_TREND_MAX,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMax = (short) args[1];
}


public Point computeSize(int wHint, int hHint, boolean changed) {
checkWidget();
int [] result = new int[2];
computeSize(handles[0], result);
if (wHint != SWT.DEFAULT) result[0] = wHint;
if (hHint != SWT.DEFAULT) result[1] = hHint;
int border = getBorderWidth();
return new Point(result[0] + border*2, result[1] + border*2);
}


/** Enables the graphic widget to draw grid if argument is
<code>true</code>
* and disabes it otherwise.
* @param flag the new grid state */
public void setGrid(boolean flag) {
OS.PtSetResource(handleTrend, Pt_ARG_TREND_FLAGS, ((flag) ? -1 :
0), Pt_RESULT_GRID);
}


/**
* Set grid's lines color
*/
public void setGridColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff) << 8 |
(c.getBlue() & 0xff);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_COLOR, color, 0);
}


/**
* Set grid dimensions
*/
public void setGridSize(int x,int y){
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_X, x, 0);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_Y, y, 0);
}


/**
* Set min/max boundaries for the trend
*/
public void setMinMaxBounds(double min,double max){
this.min = min; this.max = max;
}


/**
* Set pen's color
*/
public void setPenColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff) << 8 |
(c.getBlue() & 0xff);
int [] jarray = new int[] {color};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_COLOR_LIST, ptr, 1);

jarray[0] = 1; // number of color here
OS.memset(ptr,0,4);
OS.memmove(ptr,jarray,4);

OS.PtSetResource(handleTrend,Pt_ARG_TREND_ATTRIBUTES,ptr,1);
OS.free(ptr);
}


/**
* Push data at end of trend
*/
public void pushData(double v){
if(v>max) v = max;
if(v<min) v = min;
short data = (short)(v * (trendMax-trendMin)/(max-min) + trendMin);
int [] jarray = new int[] {data};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_DATA,ptr,1);
OS.free(ptr);
}

static final native int createControl(int handleParent,int [] res);
static final native void resizeControl(int handle, int x, int y, int
width, int height);
static final native void setFocus(int handle);
static final native void computeSize(int handle, int [] result);
}

This is the native code:

#include <unistd.h>
#include <jni.h>
#include <math.h>

#include <Ph.h>
#include <Pt.h>

#define NATIVE(func) Java_org_eclipse_swt_widgets_Trend_##func

/**
* PtOSContainer -> [0]
* PtTrend -> [1]
*/
JNIEXPORT jint JNICALL NATIVE(createControl)(JNIEnv *env, jclass that,
jint parent, jintArray handles) {
jint *result = (*env)->GetIntArrayElements(env, handles, NULL);

result[0] = (jint) PtCreateWidget(PtOSContainer,(PtWidget_t*)
parent,0,NULL);
result[1] = (jint) PtCreateWidget(PtTrend,(PtWidget_t*)
result[0],0,NULL);

PtSetResource((PtWidget_t*) result[1], Pt_ARG_ANCHOR_FLAGS, Pt_TRUE,
Pt_LEFT_ANCHORED_LEFT |
Pt_RIGHT_ANCHORED_RIGHT | Pt_TOP_ANCHORED_TOP |
Pt_BOTTOM_ANCHORED_BOTTOM );
(*env)->ReleaseIntArrayElements(env, handles, result, 0);
return result[0];
}


JNIEXPORT void JNICALL NATIVE(resizeControl)(JNIEnv* env,jclass
that,jint handle,jint x,jint y,jint width,jint height){
PhArea_t area;
area.pos.x = x;
area.pos.y = y;
area.size.w = width;
area.size.h = height;
PtSetResource((PtWidget_t*)handle,Pt_ARG_AREA,&area,0);
PtUnrealizeWidget((PtWidget_t*)handle);
PtRealizeWidget((PtWidget_t*)handle);
}

JNIEXPORT void JNICALL NATIVE(setFocus)(JNIEnv *env, jclass that, jint
handle){}


JNIEXPORT void JNICALL NATIVE(computeSize)(JNIEnv *env, jclass that,
jint handle, jintArray result){
jint *result1 = (*env)->GetIntArrayElements(env,result,NULL);
PhDim_t dim;

PtWidgetPreferredSize((PtWidget_t*) handle,&dim);
result1[0] = dim.w;
result1[1] = dim.h;
(*env)->ReleaseIntArrayElements(env,result,result1,0);
}

Sergiy Uvarov wrote:

Hi, All.

I use SWT to build gui applications and added some extra widgets to
SWT as eclipse recommending. In QNX6.2.1 all my applications work well
but in QNX6.3 during any photon call in JNI j9 is stopped by
unhandeled exception.

What have changed that I can't create widget in JNI?

--
Sergiy Uvarov
Sergiy Uvarov
 

Re: Photon & J9 JNI

Postby Sergiy Uvarov » Wed Sep 21, 2005 10:20 am

Rodney Dowdall wrote:
Can you please post the code where you added the extra widget? You have
to make sure that the mapping in the Display class is correct. If it is
off it will cause this problem.

I added widgets as this article recommends:

http://www.eclipse.org/articles/Article ... Widget.htm

By the way I moved all native calls for printing in separate library
so that I don't need to recompile SWT native but printing also doesn't
work. At first photon call (PpCreatePC) j9 throws unhandeled exception.

This is the widget class:
package org.eclipse.swt.widgets;

import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.photon.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;

/**
* Wrapper around Photon PtTrend widget
*/
public class Trend extends Composite {
int handleTrend;
private static final int Pt_ARG_TREND_FLAGS = 0x11D2F;
private static final int Pt_ARG_TREND_GRID_COLOR = 0x11D30;
private static final int Pt_ARG_TREND_GRID_X = 0x11D29;
private static final int Pt_ARG_TREND_GRID_Y = 0x11D2A;
private static final int Pt_ARG_TREND_COUNT = 0x11D2B;
private static final int Pt_ARG_TREND_COLOR_LIST = 0x11D31;
private static final int Pt_ARG_TREND_ATTRIBUTES = 0x11D32;
private static final int Pt_ARG_TREND_DATA = 0x11D28;
private static final int Pt_ARG_TREND_MAX = 0x11D2C;
private static final int Pt_ARG_TREND_MIN = 0x11D2D;

private static final int Pt_GRID = 2;
private static final int Pt_GRID_IS_TRANSLUCENT = 0x400;
private static final int Pt_GRID_FORCE = 0x800;
private static final int Pt_RESULT_GRID = (Pt_GRID |
Pt_GRID_IS_TRANSLUCENT | Pt_GRID_FORCE);

private double min = 0,max = 100;
private short trendMin, trendMax;
private int [] handles = new int[2];

static { System.loadLibrary("jinf"); }

public Trend(Composite parent, int style) {
// create parent composite
super(parent,style);

// create native widget
// PtOSContainer -> handles[0]
// PtTrend -> handles[1]
createControl(handle,handles);
handleTrend = handles[1];
if(handleTrend==0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.PtSetResource(handleTrend,Pt_ARG_TREND_COUNT,1,0);
addControlListener(new ControlAdapter(){
public void controlResized(ControlEvent e) {
Rectangle rect = getClientArea();
resizeControl(handles[0], rect.x, rect.y, rect.width, rect.height);
}
});

addFocusListener( new FocusAdapter() {
public void focusGained(FocusEvent e) {
setFocus(handles[0]);
}
});

/* Get min/mx biunds from trend */
int [] args = new int[] {Pt_ARG_TREND_MIN,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMin = (short) args[1];

args = new int[] {Pt_ARG_TREND_MAX,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMax = (short) args[1];
}


public Point computeSize(int wHint, int hHint, boolean changed) {
checkWidget();
int [] result = new int[2];
computeSize(handles[0], result);
if (wHint != SWT.DEFAULT) result[0] = wHint;
if (hHint != SWT.DEFAULT) result[1] = hHint;
int border = getBorderWidth();
return new Point(result[0] + border*2, result[1] + border*2);
}


/** Enables the graphic widget to draw grid if argument is
<code>true</code>
* and disabes it otherwise.
* @param flag the new grid state */
public void setGrid(boolean flag) {
OS.PtSetResource(handleTrend, Pt_ARG_TREND_FLAGS, ((flag) ? -1 :
0), Pt_RESULT_GRID);
}


/**
* Set grid's lines color
*/
public void setGridColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff) << 8 |
(c.getBlue() & 0xff);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_COLOR, color, 0);
}


/**
* Set grid dimensions
*/
public void setGridSize(int x,int y){
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_X, x, 0);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_Y, y, 0);
}


/**
* Set min/max boundaries for the trend
*/
public void setMinMaxBounds(double min,double max){
this.min = min; this.max = max;
}


/**
* Set pen's color
*/
public void setPenColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff) << 8 |
(c.getBlue() & 0xff);
int [] jarray = new int[] {color};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_COLOR_LIST, ptr, 1);

jarray[0] = 1; // number of color here
OS.memset(ptr,0,4);
OS.memmove(ptr,jarray,4);

OS.PtSetResource(handleTrend,Pt_ARG_TREND_ATTRIBUTES,ptr,1);
OS.free(ptr);
}


/**
* Push data at end of trend
*/
public void pushData(double v){
if(v>max) v = max;
if(v<min) v = min;
short data = (short)(v * (trendMax-trendMin)/(max-min) + trendMin);
int [] jarray = new int[] {data};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_DATA,ptr,1);
OS.free(ptr);
}

static final native int createControl(int handleParent,int [] res);
static final native void resizeControl(int handle, int x, int y, int
width, int height);
static final native void setFocus(int handle);
static final native void computeSize(int handle, int [] result);
}

This is the native code:

#include <unistd.h>
#include <jni.h>
#include <math.h>

#include <Ph.h>
#include <Pt.h>

#define NATIVE(func) Java_org_eclipse_swt_widgets_Trend_##func

/**
* PtOSContainer -> [0]
* PtTrend -> [1]
*/
JNIEXPORT jint JNICALL NATIVE(createControl)(JNIEnv *env, jclass that,
jint parent, jintArray handles) {
jint *result = (*env)->GetIntArrayElements(env, handles, NULL);

result[0] = (jint) PtCreateWidget(PtOSContainer,(PtWidget_t*)
parent,0,NULL);
result[1] = (jint) PtCreateWidget(PtTrend,(PtWidget_t*)
result[0],0,NULL);

PtSetResource((PtWidget_t*) result[1], Pt_ARG_ANCHOR_FLAGS, Pt_TRUE,
Pt_LEFT_ANCHORED_LEFT |
Pt_RIGHT_ANCHORED_RIGHT | Pt_TOP_ANCHORED_TOP |
Pt_BOTTOM_ANCHORED_BOTTOM );
(*env)->ReleaseIntArrayElements(env, handles, result, 0);
return result[0];
}


JNIEXPORT void JNICALL NATIVE(resizeControl)(JNIEnv* env,jclass
that,jint handle,jint x,jint y,jint width,jint height){
PhArea_t area;
area.pos.x = x;
area.pos.y = y;
area.size.w = width;
area.size.h = height;
PtSetResource((PtWidget_t*)handle,Pt_ARG_AREA,&area,0);
PtUnrealizeWidget((PtWidget_t*)handle);
PtRealizeWidget((PtWidget_t*)handle);
}

JNIEXPORT void JNICALL NATIVE(setFocus)(JNIEnv *env, jclass that, jint
handle){}


JNIEXPORT void JNICALL NATIVE(computeSize)(JNIEnv *env, jclass that,
jint handle, jintArray result){
jint *result1 = (*env)->GetIntArrayElements(env,result,NULL);
PhDim_t dim;

PtWidgetPreferredSize((PtWidget_t*) handle,&dim);
result1[0] = dim.w;
result1[1] = dim.h;
(*env)->ReleaseIntArrayElements(env,result,result1,0);
}

Sergiy Uvarov wrote:

Hi, All.

I use SWT to build gui applications and added some extra widgets to
SWT as eclipse recommending. In QNX6.2.1 all my applications work well
but in QNX6.3 during any photon call in JNI j9 is stopped by
unhandeled exception.

What have changed that I can't create widget in JNI?

--
Sergiy Uvarov
Sergiy Uvarov
 

Re: Photon & J9 JNI

Postby Rodney Dowdall » Wed Sep 21, 2005 11:58 am

Where does the below code fail? What does the JNI create controls do?

Thanks,
Rodney



Sergiy Uvarov wrote:
Rodney Dowdall wrote:

Can you please post the code where you added the extra widget? You
have to make sure that the mapping in the Display class is correct.
If it is off it will cause this problem.

I added widgets as this article recommends:
http://www.eclipse.org/articles/Article ... Widget.htm


By the way I moved all native calls for printing in separate library
so that I don't need to recompile SWT native but printing also doesn't
work. At first photon call (PpCreatePC) j9 throws unhandeled exception.

This is the widget class:
package org.eclipse.swt.widgets;

import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.photon.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;

/**
* Wrapper around Photon PtTrend widget
*/
public class Trend extends Composite {
int handleTrend;
private static final int Pt_ARG_TREND_FLAGS = 0x11D2F;
private static final int Pt_ARG_TREND_GRID_COLOR = 0x11D30;
private static final int Pt_ARG_TREND_GRID_X = 0x11D29;
private static final int Pt_ARG_TREND_GRID_Y = 0x11D2A;
private static final int Pt_ARG_TREND_COUNT = 0x11D2B;
private static final int Pt_ARG_TREND_COLOR_LIST = 0x11D31;
private static final int Pt_ARG_TREND_ATTRIBUTES = 0x11D32;
private static final int Pt_ARG_TREND_DATA = 0x11D28;
private static final int Pt_ARG_TREND_MAX = 0x11D2C;
private static final int Pt_ARG_TREND_MIN = 0x11D2D;

private static final int Pt_GRID = 2;
private static final int Pt_GRID_IS_TRANSLUCENT = 0x400;
private static final int Pt_GRID_FORCE = 0x800;
private static final int Pt_RESULT_GRID = (Pt_GRID |
Pt_GRID_IS_TRANSLUCENT | Pt_GRID_FORCE);

private double min = 0,max = 100;
private short trendMin, trendMax;
private int [] handles = new int[2];

static { System.loadLibrary("jinf"); }

public Trend(Composite parent, int style) {
// create parent composite
super(parent,style);

// create native widget
// PtOSContainer -> handles[0]
// PtTrend -> handles[1]
createControl(handle,handles);
handleTrend = handles[1];
if(handleTrend==0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.PtSetResource(handleTrend,Pt_ARG_TREND_COUNT,1,0);
addControlListener(new ControlAdapter(){
public void controlResized(ControlEvent e) {
Rectangle rect = getClientArea();
resizeControl(handles[0], rect.x, rect.y, rect.width,
rect.height);
}
});

addFocusListener( new FocusAdapter() {
public void focusGained(FocusEvent e) {
setFocus(handles[0]);
}
});

/* Get min/mx biunds from trend */
int [] args = new int[] {Pt_ARG_TREND_MIN,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMin = (short) args[1];

args = new int[] {Pt_ARG_TREND_MAX,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMax = (short) args[1];
}


public Point computeSize(int wHint, int hHint, boolean changed) {
checkWidget();
int [] result = new int[2];
computeSize(handles[0], result);
if (wHint != SWT.DEFAULT) result[0] = wHint;
if (hHint != SWT.DEFAULT) result[1] = hHint;
int border = getBorderWidth();
return new Point(result[0] + border*2, result[1] + border*2);
}


/** Enables the graphic widget to draw grid if argument is
code>true</code
* and disabes it otherwise.
* @param flag the new grid state */
public void setGrid(boolean flag) {
OS.PtSetResource(handleTrend, Pt_ARG_TREND_FLAGS, ((flag) ? -1 :
0), Pt_RESULT_GRID);
}


/**
* Set grid's lines color
*/
public void setGridColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff) << 8 |
(c.getBlue() & 0xff);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_COLOR, color, 0);
}


/**
* Set grid dimensions
*/
public void setGridSize(int x,int y){
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_X, x, 0);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_Y, y, 0);
}


/**
* Set min/max boundaries for the trend
*/
public void setMinMaxBounds(double min,double max){
this.min = min; this.max = max;
}


/**
* Set pen's color
*/
public void setPenColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff) << 8 |
(c.getBlue() & 0xff);
int [] jarray = new int[] {color};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_COLOR_LIST, ptr, 1);

jarray[0] = 1; // number of color here
OS.memset(ptr,0,4);
OS.memmove(ptr,jarray,4);

OS.PtSetResource(handleTrend,Pt_ARG_TREND_ATTRIBUTES,ptr,1);
OS.free(ptr);
}


/**
* Push data at end of trend
*/
public void pushData(double v){
if(v>max) v = max;
if(v<min) v = min;
short data = (short)(v * (trendMax-trendMin)/(max-min) + trendMin);
int [] jarray = new int[] {data};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_DATA,ptr,1);
OS.free(ptr);
}

static final native int createControl(int handleParent,int [] res);
static final native void resizeControl(int handle, int x, int y, int
width, int height);
static final native void setFocus(int handle);
static final native void computeSize(int handle, int [] result);
}

This is the native code:

#include <unistd.h
#include <jni.h
#include <math.h

#include <Ph.h
#include <Pt.h

#define NATIVE(func) Java_org_eclipse_swt_widgets_Trend_##func

/**
* PtOSContainer -> [0]
* PtTrend -> [1]
*/
JNIEXPORT jint JNICALL NATIVE(createControl)(JNIEnv *env, jclass that,
jint parent, jintArray handles) {
jint *result = (*env)->GetIntArrayElements(env, handles, NULL);

result[0] = (jint) PtCreateWidget(PtOSContainer,(PtWidget_t*)
parent,0,NULL);
result[1] = (jint) PtCreateWidget(PtTrend,(PtWidget_t*)
result[0],0,NULL);

PtSetResource((PtWidget_t*) result[1], Pt_ARG_ANCHOR_FLAGS, Pt_TRUE,
Pt_LEFT_ANCHORED_LEFT |
Pt_RIGHT_ANCHORED_RIGHT | Pt_TOP_ANCHORED_TOP |
Pt_BOTTOM_ANCHORED_BOTTOM );
(*env)->ReleaseIntArrayElements(env, handles, result, 0);
return result[0];
}


JNIEXPORT void JNICALL NATIVE(resizeControl)(JNIEnv* env,jclass
that,jint handle,jint x,jint y,jint width,jint height){
PhArea_t area;
area.pos.x = x;
area.pos.y = y;
area.size.w = width;
area.size.h = height;
PtSetResource((PtWidget_t*)handle,Pt_ARG_AREA,&area,0);
PtUnrealizeWidget((PtWidget_t*)handle);
PtRealizeWidget((PtWidget_t*)handle);
}

JNIEXPORT void JNICALL NATIVE(setFocus)(JNIEnv *env, jclass that, jint
handle){}


JNIEXPORT void JNICALL NATIVE(computeSize)(JNIEnv *env, jclass that,
jint handle, jintArray result){
jint *result1 = (*env)->GetIntArrayElements(env,result,NULL);
PhDim_t dim;

PtWidgetPreferredSize((PtWidget_t*) handle,&dim);
result1[0] = dim.w;
result1[1] = dim.h;
(*env)->ReleaseIntArrayElements(env,result,result1,0);
}


Sergiy Uvarov wrote:

Hi, All.

I use SWT to build gui applications and added some extra widgets to
SWT as eclipse recommending. In QNX6.2.1 all my applications work well
but in QNX6.3 during any photon call in JNI j9 is stopped by
unhandeled exception.

What have changed that I can't create widget in JNI?

--
Sergiy Uvarov
Rodney Dowdall
 

Re: Photon & J9 JNI

Postby Rodney Dowdall » Wed Sep 21, 2005 2:02 pm

Sorry, I missed the JNI.

Can you check the value of handle in your constructor and make sure it
is not 0 before you pass it to your create control function. If it is
zero, then you need to have a createHandle function in your class. This
is where you could call jni create control. If it is greater than 0,
and you are actually picking up the Composites handle, then try removing
the return from your createControls. After you call releaseElements, I
don't think you can access the array anymore.

Thanks,
Rodney


Sergiy Uvarov wrote:
Rodney Dowdall wrote:

Sergiy Uvarov wrote:

Rodney Dowdall wrote:

Where does the below code fail?



The problem occurs in native function createControl() when widget is
created

What does the JNI create controls do?



What do you mean?



Can I see the code for the call?

I had added below the java and native code. Is it not enough?


This is the widget class:
package org.eclipse.swt.widgets;

import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.photon.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;

/**
* Wrapper around Photon PtTrend widget
*/
public class Trend extends Composite {
int handleTrend;
private static final int Pt_ARG_TREND_FLAGS = 0x11D2F;
private static final int Pt_ARG_TREND_GRID_COLOR = 0x11D30;
private static final int Pt_ARG_TREND_GRID_X = 0x11D29;
private static final int Pt_ARG_TREND_GRID_Y = 0x11D2A;
private static final int Pt_ARG_TREND_COUNT = 0x11D2B;
private static final int Pt_ARG_TREND_COLOR_LIST = 0x11D31;
private static final int Pt_ARG_TREND_ATTRIBUTES = 0x11D32;
private static final int Pt_ARG_TREND_DATA = 0x11D28;
private static final int Pt_ARG_TREND_MAX = 0x11D2C;
private static final int Pt_ARG_TREND_MIN = 0x11D2D;

private static final int Pt_GRID = 2;
private static final int Pt_GRID_IS_TRANSLUCENT = 0x400;
private static final int Pt_GRID_FORCE = 0x800;
private static final int Pt_RESULT_GRID = (Pt_GRID |
Pt_GRID_IS_TRANSLUCENT | Pt_GRID_FORCE);

private double min = 0,max = 100;
private short trendMin, trendMax;
private int [] handles = new int[2];

static { System.loadLibrary("jinf"); }

public Trend(Composite parent, int style) {
// create parent composite
super(parent,style);
// create native widget
// PtOSContainer -> handles[0]
// PtTrend -> handles[1]
createControl(handle,handles);
handleTrend = handles[1];
if(handleTrend==0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.PtSetResource(handleTrend,Pt_ARG_TREND_COUNT,1,0);
addControlListener(new ControlAdapter(){
public void controlResized(ControlEvent e) {
Rectangle rect = getClientArea();
resizeControl(handles[0], rect.x, rect.y, rect.width,
rect.height);
}
});
addFocusListener( new FocusAdapter() {
public void focusGained(FocusEvent e) {
setFocus(handles[0]);
}
});

/* Get min/mx biunds from trend */
int [] args = new int[] {Pt_ARG_TREND_MIN,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMin = (short) args[1];
args = new int[] {Pt_ARG_TREND_MAX,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMax = (short) args[1];
}


public Point computeSize(int wHint, int hHint, boolean changed) {
checkWidget();
int [] result = new int[2];
computeSize(handles[0], result);
if (wHint != SWT.DEFAULT) result[0] = wHint;
if (hHint != SWT.DEFAULT) result[1] = hHint;
int border = getBorderWidth();
return new Point(result[0] + border*2, result[1] + border*2);
}


/** Enables the graphic widget to draw grid if argument is
code>true</code
* and disabes it otherwise.
* @param flag the new grid state */
public void setGrid(boolean flag) {
OS.PtSetResource(handleTrend, Pt_ARG_TREND_FLAGS, ((flag) ? -1
: 0), Pt_RESULT_GRID); }


/**
* Set grid's lines color
*/
public void setGridColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff)
8 | (c.getBlue() & 0xff);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_COLOR, color,
0); }


/**
* Set grid dimensions
*/
public void setGridSize(int x,int y){
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_X, x,
0); OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_Y, y,
0); }


/**
* Set min/max boundaries for the trend
*/
public void setMinMaxBounds(double min,double max){
this.min = min; this.max = max;
}


/**
* Set pen's color
*/
public void setPenColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff)
8 | (c.getBlue() & 0xff);
int [] jarray = new int[] {color};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_COLOR_LIST, ptr, 1);

jarray[0] = 1; // number of color here
OS.memset(ptr,0,4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend,Pt_ARG_TREND_ATTRIBUTES,ptr,1);
OS.free(ptr);
}


/**
* Push data at end of trend
*/
public void pushData(double v){
if(v>max) v = max;
if(v<min) v = min;
short data = (short)(v * (trendMax-trendMin)/(max-min) +
trendMin);
int [] jarray = new int[] {data};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_DATA,ptr,1);
OS.free(ptr);
}

static final native int createControl(int handleParent,int [] res);
static final native void resizeControl(int handle, int x, int y,
int width, int height);
static final native void setFocus(int handle);
static final native void computeSize(int handle, int [] result);
}

This is the native code:

#include <unistd.h
#include <jni.h
#include <math.h

#include <Ph.h
#include <Pt.h

#define NATIVE(func) Java_org_eclipse_swt_widgets_Trend_##func

/**
* PtOSContainer -> [0]
* PtTrend -> [1]
*/
JNIEXPORT jint JNICALL NATIVE(createControl)(JNIEnv *env, jclass
that, jint parent, jintArray handles) {
jint *result = (*env)->GetIntArrayElements(env, handles, NULL);

result[0] = (jint) PtCreateWidget(PtOSContainer,(PtWidget_t*)
parent,0,NULL);
result[1] = (jint) PtCreateWidget(PtTrend,(PtWidget_t*)
result[0],0,NULL);

PtSetResource((PtWidget_t*) result[1], Pt_ARG_ANCHOR_FLAGS,
Pt_TRUE, Pt_LEFT_ANCHORED_LEFT |
Pt_RIGHT_ANCHORED_RIGHT | Pt_TOP_ANCHORED_TOP |
Pt_BOTTOM_ANCHORED_BOTTOM );
(*env)->ReleaseIntArrayElements(env, handles, result, 0);
return result[0];
}


JNIEXPORT void JNICALL NATIVE(resizeControl)(JNIEnv* env,jclass
that,jint handle,jint x,jint y,jint width,jint height){
PhArea_t area;
area.pos.x = x;
area.pos.y = y;
area.size.w = width;
area.size.h = height;
PtSetResource((PtWidget_t*)handle,Pt_ARG_AREA,&area,0);
PtUnrealizeWidget((PtWidget_t*)handle);
PtRealizeWidget((PtWidget_t*)handle);
}

JNIEXPORT void JNICALL NATIVE(setFocus)(JNIEnv *env, jclass that,
jint handle){}


JNIEXPORT void JNICALL NATIVE(computeSize)(JNIEnv *env, jclass
that, jint handle, jintArray result){
jint *result1 = (*env)->GetIntArrayElements(env,result,NULL);
PhDim_t dim;

PtWidgetPreferredSize((PtWidget_t*) handle,&dim);
result1[0] = dim.w;
result1[1] = dim.h;
(*env)->ReleaseIntArrayElements(env,result,result1,0);
}

Rodney Dowdall
 

Re: Photon & J9 JNI

Postby Sergiy Uvarov » Wed Sep 21, 2005 2:20 pm

Rodney Dowdall wrote:
Where does the below code fail?

The problem occurs in native function createControl() when widget is created


What does the JNI create controls do?
What do you mean?


Sergiy Uvarov wrote:

Rodney Dowdall wrote:

Can you please post the code where you added the extra widget? You
have to make sure that the mapping in the Display class is correct.
If it is off it will cause this problem.

I added widgets as this article recommends:
http://www.eclipse.org/articles/Article ... Widget.htm


By the way I moved all native calls for printing in separate library
so that I don't need to recompile SWT native but printing also doesn't
work. At first photon call (PpCreatePC) j9 throws unhandeled exception.

This is the widget class:
package org.eclipse.swt.widgets;

import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.photon.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;

/**
* Wrapper around Photon PtTrend widget
*/
public class Trend extends Composite {
int handleTrend;
private static final int Pt_ARG_TREND_FLAGS = 0x11D2F;
private static final int Pt_ARG_TREND_GRID_COLOR = 0x11D30;
private static final int Pt_ARG_TREND_GRID_X = 0x11D29;
private static final int Pt_ARG_TREND_GRID_Y = 0x11D2A;
private static final int Pt_ARG_TREND_COUNT = 0x11D2B;
private static final int Pt_ARG_TREND_COLOR_LIST = 0x11D31;
private static final int Pt_ARG_TREND_ATTRIBUTES = 0x11D32;
private static final int Pt_ARG_TREND_DATA = 0x11D28;
private static final int Pt_ARG_TREND_MAX = 0x11D2C;
private static final int Pt_ARG_TREND_MIN = 0x11D2D;

private static final int Pt_GRID = 2;
private static final int Pt_GRID_IS_TRANSLUCENT = 0x400;
private static final int Pt_GRID_FORCE = 0x800;
private static final int Pt_RESULT_GRID = (Pt_GRID |
Pt_GRID_IS_TRANSLUCENT | Pt_GRID_FORCE);

private double min = 0,max = 100;
private short trendMin, trendMax;
private int [] handles = new int[2];

static { System.loadLibrary("jinf"); }

public Trend(Composite parent, int style) {
// create parent composite
super(parent,style);
// create native widget
// PtOSContainer -> handles[0]
// PtTrend -> handles[1]
createControl(handle,handles);
handleTrend = handles[1];
if(handleTrend==0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.PtSetResource(handleTrend,Pt_ARG_TREND_COUNT,1,0);
addControlListener(new ControlAdapter(){
public void controlResized(ControlEvent e) {
Rectangle rect = getClientArea();
resizeControl(handles[0], rect.x, rect.y, rect.width,
rect.height);
}
});
addFocusListener( new FocusAdapter() {
public void focusGained(FocusEvent e) {
setFocus(handles[0]);
}
});

/* Get min/mx biunds from trend */
int [] args = new int[] {Pt_ARG_TREND_MIN,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMin = (short) args[1];
args = new int[] {Pt_ARG_TREND_MAX,0,0};
OS.PtGetResources(handleTrend,args.length / 3,args);
trendMax = (short) args[1];
}


public Point computeSize(int wHint, int hHint, boolean changed) {
checkWidget();
int [] result = new int[2];
computeSize(handles[0], result);
if (wHint != SWT.DEFAULT) result[0] = wHint;
if (hHint != SWT.DEFAULT) result[1] = hHint;
int border = getBorderWidth();
return new Point(result[0] + border*2, result[1] + border*2);
}


/** Enables the graphic widget to draw grid if argument is
code>true</code
* and disabes it otherwise.
* @param flag the new grid state */
public void setGrid(boolean flag) {
OS.PtSetResource(handleTrend, Pt_ARG_TREND_FLAGS, ((flag) ? -1 :
0), Pt_RESULT_GRID); }


/**
* Set grid's lines color
*/
public void setGridColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff) << 8
| (c.getBlue() & 0xff);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_COLOR, color,
0); }


/**
* Set grid dimensions
*/
public void setGridSize(int x,int y){
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_X, x, 0);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_GRID_Y, y, 0); }


/**
* Set min/max boundaries for the trend
*/
public void setMinMaxBounds(double min,double max){
this.min = min; this.max = max;
}


/**
* Set pen's color
*/
public void setPenColor(Color c){
int color = (c.getRed() & 0xff) << 16 | (c.getGreen() & 0xff) << 8
| (c.getBlue() & 0xff);
int [] jarray = new int[] {color};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_COLOR_LIST, ptr, 1);

jarray[0] = 1; // number of color here
OS.memset(ptr,0,4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend,Pt_ARG_TREND_ATTRIBUTES,ptr,1);
OS.free(ptr);
}


/**
* Push data at end of trend
*/
public void pushData(double v){
if(v>max) v = max;
if(v<min) v = min;
short data = (short)(v * (trendMax-trendMin)/(max-min) + trendMin);
int [] jarray = new int[] {data};
int ptr = OS.malloc(4);
OS.memmove(ptr,jarray,4);
OS.PtSetResource(handleTrend, Pt_ARG_TREND_DATA,ptr,1);
OS.free(ptr);
}

static final native int createControl(int handleParent,int [] res);
static final native void resizeControl(int handle, int x, int y, int
width, int height);
static final native void setFocus(int handle);
static final native void computeSize(int handle, int [] result);
}

This is the native code:

#include <unistd.h
#include <jni.h
#include <math.h

#include <Ph.h
#include <Pt.h

#define NATIVE(func) Java_org_eclipse_swt_widgets_Trend_##func

/**
* PtOSContainer -> [0]
* PtTrend -> [1]
*/
JNIEXPORT jint JNICALL NATIVE(createControl)(JNIEnv *env, jclass that,
jint parent, jintArray handles) {
jint *result = (*env)->GetIntArrayElements(env, handles, NULL);

result[0] = (jint) PtCreateWidget(PtOSContainer,(PtWidget_t*)
parent,0,NULL);
result[1] = (jint) PtCreateWidget(PtTrend,(PtWidget_t*)
result[0],0,NULL);

PtSetResource((PtWidget_t*) result[1], Pt_ARG_ANCHOR_FLAGS, Pt_TRUE,
Pt_LEFT_ANCHORED_LEFT |
Pt_RIGHT_ANCHORED_RIGHT | Pt_TOP_ANCHORED_TOP |
Pt_BOTTOM_ANCHORED_BOTTOM );
(*env)->ReleaseIntArrayElements(env, handles, result, 0);
return result[0];
}


JNIEXPORT void JNICALL NATIVE(resizeControl)(JNIEnv* env,jclass
that,jint handle,jint x,jint y,jint width,jint height){
PhArea_t area;
area.pos.x = x;
area.pos.y = y;
area.size.w = width;
area.size.h = height;
PtSetResource((PtWidget_t*)handle,Pt_ARG_AREA,&area,0);
PtUnrealizeWidget((PtWidget_t*)handle);
PtRealizeWidget((PtWidget_t*)handle);
}

JNIEXPORT void JNICALL NATIVE(setFocus)(JNIEnv *env, jclass that, jint
handle){}


JNIEXPORT void JNICALL NATIVE(computeSize)(JNIEnv *env, jclass that,
jint handle, jintArray result){
jint *result1 = (*env)->GetIntArrayElements(env,result,NULL);
PhDim_t dim;

PtWidgetPreferredSize((PtWidget_t*) handle,&dim);
result1[0] = dim.w;
result1[1] = dim.h;
(*env)->ReleaseIntArrayElements(env,result,result1,0);
}


Sergiy Uvarov wrote:

Hi, All.

I use SWT to build gui applications and added some extra widgets to
SWT as eclipse recommending. In QNX6.2.1 all my applications work well
but in QNX6.3 during any photon call in JNI j9 is stopped by
unhandeled exception.

What have changed that I can't create widget in JNI?

--
Sergiy Uvarov
Sergiy Uvarov
 

disable the login

Postby Shashank » Mon Apr 10, 2006 6:12 pm

How can I disable the photon login prompt on QNX 6.3

Thanks,
Shashank
Shashank
 

disable the login

Postby Shashank » Mon Apr 10, 2006 6:12 pm

How can I disable the photon login prompt on QNX 6.3

Thanks,
Shashank
Shashank
 

disable the login

Postby Shashank » Mon Apr 10, 2006 6:12 pm

How can I disable the photon login prompt on QNX 6.3

Thanks,
Shashank
Shashank
 

disable the login

Postby Shashank » Mon Apr 10, 2006 6:12 pm

How can I disable the photon login prompt on QNX 6.3

Thanks,
Shashank
Shashank
 

Re: disable the login

Postby mfeil » Wed Apr 12, 2006 2:02 pm

If you don't want photon to start, you just have to create a file called
"/etc/system/config/nophoton". Then you can do a console login and start
photon later.

In an emergency, you can do a one-time disable of photon startup at boot
time by using one of the safe modes: press space bar to select boot options,
then F1 then F3.

--
Max Feil
QNX Software Systems
Stay up-to-date on all the QNX news! Register here to receive our
newsletter:
http://www.qnx.com/news/forms/newsletter.html

"Shashank" <sbalijepalli@precitech.com> wrote in message
news:e1e90o$e4d$7@inn.qnx.com...
How can I disable the photon login prompt on QNX 6.3

Thanks,
Shashank



mfeil
Active Member
 
Posts: 36
Joined: Thu Oct 28, 2004 6:44 pm

Previous

Return to qnx.gui

Who is online

Users browsing this forum: No registered users and 1 guest

cron