IntegerStyleRange1OutPropertyGeneralWidget::IntegerStyleRange1OutPropertyGeneralWidget(IntegerStyleRange1Out * comp, QWidget *parent, const char *name)
    :	IntegerStyle1OutPropertyGeneralWidget(comp, parent, name)
{
    m_maxValueLabel = new QLabel(i18n("Maximum value: "), this, "MaxValueLabel");
    Q_CHECK_PTR(m_maxValueLabel);

    m_maxValue = new KSimBaseIntEdit(this, "MaxValue");
    Q_CHECK_PTR(m_maxValue);
    QString tip(i18n("The maximum value of the component."));
    addToolTip(tip, m_maxValue, m_maxValueLabel);
    addWhatsThis(tip, m_maxValue, m_maxValueLabel);
    m_maxValueLabel->setBuddy(m_maxValue);


    m_minValueLabel = new QLabel(i18n("Minimum value: "), this, "MinValueLabel");
    Q_CHECK_PTR(m_minValueLabel);

    m_minValue = new KSimBaseIntEdit(this, "MinValue");
    Q_CHECK_PTR(m_minValue);
    tip = i18n("The minimum value of the component.");
    addToolTip(tip, m_minValue, m_minValueLabel);
    addWhatsThis(tip, m_minValue, m_minValueLabel);
    m_minValueLabel->setBuddy(m_minValue);

    // Setup value
    m_maxValue->setValue(comp->getMaxValue());
    m_minValue->setValue(comp->getMinValue());
}
ConvertBoolFloatPropertyGeneralWidget::ConvertBoolFloatPropertyGeneralWidget(ConvertBoolFloat * comp, QWidget *parent, const char *name)
	:	ComponentPropertyGeneralWidget(comp, parent, name)
{
	QString tip;
	
	m_trueValueLabel = new QLabel(i18n("FloatingPoint", "True Value: "), this, "m_trueValueLabel");
	Q_CHECK_PTR(m_trueValueLabel);
	
	m_trueValue = new KSimDoubleEdit(this, "m_trueValue");
	Q_CHECK_PTR(m_trueValue);
	tip = i18n("FloatingPoint", "Sets the value which represents the true level.");
	addToolTip(tip, m_trueValue, m_trueValueLabel);
	addWhatsThis(tip, m_trueValue, m_trueValueLabel);
	m_trueValueLabel->setBuddy(m_trueValue);
	
	
	m_falseValueLabel = new QLabel(i18n("FloatingPoint", "False Value: "), this, "m_falseValueLabel");
	Q_CHECK_PTR(m_falseValueLabel);
	
	m_falseValue = new KSimDoubleEdit(this, "m_falseValue");
	Q_CHECK_PTR(m_falseValue);
	tip = i18n("FloatingPoint", "Sets the value which represents the false level.");
	addToolTip(tip, m_falseValue, m_falseValueLabel);
	addWhatsThis(tip, m_falseValue, m_falseValueLabel);
	m_falseValueLabel->setBuddy(m_falseValue);
	
	
	// Setup value
	m_trueValue->setValue(comp->getTrueValue());
	m_falseValue->setValue(comp->getFalseValue());
}
FloatLatchPropertyGeneralWidget::FloatLatchPropertyGeneralWidget(FloatLatch * comp, QWidget *parent, const char *name)
	:	ComponentPropertyGeneralWidget(comp, parent, name)
{
	
	QString tip;
	m_min = QMAX ( comp->getInputPack()->getNumberOfNotDeletableConnectors(),
	               comp->getOutputPack()->getNumberOfNotDeletableConnectors());

	
	m_channelsLabel = new QLabel(i18n("Channel count: "), getGrid(), "m_channelsLabel");
	CHECK_PTR(m_channelsLabel);
	
	m_channels = new QSpinBox(m_min, MAX_CHANNELS, 1, getGrid(), "m_channels");
	CHECK_PTR(m_channels);
	tip = i18n("Change count of channels here.");
	addToolTip(tip, m_channels, m_channelsLabel);
	addWhatsThis(tip, m_channels, m_channelsLabel);
	
	
	m_resetValueLabel = new QLabel(i18n("Reset value: "), getGrid(), "m_resetValueLabel");
	CHECK_PTR(m_resetValueLabel);
	
	m_resetValue = new KSimDoubleEdit(getGrid(), "m_resetValue");
	CHECK_PTR(m_resetValue);
	tip = i18n("Change the reset value of the component here.");
	addToolTip(tip, m_resetValue, m_resetValueLabel);
	addWhatsThis(tip, m_resetValue, m_resetValueLabel);
	
	
	// Setup value
	m_resetValue->setValue(comp->getResetValue());
	m_channels->setValue(comp->getInputPack()->getConnectorCount());
}
ConvertIntegerBool::PropertyGeneralWidget::PropertyGeneralWidget(ConvertIntegerBool * comp, QWidget *parent, const char *name)
	:	ComponentPropertyGeneralWidget(comp, parent, name)
{
	QString tip;
	
	m_trueThresholdLabel = new QLabel(i18n("Integer", "True Threshold: "), this, "m_trueThresholdLabel");
	Q_CHECK_PTR(m_trueThresholdLabel);
	
	m_trueThreshold = new KSimBaseIntEdit(this, "m_trueThreshold");
	Q_CHECK_PTR(m_trueThreshold);
	tip = i18n("Integer", "Sets the threshold where the converter switch to true.");
	addToolTip(tip, m_trueThreshold, m_trueThresholdLabel);
	addWhatsThis(tip, m_trueThreshold, m_trueThresholdLabel);
	m_trueThresholdLabel->setBuddy(m_trueThreshold);


	m_falseThresholdLabel = new QLabel(i18n("Integer", "False Threshold: "), this, "m_falseThresholdLabel");
	Q_CHECK_PTR(m_falseThresholdLabel);

	m_falseThreshold = new KSimBaseIntEdit(this, "m_falseThreshold");
	Q_CHECK_PTR(m_falseThreshold);
	tip = i18n("Integer", "Sets the threshold where the converter switch to false.");
	addToolTip(tip, m_falseThreshold, m_falseThresholdLabel);
	addWhatsThis(tip, m_falseThreshold, m_falseThresholdLabel);
	m_falseThresholdLabel->setBuddy(m_falseThreshold);

	// Setup value
	m_trueThreshold->setValue(comp->getTrueThreshold());
	m_falseThreshold->setValue(comp->getFalseThreshold());
}
void ToolTipItem::refresh(struct graphics_context *gc, QPointF pos)
{
    clear();
    int time = (pos.x() * gc->maxtime) / gc->maxx;
    char buffer[500];
    get_plot_details(gc, time, buffer, 500);
    addToolTip(QString(buffer));

    QList<QGraphicsItem*> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, transform());
    Q_FOREACH(QGraphicsItem *item, items) {
        if (!item->toolTip().isEmpty())
            addToolTip(item->toolTip());
    }

}
ExtConnIntegerIn::PropertyGeneralWidget::PropertyGeneralWidget(ExtConnIntegerIn * comp, QWidget *parent, const char *name)
	:	ExternalConnectorPropertyGeneralWidget(comp, parent, name)
{
	m_defaultValueLabel = new QLabel(i18n("Integer", "Default value:"), this, "m_defaultValueLabel");
	Q_CHECK_PTR(m_defaultValueLabel);

	m_defaultValue = new KSimBaseIntEdit(this, "m_defaultValue");
	Q_CHECK_PTR(m_defaultValue);
	QString tip(i18n("Integer", "Sets the value state of the external connector.\n"
	                            "This value is used if the external connector is not connected."));
	addToolTip(tip, m_defaultValue, m_defaultValueLabel);
	addWhatsThis(tip, m_defaultValue, m_defaultValueLabel);
	m_defaultValueLabel->setBuddy(m_defaultValue);



	// Setup value
	m_defaultValue->setValue(getExtConnIn()->getDefaultValue());
}
ComponentPropertyStyleWidget::ComponentPropertyStyleWidget(ComponentStyle * comp, QWidget *parent, const char *name)
	:	ComponentPropertyBaseWidget(comp, 1, parent, name)
{
	setCenterColStretch(0);
	setRightColStretch(1);
	
	QString str;
	QLabel * label;
	
	// Color Group	
	m_colorGroup = new QVGroupBox(i18n("Color:"), this, "Style Color Box");
	Q_CHECK_PTR(m_colorGroup);
	
	// Color Group - Default colors
	m_defaultColors = new QCheckBox(i18n("Use system colors"), getColorBox(), "Default Colors");
	Q_CHECK_PTR(m_defaultColors);
	str = i18n("Check the box if the component have to use the color scheme of your system.");
	addToolTip(str, m_defaultColors);
	addWhatsThis(str, m_defaultColors);
	
	// Color Group - Color button group
	QGrid * colButGrp = new QGrid(2, /*QGrid::Horizontal,*/ getColorBox());
	Q_CHECK_PTR(colButGrp);
	
	// Color Group - Color button group - Foreground color
	label = new QLabel(i18n("Foreground Color:"), colButGrp);
	Q_CHECK_PTR(label);
	m_foreGround = new KColorButton(colButGrp);
	Q_CHECK_PTR(m_foreGround);
	label->setBuddy(m_foreGround);
	str = i18n("Select the foreground color.");
	addToolTip(str, m_foreGround, label);
	addWhatsThis(str, m_foreGround, label);

	// Color Group - Color button group - Background color
	label = new QLabel(i18n("Background Color:"), colButGrp);
	Q_CHECK_PTR(label);
	m_backGround = new KColorButton(colButGrp);
	Q_CHECK_PTR(m_backGround);
	label->setBuddy(m_backGround);
	str = i18n("Select the background color.");
	addToolTip(str, m_backGround, label);
	addWhatsThis(str, m_backGround, label);

	
	// Frame Group	
	m_frameGroup = new QVGroupBox(i18n("Frame:"), this, "Style Frame Box");
	Q_CHECK_PTR(m_frameGroup);
	
	// Frame Group - Frame ena
	m_enaFrame = new QCheckBox(i18n("Enable frame in user interface"), getFrameBox(), "Frame Ena");
	Q_CHECK_PTR(m_enaFrame);
	str = i18n("Check the box if component have to display a frame.");
	addToolTip(str, m_enaFrame);
	addWhatsThis(str, m_enaFrame);
	
	
	// Font Group	
	m_fontGroup = new QVGroupBox(i18n("Font:"), this, "Style Font Box");
	Q_CHECK_PTR(m_fontGroup);
	
	// Font Group - Default Font
	m_defaultFont = new QCheckBox(i18n("Use default font"), getFontBox(), "Font default");
	Q_CHECK_PTR(m_defaultFont);
	str = i18n("Check the box if component have to use the default (the application) font.");
	addToolTip(str, m_defaultFont);
	addWhatsThis(str, m_defaultFont);
	
	// Font Group - Font Dialog Button
  m_fontButton = new QPushButton(i18n("Select font"), getFontBox(), "Font Button");
	Q_CHECK_PTR(m_fontButton);
	
	m_exampleFont = new QLabel(getFontBox(), "Font Example");
	Q_CHECK_PTR(m_fontButton);
	


  //######## Setup values
  //*** color ***
  // Ena color box
	if (!getCompStyle()->isColorAdjustmentEnabled())
		getColorBox()->hide();
	// def color
	bool useDefaultColor = !(getCompStyle()->getForegroundColor().isValid()
	                        && getCompStyle()->getBackgroundColor().isValid());
	
	m_defaultColors->setChecked(useDefaultColor);
	// Fore color
	if (getCompStyle()->getForegroundColor().isValid())
	{
		m_foreGround->setColor(getCompStyle()->getForegroundColor());
	}
	else
	{
		m_foreGround->setColor(palette().color(QPalette::Active, QColorGroup::Foreground));
	}
	m_foreGround->setDisabled(useDefaultColor);
	connect(m_defaultColors, SIGNAL(toggled(bool)), m_foreGround, SLOT(setDisabled(bool)));
	// Back color
	if (getCompStyle()->getBackgroundColor().isValid())
	{
		m_backGround->setColor(getCompStyle()->getBackgroundColor());
	}
	else
	{
		m_backGround->setColor(palette().color(QPalette::Active, QColorGroup::Background));
	}
	m_backGround->setDisabled(useDefaultColor);
	connect(m_defaultColors, SIGNAL(toggled(bool)), m_backGround, SLOT(setDisabled(bool)));
	
	
	
  //*** frame ***
  // Ena frame box
	if (!getCompStyle()->isFrameAdjustmentEnabled())
		getFrameBox()->hide();
	// frame ena
	m_enaFrame->setChecked(getCompStyle()->isFrameEnabled());
		

  //*** font ***
  // Ena color box
	if (!getCompStyle()->isFontAdjustmentEnabled())
		getFontBox()->hide();
	m_defaultFont->setChecked(getCompStyle()->isDefaultFontEnabled());
	m_fontButton->setDisabled(getCompStyle()->isDefaultFontEnabled());
	connect(m_defaultFont, SIGNAL(toggled(bool)), m_fontButton, SLOT(setDisabled(bool)));
	connect(m_fontButton, SIGNAL(clicked()), this, SLOT(slotFontDialog()));
	m_font = getCompStyle()->getFont();
	m_exampleFont->setFont(m_font);
	m_exampleFont->setText(m_font.family());
	connect(m_defaultFont, SIGNAL(toggled(bool)), m_exampleFont, SLOT(setDisabled(bool)));
		
}
BOOL CUserOptions::OnInitDialog()
{
	CDialog::OnInitDialog();

  CString s1;

  s1.LoadStringW( IDS_CPUPOL1 );

  addToolTip( 0, IDC_EDIT1, s1 );
  addToolTip( 1, IDC_EDIT2, s1 );

  s1.LoadStringW( IDS_CPUPOL2 );
  addToolTip( 2, IDC_EDIT3, s1 );
  addToolTip( 3, IDC_EDIT4, s1 );

  s1.LoadStringW( IDS_CPUPOL3 );
  addToolTip( 4, IDC_COMBO1, s1 );
  addToolTip( 5, IDC_COMBO2, s1 );

  s1.LoadStringW( IDS_CPUPOL4 );
  addToolTip( 6, IDC_COMBO3, s1 );
  addToolTip( 7, IDC_COMBO4, s1 );

  s1.LoadStringW( IDS_CPUPOL5 );
  addToolTip( 8, IDC_EDIT5, s1 );
  addToolTip( 9, IDC_EDIT7, s1 );

  s1.LoadStringW( IDS_CPUPOL6 );
  addToolTip( 10, IDC_EDIT8, s1 );
  addToolTip( 11, IDC_EDIT6, s1 );

  s1.LoadStringW( IDS_CPUPOL7 );
  addToolTip( 12, IDC_COMBO5, s1 );
  addToolTip( 13, IDC_COMBO6, s1 );

  s1.LoadStringW( IDS_CPUPOL8 );
  addToolTip( 14, IDC_EDIT10, s1 );
  addToolTip( 15, IDC_EDIT9, s1 );

  s1.LoadStringW( IDS_CPUPOL9 );
  addToolTip( 16, IDC_EDIT11, s1 );
  addToolTip( 17, IDC_EDIT12, s1 );

  return TRUE;
}