Exemple #1
0
void KURLLabel::m_resetPalette()
{
	/* reset the palette with any colors that have changed */
	m_nsp.setNormal(
		QColorGroup(
			m_hc,
			m_bc,
			palette().normal().light(),
			palette().normal().dark(),
			palette().normal().mid(),
			m_hc,
			palette().normal().base()
		)
	);
	m_sp.setNormal(
		QColorGroup(
			m_sc,
			m_bc,
			palette().normal().light(),
			palette().normal().dark(),
			palette().normal().mid(),
			m_sc,
			palette().normal().base()
		)
	);
}
void K3DockButton_Private::drawButton( QPainter* p )
{
  p->fillRect( 0,0, width(), height(), QBrush(QColorGroup(palette()).brush(QPalette::Background)) );
#if 1
  // ### TODO: is the centering done automatically or do we need some codelike for KDE3 (see below the #else part)
  icon().paint( p, rect() );
#else
  p->drawPixmap( (width() - pixmap()->width()) / 2, (height() - pixmap()->height()) / 2, *pixmap() );
#endif
  if ( moveMouse && !isDown() ){
    p->setPen( Qt::white );
    p->drawLine( 0, height() - 1, 0, 0 );
    p->drawLine( 0, 0, width() -1 , 0 );

    p->setPen( QColorGroup(palette()).dark() );
    p->drawLine( width() -1, 0, width() - 1, height() - 1 );
    p->drawLine( width() - 1, height() - 1, 0, height() - 1 );
  }
  if ( isChecked() || isDown() ){
    p->setPen( QColorGroup(palette()).dark() );
    p->drawLine(0 , height() - 1, 0, 0);
    p->drawLine(0, 0, width() -1 , 0);

    p->setPen( Qt::white );
    p->drawLine(width() - 1, height() - 1, 0, height() - 1);
  }
}
Exemple #3
0
QPalette::QPalette( const QColor &button, const QColor &background )
{
    data = new QPalData;
    Q_CHECK_PTR( data );
    data->ser_no = palette_count++;
    QColor bg = background, btn = button, fg, base, disfg;
    int h, s, v;
    bg.hsv( &h, &s, &v );
    if ( v > 128 ) {				// light background
	fg   = Qt::black;
	base = Qt::white;
	disfg = Qt::darkGray;
    } else {					// dark background
	fg   = Qt::white;
	base = Qt::black;
	disfg = Qt::darkGray;
    }
    data->active   = QColorGroup( fg, btn, btn.light(150), btn.dark(),
				  btn.dark(150), fg, Qt::white, base, bg );
    data->disabled = QColorGroup( disfg, btn, btn.light(150), btn.dark(),
				  btn.dark(150), disfg, Qt::white, base, bg );
    data->inactive = data->active;
}
Exemple #4
0
void PWidget::messageHandler(int fd, PukeMessage *pm)
{
  PukeMessage pmRet;
  switch(pm->iCommand){
  case PUKE_WIDGET_SHOW:
    widget()->show();
    pmRet.iCommand = PUKE_WIDGET_SHOW_ACK;
    pmRet.iWinId = pm->iWinId;
    pmRet.iArg = 0;
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;
  case PUKE_WIDGET_HIDE:
    widget()->hide();
    pmRet.iCommand = PUKE_WIDGET_HIDE_ACK;
    pmRet.iWinId = pm->iWinId;
    pmRet.iArg = 0;
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;    
  case PUKE_WIDGET_REPAINT:
    widget()->repaint(pm->iArg);
    pmRet.iCommand = PUKE_WIDGET_REPAINT_ACK;
    pmRet.iWinId = pm->iWinId;
    pmRet.iArg = 0;
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;
  case PUKE_WIDGET_RESIZE:
    {
      int x, y;
      int found = sscanf(pm->cArg, "%d\t%d", &x, &y);
      if(found != 2)
	throw(errorCommandFailed(PUKE_INVALID,10));

      widget()->resize(x, y);

      pmRet.iCommand = PUKE_WIDGET_RESIZE_ACK;
      pmRet.iWinId = pm->iWinId;      
      pmRet.iArg = pm->iArg;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
    }
    break;
  case PUKE_WIDGET_MOVE:
    {
      int x, y;
      int found = sscanf(pm->cArg, "%d\t%d", &x, &y);
      if(found != 2)
	throw(errorCommandFailed(PUKE_INVALID,10));
      
      //      debug("Moving to: %d => %d %d", pm->iArg, pos[0], pos[1]);
      widget()->move(x, y);
      pmRet.iCommand = PUKE_WIDGET_MOVE_ACK;
      pmRet.iWinId = pm->iWinId;      
      pmRet.iArg = 0;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
    }
    break;
  case PUKE_WIDGET_SETMINSIZE:
    {
      int x, y;
      int found = sscanf(pm->cArg, "%d\t%d", &x, &y);
      if(found != 2)
	throw(errorCommandFailed(PUKE_INVALID,11));

      widget()->setMinimumSize(x, y);

      pmRet.iCommand = PUKE_WIDGET_SETMINSIZE_ACK;
      pmRet.iWinId = pm->iWinId;      
      pmRet.iArg = 0;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
    }
    break;
  case PUKE_WIDGET_SETMAXSIZE:
    {
      int x, y;
      int found = sscanf(pm->cArg, "%d\t%d", &x, &y);
      if(found != 2)
	throw(errorCommandFailed(PUKE_INVALID,12));

      widget()->setMaximumSize(x, y);

      pmRet.iCommand = -pm->iCommand;
      pmRet.iWinId = pm->iWinId;      
      pmRet.iArg = pm->iArg;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
      break;
    }
  case PUKE_WIDGET_SETCAPTION:
    widget()->setCaption(pm->cArg);
    pmRet.iCommand = PUKE_WIDGET_SETCAPTION_ACK;
    pmRet.iWinId = pm->iWinId;
    pmRet.iArg = 0;
    pmRet.iTextSize = strlen(widget()->caption());
    pmRet.cArg = strdup(widget()->caption());
    emit outputMessage(fd, &pmRet);
    free(pmRet.cArg);
    break;
  case PUKE_WIDGET_GET_BACKGROUND_COLOUR:
    {
      pmRet.cArg = new char[15];
      pmRet.iTextSize = 15;
      QColor back = widget()->backgroundColor();
      sprintf(pmRet.cArg, "%d,%d,%d", back.red(), back.green(), back.blue());
      
      pmRet.iCommand = -pm->iCommand;
      pmRet.iWinId = pm->iWinId;      
      pmRet.iArg = 0;
      emit outputMessage(fd, &pmRet);
      delete pmRet.cArg;
      break;
    }
  case PUKE_WIDGET_SET_BACKGROUND_PIXMAP:
    widget()->setBackgroundPixmap(QPixmap(pm->cArg));

    pmRet.iCommand = -pm->iCommand;
    pmRet.iWinId = pm->iWinId;
    pmRet.iArg = 0;
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;
  case PUKE_WIDGET_SET_BACKGROUND_MODE:
    widget()->setBackgroundMode((QWidget::BackgroundMode) pm->iArg);

    pmRet.iCommand = -pm->iCommand;
    pmRet.iWinId = pm->iWinId;
    pmRet.iArg = (int) widget()->backgroundMode();
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;

  case PUKE_WIDGET_SET_BACKGROUND_COLOUR:
    {
      int *pos;
      pos = (int *) pm->cArg;
      QColor bg(pos[0], pos[1], pos[2]);
      QColorGroup cg = QColorGroup(widget()->colorGroup().foreground(),
                                   bg,
                                   widget()->colorGroup().light(),
                                   widget()->colorGroup().dark(),
                                   widget()->colorGroup().mid(),
                                   widget()->colorGroup().text(),
                                   bg);
      widget()->setPalette(QPalette(cg,cg,cg));

      pmRet.iCommand = -pm->iCommand;
      pmRet.iWinId = pm->iWinId;      
      pmRet.iArg = 0;
      pmRet.cArg = 0;
      emit outputMessage(fd, &pmRet);
      break;
    }

  case PUKE_WIDGET_SET_ENABLED:
    widget()->setEnabled((bool) pm->iArg);
    pmRet.iCommand = PUKE_WIDGET_SET_ENABLED_ACK;
    pmRet.iWinId = pm->iWinId;
    pmRet.iArg = 0;
    pmRet.cArg = 0;
    emit outputMessage(fd, &pmRet);
    break;
  case PUKE_WIDGET_RECREATE:
  {
    QWidget *nparent = 0x0;
    if(pm->iArg != 0x0){
      widgetId wiWidget;
      wiWidget.fd = fd;
      wiWidget.iWinId = pm->iArg;
      nparent = controller()->id2pwidget(&wiWidget)->widget();
    }
    if(pm->iTextSize != 3*sizeof(int)){
       throw(errorCommandFailed(pm->iCommand, pm->iArg));
    }
    int *point_show = (int *) pm->cArg;

    warning("Recreate: %d %d %d", point_show[0], point_show[1], point_show[3]);
    
    widget()->recreate(nparent, (WFlags) 0, QPoint(point_show[0], point_show[1]), point_show[3]);

   pmRet.iCommand = PUKE_WIDGET_RECREATE_ACK;
   pmRet.iWinId = pm->iWinId;
   pmRet.iArg = 0;
   pmRet.cArg = 0;
   emit outputMessage(fd, &pmRet);
   break; 
  }
  default:
    PObject::messageHandler(fd, pm);
  }
}
	void KviCanvasRichText::draw(QPainter & p)
	{
		if(isEnabled())
		{
			QString szText = m_properties["szText"].asString();
			QSimpleRichText text(szText,m_properties["fntDefault"].asFont());
			text.setWidth(width());
			text.draw(&p,(int)x() + 1,(int)y() + 1,QRegion(QRect((int)x() + 1,(int)y() + 1,width(),height())),QColorGroup());
		}

		if(isSelected())drawSelection(p);
	}