Example #1
0
StatusBarManager::StatusBarManager(KXmlGuiWindow *mainWindow)
    : QObject(mainWindow)
{
    mStatusBar = mainWindow->statusBar();

    // Messages
    mStatusBar->insertItem(i18nc("@info:status", "Ready"), StatusBarManager::Message, 1);
    mStatusBar->setItemAlignment(StatusBarManager::Message, Qt::AlignLeft);

    // Image dimensions
    QString s = ImageCanvas::imageInfoString(2000, 2000, 48);
    initItem(s, StatusBarManager::ImageDims,
             i18nc("@info:tooltip", "The size of the image being viewed in the gallery"));

    // Preview dimensions
    s = Previewer::previewInfoString(500.0, 500.0, 1200, 1200);
    initItem(s, StatusBarManager::PreviewDims,
             i18nc("@info:tooltip", "The size of the selected area that will be scanned"));

    // Preview size
    mFileSize = new SizeIndicator(NULL);
    mFileSize->setMaximumWidth(100);
    mFileSize->setFrameStyle(QFrame::NoFrame);
    mFileSize->setToolTip(i18nc("@info:tooltip", "<qt>This is the uncompressed size of the scanned image. "
                                "It tries to warn you if you try to produce too big an image by "
                                "changing its background color."));
    mStatusBar->addPermanentWidget(mFileSize);

    mStatusBar->show();
}
Example #2
0
/*!
  Constructs an empty Gantt item of type event.

  \param view the Gantt view to insert this item into
  \param lvtext the text to show in the list view
  \param name the name by which the item can be identified. If no name
  is specified, a unique name will be generated
*/
KDGanttViewEventItem::KDGanttViewEventItem( KDGanttView* view,
                                            const QString& lvtext,
                                            const QString& name ) :
    KDGanttViewItem( Event, view, lvtext, name )
{
  initItem();
}
GraphicsClientItem::GraphicsClientItem(GraphicsClientItemsClient *clientItemsClient_, JackClient *jackClient_,bool isMacro_, const QString &clientName_, int clientStyle_, int audioPortStyle_, int midiPortStyle_, QFont font_, QGraphicsItem *parent) :
    QGraphicsPathItem(parent, clientItemsClient_->getScene()),
    clientItemsClient(clientItemsClient_),
    jackClient(jackClient_),
    clientName(clientName_),
    clientStyle(clientStyle_),
    audioPortStyle(audioPortStyle_),
    midiPortStyle(midiPortStyle_),
    font(font_),
    controlsItem(0),
    isMacro(isMacro_)
{
    setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsGeometryChanges | QGraphicsItem::ItemSendsScenePositionChanges | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsSelectable);
    setCursor(Qt::ArrowCursor);
    font.setStyleStrategy(QFont::PreferAntialias);
    if (isMacroItem()) {
        setPen(QPen(QBrush(QColor("steelblue")), 3));
    } else {
        setPen(QPen(QBrush(Qt::black), 3));
    }
    setBrush(QBrush(Qt::white));
    initItem();
    if (jackClient && (controlsItem = jackClient->createGraphicsItem())) {
        controlsItem->setFlag(QGraphicsItem::ItemIsFocusable, true);
        controlsItem->setZValue(1);
        controlsItem->setVisible(false);
        controlsItem->setParentItem(this);
        controlsItem->setPos(getRect().bottomLeft());
        controlsItem->setCursor(Qt::ArrowCursor);
    }
}
Example #4
0
/*!
  Constructs an empty Gantt item of type event.

  \param view the Gantt view to insert this item into
  \param lvtext the text to show in the list view
  \param name the name by which the item can be identified. If no name
  is specified, a unique name will be generated
*/
KDGanttViewSummaryItem::KDGanttViewSummaryItem( KDGanttView* view,
                                                const QString& lvtext,
                                                const QString& name ) :
    KDGanttViewItem( Summary, view, lvtext, name )
{
  initItem();
}
Example #5
0
/*!
  Constructs an empty Gantt item of type event.

  \param parent a parent item under which this one goes
  \param lvtext the text to show in the list view
  \param name the name by which the item can be identified. If no name
  is specified, a unique name will be generated
*/
KDGanttViewSummaryItem::KDGanttViewSummaryItem( KDGanttViewItem* parent,
                                                const QString& lvtext,
                                                const QString& name ) :
    KDGanttViewItem( Summary, parent, lvtext, name )
{
  initItem();
}
Example #6
0
void PrepareLayer::backFromShopLayer(CCObject *pSender)
{
	initItem(0);
	//	initItem(1);
	setCoin();
	this->m_menu->setEnabled(true);
}
Example #7
0
/*!
  Constructs an empty Gantt item of type event.

  \param parent a parent item under which this one goes
  \param lvtext the text to show in the list view
  \param name the name by which the item can be identified. If no name
  is specified, a unique name will be generated
*/
KDGanttViewEventItem::KDGanttViewEventItem( KDGanttViewItem* parent,
                                            const QString& lvtext,
                                            const QString& name ) :
    KDGanttViewItem( Event, parent, lvtext, name )
{
 initItem();

}
Example #8
0
item* parseItem(char* userInput)
{
    if(userInput == NULL)
    {
        fprintf(stderr, "You have not provided any itemname required by the command.");
        return NULL;
    }
    item* it = initItem(userInput, NO_DATE_SPECIFIED);
    return it;
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    initItem();
    // 初始化布局
    init();
    // 建立TCP
    connect(ui->get_btn,SIGNAL(clicked()),this,SLOT(GetData()));

}
/** \brief Constructor to create a trigger item.
  * Trigger items are invisible and can be used to trigger a behavior when
  * approaching a point.
  */
Item::Item(const Vec3& xyz, float distance, TriggerItemListener* trigger)
{
    m_distance_2        = distance*distance;
    initItem(ITEM_TRIGGER, xyz);
    m_original_rotation = btQuaternion(0, 0, 0, 1);
    m_rotation_angle    = 0.0f;
    m_original_mesh     = NULL;
    m_original_lowmesh  = NULL;
    m_node              = NULL;
    m_listener          = trigger;
}   // Item(xyz, distance, trigger)
Example #11
0
/** \brief Constructor to create a trigger item.
  * Trigger items are invisible and can be used to trigger a behavior when
  * approaching a point.
  */
Item::Item(const Vec3& xyz, float distance, TriggerItemListener* trigger)
{
    m_distance_2        = distance*distance;
    initItem(ITEM_TRIGGER, xyz);
    // Sets heading to 0, and sets pitch and roll depending on the normal. */
    m_original_hpr      = Vec3(0, 0, 0);
    m_original_mesh     = NULL;
    m_original_lowmesh  = NULL;
    m_node              = NULL;
    m_listener          = trigger;
}   // Item(xyz, distance, trigger)
Example #12
0
Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
           scene::IMesh* mesh, scene::IMesh* lowres_mesh)
{
    assert(type != ITEM_TRIGGER); // use other constructor for that

    m_distance_2        = 1.2f;
    initItem(type, xyz);

    m_original_rotation = shortestArcQuat(Vec3(0, 1, 0), normal);
    m_rotation_angle    = 0.0f;
    m_original_mesh     = mesh;
    m_original_lowmesh  = lowres_mesh;
    m_listener          = NULL;

    LODNode* lodnode    = new LODNode("item",
                                      irr_driver->getSceneManager()->getRootSceneNode(),
                                      irr_driver->getSceneManager());
    scene::IMeshSceneNode* meshnode = 
        irr_driver->addMesh(mesh, StringUtils::insertValues("item_%i", (int)type));

    if (lowres_mesh != NULL)
    {
        lodnode->add(35, meshnode, true);
        scene::IMeshSceneNode* meshnode = 
            irr_driver->addMesh(lowres_mesh, 
                                StringUtils::insertValues("item_lo_%i", (int)type));
        lodnode->add(100, meshnode, true);
    }
    else
    {
        lodnode->add(100, meshnode, true);
    }

    m_node              = lodnode;

    //m_node             = irr_driver->addMesh(mesh);
#ifdef DEBUG
    std::string debug_name("item: ");
    debug_name += m_type;
    m_node->setName(debug_name.c_str());
#endif

    World::getWorld()->getTrack()->adjustForFog(m_node);
    m_node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
    m_node->setPosition(xyz.toIrrVector());
    Vec3 hpr;
    hpr.setHPR(m_original_rotation);
    m_node->setRotation(hpr.toIrrHPR());
    m_node->grab();
}   // Item(type, xyz, normal, mesh, lowres_mesh)
Example #13
0
void MainWindow::on_addButton_clicked()
{
    int row = ui->tableWidget->rowCount();
    for(int i = 0 ; i < row ; i++)
    {
        if(ui->tableWidget->item(i,0)->text() == "")
        {
            QMessageBox::critical(0, tr("警告"), tr("上次新增的一行未提交,请先提交!!!"));
            return;
        }
    }
    ui->tableWidget->setRowCount(row + 1);
    initItem(row);
    setCulReadOnlay();
    inEditMode();
}
Example #14
0
//BEGIN class PinItem
PinItem::PinItem( FlowCodeDocument* _view, QPoint position, bool _onLeft, PinSettings * pinSettings )
	: KtlQCanvasRectangle(0)
{
	m_pinSettings = pinSettings;
	view = _view;
	onLeft = _onLeft;
	
	connect( m_pinSettings, SIGNAL(settingsChanged()), this, SLOT(updateDrawing()) );
	
	if ( QFontInfo(m_font).pixelSize() > 11 ) // It has to be > 11, not > 12, as (I think) pixelSize() rounds off the actual size
		m_font.setPixelSize(12);
	
	setCanvas( view->canvas() );
	
	move ( position.x(), position.y() );
	initItem();
	setZ( (ICNDocument::Z::RaisedItem + ICNDocument::Z::ResizeHandle)/2 + 1 ); // Hackish, but whatever
}
Example #15
0
/** Constructor for an item.
 *  \param type Type of the item.
 *  \param xyz Location of the item.
 *  \param normal The normal upon which the item is placed (so that it can
 *         be aligned properly with the ground).
 *  \param mesh The mesh to be used for this item.
 *  \param owner 'Owner' of this item, i.e. the kart that drops it. This is
 *         used to deactivate this item for the owner, i.e. avoid that a kart
 *         'collects' its own bubble gum. NULL means no owner, and the item
 *         can be collected immediatley by any kart.
 */
Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
           scene::IMesh* mesh, scene::IMesh* lowres_mesh,
           const AbstractKart *owner)
    : ItemState(type, owner)
{
    m_was_available_previously = true;
    m_distance_2        = 1.2f;
    initItem(type, xyz, normal);
    m_graphical_type    = getGrahpicalType();

    LODNode* lodnode =
        new LODNode("item", irr_driver->getSceneManager()->getRootSceneNode(),
                    irr_driver->getSceneManager());
    scene::ISceneNode* meshnode =
        irr_driver->addMesh(mesh, StringUtils::insertValues("item_%i", (int)type));

    if (lowres_mesh != NULL)
    {
        lodnode->add(35, meshnode, true);
        scene::ISceneNode* meshnode =
            irr_driver->addMesh(lowres_mesh,
                                StringUtils::insertValues("item_lo_%i", (int)type));
        lodnode->add(100, meshnode, true);
    }
    else
    {
        lodnode->add(100, meshnode, true);
    }
    m_node              = lodnode;
    setType(type);
    handleNewMesh(getGrahpicalType());

#ifdef DEBUG
    std::string debug_name("item: ");
    debug_name += getType();
    m_node->setName(debug_name.c_str());
#endif
    m_node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
    m_node->setPosition(xyz.toIrrVector());
    Vec3 hpr;
    hpr.setHPR(getOriginalRotation());
    m_node->setRotation(hpr.toIrrHPR());
    m_node->grab();
}   // Item(type, xyz, normal, mesh, lowres_mesh)
Example #16
0
void resetGame(Game& game) {
    initBox(game.daBox, game.boxSprite);
    initItem(game.bonusItem);

    game.daEnemies.clear();
    game.daMissiles.clear();
    game.daBlasts.clear();
    game.lives.clear();

    for (int i = 0; i < STARTING_LIVES; i++) {
        BlastLogic life;
        initBlast(life, game.heartSprite, 7.0+(i*17.0), 5.0);
        life.outRect.w = life.outRect.h = 16;
        game.lives.push_back(life);
    }

    game.score = 0;
    game.multiplier = 1.0f;
    game.lastSpawnDate = SDL_GetTicks();
    game.lastTime = SDL_GetTicks();
    game.lag = 0;
}
Example #17
0
int importItemFile(Sugoroku *sugoroku, char* dir)
{
  FILE *fp;
  int i;
  int c;

  if ((fp = fopen(dir, "r")) == NULL) {
    printf("can't open item file.\n");
    return 0;
  }

  sugoroku->item_num = 0;
  do {
    c = getc(fp);
    if (c == '\n') {
      sugoroku->item_num++;
    }
  } while (c != EOF);

  fclose(fp);
  if ((fp = fopen(dir, "r")) == NULL) {
    printf("can't open item file.\n");
    return 0;
  }

  sugoroku->item = (Item *)malloc((sizeof(Item)* sugoroku->item_num));

  for (i = 0; i < sugoroku->item_num; i++) {
    initItem(&sugoroku->item[i]);
    fscanf(fp, "%d, %[^,], %d\n", &sugoroku->item[i].id,  sugoroku->item[i].name, &sugoroku->item[i].hastarget);
  }


  fclose(fp);
  return 1;
}
Example #18
0
/*********************************************************************
 * @fn      osal_nv_item_init
 *
 * @brief   If the NV item does not already exist, it is created and
 *          initialized with the data passed to the function, if any.
 *          This function must be called before calling osal_nv_read() or
 *          osal_nv_write().
 *
 * @param   id  - Valid NV item Id.
 * @param   len - Item length.
 * @param  *buf - Pointer to item initalization data. Set to NULL if none.
 *
 * @return  NV_ITEM_UNINIT - Id did not exist and was created successfully.
 *          SUCCESS        - Id already existed, no action taken.
 *          NV_OPER_FAILED - Failure to find or create Id.
 */
uint8 osal_nv_item_init( uint16 id, uint16 len, void *buf )
{
  uint16 offset;

  if ( !OSAL_NV_CHECK_BUS_VOLTAGE )
  {
    return NV_OPER_FAILED;
  }
  else if ((offset = findItem(id)) != OSAL_NV_ITEM_NULL)
  {
    // Re-populate the NV hot item data if the corresponding items are already established.
    hotItemUpdate(findPg, offset, id);

    return SUCCESS;
  }
  else if ( initItem( TRUE, id, len, buf ) != OSAL_NV_PAGE_NULL )
  {
    return NV_ITEM_UNINIT;
  }
  else
  {
    return NV_OPER_FAILED;
  }
}
void SpellIntroPage::layoutCompleted()
{
    BasSysPage::layoutCompleted();
    if(m_scroll == 0)
        initItem();
}
void StackedSet::update()
{
   clear();

   // Since overlap should be calculated using the precision scaled dimensions
   // we need to precision scale the bounding box for the screen.
   PixelBox screenBox = m_projection.getPixelBoundingBox();

   MC2Point topLeft(screenBox.getTopLeft().getX() * SCALING_CONSTANT,
                    screenBox.getTopLeft().getY() * SCALING_CONSTANT);
   MC2Point bottomRight(screenBox.getBottomRight().getX() * SCALING_CONSTANT,
                        screenBox.getBottomRight().getY() * SCALING_CONSTANT);
   PixelBox screenBoxScaled(topLeft, bottomRight);
   
   for( OverlayViewLayerInterface::LayerMap::iterator itr =
           m_layerInterface.begin();
        itr != m_layerInterface.end(); itr++)
   {
      Layer& l = *itr->second;

      if(!l.getVisible()) {
         // We don't need to detect any overlaps with invisible layers.
         continue;
      }

      for(Layer::const_iterator itemItr = l.items_begin();
          itemItr != l.items_end(); itemItr++)
      {
         OverlayItemInternal* item = *itemItr;
         
         initItem(item);
         
         if (!screenBoxScaled.overlaps(item->getPrecisionScaledPixelBox())) {
            // The item lies outside the screen, do NOT add it to the stacks.
            continue;
         }
         
         addToStackSet(item);
      }
   }

   
#ifdef USE_SMOOTHING
   // Smooth the positions of the stacks to represent the average
   // of the contained items' positions.
   smoothPositions();
#endif 
   
#ifdef USE_SMOOTHING
#ifdef USE_ITERATIVE_SMOOTHING
   // Since we have changed the position of the stacks, we run another
   // pass of overlap detection.
   unsigned int prevSize = 0; 
   unsigned int iterationCap = ITERATIVE_SMOOTHING_CAP;

   // If the number of stacks has not changed, no stacks overlapped
   // so the iteration should terminate.
   while (prevSize != m_stacks.size() && iterationCap > 0) {
      StackVec tempVec = m_stacks;
      prevSize = m_stacks.size();

      clear();
   
      for(StackVec::iterator itr = tempVec.begin();
          itr != tempVec.end(); itr++) {
         addToStackSet(*itr);
         
      }
   
      smoothPositions();
      --iterationCap;
   }
#endif
#endif
   
   OverlayItemInternal* currClosest = NULL;
   if ( m_stacks.size() != 0 && m_automaticHighlightMode){
      // Find out which item is closest to the center of the screen
      
      MC2Point screenCenter;
      m_projection.transform(screenCenter, m_projection.getCenter());
   
      WFAPI::wf_float64 closestDistSq = 0;

      currClosest = *m_stacks.begin();
      closestDistSq = getSquareScreenDistance(screenCenter, currClosest);
         
      for(StackedSet::StackVec::const_iterator itr = m_stacks.begin();
          itr != m_stacks.end(); itr++)
      {
         WFAPI::wf_float64 currDistSq = getSquareScreenDistance(screenCenter,
                                                                *itr);
         if (currDistSq < closestDistSq){
            currClosest = *itr;
            closestDistSq = currDistSq;
         }
      }
      // If the currently closest item is further away than RADIUS pixels,
      // disregard it.
      const unsigned int RADIUS = 75;
      if (closestDistSq > RADIUS * RADIUS){
         currClosest = NULL;
         closestDistSq = 0;
      }
   }
   updateClosest(currClosest);
   
   if (m_closest.item && automaticHighlightEnabled()){
      m_closest.item->m_isHighlighted = true;
      // Since we don't care pixel scale the item is on, we
      // use 0 as the current pixel scale.
      const WFAPI::OverlayItemVisualSpec* highlighted =
         OverlayItemUtil::getCurrentVisualSpec(m_closest.item, 0);
      
      if(highlighted) {
         updateItemPixelBox(m_closest.item, highlighted,
                            m_closest.item->m_adjustedPosition);
      }
   }
   
}
KonqSidebarTreeItem::KonqSidebarTreeItem( KonqSidebarTree *parent, KonqSidebarTreeTopLevelItem *topLevelItem )
    : Q3ListViewItem( parent )
{
    initItem( topLevelItem );
}
void FaceBookPage::layoutCompleted()
{
    BasSysPage::layoutCompleted();
    if(!m_itemInit)
        initItem();
}
void ScreenShotPage::layoutCompleted()
{
    BasSysPage::layoutCompleted();
    if(!m_itemInit)
        initItem();
}
Example #24
0
/*********************************************************************
 * @fn      osal_nv_write
 *
 * @brief   Write a data item to NV. Function can write an entire item to NV or
 *          an element of an item by indexing into the item with an offset.
 *
 * @param   id  - Valid NV item Id.
 * @param   ndx - Index offset into item
 * @param   len - Length of data to write.
 * @param  *buf - Data to write.
 *
 * @return  SUCCESS if successful, NV_ITEM_UNINIT if item did not
 *          exist in NV and offset is non-zero, NV_OPER_FAILED if failure.
 */
uint8 osal_nv_write( uint16 id, uint16 ndx, uint16 len, void *buf )
{
  uint8 rtrn = SUCCESS;

  if ( !OSAL_NV_CHECK_BUS_VOLTAGE )
  {
    return NV_OPER_FAILED;
  }
  else if ( len != 0 )
  {
    osalNvHdr_t hdr;
    uint16 origOff, srcOff;
    uint16 cnt, chk;
    uint8 *ptr, srcPg;

    origOff = srcOff = findItem( id );
    srcPg = findPg;
    if ( srcOff == OSAL_NV_ITEM_NULL )
    {
      return NV_ITEM_UNINIT;
    }

    HalFlashRead(srcPg, (srcOff - OSAL_NV_HDR_SIZE), (uint8 *)(&hdr), OSAL_NV_HDR_SIZE);
    if ( hdr.len < (ndx + len) )
    {
      return NV_OPER_FAILED;
    }

    srcOff += ndx;
    ptr = buf;
    cnt = len;
    chk = 0;
    while ( cnt-- )
    {
      uint8 tmp;
      HalFlashRead(srcPg, srcOff, &tmp, 1);
      if ( tmp != *ptr )
      {
        chk = 1;  // Mark that at least one byte is different.
        // Calculate expected checksum after transferring old data and writing new data.
        hdr.chk -= tmp;
        hdr.chk += *ptr;
      }
      srcOff++;
      ptr++;
    }

    if ( chk != 0 )  // If the buffer to write is different in one or more bytes.
    {
      uint8 comPg = OSAL_NV_PAGE_NULL;
      uint8 dstPg = initItem( FALSE, id, hdr.len, &comPg );

      if ( dstPg != OSAL_NV_PAGE_NULL )
      {
        uint16 tmp = OSAL_NV_DATA_SIZE( hdr.len );
        uint16 dstOff = pgOff[dstPg-OSAL_NV_PAGE_BEG] - tmp;
        srcOff = origOff;

        /* Prevent excessive re-writes to item header caused by numerous, rapid, & successive
         * OSAL_Nv interruptions caused by resets.
         */
        if ( hdr.stat == OSAL_NV_ERASED_ID )
        {
          setItem( srcPg, srcOff, eNvXfer );
        }

        xferBuf( srcPg, srcOff, dstPg, dstOff, ndx );
        srcOff += ndx;
        dstOff += ndx;

        writeBuf( dstPg, dstOff, len, buf );
        srcOff += len;
        dstOff += len;

        xferBuf( srcPg, srcOff, dstPg, dstOff, (hdr.len-ndx-len) );

        // Calculate and write the new checksum.
        dstOff = pgOff[dstPg-OSAL_NV_PAGE_BEG] - tmp;

        if ( hdr.chk == calcChkF( dstPg, dstOff, hdr.len ) )
        {
          if ( hdr.chk != setChk( dstPg, dstOff, hdr.chk ) )
          {
            rtrn = NV_OPER_FAILED;
          }
          else
          {
            hotItemUpdate(dstPg, dstOff, hdr.id);
          }
        }
        else
        {
          rtrn = NV_OPER_FAILED;
        }
      }
      else
      {
        rtrn = NV_OPER_FAILED;
      }

      if ( comPg != OSAL_NV_PAGE_NULL )
      {
        /* Even though the page compaction succeeded, if the new item is coming from the compacted
         * page and writing the new value failed, then the compaction must be aborted.
         */
        if ( (srcPg == comPg) && (rtrn == NV_OPER_FAILED) )
        {
          erasePage( pgRes );
        }
        else
        {
          COMPACT_PAGE_CLEANUP( comPg );
        }
      }

      /* Zero of the old item must wait until after compact page cleanup has finished - if the item
       * is zeroed before and cleanup is interrupted by a power-cycle, the new item can be lost.
       */
      if ( (srcPg != comPg) && (rtrn != NV_OPER_FAILED) )
      {
        setItem( srcPg, origOff, eNvZero );
      }
    }
  }

  return rtrn;
}
Example #25
0
FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name,
               const QString &server, const QString &destination,
               OPackageManager::Status status, const QString &category )
    : QDialog( parent, QString::null, true, WStyle_ContextHelp )
{
    setCaption( tr( "Filter packages" ) );

    QVBoxLayout *layout = new QVBoxLayout( this );
    QScrollView *sv = new QScrollView( this );
    layout->addWidget( sv, 0, 0 );
    sv->setResizePolicy( QScrollView::AutoOneFit );
    sv->setFrameStyle( QFrame::NoFrame );
    QWidget *container = new QWidget( sv->viewport() );
    sv->addChild( container );
    layout = new QVBoxLayout( container, 4, 4 );

    // Category
    m_categoryCB = new QCheckBox( tr( "Category:" ), container );
    QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) );
    connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) );
    m_category = new QComboBox( container );
    QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) );
    m_category->insertStringList( pm->categories() );
    initItem( m_category, m_categoryCB, category );
    layout->addWidget( m_categoryCB );
    layout->addWidget( m_category );

    // Package name
    m_nameCB = new QCheckBox( tr( "Names containing:" ), container );
    QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) );
    connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) );
    m_name = new QLineEdit( name, container );
    QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) );
    if ( !name.isNull() )
        m_nameCB->setChecked( true );
    m_name->setEnabled( !name.isNull() );
    layout->addWidget( m_nameCB );
    layout->addWidget( m_name );

    // Status
    m_statusCB = new QCheckBox( tr( "With the status:" ), container );
    QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) );
    connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) );
    m_status = new QComboBox( container );
    QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) );
    connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) );
    QString currStatus;
    switch ( status )
    {
        case OPackageManager::All : currStatus = tr( "All" );
            break;
        case OPackageManager::Installed : currStatus = tr( "Installed" );
            break;
        case OPackageManager::NotInstalled : currStatus = tr( "Not installed" );
            break;
        case OPackageManager::Updated : currStatus = tr( "Updated" );
            break;
        default : currStatus = QString::null;
    };
    m_status->insertItem( tr( "All" ) );
    m_status->insertItem( tr( "Installed" ) );
    m_status->insertItem( tr( "Not installed" ) );
    m_status->insertItem( tr( "Updated" ) );
    initItem( m_status, m_statusCB, currStatus );
    layout->addWidget( m_statusCB );
    layout->addWidget( m_status );

    // Server
    m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container );
    QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) );
    connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) );
    m_server = new QComboBox( container );
    QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) );
    m_server->insertStringList( pm->servers() );
    initItem( m_server, m_serverCB, server );
    layout->addWidget( m_serverCB );
    layout->addWidget( m_server );

    // Destination
    m_destCB = new QCheckBox( tr( "Installed on device at:" ), container );
    QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) );
    connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) );
    m_destination = new QComboBox( container );
    QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) );
    m_destination->insertStringList( pm->destinations() );
    initItem( m_destination, m_destCB, destination );
    layout->addWidget( m_destCB );
    layout->addWidget( m_destination );
}
Example #26
0
/* cAdjust:
 * Use optimization to remove overlaps.
 * Modifications;
 *  - do y;x then x;y and use the better one
 *  - for all overlaps (or if overlap with leftmost nodes), add a constraint;
 *     constraint could move both x and y away, or the smallest, or some
 *     mixture.
 *  - follow by a scale down using actual shapes
 * We use an optimization based on Marriott, Stuckey, Tam and He,
 * "Removing Node Overlapping in Graph Layout Using Constrained Optimization",
 * Constraints,8(2):143--172, 2003.
 * We solve 2 constraint problem, one in X, one in Y. In each dimension,
 * we require relative positions to remain the same. That is, if two nodes
 * have the same x originally, they have the same x at the end, and if one
 * node is to the left of another, it remains to the left. In addition, if
 * two nodes could overlap by moving their X coordinates, we insert a constraint * to keep the two nodes sufficiently apart. Similarly, for Y.
 * 
 * mode = AM_ORTHOXY => first X, then Y
 * mode = AM_ORTHOYX => first Y, then X
 * mode = AM_ORTHO   => first X, then Y
 * mode = AM_ORTHO_YX   => first Y, then X
 * In the last 2 cases, relax the constraints as follows: during the X pass,
 * if two nodes actually intersect and a smaller move in the Y direction
 * will remove the overlap, we don't force the nodes apart in the X direction,
 * but leave it for the Y pass to remove any remaining overlaps. Without this,
 * the X pass will remove all overlaps, and the Y pass only compresses in the
 * Y direction, causing a skewing of the aspect ratio.
 * 
 * mode = AM_ORTHOXY => first X, then Y
 * mode = AM_ORTHOYX => first Y, then X
 * mode = AM_ORTHO   => first X, then Y
 * mode = AM_ORTHO_YX   => first Y, then X
 */
int cAdjust(graph_t * g, int mode)
{
    expand_t margin;
    int ret, i, nnodes = agnnodes(g);
    nitem *nlist = N_GNEW(nnodes, nitem);
    nitem *p = nlist;
    node_t *n;

    margin = sepFactor (g);

    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
	initItem(n, p, margin);
	p++;
    }

    if (overlaps(nlist, nnodes)) {
	point pt;

	switch ((adjust_mode)mode) {
	case AM_ORTHOXY:
	    constrainX(g, nlist, nnodes, intersectY, 1);
	    constrainY(g, nlist, nnodes, intersectX, 1);
	    break;
	case AM_ORTHOYX:
	    constrainY(g, nlist, nnodes, intersectX, 1);
	    constrainX(g, nlist, nnodes, intersectY, 1);
	    break;
	case AM_ORTHO :
	    constrainX(g, nlist, nnodes, intersectY0, 1);
	    constrainY(g, nlist, nnodes, intersectX, 1);
	case AM_ORTHO_YX :
	    constrainY(g, nlist, nnodes, intersectX0, 1);
	    constrainX(g, nlist, nnodes, intersectY, 1);
	case AM_PORTHOXY:
	    constrainX(g, nlist, nnodes, intersectY, 0);
	    constrainY(g, nlist, nnodes, intersectX, 0);
	    break;
	case AM_PORTHOYX:
	    constrainY(g, nlist, nnodes, intersectX, 0);
	    constrainX(g, nlist, nnodes, intersectY, 0);
	    break;
	case AM_PORTHO_YX :
	    constrainY(g, nlist, nnodes, intersectX0, 0);
	    constrainX(g, nlist, nnodes, intersectY, 0);
	    break;
	case AM_PORTHO :
	default :
	    constrainX(g, nlist, nnodes, intersectY0, 0);
	    constrainY(g, nlist, nnodes, intersectX, 0);
	    break;
	}
	p = nlist;
	for (i = 0; i < nnodes; i++) {
	    n = p->np;
	    pt = p->pos;
	    ND_pos(n)[0] = PS2INCH(pt.x) / SCALE;
	    ND_pos(n)[1] = PS2INCH(pt.y) / SCALE;
	    p++;
	}
	ret = 1;
    }
    else ret = 0;
    free(nlist);
    return ret;
}
void GraphicsClientItem::updatePorts()
{
    initItem();
}
Example #28
0
bool PrepareLayer::init()
{
	CCSize size = ToolsFun::sharedTools()->getSceneSize();
	//背景
	CCSprite *spBkg = CCSprite::create("ui/shared/bkg.png");
	this->addChild(spBkg,-1);
	spBkg->setPosition(size/2);

	//放置人物设定背景
	CCSprite *spBkgHero = CCSprite::create("ui/prepareUI/mainbkg.png");
	this->addChild(spBkgHero,-1);
	spBkgHero->setPosition(ccp(size.width/2,size.height - spBkgHero->getContentSize().height/2 - 50*gScaleY));

	//购物
	CCSprite *spBkgTop = CCSprite::create("ui/shared/top.png");
	this->addChild(spBkgTop,0,108);
	spBkgTop->setPosition(ccp(size.width/2,size.height - spBkgTop->getContentSize().height/2));

	//人物游戏记录背景
	CCSprite *spRecoreBkg = CCSprite::create("ui/prepareUI/recordbkg.png");
	this->addChild(spRecoreBkg,-1);
	spRecoreBkg->setPosition(ccp(315*gScaleX,600*gScaleY));
	//spRecoreBkg->setScale(PRE_SCALE);

	//宠物,道具背景
	for (int i=0;i!=1;++i)
	{
		CCSprite *sp = CCSprite::create("ui/shared/placeboard.png");
		this->addChild(sp,-1);
		sp->setPosition(ccp(size.width/4 + i * size.width/2,165*gScaleY));
		sp->setScale(1.10f);
	}

	int level = GameConfigData::initialGameData().getCurLevel();
	int killTotal = 0;

	killTotal = atoi( GameConfigData::initialGameData().getKillTotal().c_str());

	char buf[64];
	sprintf(buf,"%d",killTotal);

	int levelMaxStr = GameConfigData::initialGameData().getMaxUnLockLevel();
	string strs[4] = 
	{
		GameConfigData::initialGameData().getHScores(),
		GameConfigData::initialGameData().getHLenght(),
		string(buf),
		ToolsFun::sharedTools()->intToString(levelMaxStr)
	};

	for (int i=0;i!=4;++i)
	{
		CCLabelBMFont *hScores = CCLabelBMFont::create(strs[i].c_str() ,"font/white_30.fnt");
		spRecoreBkg->addChild(hScores);
		hScores->setPosition(ccp(150*gScaleX,(165-8-38*i))*gScaleY);
		hScores->setAnchorPoint(ccp(0,0.5f));
	}

	m_menu = CCMenu::create();
	this->addChild(m_menu,1);
	m_menu->setPosition(CCPointZero);

	//所有按钮的放置
	const char* fName[9] = 
	{
		"ui/shared/back.png",//返回
		"ui/shared/coinplus.png",//添加金币
		"ui/prepareUI/head.png",//主角头像
		"ui/prepareUI/upgrade.png",//升级按钮
		"ui/shared/shop_item.png",//宠物1
		"ui/shared/shop_item.png",//宠物2
		"ui/shared/shop_item.png",//道具1
		//	"ui/shared/shop_item.png",//道具2
		"ui/shared/confirm.png"//确定开始游戏
	};

	const CCPoint posArray[9] = 
	{
		ccp(37*gScaleX,size.height-37*gScaleY),ccp(430*gScaleX,size.height-30*gScaleY),ccp(290*gScaleX,435*gScaleY),ccp(360*gScaleX,335*gScaleY),
		ccp(54*gScaleX,145*gScaleY),ccp(144*gScaleX,145*gScaleY),ccp(355*gScaleX,145*gScaleY),ccp(235*gScaleX,40*gScaleY),ccp(235*gScaleX,40*gScaleY)
	};

	for (int i=0;i!=8;++i)
	{
		CCSprite *spNml = CCSprite::create(fName[i]);
		CCSprite *spSel = CCSprite::create(fName[i]);
		spSel->setColor(ccc3(80,80,80));
		CCMenuItemSprite *itemSp = CCMenuItemSprite::create(spNml,spSel,
			this,menu_selector(PrepareLayer::menuTouch));
		if(i==2)
		{
			m_menu->addChild(itemSp,1,100+i);
			itemSp->setPosition(posArray[i]);
			itemSp->setScale(0.8f);
		}
		else if(i ==3)
		{
			m_menu->addChild(itemSp,1,100+i);
			itemSp->setPosition(posArray[i]);
			itemSp->setScale(PRE_SCALE);

			CCLabelBMFont *upGrade = CCLabelBMFont::create(gGetLanguageDesc(K.UPGRADE_DES).c_str(),"font/upgrade_des.fnt");
			itemSp->addChild(upGrade);
			upGrade->setPosition(ccp(80*gScaleX,-25*gScaleY));
		}
		else
		{
			m_menu->addChild(itemSp,1,100+i);
			itemSp->setPosition(posArray[i]);
		}
	}

	int curLevel  = GameConfigData::initialGameData().getCurHeroLevel();
	if (curLevel >= HERO_MAXLEVEL)
	{
		CCMenuItemSprite *upItem = (CCMenuItemSprite*)m_menu->getChildByTag(103);
		upItem->setEnabled(false);
		upItem->setVisible(false);
		if (this->getChildByTag(1430))
		{
			this->getChildByTag(1430)->setVisible(false);
		}
	}

	//金币放置最上方商城

	CCSprite *coinIcon = CCSprite::create("ui/shared/coin.png");
	this->addChild(coinIcon,2,1429);
	coinIcon->setPosition(ccp(280 * gScaleX, size.height - 30 * gScaleY));

	m_moneyLabel = CCLabelBMFont::create("10000000","font/level_big.fnt");
	this->addChild(m_moneyLabel,4);
	m_moneyLabel->setAnchorPoint(ccp(0,0.5f));
	m_moneyLabel->setPosition(ccp(300*gScaleX,size.height-25*gScaleY));
	m_moneyLabel->setScale(0.6F);

	setCoin();

	//升级所需金币数
	m_nextLevelPriceLabel = CCLabelBMFont::create("1000000000","font/level_big.fnt");
	this->addChild(m_nextLevelPriceLabel,2);
	m_nextLevelPriceLabel->setPosition(ccp(345*gScaleX,342*gScaleY));
	m_nextLevelPriceLabel->setScale(0.45);

	int curHeroId = GameConfigData::initialGameData().getCurHeroId();
	int heroLevel = GameConfigData::initialGameData().getCurHeroLevel();

	//名字label
	m_heroNameLabel = CCLabelBMFont::create("name","font/hero_name.fnt");
	this->addChild(m_heroNameLabel,10);
	m_heroNameLabel->setPosition(ccp(390*gScaleX,475*gScaleY));
	m_heroNameLabel->setScale(0.8f);

	//主角现在等级
	CCSprite* curHeroLevel=CCSprite::create("ui/prepareUI/level.png");
	this->addChild(curHeroLevel,2);
	curHeroLevel->setPosition(ccp(370*gScaleX,445*gScaleY));
	curHeroLevel->setScale(0.8f);

	//数字改变部分
	m_curHeroLevel = CCLabelBMFont::create("10000000",GOLD_FONT);
	this->addChild(m_curHeroLevel,2);
	m_curHeroLevel->setPosition(ccp(420*gScaleX,445*gScaleY));
	string levelStr = ToolsFun::sharedTools()->intToString(heroLevel);
	m_curHeroLevel->setString((levelStr).c_str());
	m_curHeroLevel->setScale(0.8f);

	//点击头像改变
	CCSprite* changeName=CCSprite::create("ui/prepareUI/changename.png");
	this->addChild(changeName,2);
	changeName->setPosition(ccp(390*gScaleX,400*gScaleY));
	changeName->setScale(0.8f);

	CCSprite *itemBkg = CCSprite::create("ui/shared/itemBkg.png");
	this->addChild(itemBkg);
	itemBkg->setPosition(ccp(360,145));
	initPet(0);
	initPet(1);
	initHeroSp(GameConfigData::initialGameData().getCurHeroId());
	initItem(0);
	//initItem(1);

	playUpEffect(heroLevel,false);

	registerNDK();

	return true;
}