예제 #1
0
int lfjport_get_screen_width() {
    if (inFullScreenMode) {
        return qteapp_get_mscreen()->getDisplayFullWidth();
    } else {
        return qteapp_get_mscreen()->getDisplayWidth();
    }
}
MidpError Item::preferredWidth(int *w, int h) {


  if (h == -1) {
    
    int maxWidth = qteapp_get_mscreen()->getScreenWidth() - ITEM_BOUND_PAD - ITEM_BOUND_PAD;
    int bodyTakenWidth;
    int bodyHeight = bodyHeightForWidth(&bodyTakenWidth, maxWidth);

    QRect labelRect = 
      QFontMetrics(labelFont).boundingRect(ITEM_BOUND_PAD, ITEM_BOUND_PAD, 
					   maxWidth,
					   PREF_HEIGHT_LIMIT,
					   WordBreak, label);
    // take care of the simple cases:
    // 1. both label and body are empty
    // 2. only label is empty
    // 3. only body is empty
    // Note that label or text do not take any space if its height is 0,
    // width cannot be checked since for end of line width will be 0
    // but such string has to be displayed
    if (label.isEmpty() || labelRect.height() == 0) {
      if (bodyHeight == 0) {
	*w = 0;
      } else {
	*w = ITEM_BOUND_PAD + bodyTakenWidth + ITEM_BOUND_PAD;
      }
      return KNI_OK;

    } else if (bodyHeight == 0) {
      *w = ITEM_BOUND_PAD + labelRect.width() + ITEM_BOUND_PAD;
      return KNI_OK;
    }
    
    // single line case 
    if (labelCanBeOnSameLine(labelRect.height()) && 
	bodyCanBeOnSameLine(bodyHeight) &&
	labelRect.width() + LABEL_BODY_HRZN_PAD + bodyTakenWidth <= maxWidth) {

	*w = ITEM_BOUND_PAD + labelRect.width()
	   + LABEL_BODY_HRZN_PAD + bodyTakenWidth + ITEM_BOUND_PAD;
    
    // multiline case
    } else {
      // Take the wider one of label and body
      *w = ITEM_BOUND_PAD + (bodyTakenWidth > labelRect.width()
			     ? bodyTakenWidth : 
			     labelRect.width()) + ITEM_BOUND_PAD;
	// Sometimes the label or subclass returns taken width that is larger
	// than the tentative width. Patch it here.
	if (*w > qteapp_get_mscreen()->getScreenWidth()) {
	    *w  = qteapp_get_mscreen()->getScreenWidth();
	}
    }
  } else {
    *w = qteapp_get_mscreen()->getScreenWidth();
  }
  
  return KNI_OK;
}
예제 #3
0
int lfjport_get_screen_height() {
    if (inFullScreenMode) {
        return qteapp_get_mscreen()->getDisplayFullHeight();
    } else {
        return qteapp_get_mscreen()->getDisplayHeight();
    }
}
int lfpport_get_screen_height(int hardwareId) {
  (void)hardwareId;
    if (inFullScreenMode) {
        return qteapp_get_mscreen()->getDisplayFullHeight();
    } else {
        return qteapp_get_mscreen()->getDisplayHeight();            
    }
}
int lfpport_get_screen_width(int hardwareId) {
  (void)hardwareId;
    if (inFullScreenMode) {
        return qteapp_get_mscreen()->getDisplayFullWidth();
    } else {
        return qteapp_get_mscreen()->getDisplayWidth();
    }
}
예제 #6
0
extern "C" void gxpport_render_immutableimage
(gxpport_image_native_handle immutableImagePtr,
 gxpport_mutableimage_native_handle dstMutableImagePtr,
 const jshort *clip,
 jint x_dest, jint y_dest) {

    _Platform_ImmutableImage* immutableImage = 
        (_Platform_ImmutableImage*)immutableImagePtr;
    QPixmap *qpixmapDst =
      gxpportqt_get_mutableimage_pixmap(dstMutableImagePtr);

    if (NULL == immutableImage || immutableImage->qimage->isNull()) {
        /* not a valid image should not happen, log this */
        return;
    }

    MScreen * mscreen = qteapp_get_mscreen();
    QPainter *gc = mscreen->setupGC(-1, -1, clip, 
                                    (QPaintDevice *)qpixmapDst, 
                                    0);
    if (immutableImage->qimage->hasAlphaBuffer()) {
        gc->drawImage(x_dest, y_dest, *immutableImage->qimage);
        return;
    }

    gc->drawPixmap(x_dest, y_dest,
        *(gxpportqt_get_immutableimage_pixmap(immutableImagePtr)));
}
예제 #7
0
extern "C" void
gxpport_destroy_mutable(gxpport_mutableimage_native_handle imagePtr) {

    /* we know : 
       non-null QPixmap object has been allocated */  
    QPixmap* qpixmap = (QPixmap *)(imagePtr);

    /* make sure there is a valid qpixmap */
    if (qpixmap == NULL) {
	return;
    }

    MScreen * mscreen = qteapp_get_mscreen();
    if (mscreen->isCurrentPaintDevice(qpixmap)) { 
        // remove pixmap as the current painting device 
        short clip[] = {0, 0, 0, 0}; 
        mscreen->setupGC(-1, -1, clip, NULL, 0); 
    } 

    /* Update the resource count */
    if (midpDecResourceCount(RSC_TYPE_IMAGE_MUT, ImgRscSize(qpixmap)) == 0) {
        REPORT_INFO(LC_LOWUI,"Error in updating resource limit for" 
                             " Mutable image");
    }

    /* RELEASE QT RESOURCES HELD */
    delete qpixmap;
}
MidpError Item::preferredHeight(int *h, int w) {

  // item cannot be laid out in a 0 width
  if (w == 0) {
    *h = 0;
    return KNI_OK;
  }

  // default preferred width is the whole screen width
  if (w == -1) {
    w = qteapp_get_mscreen()->getScreenWidth();
  }

  // now lets calculate height based on given tentative width
  w -= (ITEM_BOUND_PAD + ITEM_BOUND_PAD);


  int bodyTakenWidth;
  int bodyHeight  = bodyHeightForWidth(&bodyTakenWidth, w);

  QRect labelRect = 
    QFontMetrics(labelFont).boundingRect(ITEM_BOUND_PAD, ITEM_BOUND_PAD, 
					 w, PREF_HEIGHT_LIMIT,
					 WordBreak, label);

  // take care of the simple cases:
  // 1. both label and body are empty
  // 2. only label is empty
  // 3. only body is empty
  // Note that label or text do not take any space if its height is 0,
  // width cannot be checked since for end of line width will be 0
  // but such string has to be displayed
  if (label.isEmpty() || labelRect.height() == 0) {
    if (bodyHeight == 0) {
      *h = 0;
    } else {
      *h = ITEM_BOUND_PAD + bodyHeight + ITEM_BOUND_PAD;
    }
    return KNI_OK;
  } else if (bodyHeight == 0) {
    *h = ITEM_BOUND_PAD + labelRect.height() + ITEM_BOUND_PAD;
    return KNI_OK;
  }

  // single line case
  if (labelCanBeOnSameLine(labelRect.height()) && 
      bodyCanBeOnSameLine(bodyHeight) &&
      labelRect.width() + LABEL_BODY_HRZN_PAD + bodyTakenWidth <= w) {
      *h = ITEM_BOUND_PAD
	 + (labelRect.height() > bodyHeight ? labelRect.height() : bodyHeight)
	 + ITEM_BOUND_PAD;
      return KNI_OK;
  }

  // Multiline case
  *h = ITEM_BOUND_PAD + labelRect.height()
     + LABEL_BODY_VERT_PAD + bodyHeight + ITEM_BOUND_PAD;

  return KNI_OK;
}
MIDPError suspend_vm(void *resource) {
    VM *vm = (VM*) resource;

    qteapp_get_mscreen()->suspendVM();
    vm->isSuspended = KNI_TRUE;

    return ALL_OK;
}
예제 #10
0
jboolean lfjport_reverse_orientation()
{
   ChameleonMIDPMainWindow * mainWindow =
    ChameleonMIDPMainWindow::getMainWindow();
   jboolean r = qteapp_get_mscreen()->reverse_orientation();
   mainWindow->resizeScreen();
   return r;
}
MIDPError resume_vm(void *resource) {
    VM *vm = (VM*) resource;

    qteapp_get_mscreen()->resumeVM();
    vm->isSuspended = KNI_FALSE;

    return ALL_OK;
}
jboolean lfpport_reverse_orientation(int hardwareId)
{
  (void)hardwareId;
    jboolean res = qteapp_get_mscreen()->reverse_orientation();
    PlatformMIDPMainWindow * mainWindow =
        PlatformMIDPMainWindow::getMainWindow();
    mainWindow->resizeScreen();
    return res;
}
int StringBody::heightForWidth(int *takenWidth, int w) {
    if (text.isEmpty()) {
      *takenWidth = 0;
      return 0;
    }

    QRect textRect = QFontMetrics(font()).boundingRect(PAD, PAD, 
                                                       w - PAD - PAD,
                                                       qteapp_get_mscreen()->getScreenHeight(),
                                                       WordBreak, text);
    *takenWidth = PAD + textRect.width() + PAD;

    return (PAD + textRect.height() + PAD);
}
예제 #14
0
/**
 * Draw the first n characters in charArray, with the anchor point of the
 * entire (sub)string located at x, y.
 */
extern "C" void
gxpport_draw_chars(
  jint pixel, const jshort *clip, 
  gxpport_mutableimage_native_handle dst,
  int dotted,
  int face, int style, int size,
  int x, int y, int anchor, 
  const jchar *charArray, int n) {
    QPixmap* qpixmap = gxpportqt_get_mutableimage_pixmap(dst);
    QString s(make_string(charArray, n));

    REPORT_INFO4(LC_LOWUI, "gxpport_draw_chars(%d, %d, %x, [chars...], %d)", 
		 x, y, anchor, n); 

    find_font(face, style, size);

    switch (anchor & (LEFT | RIGHT | HCENTER)) {
    case LEFT:
        break;

    case RIGHT:
        x -= qfontInfo->width(s);
        break;

    case HCENTER:
        x -= (qfontInfo->width(s) >> 1);
        break;
    }

    switch (anchor & (TOP | BOTTOM | BASELINE)) {
    case BOTTOM:
      /* 1 pixel has to be added to account for baseline in Qt */
        y -= qfontInfo->descent()+1;

    case BASELINE:
        break;

    case TOP:
    default:
        y += qfontInfo->ascent();
        break;
    }

    MScreen * mscreen = qteapp_get_mscreen();
    QPainter *gc = mscreen->setupGC(pixel, -1, clip, (QPaintDevice*)qpixmap, 
				    dotted);
    gc->setFont(find_font(face, style, size));
    gc->drawText(x, y, s, n);
}
예제 #15
0
extern "C" void
gxpport_render_mutableimage(gxpport_mutableimage_native_handle srcImagePtr,
			    gxpport_mutableimage_native_handle dstImagePtr,
			    const jshort *clip,
			    jint x_dest, jint y_dest) {

    QPixmap *qpixmapDst = (QPixmap *)(dstImagePtr);

    MScreen * mscreen = qteapp_get_mscreen();
    QPainter *gc = mscreen->setupGC(-1, -1, clip, 
                                    (QPaintDevice *)qpixmapDst, 
                                    0);

    QPixmap *qpixmapSrc = (QPixmap *)(srcImagePtr);

    gc->drawPixmap(x_dest, y_dest, *qpixmapSrc);
}
예제 #16
0
/**
 * Gets the width of the custom item's native label.
 *
 * @param widthRet the calculated label width, based on tentative 
 *                 width passed in.
 * @param width the tentative width for the label (without padding)
 * @param ciPtr pointer to the custom item's MidpItem structure.
 *
 * @return an indication of success or the reason for failure
 */
extern "C" MidpError
lfpport_customitem_get_label_width(int *widthRet,
				   int width,
				   MidpItem* ciPtr)
{

  REPORT_INFO1(LC_HIGHUI, "[lfpport_qte_customitem.cpp:%d] "
	       "lfpport_customitem_GetLabelWidth", __LINE__);

  // NOT TESTED

  if (width < 0) {
    width = qteapp_get_mscreen()->getScreenWidth() - ITEM_BOUND_PAD - ITEM_BOUND_PAD;
  }
  *widthRet = ((Item *)ciPtr->widgetPtr)->getLabelWidth(width);

  return KNI_OK;
}
/**
 * Construct a new modal window.
 *
 * @param parent parent widget pointer
 */
Alert::Alert(QWidget* parent)
    : QWidget(parent, NULL, WType_TopLevel | WType_Modal) {

    imageHolder = NULL;
    textViewer = NULL;
    numButtons = 0;

    for (int i = 0; i < ALERT_NUM_OF_BUTTONS; i++) {
	buttons[i] = NULL;
    }

    mscreen = (PlatformMScreen*)qteapp_get_mscreen();
    // Set geometry
    QWidget::setGeometry(
        (mscreen->getDisplayFullWidth() - mscreen->getAlertWidth()) / 2,                       // X
        MENUBAR_HEIGHT + (mscreen->getDisplayFullHeight() - mscreen->getAlertHeight()) / 2,    // Y
		mscreen->getAlertWidth(), mscreen->getAlertHeight());
	// Prevents resizing
    QWidget::setFixedSize(QWidget::size());
}
예제 #18
0
extern "C" void gxpport_render_immutableregion
(gxpport_image_native_handle immutableImagePtr,
 gxpport_mutableimage_native_handle dstMutableImagePtr,
 const jshort *clip,
 jint x_dest, jint y_dest, 
 jint width, jint height,
 jint x_src, jint y_src,
 jint transform) {

    _Platform_ImmutableImage* immutableImage = 
        (_Platform_ImmutableImage*)immutableImagePtr;
    QPixmap *qpixmapDst =
    gxpportqt_get_mutableimage_pixmap(dstMutableImagePtr);

    if (NULL == immutableImagePtr || immutableImage->qimage->isNull()) {
      /* not a valid image should not happen, log this */
        return;
    }

    MScreen * mscreen = qteapp_get_mscreen();
    QPainter *gc = mscreen->setupGC(-1, -1, clip, 
                                    (QPaintDevice *)qpixmapDst, 
                                    0);
    if (0 == transform) {
        gc->drawImage(x_dest, y_dest,
                      *immutableImage->qimage,
                      x_src, y_src,
                      width, height,
                      0);
        return;
    }

    QImage image = immutableImage->qimage->copy(x_src, y_src, 
                                               width, height);

    transform_image(&image, transform);
    
    if (!image.isNull()) {
        gc->drawImage(x_dest, y_dest, image);
    }
}
예제 #19
0
/**
 * Helper function.
 * Retrieve buffer for the specified graphics.
 *
 * @param graphicshandle   A KNI handle to a graphics object.
 * @return QPixmap that represents the graphics buffer.
 */
static QPixmap* getGraphicsBuffer(jobject graphicsHandle) {
    QPixmap* pixmap;
    java_image* image;

    image = GXAPI_GET_GRAPHICS_PTR(graphicsHandle)->img;
    if (image != NULL) {
        /*
         * If the graphics context has a parent image bound to it,
         * pick up the pixmap.
         */
        pixmap = gxpportqt_get_mutableimage_pixmap(
            (gxpport_mutableimage_native_handle)
                (image->imageData->nativeImageData));

    } else {
        /* If no image is bound, render to back buffer */
        pixmap = qteapp_get_mscreen()->getBackBuffer();
    }

    return pixmap;
}
예제 #20
0
/**
 * Gets the height of the custom item's native label. 
 *
 * @param width the tentative width for the label (without padding)
 * @param heightRet the calculated label height, based on tentative 
 *                  width passed in.
 * @param ciPtr pointer to the custom item's MidpItem structure.
 *
 * @return an indication of success or the reason for failure
 */
extern "C" MidpError
lfpport_customitem_get_label_height(int width,
				    int *heightRet,
				    MidpItem* ciPtr)
{

  REPORT_INFO1(LC_HIGHUI, "[lfpport_qte_customitem.cpp:%d] "
	       "lfpport_customitem_GetLabelHeight" , __LINE__);

  if (width < 0) {
    width = qteapp_get_mscreen()->getScreenWidth() - ITEM_BOUND_PAD - ITEM_BOUND_PAD;
  }
  *heightRet = ((Item *)ciPtr->widgetPtr)->getLabelHeight(width);

  REPORT_INFO2(LC_HIGHUI, 
	      "\t lfpport_customitem_GetLabelHeight(%d): labelHeight=%d\n",
	      width, heightRet);


  return KNI_OK;
}
예제 #21
0
extern "C" void
gxpport_render_mutableregion(gxpport_mutableimage_native_handle srcImagePtr,
			     gxpport_mutableimage_native_handle dstImagePtr,
			     const jshort *clip,
			     jint x_dest, jint y_dest, 
			     jint width, jint height,
			     jint x_src, jint y_src,
			     jint transform) {
    QPixmap *qpixmapDst = (QPixmap *)(dstImagePtr);
    
    MScreen * mscreen = qteapp_get_mscreen();
    QPainter *gc = mscreen->setupGC(-1, -1, clip, 
                                    (QPaintDevice *)qpixmapDst, 
                                    0);

    QPixmap *qpixmapSrc = (QPixmap *)(srcImagePtr);

    if (NULL == qpixmapSrc || qpixmapSrc->isNull()) {
        /* not a valid pixmap. */
        return;
    }

    if (0 == transform) {
        gc->drawPixmap(x_dest, y_dest,
                       *qpixmapSrc,
                       x_src, y_src,
                       width, height);
        return;
    }

    QPixmap *qpixmap = new QPixmap();

    get_transformed_pixmap(qpixmapSrc, qpixmap,
			   x_src, y_src, width, height,
			   transform, FALSE);

    gc->drawPixmap(x_dest, y_dest, *qpixmap);
    delete qpixmap;
}
jboolean lfpport_get_reverse_orientation(int hardwareId)
{
  (void)hardwareId;
    return qteapp_get_mscreen()->get_reverse_orientation();
}
/**
 * Resets native resources when foreground is gained by a new display.
 */
void lfpport_gained_foreground(int hardwareId) {
  (void)hardwareId;
  qteapp_get_mscreen()->gainedForeground();
}
/**
 * Bridge function to request a repaint 
 * of the area specified.
 *
 * @param x1 top-left x coordinate of the area to refresh
 * @param y1 top-left y coordinate of the area to refresh
 * @param x2 bottom-right x coordinate of the area to refresh
 * @param y2 bottom-right y coordinate of the area to refresh
 */
void lfpport_refresh(int hardwareId, int x1, int y1, int x2, int y2)
{
  (void) hardwareId;
  qteapp_get_mscreen()->refresh(x1, y1, x2, y2);
}
예제 #25
0
/**
 * Bridge function to request a repaint 
 * of the area specified.
 *
 * @param x1 top-left x coordinate of the area to refresh
 * @param y1 top-left y coordinate of the area to refresh
 * @param x2 bottom-right x coordinate of the area to refresh
 * @param y2 bottom-right y coordinate of the area to refresh
 */
void lfjport_refresh(int x1, int y1, int x2, int y2)
{
  qteapp_get_mscreen()->refresh(x1, y1, x2, y2);
}
예제 #26
0
/**
 * Resets native resources when foreground is gained by a new display.
 */
void lfjport_gained_foreground() {
  qteapp_get_mscreen()->gainedForeground();
}
예제 #27
0
jboolean lfjport_get_reverse_orientation()
{
   return qteapp_get_mscreen()->get_reverse_orientation();
}
void midp_slavemode_schedule_vm_timeslice(void) {
    qteapp_get_mscreen()->setNextVMTimeSlice(0);
}
void midp_slavemode_event_loop(void) {
  qteapp_get_mscreen()->startVM();
  qteapp_get_application()->enter_loop();
  qteapp_get_mscreen()->stopVM();
}