Esempio n. 1
0
Image
ws_grab_image_display(DisplayObj d, int x, int y, int width, int height)
{ HDC hdc = GetDC(NULL);
  RECT rect;
  Image image;
  int w, h;
  HBITMAP obm, bm;
  HDC hdcimg;
  Size size = getSizeDisplay(d);

  rect.left   = x;
  rect.top    = y;
  rect.right  = x + width;
  rect.bottom = y + height;
  if ( rect.left < 0 ) rect.left = 0;
  if ( rect.top < 0 )  rect.top  = 0;
  if ( rect.bottom > valInt(size->h) ) rect.bottom = valInt(size->h);
  if ( rect.right >  valInt(size->w) ) rect.right  = valInt(size->w);

  w = rect.right - rect.left;
  h = rect.bottom - rect.top;

  image = answerObject(ClassImage, NIL,
		       toInt(w), toInt(h), NAME_pixmap, EAV);
  assign(image, display, d);
  bm = ZCreateCompatibleBitmap(hdc, w, h);
  hdcimg = CreateCompatibleDC(hdc);
  obm = SelectObject(hdcimg, bm);

  BitBlt(hdcimg, 0, 0, w, h, hdc, rect.left, rect.top, SRCCOPY);

  SelectObject(hdcimg, obm);
  ZDeleteObject(hdcimg);
  ReleaseDC(NULL, hdc);

  registerXrefObject(image, image->display, (void *) bm);

  return image;
}
Esempio n. 2
0
void MenuItem::updateSizes(){
  //this method only works if the device is currently mounted
  bool ok = FALSE;
  if(isMounted()){
    QString cmd = "df \""+mountpoint+"\"";
    QStringList output = systemCMD(cmd); //make sure we use the one with a 1K blocksize
    if(output.length() > 1){
      //parse the output (1K blocks) and save them
      QString line = output[1].replace("\t"," ");
      //qDebug() << "df output:" << output << cmd;
      maxSize = line.section(" ",1,1,QString::SectionSkipEmpty).simplified();
      currentSize = line.section(" ",2,2,QString::SectionSkipEmpty).simplified();
      ok=TRUE;
    }else{
      maxSize.clear();
      currentSize.clear();	    
    }
  }else{
    maxSize.clear();
    currentSize.clear();
  }
  //Now setup the display progressbar display
  if(ok){
    currentSpace->setMaximum( maxSize.toInt() );
    currentSpace->setValue( currentSize.toInt() );
    currentSpace->setVisible(TRUE);
    //display the actual size available in the tooltip
    QString diskAvailable = getSizeDisplay( maxSize.toInt() - currentSize.toInt() );
    //qDebug() << "MaxSize:" << maxSize << maxSize.toInt();
    //qDebug() << "CurrentSize:" << currentSize << currentSize.toInt();
    //qDebug() << "Disk Available:" << diskAvailable;
    currentSpace->setToolTip( QString( tr("%1 of disk space available") ).arg(diskAvailable) );
  }else{
    currentSpace->setVisible(FALSE);
  }
  	
}