lfpport_qte_mscreen.cpp
来自「This is a resource based on j2me embedde」· C++ 代码 · 共 643 行 · 第 1/2 页
CPP
643 行
/* * * * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * * This source file is specific for Qt-based configurations. */#include <kni.h>#include <jvmspi.h>#include <sni.h>#include "lfpport_qte_util.h"#include <qapplication.h>#include <qmainwindow.h>#include <qpainter.h>#include <qpaintdevice.h>#include <qpaintdevicemetrics.h>#include <qlayout.h>#include <qtoolbar.h>#include <qpalette.h>#include <qaction.h>#include <qmessagebox.h>#include <qstatusbar.h>#include <qsizepolicy.h>#include <midp_constants_data.h>#include <keymap_input.h>#include <midpServices.h>#include <midpMalloc.h>#include <midpString.h>#include <midpEventUtil.h>#include <lfpport_font.h>#include <lfp_registry.h>#include <qteapp_key.h>#include "lfpport_qte_mscreen.h"#include "lfpport_qte_mainwindow.h"#include <moc_lfpport_qte_mscreen.cpp>/** * @file lfpport_qte_mscreen.cpp * * A frame-less widget that all Displayables are rendered on. */jboolean PlatformMScreen::r_orientation = false;/** * A frame-less widget that all Displayables are rendered on. */PlatformMScreen::PlatformMScreen(QWidget *parent, const char* name) :QScrollView(parent, name) { vm_stopped = false; // MainWindow already has frame, no frame for MScreen setFrameStyle(QFrame::NoFrame); // Graphics context gc = new QPainter(); force_refresh = true; last_pen = -1; last_brush = -1; last_dotted = 0; TRACE_MSC( PlatformMScreen::MScreen..); connect(&vm_slicer, SIGNAL(timeout()), this, SLOT(slotTimeout())); TRACE_MSC(..PlatformMScreen::MScreen);}/** * full screen mode in Qt does not work nicely with menu bar * so we have to fall back to the design where full screen * in Qt platform widget means only ticker is gone. */void PlatformMScreen::init() { TRACE_MSC( PlatformMScreen::init..); setFocusPolicy(QWidget::ClickFocus); // Always ... setHScrollBarMode(QScrollView::AlwaysOff); DISPLAY_WIDTH = NORMALWIDTH; DISPLAY_HEIGHT = NORMALHEIGHT; SCREEN_WIDTH = NORMALWIDTH - VERT_SCROLLBAR_WIDTH; SCREEN_HEIGHT = NORMALHEIGHT; DISPLAY_FULLWIDTH = FULLWIDTH; DISPLAY_FULLHEIGHT = FULLHEIGHT; /* * Use the values from constants.xml. No more dynamic querying. * // Measure without scrollbar setVScrollBarMode(QScrollView::AlwaysOff); DISPLAY_WIDTH = visibleWidth(); // width for full and normal screen mode DISPLAY_HEIGHT = visibleHeight(); // height for normal mode // Measure with scrollbar setVScrollBarMode(QScrollView::AlwaysOn); SCREEN_WIDTH = visibleWidth(); // width that should be used for layout SCREEN_HEIGHT = visibleHeight(); // height that form should return // Special case, see above for explanation; // for canvas: no scroll, no ticker DISPLAY_FULLWIDTH = DISPLAY_WIDTH; DISPLAY_FULLHEIGHT = DISPLAY_HEIGHT + MainWindow->getTicker()->sizeHint().height(); // for canvas: no border in layout and no spacing between mscreen and ticker QLayout *layout = parentWidget() == NULL ? NULL : parentWidget()->layout(); if (layout != NULL) { DISPLAY_FULLWIDTH += 2*layout->margin(); DISPLAY_FULLHEIGHT += 2*layout->margin() + layout->spacing(); } */ setVScrollBarMode(QScrollView::Auto); // Set the size of the midlet suites app area setFixedSize(getDisplayWidth(), getDisplayHeight()); qpixmap.resize(getDisplayWidth(), getDisplayHeight()); qpixmap.fill(); // Qt::white is default TRACE_MSC(..PlatformMScreen::init);}/** * Resize the buffer size (either normal or fullscreen) * * @param newSize Specify the size of the screen */void PlatformMScreen::setBufferSize(BufferSize newSize){ if (newSize == fullScreenSize) { if (gc->isActive()) { gc->end(); } qpixmap.resize(getDisplayFullWidth(), getDisplayFullHeight()); } else { qpixmap.resize(getDisplayWidth(), getDisplayHeight()); } // Whether current Displayable won't repaint the entire screen on // resize event, the artefacts from the old screen content can appear. // That's why the buffer content is not preserved. qpixmap.fill(); // Qt::white is default}/** * Start VM by starting a time share request for it. */void PlatformMScreen::startVM() { vm_stopped = false; key_press_count = 0; // Setup next VM time slice to happen immediately setNextVMTimeSlice(0);}/** * Stop VM by stopping requests for VM time slice. * Any leftover UI resource will be freed also. */void PlatformMScreen::stopVM() { // Stop any further VM time slice setNextVMTimeSlice(-1); // Clean up any leftover native UI resources since VM is exiting MidpDeleteAllComponents(); // Clean up any leftovers of native font resources lfpport_font_finalize();}PlatformMScreen::~PlatformMScreen(){ killTimers(); delete gc; gc = NULL;}/** * Handle mouse press event in the VIEWPORT * * @param mouse QT's QMouseEvent */void PlatformMScreen::viewportMousePressEvent(QMouseEvent *mouse){ MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); evt.type = MIDP_PEN_EVENT; evt.ACTION = KEYMAP_STATE_PRESSED; evt.X_POS = mouse->x(); evt.Y_POS = mouse->y(); midpStoreEventAndSignalForeground(evt);}/** * Handle mouse move event in the VIEWPORT * * @param mouse QT's QMouseEvent */void PlatformMScreen::viewportMouseMoveEvent(QMouseEvent *mouse){ MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); evt.type = MIDP_PEN_EVENT; evt.ACTION = KEYMAP_STATE_DRAGGED; evt.X_POS = mouse->x(); evt.Y_POS = mouse->y(); midpStoreEventAndSignalForeground(evt);}/** * Handle mouse move release in the VIEWPORT * * @param mouse QT's QMouseEvent */void PlatformMScreen::viewportMouseReleaseEvent(QMouseEvent *mouse){ MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); evt.type = MIDP_PEN_EVENT; evt.ACTION = KEYMAP_STATE_RELEASED; evt.X_POS = mouse->x(); evt.Y_POS = mouse->y(); midpStoreEventAndSignalForeground(evt);}/** * Handle key press event * * @param key QT's QKeyEvent * @see keyReleaseEvent or <a href="http://doc.trolltech.com/qtopia/html/qwidget.html#0a4482">online menu.</a> */void PlatformMScreen::keyPressEvent(QKeyEvent *key){ key_press_count += 1;#if ENABLE_MULTIPLE_ISOLATES if (key->key() == Qt::Key_F7 || key->key() == Qt::Key_Home) { // F7 to display the foreground selector if (!key->isAutoRepeat()) { MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); evt.intParam1 = 0; evt.type = SELECT_FOREGROUND_EVENT; midpStoreEventAndSignalAms(evt); }#ifdef QT_KEYPAD_MODE } else if (key->key() == Qt::Key_Flip) {#else } else if (key->key() == Qt::Key_F4) {#endif if (!key->isAutoRepeat()) { MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); evt.type = SELECT_FOREGROUND_EVENT; evt.intParam1 = 1; midpStoreEventAndSignalAms(evt); } }#else // F7 pause or activate all Java apps if ((key->key() == Qt::Key_F7 || key->key() == Qt::Key_Home) && !key->isAutoRepeat()) { pauseAll(); }#endif else { MidpEvent evt; MIDP_EVENT_INITIALIZE(evt); if ((evt.CHR = mapKey(key)) != KEYMAP_KEY_INVALID) { if (evt.CHR == KEYMAP_KEY_SCREEN_ROT) { evt.type = ROTATION_EVENT; } else if (evt.CHR == KEYMAP_KEY_VIRT_KEYB) { evt.type = VIRTUAL_KEYBOARD_EVENT; } else { evt.type = MIDP_KEY_EVENT; } evt.ACTION = key->isAutoRepeat() ? KEYMAP_STATE_REPEATED : KEYMAP_STATE_PRESSED;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?