/**
 * Creates a cairo surface, ARGB32, native ordering, premultiplied alpha.
 */
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_CairoSurface_create
(JNIEnv *env, jobject obj, jint width, jint height, jint stride,
 jintArray buf )
{
  cairo_surface_t* surface;
  jboolean isCopy;

  /* Retrieve java-created data array */
  void *data = (*env)->GetIntArrayElements (env, buf, &isCopy);
  
  /* Set sharedBuffer variable */
  jclass cls = (*env)->GetObjectClass (env, obj);
  jfieldID field = (*env)->GetFieldID (env, cls, SHARED, "Z");
  g_assert (field != 0);
  
  if (isCopy == JNI_TRUE)
    {
      (*env)->SetBooleanField (env, obj, field, JNI_FALSE);
      void* temp = g_malloc(stride * height * 4);
      memcpy(temp, data, stride * height * 4);
      (*env)->ReleaseIntArrayElements (env, buf, data, 0);
      data = temp;
    }
  else
    (*env)->SetBooleanField (env, obj, field, JNI_TRUE);

  /* Create the cairo surface and set the java pointer */  	
  surface = cairo_image_surface_create_for_data
    (data, CAIRO_FORMAT_ARGB32, width, height, stride * 4);

  setNativeObject(env, obj, surface, SURFACE);
}
Exemple #2
0
/*
 * Generic disposal.
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtComponentPeer_disposeNative
(JNIEnv *env, jobject obj)
{
  QWidget *widget = (QWidget *) getNativeObject( env, obj );
  setNativeObject(env, obj, NULL);
  mainThread->postEventToMain( new AWTDestroyEvent( widget ) );
}
void TiUITableViewRow::initializeTiObject(TiObject* parentContext) {
    if (isInitialized()) return;
    TiUIBase::initializeTiObject(parentContext);
    NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_TABLE_VIEW_ROW, this);
    setNativeObject(obj);
    obj->release();
}
Exemple #4
0
void TiResultSetObject::initializeTiObject(TiObject* parentContext) {
    if (!isInitialized()) {
        TiProxy::initializeTiObject(parentContext);
        NativeResultSetObject* obj = (NativeResultSetObject*)getNativeObjectFactory()->createNativeObject(N_TYPE_RESULTSET, this);
        setNativeObject(obj);
        obj->release();
    }
}
Exemple #5
0
/*
 * Constructs a QDialog native object.
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFileDialogPeer_init
(JNIEnv *env, jobject obj)
{
  QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
  QFileDialog *dialog = new QFileDialog(parentWidget);
  assert( dialog );
  setNativeObject( env, obj, dialog );
}
Exemple #6
0
/*
 * Dispose of the thing.
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_dispose
(JNIEnv *env, jobject obj)
{
  QMatrix *matrix = (QMatrix *)getNativeObject(env, obj);
  if( matrix )
    delete matrix;
  setNativeObject(env, obj, NULL);
}
Exemple #7
0
/*
 * Init a QLabel
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtLabelPeer_init
(JNIEnv *env, jobject obj)
{
  QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );  
  QLabel *label = new MyLabel( env, obj, parentWidget );
  assert( label );
  setNativeObject( env, obj, label );
}
void TiUIImageButton::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiUIBase::initializeTiObject(parentContext);
        NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_IMAGE_BUTTON, this);
        setNativeObject(obj);
        obj->release();
    }
}
void TiAnnotationObject::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiUIBase::initializeTiObject(parentContext);
        NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_ANNOTATION, this);
        setNativeObject(obj);
        obj->release();
    }
}
Exemple #10
0
/*
 * Creates a QMatrix
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QMatrix_init
(JNIEnv *env, jobject obj, jdouble m00, jdouble m10, jdouble m01, jdouble m11, 
 jdouble m02, jdouble m12 )
{
  QMatrix *matrix = new QMatrix( (qreal) m00, (qreal) m10, 
				 (qreal) m01, (qreal) m11, 
				 (qreal) m02, (qreal) m12 );
  assert( matrix );
  setNativeObject(env, obj, matrix);
}
void TiVideoPlayerObject::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiUIBase::initializeTiObject(parentContext);
        NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_VIDEOPLAYER, this);
        setNativeObject(obj);
        obj->release();
    }
}
void TiAudioRecorderObject::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiUIBase::initializeTiObject(parentContext);
        NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_AUDIORECORDER, this);
        setNativeObject(obj);
        obj->release();
    }
}
void TiGeolocation::initializeTiObject(TiObject* parentContext) {
    if (isInitialized()) {
        return;
    }

    TiProxy::initializeTiObject(parentContext);
    NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_GEOLOCATION, this);
    setNativeObject(obj);
    obj->release();
}
void TiAccelerometer::initializeTiObject(TiObject* parentContext) {
    if (isInitialized()) {
        return;
    }

    TiProxy::initializeTiObject(parentContext);
    NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_ACCELEROMETER, this);
    setNativeObject(obj);
    obj->release();
}
void TiUIAlertDialog::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiProxy::initializeTiObject(parentContext);
        NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_ALERTDIALOG, this);
        setNativeObject(obj);
        obj->release();
    }
}
void TiTCPSocketObject::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiIOStreamObject::initializeTiObject(parentContext);
        NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_TCPSOCKET, this);
        setNativeObject(obj);
        obj->release();
    }
}
void TiMapView::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiUIBase::initializeTiObject(parentContext);
        NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_MAPVIEW, this);
        setNativeObject(obj);
        obj->release();
    }
}
void TiUITextArea::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiUIBase::initializeTiObject(parentContext);
        NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_TEXT_AREA, this);
        setNativeObject(obj);
        obj->release();
    }
}
Exemple #19
0
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextFieldPeer_init
(JNIEnv *env, jobject obj)
{
  QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
  assert( parentWidget );
  QLineEdit *line = new QLineEdit( parentWidget );
  assert( line );
  
  setNativeObject( env, obj, line );
  connectLineEdit(line, env, obj);
}
Exemple #20
0
/*
 * Constructs tha QComboBox object
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtChoicePeer_init
(JNIEnv *env, jobject obj)
{
  QWidget *parentWidget = (QWidget *)getParentWidget(env, obj);
      
  QComboBox *box = new QComboBox( parentWidget );
  assert( box );

  setNativeObject( env, obj, box );

  connectChoice(box, env, obj); // connect the fireChoice method.
}
Exemple #21
0
/*
 * Construct a QScrollbar object
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_init
(JNIEnv *env, jobject obj)
{
  QWidget *parentWidget = (QWidget *)getParentWidget( env, obj );
  assert( parentWidget );
  //  QScrollBar *scrollbar = new QScrollBar( parentWidget );
  MyScrollBar *scrollbar = new MyScrollBar( env, obj, parentWidget );
  assert( scrollbar );
      
  setNativeObject( env, obj, scrollbar );
  connectScrollBar(scrollbar, env, obj);
}
void TiUIBase::initializeTiObject(TiObject* parentContext)
{
    if (!isInitialized())
    {
        TiProxy::initializeTiObject(parentContext);
        /* Don't create a native view object for derived classes */
        if (string("View") == getName())
        {
            NativeObject* obj = getNativeObjectFactory()->createNativeObject(N_TYPE_VIEW, this);
            setNativeObject(obj);
            obj->release();
        }
    }
}
void TiProxy::onAddEventListener(const char* eventName, Handle<Function> eventFunction)
{
    NativeObject* no = getNativeObject();
    if (no == NULL)
    {
        // To support events we need to create a native proxy
        // instance here if no native object has been set yet.
        no = new NativeProxyObject(this);
        setNativeObject(no);
    }
    Handle<Object> source = Handle<Object>::Cast(getValue());
    TiV8Event* event = TiV8Event::createEvent(eventName, eventFunction, source);
    no->setEventHandler(eventName, event);
    no->release();
    no = NULL;
    int id = event->getId();
    eventFunction->SetHiddenValue(String::New("POINTER"), External::New(event));
    eventFunction->SetHiddenValue(String::New("OWNER"), External::New(this));
    eventFunction->SetHiddenValue(String::New("ID"), Integer::New(id));
}