예제 #1
0
void ShowWidget::DisplayAnswer()
{
    Table t = this->table;

    QLayoutItem *child;
    while((child = gridlayout->takeAt(0)) != 0)
    {
        delete child->widget();
        delete child;
    }

    for(int i=0;i<t.n;i++)
        for(int j=0;j<t.n;j++)
        {
            QLabel *label = new QLabel();
            QPixmap pmap(":/new/prefix1/Back");
            QPainter painter1;
            QFont font1("Arial",13,QFont::Bold,false);
            QFont font2("Arial",9,QFont::Bold,false);
            painter1.begin(&pmap);
            if(t.n<10) painter1.setFont(font1);
            else painter1.setFont(font2);
            painter1.setPen(Qt::blue);
            painter1.drawText(3,3,20,20,Qt::AlignCenter,QString::number(t.data[i][j],10));//将数字转化成输出
            painter1.end();
            label->setPixmap(pmap);
            gridlayout->addWidget(label,i,j);
        }

    this->setWindowTitle(QString::number(t.n,10) + tr("阶魔方阵"));
    this->show();
}
예제 #2
0
CNotificationDlg::CNotificationDlg(CWnd* pParent /*=NULL*/, wchar_t* title, wchar_t* content, int _idx, int _uid)
	: CDialog(CNotificationDlg::IDD, pParent)
{
	idx=_idx;
	uid=_uid;
	CDC scrdc;
	scrdc.Attach(::GetDC(0));
	bdc.CreateCompatibleDC(&scrdc);
	CBitmap bmp;
	bmp.CreateCompatibleBitmap(&scrdc, 200, 95);
	CBitmap* obmp=bdc.SelectObject(&bmp);
	skin.notifierBG.DrawUnscaled(&bdc, 0, 0, 200, 95, 0, 0);
	skin.tabCloseInact.DrawUnscaled(&bdc, 168, 15, 15, 15, 0, 0);
	std::wstring _content=content;
	int cl=_content.length();
	int nPos;
	while((nPos=_content.find(L"<br>"))!=-1){
		_content.replace(nPos, 4, L" ");
		cl-=3;
	}
	while((nPos=_content.find(L"&lt;"))!=-1){
		_content.replace(nPos, 4, L"<");
		cl-=3;
	}
	while((nPos=_content.find(L"&gt;"))!=-1){
		_content.replace(nPos, 4, L">");
		cl-=3;
	}
	while((nPos=_content.find(L"&quot;"))!=-1){
		_content.replace(nPos, 6, L"\"");
		cl-=5;
	}
	while((nPos=_content.find(L"&amp;"))!=-1){
		_content.replace(nPos, 5, L"&");
		cl-=4;
	}

	Gdiplus::Graphics g(bdc.GetSafeHdc());
    Gdiplus::FontFamily ff(_T("Tahoma"));
    Gdiplus::Font font(&ff, 11, Gdiplus::FontStyleBold, Gdiplus::UnitPixel);
	Gdiplus::Font font2(&ff, 11, Gdiplus::FontStyleRegular, Gdiplus::UnitPixel);
    Gdiplus::PointF pt(15, 40);
	Gdiplus::RectF rc(15,55, 170, 27);
	Gdiplus::SolidBrush brush1(Gdiplus::Color(254, GetRValue(skin.notifyTitleColor), GetGValue(skin.notifyTitleColor), GetBValue(skin.notifyTitleColor)));
	Gdiplus::SolidBrush brush2(Gdiplus::Color(254, GetRValue(skin.notifyTextColor), GetGValue(skin.notifyTextColor), GetBValue(skin.notifyTextColor)));
    g.DrawString(title, wcslen(title), &font, pt, &brush1);
	g.DrawString(_content.c_str(), wcslen(content), &font2, rc, NULL, &brush2);

	::ReleaseDC(0, scrdc);

	mouseInside=true;
	needClose=false;
	_i=0;

	Create(IDD, pParent);
}
                               int *width, int *height) const
#else
/** Get required size for cell.
 * @param widget widget
 * @param cell_area area of the cell
 * @param x_offset ignored
 * @param y_offset ignored
 * @param width upon return contains the required width of the cell
 * @param height upon return contains the required height of the cell
 */
void
TwoLinesCellRenderer::get_size_vfunc(Gtk::Widget &widget,
				     const Gdk::Rectangle *cell_area,
				     int *x_offset, int *y_offset,
				     int *width, int *height) const
#endif
{
#ifdef GLIBMM_PROPERTIES_ENABLED
  // Compute text width
  Glib::RefPtr<Pango::Layout> layout_ptr = widget.create_pango_layout(__property_line1);
  Pango::Rectangle rect = layout_ptr->get_pixel_logical_extents();
	
  int line1_width  = property_xpad() * 2 + rect.get_width();
  int line1_height = property_ypad() * 2 + rect.get_height();
  int line2_height;

  if (__property_line2_enabled.get_value()) {
    Glib::RefPtr<Pango::Layout> layout2 = widget.create_pango_layout(__property_line2);
#if GTK_VERSION_GE(3,0)
    Pango::FontDescription font2("sans 10");
#else
    Glib::RefPtr<Gtk::Style> style = widget.get_style();
    Pango::FontDescription font2 = style->get_font();
#endif

    font2.set_size((int)roundf(Pango::SCALE_SMALL * font2.get_size()));
    layout2->set_font_description(font2);
    Pango::Rectangle rect2 = layout2->get_pixel_logical_extents();
    layout2->set_ellipsize(Pango::ELLIPSIZE_END);

    line2_height = property_ypad() * 2 + rect2.get_height();
  } else {
    line2_height = 0;
  }

  if (width)  *width  = line1_width;
  if (height) *height = line1_height + 4 + line2_height;
#endif
}
void tst_QFont::isCopyOf()
{
    QFont font;
    QVERIFY(font.isCopyOf(QGuiApplication::font()));

    QFont font2("bogusfont",  23);
    QVERIFY(! font2.isCopyOf(QGuiApplication::font()));

    QFont font3 = font;
    QVERIFY(font3.isCopyOf(font));

    font3.setPointSize(256);
    QVERIFY(!font3.isCopyOf(font));
    font3.setPointSize(font.pointSize());
    QVERIFY(!font3.isCopyOf(font));
}
예제 #5
0
UIReportQuery::UIReportQuery(QDialog *parent,Qt::WindowFlags f) :
    QDialog(parent,f)
{
    QObject::installEventFilter(this);
    RemoveKeyEventBug();

    QPixmap bg;
    bg.load(":/images/commonbg.png");
    QPalette palette;
    palette.setBrush(backgroundRole(),QBrush(bg));
    this->setPalette(palette);
    this->setAutoFillBackground(true);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setGeometry(0,FRAME420_THVALUE,FRAME420_WIDTH,FRAME420_HEIGHT);
    this->setFixedSize(FRAME420_WIDTH,FRAME420_HEIGHT);
    QFont font("Helvetica",12,QFont::Bold);
    QFont font2("Helvetica",14,QFont::Bold);
    QFont font3("Helvetica",14);

    this->setStyleSheet("QDialog{border: 3px solid silver;}");

    lbHead=new QLabel();
    QFont fontH("Helvetica",18,QFont::Bold);
    lbHead->setText(tr("Transaction List"));
    lbHead->setFont(fontH);
    lbHead->setAlignment(Qt::AlignCenter);
    lbHead->setMinimumHeight(40);
    lbHead->setMaximumHeight(40);
    lbHead->setStyleSheet(HEAD_STYLE);
    lbHead->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    //--------------define--------------------//
    tbTransList=new QTableWidget();
    tbTransList->setFrameShape(QFrame::NoFrame);
    tbTransList->setEditTriggers(QAbstractItemView::NoEditTriggers);
    tbTransList->setSelectionMode(QAbstractItemView::SingleSelection);
    tbTransList->setSelectionBehavior(QAbstractItemView::SelectRows);
    tbTransList->horizontalHeader()->setVisible(false);
    tbTransList->horizontalHeader()->setDefaultSectionSize(130);
    tbTransList->horizontalHeader()->setStretchLastSection(true);
    tbTransList->verticalHeader()->setVisible(false);

    tbTransList->verticalScrollBar()->setStyleSheet(SCROLL_VERTICAL_STYLE);

    //    ----------------------------------  //
    btnCancel=new QPushButton;
    btnSubmit=new QPushButton;
    btnCancel->setText(tr("Cancel"));
    btnSubmit->setText(tr("Detail"));
    btnCancel->setFont(font2);
    btnSubmit->setFont(font2);
    btnCancel->setMinimumHeight(30);
    btnSubmit->setMinimumHeight(30);
    btnCancel->setStyleSheet(BTN_BLUE_STYLE);
    btnSubmit->setStyleSheet(BTN_GREEN_STYLE);

//    QSpacerItem *sp1=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
//    QSpacerItem *sp2=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);

    QVBoxLayout *v1Lay=new QVBoxLayout();
    //    v1Lay->addItem(sp1);
    v1Lay->addWidget(tbTransList);
    //    v1Lay->addItem(sp2);

    QHBoxLayout *h2Lay=new QHBoxLayout();
    //    h2Lay->addSpacing(10);
    h2Lay->addWidget(btnCancel);
    h2Lay->addWidget(btnSubmit);
    //    h2Lay->addSpacing(10);

    QVBoxLayout *layout=new QVBoxLayout(this);
    layout->addWidget(lbHead);
    layout->addLayout(v1Lay);
    layout->addLayout(h2Lay);

    connect(btnCancel, SIGNAL(clicked()), this, SLOT(close()));
    connect(btnSubmit, SIGNAL(clicked()), this, SLOT(slotDetailClicked()));
    connect(tbTransList,SIGNAL(viewportEntered()),this,SLOT(restartTimeOut()));
    connect(tbTransList,SIGNAL(clicked(QModelIndex)),this,SLOT(restartTimeOut()));
    connect(tbTransList->verticalScrollBar(),SIGNAL(sliderMoved(int)),this,SLOT(restartTimeOut()));
    //Animation
    QPropertyAnimation *animation1 = new QPropertyAnimation(this, "pos");
    animation1->setDuration(100);
    animation1->setStartValue(mapToParent(QPoint(FRAME420_WIDTH, 0)));
    animation1->setEndValue(mapToParent(QPoint(0, 0)));
    animation1->setEasingCurve(QEasingCurve::OutQuint);
    animation1->start();

    this->ergodicTrans();  //遍历交易
    this->setAutoClose(g_constantParam.TIMEOUT_UI);
}
예제 #6
0
void gtAction::write(const QString& text, gtStyle *style, bool isNote)
{
	if (isFirstWrite)
	{
		if (!doAppend)
		{
			if (it->nextInChain() != 0)
			{
				PageItem *nextItem = it->nextInChain();
				while (nextItem != 0)
				{
					nextItem->itemText.clear();
					nextItem = nextItem->nextInChain();
				}
			}
			it->itemText.clear();
		}
	}
	int paragraphStyle = -1;
	if (style->target() == "paragraph")
	{
		gtParagraphStyle* pstyle = dynamic_cast<gtParagraphStyle*>(style);
		assert(pstyle != NULL);
		paragraphStyle = applyParagraphStyle(pstyle);
		if (isFirstWrite)
			inPara = true;
	}
	else if (style->target() == "frame")
	{
		gtFrameStyle* fstyle = dynamic_cast<gtFrameStyle*>(style);
		assert(fstyle != NULL);
		applyFrameStyle(fstyle);
	}

	if ((inPara) && (!lastCharWasLineChange) && (text.left(1) != "\n") && (lastParagraphStyle != -1))
		paragraphStyle = lastParagraphStyle;

	if (paragraphStyle == -1)
		paragraphStyle = 0; //::findParagraphStyle(textFrame->doc(), textFrame->doc()->currentStyle);

	const ParagraphStyle& paraStyle = textFrame->doc()->paragraphStyles()[paragraphStyle];

	gtFont* font = style->getFont();
	QString fontName = validateFont(font).scName();
	CharStyle lastStyle, newStyle;
	int lastStyleStart = 0;
	
	if ((inPara) && (!overridePStyleFont))
	{
		if (paraStyle.charStyle().font().isNone())
		{
			gtFont font2(*font);
			font2.setName(paraStyle.charStyle().font().scName());
			QString fontName2 = validateFont(&font2).scName();
			newStyle.setFont((*textFrame->doc()->AllFonts)[fontName2]);
		}
	}
	else
	{
		setCharStyleAttributes(font, newStyle);
	}
	/*newStyle.eraseCharStyle(paraStyle.charStyle());*/

	lastStyle = newStyle;
	lastStyleStart = it->itemText.length();
	StoryText* story = NULL;
	if (isNote)
	{
		if (noteStory == NULL)
		{
			note = it->m_Doc->newNote(it->m_Doc->m_docNotesStylesList.at(0));
			noteStory = new StoryText(it->m_Doc);
		}
		story = noteStory;
	}
	else
		story = &it->itemText;

	QChar ch0(0), ch5(5), ch10(10), ch13(13); 
	for (int a = 0; a < text.length(); ++a)
	{
		if ((text.at(a) == ch0) || (text.at(a) == ch13))
			continue;
		QChar ch = text.at(a);
		if ((ch == ch10) || (ch == ch5))
			ch = ch13;
		
		int pos = story->length();
		if (isNote && ch == SpecialChars::OBJECT)
		{
			NotesStyle* nStyle = note->notesStyle();
			QString label = "NoteMark_" + nStyle->name();
			if (nStyle->range() == NSRsection)
				label += " in section " + it->m_Doc->getSectionNameForPageIndex(it->OwnPage) + " page " + QString::number(it->OwnPage +1);
			else if (nStyle->range() == NSRpage)
				label += " on page " + QString::number(it->OwnPage +1);
			else if (nStyle->range() == NSRstory)
				label += " in " + it->firstInChain()->itemName();
			else if (nStyle->range() == NSRframe)
				label += " in frame" + it->itemName();
			if (it->m_Doc->getMark(label + "_1", MARKNoteMasterType) != NULL)
				getUniqueName(label,it->m_Doc->marksLabelsList(MARKNoteMasterType), "_"); //FIX ME here user should be warned that inserted mark`s label was changed
			else
				label = label + "_1";
			Mark* mrk = it->m_Doc->newMark();
			mrk->label = label;
			mrk->setType(MARKNoteMasterType);
			mrk->setNotePtr(note);
			note->setMasterMark(mrk);
			mrk->setString("");
			mrk->OwnPage = it->OwnPage;
			it->itemText.insertMark(mrk);
			story->applyCharStyle(lastStyleStart, story->length()-lastStyleStart, lastStyle);
			if (paraStyle.hasName())
			{
				ParagraphStyle pStyle;
				pStyle.setParent(paraStyle.name());
				story->applyStyle(qMax(0,story->length()-1), pStyle);
			}
			else
				story->applyStyle(qMax(0,story->length()-1), paraStyle);
			
			lastCharWasLineChange = text.right(1) == "\n";
			inPara = style->target() == "paragraph";
			lastParagraphStyle = paragraphStyle;
			if (isFirstWrite)
				isFirstWrite = false;
			if (story->text(pos -1) == SpecialChars::PARSEP)
				story->removeChars(pos-1, 1);
			note->setSaxedText(saxedText(story));
			note = NULL;
			delete noteStory;
			noteStory = NULL;
			return;
		}
		else
			story->insertChars(pos, QString(ch));
		if (ch == SpecialChars::PARSEP) 
		{
			if (paraStyle.hasName())
			{
				ParagraphStyle pstyle;
				pstyle.setParent(paraStyle.name());
				story->applyStyle(pos, pstyle);
			}
			else
				story->applyStyle(pos, paraStyle);
		}
	}
	story->applyCharStyle(lastStyleStart, story->length()-lastStyleStart, lastStyle);
	if (paraStyle.hasName())
	{
		ParagraphStyle pStyle;
		pStyle.setParent(paraStyle.name());
		story->applyStyle(qMax(0,story->length()-1), pStyle);
	}
	else
		story->applyStyle(qMax(0,story->length()-1), paraStyle);
	
	lastCharWasLineChange = text.right(1) == "\n";
	inPara = style->target() == "paragraph";
	lastParagraphStyle = paragraphStyle;
	if (isFirstWrite)
		isFirstWrite = false;
}
예제 #7
0
UIRePrint::UIRePrint(QDialog *parent,Qt::WindowFlags f) :
    QDialog(parent,f)
{
    QObject::installEventFilter(this);
    RemoveKeyEventBug();

    QPixmap bg;
    bg.load(":/images/commonbg.png");
    QPalette palette;
    palette.setBrush(backgroundRole(),QBrush(bg));
    this->setPalette(palette);
    this->setAutoFillBackground(true);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setGeometry(0,FRAME420_THVALUE,FRAME420_WIDTH,FRAME420_HEIGHT);
    this->setFixedSize(FRAME420_WIDTH,FRAME420_HEIGHT);
    QFont font("Helvetica",12,QFont::Bold);
    QFont font2("Helvetica",14,QFont::Bold);
    QFont font3("Helvetica",14);

    this->setStyleSheet("QDialog{border: 3px solid silver;}");

    lbHead=new QLabel();
    QFont fontH("Helvetica",18,QFont::Bold);
    lbHead->setText(tr("Print"));
    lbHead->setFont(fontH);
    lbHead->setAlignment(Qt::AlignCenter);
    lbHead->setMinimumHeight(40);
    lbHead->setMaximumHeight(40);
    lbHead->setStyleSheet(HEAD_STYLE);
    lbHead->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    //--------------define--------------------//
    btnRePrintLast=new QPushButton();
    btnRePrintWhich=new QPushButton();
    btnPrintAudit=new QPushButton();
    btnPrintSettle=new QPushButton();

    btnRePrintLast->setText("Reprint Last ");
    btnRePrintWhich->setText("Reprint At Will");
    btnPrintAudit->setText("Print Audit");
    btnPrintSettle->setText("Print Settle");

    btnRePrintLast->setFont(font2);
    btnRePrintWhich->setFont(font2);
    btnPrintAudit->setFont(font2);
    btnPrintSettle->setFont(font2);

    btnRePrintLast->setStyleSheet(BTN_MENU_STYLE);
    btnRePrintWhich->setStyleSheet(BTN_MENU_STYLE);
    btnPrintAudit->setStyleSheet(BTN_MENU_STYLE);
    btnPrintSettle->setStyleSheet(BTN_MENU_STYLE);

    btnRePrintLast->setMinimumHeight(40);
    btnRePrintLast->setMaximumHeight(40);
    btnRePrintWhich->setMinimumHeight(40);
    btnRePrintWhich->setMaximumHeight(40);
    btnPrintAudit->setMinimumHeight(40);
    btnPrintAudit->setMaximumHeight(40);
    btnPrintSettle->setMinimumHeight(40);
    btnPrintSettle->setMaximumHeight(40);
    //    ----------------------------------  //
    btnCancel=new QPushButton;
    btnCancel->setText(tr("Cancel"));
    btnCancel->setFont(font2);
    btnCancel->setMinimumHeight(30);
    btnCancel->setStyleSheet(BTN_GREY_STYLE);

    QSpacerItem *sp1=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QSpacerItem *sp2=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);

    QVBoxLayout *v1Lay=new QVBoxLayout();
    v1Lay->addItem(sp1);
    v1Lay->addWidget(btnRePrintLast);
    v1Lay->addWidget(btnRePrintWhich);
    v1Lay->addWidget(btnPrintAudit);
    v1Lay->addWidget(btnPrintSettle);
    v1Lay->addItem(sp2);

    QHBoxLayout *h2Lay=new QHBoxLayout();
    //    h2Lay->addSpacing(10);
    h2Lay->addWidget(btnCancel);
    //    h2Lay->addSpacing(10);

    QVBoxLayout *layout=new QVBoxLayout(this);
    layout->addWidget(lbHead);
    layout->addLayout(v1Lay);
    layout->addLayout(h2Lay);


    connect(btnRePrintLast,SIGNAL(clicked()),this,SLOT(slotReprintLast()));
    connect(btnRePrintWhich,SIGNAL(clicked()),this,SLOT(slotReprintWhich()));
    connect(btnPrintAudit,SIGNAL(clicked()),this,SLOT(slotPrintAudit()));
    connect(btnPrintSettle,SIGNAL(clicked()),this,SLOT(slotPrintSettle()));
    connect(btnCancel, SIGNAL(clicked()), this, SLOT(close()));

    //Animation
    QPropertyAnimation *animation1 = new QPropertyAnimation(this, "pos");
    animation1->setDuration(100);
    animation1->setStartValue(mapToParent(QPoint(FRAME420_WIDTH, 0)));
    animation1->setEndValue(mapToParent(QPoint(0, 0)));
    animation1->setEasingCurve(QEasingCurve::OutQuint);
    animation1->start();

    this->setAutoClose(g_constantParam.TIMEOUT_UI);
}
예제 #8
0
파일: uiMsg.cpp 프로젝트: Koulio/MJL_BANK
UIMsg::UIMsg(ErrorType errortype, long errorCode, QDialog *parent, Qt::WindowFlags f) :
    QDialog(parent,f)
{
    // 初始化错误代码
    this->initalErrorMsg();
    this->initalNoticeMsg();
    this->initalFileErrorMsg();
    this->initalCommErrorMsg();
    this->initalHostErrorMsg();

    QPixmap bg;
    bg.load(":/images/commonbg.png");
    QPalette palette;
    palette.setBrush(backgroundRole(),QBrush(bg));
    this->setPalette(palette);
    this->setAutoFillBackground(true);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setGeometry(20,FRAME420_THVALUE+50,FRAME420_WIDTH,FRAME420_HEIGHT-50);
    this->setFixedSize(FRAME420_WIDTH-40,FRAME420_HEIGHT-80);
    this->setStyleSheet("QDialog{border: 6px solid silver;}");

    QFont font("Helvetica",12,QFont::Bold);
    QFont font2("Helvetica",14,QFont::Bold);
    QFont font3("Helvetica",8,QFont::Bold);

    //--------------define--------------------//
    lbHead=new QLabel();
    QFont fontH("Helvetica",18,QFont::Bold);
    lbHead->setFont(fontH);
    lbHead->setAlignment(Qt::AlignCenter);
    lbHead->setMinimumHeight(40);
    lbHead->setMaximumHeight(40);
    lbHead->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    lbMsg=new QLabel();
    lbReturnCode=new QLabel();
    lbMsg->setFont(font2);
    lbReturnCode->setFont(font2);
    lbMsg->setAlignment(Qt::AlignCenter);
    lbReturnCode->setAlignment(Qt::AlignCenter);
    lbMsg->setMinimumHeight(40);
    lbReturnCode->setMinimumHeight(40);

    btnSubmit=new QPushButton;
    btnSubmit->setText(tr("OK"));
    btnSubmit->setFont(font2);
    btnSubmit->setMinimumHeight(30);
    btnSubmit->setStyleSheet(BTN_GREY_STYLE);


    this->beepTwice();   //beep

    switch(errortype)
    {
    case HOST_ERROR:
    {
        lbHead->setText("HOST ERROR");
        lbHead->setStyleSheet("background-color: rgb(255,0,0);");

        lbMsg->setText(hashHostError.value(HostErrIndex(errorCode)));
        break;
    }
    default:
        break;
    }

    QString hostCode=QString::number(errorCode);
    lbReturnCode->setText("Return Code : "+hostCode);

    // -----------layout------------//
    QSpacerItem *sp1=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QSpacerItem *sp2=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QSpacerItem *sp3=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QHBoxLayout *h1Lay=new QHBoxLayout();
    h1Lay->addSpacing(6);
    h1Lay->addWidget(lbHead);
    h1Lay->addSpacing(6);

    QVBoxLayout *v1Lay=new QVBoxLayout();
    v1Lay->addSpacing(6);
    v1Lay->addLayout(h1Lay);
    v1Lay->addItem(sp1);
    v1Lay->addWidget(lbMsg);
    v1Lay->addItem(sp2);
    v1Lay->addWidget(lbReturnCode);

    v1Lay->addItem(sp3);

    QHBoxLayout *h2Lay=new QHBoxLayout();
    h2Lay->addSpacing(10);
    h2Lay->addWidget(btnSubmit);
    h2Lay->addSpacing(10);

    QVBoxLayout *layout=new QVBoxLayout(this);
    layout->addLayout(v1Lay);
    layout->addLayout(h2Lay);

    layout->setContentsMargins(0,0,0,10);

    connect(btnSubmit,SIGNAL(clicked()),this,SLOT(close()));

}
예제 #9
0
void gtAction::write(const QString& text, gtStyle *style)
{
	if (isFirstWrite)
	{
		if (!doAppend)
		{
			if (it->nextInChain() != 0)
			{
				PageItem *nextItem = it->nextInChain();
				while (nextItem != 0)
				{
					nextItem->itemText.clear();
					nextItem = nextItem->nextInChain();
				}
			}
			it->itemText.clear();
		}
	}
	int paragraphStyle = -1;
	if (style->target() == "paragraph")
	{
		gtParagraphStyle* pstyle = dynamic_cast<gtParagraphStyle*>(style);
		assert(pstyle != NULL);
		paragraphStyle = applyParagraphStyle(pstyle);
		if (isFirstWrite)
			inPara = true;
	}
	else if (style->target() == "frame")
	{
		gtFrameStyle* fstyle = dynamic_cast<gtFrameStyle*>(style);
		assert(fstyle != NULL);
		applyFrameStyle(fstyle);
	}

	if ((inPara) && (!lastCharWasLineChange) && (text.left(1) != "\n") && (lastParagraphStyle != -1))
		paragraphStyle = lastParagraphStyle;

	if (paragraphStyle == -1)
		paragraphStyle = 0; //::findParagraphStyle(textFrame->doc(), textFrame->doc()->currentStyle);

	const ParagraphStyle& paraStyle = textFrame->doc()->paragraphStyles()[paragraphStyle];

	gtFont* font = style->getFont();
	QString fontName = validateFont(font).scName();
	CharStyle lastStyle, newStyle;
	int lastStyleStart = 0;
	
	if ((inPara) && (!overridePStyleFont))
	{
		if (paraStyle.charStyle().font().isNone())
		{
			gtFont font2(*font);
			font2.setName(paraStyle.charStyle().font().scName());
			QString fontName2 = validateFont(&font2).scName();
			newStyle.setFont((*textFrame->doc()->AllFonts)[fontName2]);
		}
	}
	else
	{
		setCharStyleAttributes(font, newStyle);
	}
	/*newStyle.eraseCharStyle(paraStyle.charStyle());*/

	lastStyle = newStyle;
	lastStyleStart = it->itemText.length();

	QChar ch0(0), ch5(5), ch10(10), ch13(13);
	for (int a = 0; a < text.length(); ++a)
	{
		if ((text.at(a) == ch0) || (text.at(a) == ch13))
			continue;
		QChar ch = text.at(a);
		if ((ch == ch10) || (ch == ch5))
			ch = ch13;
		else if (ch.unicode() == 0x2028)
			ch = SpecialChars::LINEBREAK;
		else if (ch.unicode() == 0x2029)
			ch = SpecialChars::PARSEP;
		
		int pos = it->itemText.length();
		it->itemText.insertChars(pos, QString(ch));
		if (ch == SpecialChars::PARSEP) 
		{
			if (paraStyle.hasName())
			{
				ParagraphStyle pstyle;
				pstyle.setParent(paraStyle.name());
				it->itemText.applyStyle(pos, pstyle);
			}
			else
				it->itemText.applyStyle(pos, paraStyle);
		}
	}
	it->itemText.applyCharStyle(lastStyleStart, it->itemText.length()-lastStyleStart, lastStyle);
	if (paraStyle.hasName())
	{
		ParagraphStyle pStyle;
		pStyle.setParent(paraStyle.name());
		it->itemText.applyStyle(qMax(0,it->itemText.length()-1), pStyle);
	}
	else
		it->itemText.applyStyle(qMax(0,it->itemText.length()-1), paraStyle);
	
	lastCharWasLineChange = text.right(1) == "\n";
	inPara = style->target() == "paragraph";
	lastParagraphStyle = paragraphStyle;
	if (isFirstWrite)
		isFirstWrite = false;
}
void ListViewSingleButtonDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
     //
    // This method paints a new row into the listview
    //

    painter->save();

    // Set normal background color
    painter->setBrush((QColor("#ffffff")));

    // Alternating rows
    if (index.row() % 2) {
        // Set brush to aliceblue
        painter->setBrush((QColor("#f5f5f5")));
    }

    if(index.model()->data(index, Qt::UserRole + 4).toInt() == ConnectionState::Error)
    {
        painter->setBrush(QColor("#FFCCCC"));
    }

    QString textBottom (index.model()->data(index, Qt::UserRole + 101).toString());
    QString textName (index.data(Qt::DisplayRole).toString());

    // Hindergrund zeichnen
    painter->setPen(Qt::NoPen);

    if (textBottom == "__divider__") {
        painter->setBrush(QBrush(QColor("#f2f2f2"))); //0053a1
        painter->drawRect(option.rect);
        painter->setPen(Qt::lightGray);
        painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
        if (index.row() == 0) {
            painter->drawLine(option.rect.topLeft(), option.rect.topRight());
        }

        painter->setPen(Qt::black);
        QStyleOptionViewItem nOptionD (option);
        QFont sdasda("Verdana", 10, QFont::Normal);
        //sdasda.setPixelSize(11);
        painter->setFont(sdasda);
        nOptionD.rect.adjust(3, 0, 0, 0);
        painter->drawText(nOptionD.rect, textName);
        rectForRow.insert(index.row(), QRect());
        rectForRow[index.row()] = option.rect;
         painter->restore();
        return;
    }

    painter->drawRect(option.rect);

    // Get text

    QString ip (index.data(Qt::UserRole + 1).toString());
    quint32 lastUsed(index.data(Qt::UserRole + 2).toUInt());
    quint32 lastConnected(index.data(Qt::UserRole + 3).toUInt());
    // Set and calc items width
    int buttonWidth (36* windowsDpiScale());
    int buttonHeight (36* windowsDpiScale());
    int marginRight (10* windowsDpiScale());
    int marginTop (5* windowsDpiScale());

    // Draw delete button
    QStyleOptionViewItem buttonOption (option);
    // -10 is the right margin, the margin is necessary to reset the state when mouse is leaving to the right side
    buttonOption.rect.setRight(buttonWidth + 2 * marginRight);
    buttonOption.rect.setHeight(buttonHeight);
    buttonOption.rect.adjust(10* windowsDpiScale(), option.rect.height() / 2 - buttonHeight / 2, -(marginRight), marginTop + 1);
    buttonOption.rect.setHeight(buttonHeight);
    // Draw delete button and return limits
    // This is to figure out which button is under the mouse position
    rectForRow.insert(index.row(), QRect());
    rectForRow[index.row()] = buttonOption.rect;

    auto drawButton = [](const QModelIndex &index, QPainter *painter, const QRect &rect, int role, ConnectionState conState)
    {
        // Draw delete button
        QStyleOptionButton buttonStyle;

        //
        // Set the button state to enabled
        buttonStyle.state |= QStyle::State_Enabled;
        // Set postion and size to the item
        buttonStyle.rect = rect;
        // Button is a flat button
        buttonStyle.features = QStyleOptionButton::Flat;
        // No text, only an icon
        // Icon default is 16x16
        buttonStyle.iconSize = QSize(16* windowsDpiScale(), 16* windowsDpiScale());
        //

        // Set the button states
        ButtonState state = (ButtonState) index.data(role).toInt();
        QPen pen;
        pen.setWidth(1);

        switch(conState)
        {
        case ConnectionState::Disconnected:
            {
                if(state == Hover) {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#F0D151"));
                } else if(state == Pressed) {

                } else {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#EEEEEC"));
                }
            }
            break;
        case ConnectionState::Connecting:
            {
                if(state == Hover) {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#EEEEEC"));
                } else if(state == Pressed) {
                } else {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#F1C40F"));
                }

            }
            break;
        case ConnectionState::Connected:
            {
                if(state == Hover) {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#EEEEEC"));
                } else if(state == Pressed) {
                } else {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#72C02C"));
                }
            }
            break;
        case ConnectionState::Error:
            {
                if(state == Hover) {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#F0D151"));
                } else if(state == Pressed) {
                } else {
                    pen.setColor("#808080");
                    painter->setBrush(QBrush("#FF0000"));
                }
            }
            break;
        default:
            {
                pen.setColor("#808080");
                painter->setBrush(QBrush("#EEEEEC"));
            }
        }

    // Set the pen and draw the border of the button
    painter->setPen(pen);
    painter->drawRect(buttonStyle.rect);
    painter->setBrush(Qt::NoBrush);

    QRect buttonOption(rect);



    // Draw button
    QApplication::style()->drawControl(QStyle::CE_PushButton, &buttonStyle, painter);
    };

    ConnectionState conState = (ConnectionState)index.data(Qt::UserRole + 4).toInt();

    drawButton(index, painter, buttonOption.rect, Qt::UserRole + 100, conState);

   // this->buttonLimits = this->drawButton(index, painter, buttonOption.rect, this->iconForType(this->buttonIconType, option), Qt::UserRole + 100);


    // Draw text
    QStyleOptionViewItem textOption (option);
    textOption.rect.adjust(buttonWidth + marginRight + 10 + 4, 4, buttonWidth + 2 * marginRight, 0);
    QPen pen;
    pen.setColor(QColor("#2c2c2c"));
    painter->setPen(pen);

    QFont font1("Verdana", 9, QFont::Normal);
    //font1.setPixelSize(11);
    
    QFont font2("Verdana", 7, QFont::Normal);
    //font2.setPixelSize(9);

    painter->setFont(font1);
    painter->drawText(textOption.rect, textName);
    textOption.rect.adjust(0, 13* windowsDpiScale(), 0, 0);
    painter->setFont(font2);
    //painter->drawText(textOption.rect, "Connected: ");
    //textOption.rect.adjust(0, 9, 0, 0);
    //painter->drawText(textOption.rect, "Last used: ");
    //textOption.rect.adjust(0, 9, 0, 0);

    typedef std::chrono::duration<int, std::ratio_multiply<std::chrono::hours::period, std::ratio<24>>::type> days;
    std::chrono::seconds sec((QDateTime::currentDateTime().toTime_t() - lastConnected));

    auto d = std::chrono::duration_cast<days>(sec);
    auto h = std::chrono::duration_cast<std::chrono::hours>(sec - d);
    auto m = std::chrono::duration_cast<std::chrono::minutes>((sec - d - h));
    auto s = std::chrono::duration_cast<std::chrono::seconds>((sec - d - h - m));


    QString day("%1%2 D ");
    day = day.arg(d.count() < 10 ? "0" : "")
        .arg(d.count());

    QString hour("%1%2 H ");
    hour = hour.arg(h.count() < 10 ? "0" : "")
        .arg(h.count());

    QString minute("%1%2 M ");
    minute = minute.arg(m.count() < 10 ? "0" : "")
        .arg(m.count());

    switch(conState)
    {
    case ConnectionState::Connected:
        painter->drawText(textOption.rect, QObject::tr("Connected: ") + (day) + (hour) + (d.count() > 0 ? "" : minute));
        break;
    case ConnectionState::Disconnected:
        painter->drawText(textOption.rect, QObject::tr("Last used: ") + (lastUsed == 0 ? QObject::tr("Never") : QDateTime::fromTime_t(lastUsed).toString("dd.MM.yy hh:mm")));
        break;
    default:
        painter->drawText(textOption.rect, QObject::tr("Last used: ") + (lastUsed == 0 ? QObject::tr("Never") : QDateTime::fromTime_t(lastUsed).toString("dd.MM.yy hh:mm")));
        break;
    };

    if(buttonOption.rect.size() != _lastImgSize)
    {     
        imgStart = imgStart_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgOffline = imgOffline_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgError = imgError_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgOnline = imgOnline_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgStop = imgStop_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgConnecting = imgConnecting_.scaled(buttonOption.rect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        auto s = buttonOption.rect.size();

        // I dont know why this thing has to be adjusted, but well, it works.
        s.setWidth(s.width() - 1);
        s.setHeight(s.height() - 1);
        movieKeks->setScaledSize(s);

        QSize size(16, 16);

        

        imgIconUsers = imgIconUsers_.scaled(size * windowsDpiScale(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
        imgIconAutostart = imgIconAutostart_.scaled(size * windowsDpiScale(), Qt::KeepAspectRatio, Qt::SmoothTransformation);

        _lastImgSize = buttonOption.rect.size();
    }   
    buttonOption.rect.adjust(((buttonWidth) - imgStart.width()) / 2 +1, ((buttonWidth) - imgStart.height()) / 2 + 1, 0, 0);

    ButtonState state = (ButtonState) index.data(Qt::UserRole + 100).toInt();

    switch(conState)
    {
    case ConnectionState::Disconnected:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStart);
            else
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgOffline);
        }
        break;
    case ConnectionState::Connecting:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStop);
            else
            {
                auto pixx = movieKeks->currentPixmap();
                //auto size = imgStart.size();
                ////size.setHeight(size.height() -10);
                //pixx = pixx.scaled(imgStart.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), pixx.toImage());
            }
        }
        break;
    case ConnectionState::Connected:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStop);
            else
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgOnline);
        }
        break;
    case ConnectionState::Error:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStart);
            else
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgError);
        }
        break;
    default:
        {
            if(state == Hover)
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgStart);
            else
                painter->drawImage(buttonOption.rect.left(),  buttonOption.rect.top(), imgOffline);
        }
    }


    static const int iconPadding = 5;

    textOption.rect.setTop(buttonOption.rect.bottom());
    textOption.rect.adjust(0, -imgIconAutostart.height()+2, 0, 0);
    textOption.rect.setWidth(imgIconAutostart.width());

    if(index.data(Qt::UserRole + 5).toBool())
    {
        painter->drawImage(textOption.rect.left(),  textOption.rect.top(), imgIconAutostart);
        textOption.rect.adjust(imgIconAutostart.width() + iconPadding, 0, 0, 0);
    }

    if(index.data(Qt::UserRole + 6).toBool())
    {
        painter->drawImage(textOption.rect.left(),  textOption.rect.top(), imgIconUsers);
        textOption.rect.adjust(imgIconAutostart.width() + iconPadding, 0, 0, 0);
    }
    painter->setPen(Qt::lightGray);
    painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());

    // Restore saved painter
    painter->restore();
}
예제 #11
0
파일: uiMsg.cpp 프로젝트: Koulio/MJL_BANK
UIMsg::UIMsg(ErrorType errortype, unsigned char ucErrorCode, QDialog *parent, Qt::WindowFlags f) :
    QDialog(parent,f)
{
    // 初始化错误代码
    this->initalErrorMsg();
    this->initalNoticeMsg();
    this->initalFileErrorMsg();
    this->initalCommErrorMsg();
    this->initalHostErrorMsg();

    QPixmap bg;
    bg.load(":/images/commonbg.png");
    QPalette palette;
    palette.setBrush(backgroundRole(),QBrush(bg));
    this->setPalette(palette);
    this->setAutoFillBackground(true);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setGeometry(20,FRAME420_THVALUE+50,FRAME420_WIDTH,FRAME420_HEIGHT-50);
    this->setFixedSize(FRAME420_WIDTH-40,FRAME420_HEIGHT-80);
    this->setStyleSheet("QDialog{border: 6px solid silver;}");

    QFont font("Helvetica",12,QFont::Bold);
    QFont font2("Helvetica",14,QFont::Bold);
    QFont font3("Helvetica",8,QFont::Bold);

    //--------------define--------------------//
    lbHead=new QLabel();
    QFont fontH("Helvetica",18,QFont::Bold);
    lbHead->setFont(fontH);
    lbHead->setAlignment(Qt::AlignCenter);
    lbHead->setMinimumHeight(40);
    lbHead->setMaximumHeight(40);
    lbHead->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    lbMsg=new QLabel();
    lbReturnCode=new QLabel();
    lbMsg->setFont(font2);
    lbReturnCode->setFont(font2);
    lbMsg->setAlignment(Qt::AlignCenter);
    lbReturnCode->setAlignment(Qt::AlignCenter);
    lbMsg->setMinimumHeight(40);
    lbReturnCode->setMinimumHeight(40);

    btnSubmit=new QPushButton;
    btnSubmit->setText(tr("OK"));
    btnSubmit->setFont(font2);
    btnSubmit->setMinimumHeight(30);
    btnSubmit->setStyleSheet(BTN_GREY_STYLE);


    this->beepTwice();   //beep

    switch(errortype)
    {
    case NORMAL_ERROR:
    {
        lbHead->setText("ERROR");
        lbHead->setStyleSheet("background-color: rgb(255,0,0);");

        lbMsg->setText(hashError.value(ErrIndex(ucErrorCode)));

        break;
    }
    case NOTICE_ERROR:
    {
        lbHead->setText("NOTICE");
        lbHead->setStyleSheet("background-color: rgb(0, 153, 255);");

        lbMsg->setText(hashNotice.value(MsgTabIndex(ucErrorCode)));

        break;
    }
    case FILE_ERROR:
    {
        lbHead->setText("FILE ERROR");
        lbHead->setStyleSheet("background-color: rgb(255,0,0);");
        lbMsg->setText(hashFileError.value(FileErrIndex(ucErrorCode)));


        break;
    }
    case COMM_ERROR:
    {
        lbHead->setText("COMM ERROR");
        lbHead->setStyleSheet("background-color: rgb(255,0,0);");
        lbMsg->setText(hashCommError.value(CommsErrIndex(ucErrorCode)));

        break;
    }
    case HOST_ERROR:
    {
        qDebug()<<"不应该在这里处理";
        break;
    }
    }

    unsigned char  ucCode;
    ucCode = ucErrorCode;

    unsigned char  aucErrorCode[PARAM_ANSWER_LEN + 1] = {0};
    hex_str(aucErrorCode, &ucCode, PARAM_ANSWER_LEN);
    lbReturnCode->setText("Return Code : "+QString::fromAscii((const char*)aucErrorCode));

    // -----------layout------------//
    QSpacerItem *sp1=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QSpacerItem *sp2=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QSpacerItem *sp3=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QHBoxLayout *h1Lay=new QHBoxLayout();
    h1Lay->addSpacing(6);
    h1Lay->addWidget(lbHead);
    h1Lay->addSpacing(6);

    QVBoxLayout *v1Lay=new QVBoxLayout();
    v1Lay->addSpacing(6);
    v1Lay->addLayout(h1Lay);
    v1Lay->addItem(sp1);
    v1Lay->addWidget(lbMsg);
    v1Lay->addItem(sp2);
    if(errortype!=NOTICE_ERROR)
    {
        v1Lay->addWidget(lbReturnCode);
    }
    v1Lay->addItem(sp3);

    QHBoxLayout *h2Lay=new QHBoxLayout();
    h2Lay->addSpacing(10);
    h2Lay->addWidget(btnSubmit);
    h2Lay->addSpacing(10);

    QVBoxLayout *layout=new QVBoxLayout(this);
    layout->addLayout(v1Lay);
    layout->addLayout(h2Lay);

    layout->setContentsMargins(0,0,0,10);

    connect(btnSubmit,SIGNAL(clicked()),this,SLOT(close()));

}
예제 #12
0
GuiFontInfo::GuiFontInfo(FontInfo const & f)
	: metrics(QFont())
{
	font.setKerning(false);
	QString const pat = symbolFamily(f.family());
	if (!pat.isEmpty()) {
		bool ok;
		font = symbolFont(pat, &ok);
	} else {
		switch (f.family()) {
		case ROMAN_FAMILY: {
			QString family = makeFontName(toqstr(lyxrc.roman_font_name),
				toqstr(lyxrc.roman_font_foundry)); 
			font.setFamily(family);
#ifdef Q_WS_MACX
#if QT_VERSION >= 0x040300 //&& QT_VERSION < 0x040800
			// Workaround for a Qt bug, see http://www.lyx.org/trac/ticket/3684
			// and http://bugreports.qt.nokia.com/browse/QTBUG-11145.
			// FIXME: Check whether this is really fixed in Qt 4.8
			if (family == "Times" && !font.exactMatch())
				font.setFamily("Times New Roman");
#endif
#endif
			break;
		}
		case SANS_FAMILY:
			font.setFamily(makeFontName(toqstr(lyxrc.sans_font_name),
						    toqstr(lyxrc.sans_font_foundry)));
			break;
		case TYPEWRITER_FAMILY:
			font.setFamily(makeFontName(toqstr(lyxrc.typewriter_font_name),
						    toqstr(lyxrc.typewriter_font_foundry)));
			break;
		default:
			break;
		}
	}

	switch (f.series()) {
		case MEDIUM_SERIES:
			font.setWeight(QFont::Normal);
			break;
		case BOLD_SERIES:
			font.setWeight(QFont::Bold);
			break;
		default:
			break;
	}

	switch (f.realShape()) {
		case ITALIC_SHAPE:
		case SLANTED_SHAPE:
			font.setItalic(true);
			break;
		default:
			break;
	}

	LYXERR(Debug::FONT, "Font '" << stateText(f)
		<< "' matched by\n" << font.family());

	// Is this an exact match?
	if (font.exactMatch())
		LYXERR(Debug::FONT, "This font is an exact match");
	else
		LYXERR(Debug::FONT, "This font is NOT an exact match");

	LYXERR(Debug::FONT, "XFLD: " << font.rawName());

	font.setPointSizeF(convert<double>(lyxrc.font_sizes[f.size()])
			       * lyxrc.zoom / 100.0);

	LYXERR(Debug::FONT, "The font has size: " << font.pointSizeF());

	if (f.realShape() != SMALLCAPS_SHAPE) {
		metrics = GuiFontMetrics(font);
	} else {
		// handle small caps ourselves ...
		FontInfo smallfont = f;
		smallfont.decSize().decSize().setShape(UP_SHAPE);
		QFont font2(font);
		font2.setKerning(false);
		font2.setPointSizeF(convert<double>(lyxrc.font_sizes[smallfont.size()])
			       * lyxrc.zoom / 100.0);

		metrics = GuiFontMetrics(font, font2);
	}
}
예제 #13
0
UIInputAmount::UIInputAmount(QDialog *parent,Qt::WindowFlags f) :
    QDialog(parent,f)
{
    qDebug()<<Q_FUNC_INFO;
    //    RemoveKeyEventBug();
    QObject::installEventFilter(this);

    FLAG_ADJUST=false;
    QPixmap bg;
    bg.load(":/images/commonbg.png");
    QPalette palette;
    palette.setBrush(backgroundRole(),QBrush(bg));
    this->setPalette(palette);
    this->setAutoFillBackground(true);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setGeometry(0,FRAME420_THVALUE+40,FRAME420_WIDTH,FRAME420_HEIGHT-40);
    this->setFixedSize(FRAME420_WIDTH,FRAME420_HEIGHT-40);
    this->setStyleSheet("QDialog{border: 3px solid silver;}");

    QFont font("Helvetica",12,QFont::Bold);
    QFont font2("Helvetica",14,QFont::Bold);
    QFont font3("Helvetica",8,QFont::Bold);

    lbHead=new QLabel();
    QFont fontH("Helvetica",18,QFont::Bold);
    lbHead->setText(tr("Transaction Amount"));
    lbHead->setFont(fontH);
    lbHead->setAlignment(Qt::AlignCenter);
    lbHead->setMinimumHeight(40);
    lbHead->setMaximumHeight(40);
    lbHead->setStyleSheet(HEAD_STYLE);
    lbHead->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    //--------------define--------------------//

    lbInput=new QLabel();
    lbPic=new QLabel();
    lbPic->setPixmap(QPixmap(":/icons/amount.png"));
    lbPic->setAlignment(Qt::AlignCenter);

    lbInput->setText("Please Enter The Amount:");
    lbInput->setFont(font);
    lbInput->setAlignment(Qt::AlignCenter);

    // input amount
    leAmount=new QLineEdit();
    leAmount->setAlignment(Qt::AlignCenter);
    leAmount->setFocus();
    leAmount->setFont(font);
    leAmount->setStyleSheet("border: 3px solid silver;border-radius: 6px;");
    leAmount->setMinimumHeight(35);
    leAmount->setMaxLength(10);

    unsigned long ulinitAmt=0;
    unsigned char aucBuf[20] = {0};
    memset(aucBuf,0,sizeof(aucBuf));
    FormAmount(aucBuf,ulinitAmt,2);
    leAmount->setText(QString::fromAscii((const char *)aucBuf));

    //    const QString  REGEX_AMOUNT = "^[-]?[\\d]{1,10}([.]{1}[\\d]{1,2})?$";
    //    QRegExp regx(REGEX_AMOUNT);
    //    QValidator *validator = new QRegExpValidator(regx, leAmount);
    //    leAmount->setValidator(validator);

    //    QSpacerItem *hSpacer;
    btnCancel=new QPushButton;
    btnSubmit=new QPushButton;
    btnCancel->setText(tr("Cancel"));
    btnSubmit->setText(tr("Submit"));
    btnCancel->setFont(font2);
    btnSubmit->setFont(font2);
    btnCancel->setMinimumHeight(30);
    btnSubmit->setMinimumHeight(30);
    btnCancel->setStyleSheet(BTN_BLUE_STYLE);
    btnSubmit->setStyleSheet(BTN_GREEN_STYLE);

    //    QSpacerItem *sp=new QSpacerItem(1,1,QSizePolicy::Expanding,QSizePolicy::Expanding);
    QVBoxLayout *v1Lay=new QVBoxLayout();
    v1Lay->addWidget(lbPic);
    v1Lay->addWidget(lbInput);
    v1Lay->addWidget(leAmount);


    QHBoxLayout *h2Lay=new QHBoxLayout();
    //    h2Lay->addSpacing(10);
    h2Lay->addWidget(btnCancel);
    h2Lay->addWidget(btnSubmit);
    //    h2Lay->addSpacing(10);

    QVBoxLayout *layout=new QVBoxLayout(this);
    layout->addWidget(lbHead);
    layout->addLayout(v1Lay);
    layout->addLayout(h2Lay);

    connect(btnCancel, SIGNAL(clicked()), this, SLOT(slotQuitTrans()));
    connect(btnSubmit,SIGNAL(clicked()),this,SLOT(slotAmountInputComplete()));

    // 金额输入
    connect(leAmount,SIGNAL(textChanged(QString)),this,SLOT(slotSaveAmount(QString)));
    connect(leAmount,SIGNAL(textEdited(QString)),this,SLOT(slotSaveAmount(QString)));

    //Animation
    QPropertyAnimation *animation1 = new QPropertyAnimation(this, "pos");
    animation1->setDuration(100);
    animation1->setStartValue(mapToParent(QPoint(FRAME420_WIDTH, 0)));
    animation1->setEndValue(mapToParent(QPoint(0, 0)));
    animation1->setEasingCurve(QEasingCurve::OutQuint);
    animation1->start();

    this->setAutoClose(g_constantParam.TIMEOUT_UI);
}
예제 #14
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    /* Erstellung des Fensterlayouts*/
    this->setCentralWidget(fenster);;
    fenster->setWindowTitle("Project VON");

    /*----- Westpart wird designed -----*/

    /*Label Optionen mit einer bestimmten Form*/
    QFont font1( "Calibri", 20, QFont::Bold);
    option->setFont(font1);
    option->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
    option->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);


    /*Hintergrundfarben mit ihrem Label Hintergrund */
    QFont font2( "Calibri", 10, QFont::Bold);
    hintergrund->setFont(font2);


    QPushButton *schwarz = new QPushButton();
    schwarz->setStyleSheet("background-color: black");
    QObject::connect(schwarz, &QPushButton::clicked,this, &MainWindow::schwarz);
    QPushButton *weiss = new QPushButton();
    weiss->setStyleSheet("background-color: white");
    QObject::connect(weiss, &QPushButton::clicked,this, &MainWindow::weiss);
    QPushButton *beige = new QPushButton();
    beige->setStyleSheet("background-color: beige");
    QObject::connect(beige, &QPushButton::clicked,this, &MainWindow::beige);
    QPushButton *rose = new QPushButton();
    rose->setStyleSheet("background-color: pink");
    QObject::connect(rose, &QPushButton::clicked,this, &MainWindow::pink);
    QGridLayout *farben = new QGridLayout();
    QGridLayout *farb = new QGridLayout();
    QWidget *farbenWidget = new QWidget();
    farb->addWidget(schwarz,0,0);
    farb->addWidget(weiss,0,1);
    farb->addWidget(beige,0,2);
    farb->addWidget(rose,0,3);
    farben->addWidget(hintergrund,0,0);
    farben->addLayout(farb,1,0);
    farbenWidget->setLayout(farben);

    /*Bilderanzahl als Buttons mit dem Label "Anzahl Bilder"*/
    QFont font3( "Calibri", 10, QFont::Bold);
    anzahlBilder->setFont(font3);

    QGridLayout *bilder = new QGridLayout();
    QGridLayout *bild = new QGridLayout();
    bild->addWidget(zwanzig,1,0);
    bild->addWidget(vierzig,1,1);
    bild->addWidget(sechsig,1,2);
    bilder->addWidget(anzahlBilder,0,0);
    bilder->addLayout(bild,1,0);
    QWidget *bilderWidget = new QWidget();
    bilderWidget->setLayout(bilder);


    /*Einstellung des Vollbildmoduses mit dem Label*/
    QFont font4( "Calibri", 10, QFont::Bold);
    vollbild->setFont(font4);
    QVBoxLayout *voll = new QVBoxLayout();
    voll->addWidget(vollbild);
    voll->addWidget(vollbildmodus);
    QWidget *vollWidget = new QWidget();
    vollWidget->setLayout(voll);

    /*Filter zur Behandlung ihrer Bildermenge + Label Filter*/
    QFont font5( "Calibri", 10, QFont::Bold);
    filter->setFont(font5);
    QLineEdit *filtern = new QLineEdit();
    QGridLayout *filt = new QGridLayout();
    filt->addWidget(filter,0,1);
    filt->addWidget(filtern,2,1);
    QWidget *filterWidget = new QWidget();
    filterWidget->setLayout(filt);


    menu->addWidget(option);
    menu->addWidget(farbenWidget, 0, Qt::AlignLeft | Qt::AlignTop);
    menu->addWidget(bilderWidget, 0, Qt::AlignLeft | Qt::AlignTop);
    menu->addWidget(vollWidget, 0, Qt::AlignLeft | Qt::AlignTop);
    menu->addWidget(filterWidget, 0, Qt::AlignLeft | Qt::AlignTop);


    QVBoxLayout *menu2 = new QVBoxLayout();
    menu->insertStretch(300,30);
    menu->addLayout(menu);

    fenster->setStyleSheet("background-color:white;");
    westpart->setStyleSheet("background-color:rgb(245,245,245);");
    westpart->setLayout(menu);
    west->addWidget(westpart);
    window->addWidget(westpart);


    /*Center muss hier programmiert werden*/

//    centerpart->setStyleSheet("background-color:black;");
    center->addWidget(centerpart);


    /*Layouts dem Widget hinzufügen*/

    window->addLayout(west,0,0,0,1);
    window->addLayout(center,0,1,1,4);

    fenster->setLayout(window);
}
예제 #15
0
UIConfigPay::UIConfigPay(QDialog *parent,Qt::WindowFlags f) :
    QDialog(parent,f)
{
    QPixmap bg;
    bg.load(":/images/commonbg.png");
    QPalette palette;
    palette.setBrush(backgroundRole(),QBrush(bg));
    this->setPalette(palette);
    this->setAutoFillBackground(true);
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setGeometry(0,FRAME420_THVALUE,FRAME420_WIDTH,FRAME420_HEIGHT);

    this->setFixedSize(FRAME420_WIDTH,FRAME420_HEIGHT);
    QFont font("Helvetica",12,QFont::Bold);
    QFont font2("Helvetica",14,QFont::Bold);
    QFont fontH("Helvetica",16,QFont::Bold);

    //--------------------   HEAD ----------------------//
    lbHead=new QLabel();
    lbHead->setText(tr("Payment Configuration"));
    lbHead->setFont(fontH);
    lbHead->setAlignment(Qt::AlignCenter);
    lbHead->setMinimumHeight(40);
    lbHead->setStyleSheet(HEAD_STYLE);

    lbSeHead=new QLabel();
    lbSeHead->setText(tr("Input Fields Configuration"));
    lbSeHead->setFont(fontH);
    lbSeHead->setAlignment(Qt::AlignCenter);
    lbSeHead->setMinimumHeight(40);
    lbSeHead->setStyleSheet(HEAD_STYLE);

    //--------------------   DEFINE ----------------------//
    lbVendorID=new QLabel();
    lbVendorID->setMinimumWidth(FRAME420_WIDTH-RIGHT_WHITE);
    lbVendorName=new QLabel();
    lbVendorAccNo=new QLabel();
    lbText1=new QLabel();
    lbText2=new QLabel();
    lbText3=new QLabel();
    lbText4=new QLabel();
    lbText5=new QLabel();

    leVendorID=new QLineEdit();
    leVendorName=new QLineEdit();
    leVendorAccNo=new QLineEdit();
    leText1=new QLineEdit();
    leText2=new QLineEdit();
    leText3=new QLineEdit();
    leText4=new QLineEdit();
    leText5=new QLineEdit();

    chkText1=new QCheckBox();
    chkText2=new QCheckBox();
    chkText3=new QCheckBox();
    chkText4=new QCheckBox();
    chkText5=new QCheckBox();

    //--------------------   TEXT ----------------------//
    lbVendorID->setText(tr("Vendor ID:"));
    lbVendorName->setText(tr("Vendor Name:"));
    lbVendorAccNo->setText(tr("Vendor Account No:"));
    lbText1->setText(tr("Text Label Input Field #1:"));
    lbText2->setText(tr("Text Label Input Field #2:"));
    lbText3->setText(tr("Text Label Input Field #3:"));
    lbText4->setText(tr("Text Label Input Field #4:"));
    lbText5->setText(tr("Text Label Input Field #5:"));
    chkText1->setText(tr("Display Input Field #1:"));
    chkText2->setText(tr("Display Input Field #2:"));
    chkText3->setText(tr("Display Input Field #3:"));
    chkText4->setText(tr("Display Input Field #4:"));
    chkText5->setText(tr("Display Input Field #5:"));

    //--------------------   LAYOUT ----------------------//
    QVBoxLayout *v1Lay=new QVBoxLayout();
    v1Lay->addWidget(lbVendorID);
    v1Lay->addWidget(leVendorID);
    v1Lay->addWidget(lbVendorName);
    v1Lay->addWidget(leVendorName);
    v1Lay->addWidget(lbVendorAccNo);
    v1Lay->addWidget(leVendorAccNo);
    v1Lay->addWidget(chkText1);
    v1Lay->addWidget(lbText1);
    v1Lay->addWidget(leText1);
    v1Lay->addWidget(chkText2);
    v1Lay->addWidget(lbText2);
    v1Lay->addWidget(leText2);
    v1Lay->addWidget(chkText3);
    v1Lay->addWidget(lbText3);
    v1Lay->addWidget(leText3);
    v1Lay->addWidget(chkText4);
    v1Lay->addWidget(lbText4);
    v1Lay->addWidget(leText4);
    v1Lay->addWidget(chkText5);
    v1Lay->addWidget(lbText5);
    v1Lay->addWidget(leText5);


    //--------------------   CANCEL & SUBMIT ----------------------//
    btnCancel=new QPushButton();
    btnSubmit=new QPushButton();
    btnCancel->setText(tr("Cancel"));
    btnSubmit->setText(tr("Submit"));
    btnCancel->setFont(font2);
    btnSubmit->setFont(font2);
    btnCancel->setMinimumHeight(30);
    btnSubmit->setMinimumHeight(30);
    btnCancel->setStyleSheet("color: rgb(255, 255, 255);	background-color: rgb(0, 153, 255);border-radius: 6px;");
    btnSubmit->setStyleSheet("color: rgb(0, 0, 0);	background-color: rgb(0, 255, 0);border-radius: 6px;");


    QHBoxLayout *h1Lay=new QHBoxLayout();
    h1Lay->addSpacing(10);
    h1Lay->addWidget(btnCancel);
    h1Lay->addWidget(btnSubmit);
    h1Lay->addSpacing(10);


    // ---------------ScrollArea----------- //
    scArea=new QScrollArea();
    scWidget=new QWidget();
    hBar=new QScrollBar();
    vBar=new QScrollBar();

    QVBoxLayout *scLayout=new QVBoxLayout(scWidget);
    scLayout->addLayout(v1Lay);


    scWidget->setMaximumWidth(FRAME420_WIDTH-5);
    scWidget->setFont(font);
    scWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    vBar->setStyleSheet("QScrollBar:vertical {"
                        "border:0px solid grey;"
                        "width: 3px;"
                        "}"
                        " QScrollBar::handle:vertical {"
                        " background: #8080FF;"
                        " border: 2px solid grey;"
                        " border-radius:5px;"
                        " min-height: 10px;"
                        " }"
                        " QScrollBar::add-line:vertical {"
                        " height: 0px;"
                        " subcontrol-position: bottom;"
                        " }"
                        " QScrollBar::sub-line:vertical {"
                        " height: 0px;"
                        " subcontrol-position: top;"
                        " }"
                        "QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {"
                        " background: none;"
                        "}"
                        "QScrollArea"
                        "{"
                           "border:0;"
                            "background:rgb(64,64,71);"
                        "}");

    scArea->setVerticalScrollBar(vBar);
    scArea->setHorizontalScrollBar(hBar);
    scArea->setFrameShape(QFrame::NoFrame);
    scArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scArea->setWidget(scWidget);

//    scArea->ensureVisible(240,320,240,320);

    // ------------------------------------------- //

    QVBoxLayout *layout=new QVBoxLayout(this);
    layout->addWidget(lbHead);
    layout->addWidget(scArea);
    layout->addLayout(h1Lay);
    layout->setContentsMargins(0,0,0,5);

    connect(btnCancel, SIGNAL(clicked()), this, SLOT(close()));

    this->setAutoClose(g_constantParam.TIMEOUT_UI);

}
예제 #16
0
bool MyApp::MakeSplash()
{
	// First, load the original (template) splash image.
	int imageType = wxDetermineImageType(m_inputFilename);
	wxImage templateImage;
	if (imageType == -1 || !wxFileExists(m_inputFilename) ||
		!templateImage.LoadFile(m_inputFilename, imageType))
	{
		wxString msg;
		msg.Printf(wxT("Sorry, could not load template image %s"), (const wxChar*) m_inputFilename);
		wxLogMessage(msg);
		return FALSE;
	}

	wxString msg;
	msg.Printf(wxT("Creating new file %s from template file %s and text %s"),
		(const wxChar*) m_outputFilename, (const wxChar*) m_inputFilename, (const wxChar*) m_text);
	Log(msg);

    wxScreenDC screenDC;
	bool useScaling = m_antialias && (m_scaleFactor > 1);
	int pointSize;

#if !USE_SCALING
    useScaling = FALSE;
#endif

	if (useScaling)
		pointSize = m_scaleFactor*m_fontPointSize;
	else
		pointSize = m_fontPointSize;

	wxString faceName = m_fontFaceName;

    wxFont font(pointSize, wxDEFAULT, m_fontStyle, m_fontWeight, FALSE, faceName);
    screenDC.SetFont(font);

    int w, h, scaledW, scaledH;
    screenDC.GetTextExtent(m_text, & w, & h);

	if (useScaling)
	{
		wxFont font2(m_fontPointSize, wxDEFAULT, m_fontStyle, m_fontWeight, FALSE, faceName);
		screenDC.SetFont(font2);
		screenDC.GetTextExtent(m_text, & scaledW, & scaledH);
	}

    screenDC.SetFont(wxNullFont);

	wxBrush backgroundBrush(m_textBackgroundColour, wxSOLID);

    wxBitmap bitmap(w, h);
    wxMemoryDC memDC;
    memDC.SelectObject(bitmap);
    memDC.SetFont(font);
    memDC.SetBackgroundMode(wxTRANSPARENT);
    memDC.SetTextForeground(m_textForegroundColour);
    memDC.SetBackground(backgroundBrush);
    memDC.SetBrush(backgroundBrush);
    memDC.Clear();
    memDC.DrawText(m_text, 0, 0);
    memDC.SelectObject(wxNullBitmap);

    wxImage image = bitmap.ConvertToImage();
	if (m_antialias)
	{
		wxImage anti = wxAntiAlias(image);
		image = anti;
	}

	if (useScaling)
	{
		// Now create an image and rescale it down to the original point size
		image.Rescale(w/m_scaleFactor, h/m_scaleFactor);
	}

	image.SetMaskColour(m_textBackgroundColour.Red(), m_textBackgroundColour.Green(), m_textBackgroundColour.Blue());
    
	wxBitmap bitmap2(image);

	// Now draw the image into the template image

	wxBitmap templateBitmap(templateImage);
	wxMemoryDC memDCTemplate;
	memDCTemplate.SelectObject(templateBitmap);
	
	int x, y;
	if (m_centre)
	{
		y = m_textPosition.y; // Currently, always start at this position
		x = m_textPosition.x - (image.GetWidth() / 2);
	}
	else if (m_rightJustify)
	{
		y = m_textPosition.y; // Currently, always start at this position
		x = m_textPosition.x - (image.GetWidth());
	}
	else
	{
		y = m_textPosition.y; // Currently, always start at this position
		x = m_textPosition.x;
	}
	memDCTemplate.DrawBitmap(bitmap2, x, y, TRUE);
	memDCTemplate.SelectObject(wxNullBitmap);

	wxImage completeImage = templateBitmap.ConvertToImage();

	int saveImageType = wxDetermineImageType(m_outputFilename);
	if (saveImageType == -1)
	{
		wxLogMessage(wxT("Sorry, unknown output image file type."));
		return FALSE;
	}

	((MyFrame*) GetTopWindow())->m_viewerWindow->SetBitmap(templateBitmap);

	// TODO: get the depth from the original image, and set for this image.
	// May have to do explicit image reduction for this to work.

	if (!completeImage.SaveFile(m_outputFilename, saveImageType))
	{
		wxString msg;
		msg.Printf(wxT("Sorry, could not save image to %s"), (const wxChar*) m_outputFilename);
		wxLogMessage(msg);
		return FALSE;
	}
#if 0
    if (wxTheClipboard->Open())
    {
        wxTheClipboard->Clear();
        wxTheClipboard->SetData(new wxBitmapDataObject(bitmap2));
        wxTheClipboard->Close();
    }
#endif
    return TRUE;
}
예제 #17
0
// The start of the Application
int App::start(const std::vector<CL_String> &args)
{
	quit = false;

	// Create a console window for text-output if not available
	CL_ConsoleWindow console("Console");

	try
	{
		CL_DisplayWindow window("ClanLib Font Sprite Test", 1024, 480);

		// Connect the Window close event
		CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);

		// Connect a keyboard handler to on_key_up()
		CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);

		// Get the graphic context
		CL_GraphicContext gc = window.get_gc();

		// Load some fonts from the resource file
		CL_ResourceManager resources("font.xml");
		CL_Font_Sprite font1(gc, "Font1", &resources);
		CL_Font_Sprite font2(gc, "Font2", &resources);

		// Run until someone presses escape
		while (!quit)
		{
			gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));
			gc.clear(CL_Colorf::red);

			font1.draw_text(gc, 25, 25, "ClanLib: Phear the Power!");
			
			font2.draw_text(gc, 3, 155, "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzÆæØøÅå0123456789[]()!#$&%/\\=-+~'`\".,:;*?");

			font2.draw_text(gc, 10.0f, 200.0f, 2.0f, 2.0f, "Hello World\nMy Message");

			// Flip the display, showing on the screen what we have drawed
			// since last call to flip()
			window.flip(1);

			// This call processes user input and other events
			CL_KeepAlive::process();
		}
	}
	catch(CL_Exception& exception)
	{
		CL_Console::write_line("Exception caught:");
		CL_Console::write_line(exception.message);

		// Display the stack trace (if available)
		std::vector<CL_String> stacktrace = exception.get_stack_trace();
		int size = stacktrace.size();
		if (size > 0)
		{
			CL_Console::write_line("Stack Trace:");
			for (int cnt=0; cnt < size; cnt++)
			{
				CL_Console::write_line(stacktrace[cnt]);
			}
		}

		console.display_close_message();

		return -1;
	}
	return 0;
}
/** Render the cell.
 * This is called to render the cell.
 * @param window window
 * @param widget widget
 * @param background_area dimensions of the background area
 * @param cell_area dimensions of the cell area
 * @param expose_area dimensions of the exposed area
 * @param flags render flags
 */
void
TwoLinesCellRenderer::render_vfunc(const Glib::RefPtr<Gdk::Drawable> &window,
				   Gtk::Widget &widget,
				   const Gdk::Rectangle &background_area,
				   const Gdk::Rectangle &cell_area,
				   const Gdk::Rectangle &expose_area,
				   Gtk::CellRendererState flags)
#endif
{
#ifdef GLIBMM_PROPERTIES_ENABLED
  // Get cell size
  int x_offset = 0, y_offset = 0;
#if GTK_VERSION_LT(3,0)
  int width = 0, height = 0;
  get_size(widget, cell_area, x_offset, y_offset, width, height);

  // Get cell state
  //Gtk::StateType state;
  Gtk::StateType text_state;
  if ((flags & Gtk::CELL_RENDERER_SELECTED) != 0) {
    //state = Gtk::STATE_SELECTED;
    text_state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
  } else {
    //state = Gtk::STATE_NORMAL;
    text_state = (widget.is_sensitive()) ? Gtk::STATE_NORMAL : Gtk::STATE_INSENSITIVE;
  }
	
  // Draw color text
  Glib::RefPtr<Gdk::Window> win =
    Glib::RefPtr<Gdk::Window>::cast_dynamic(window);
#endif
  Glib::RefPtr<Pango::Layout> layout_ptr =
    widget.create_pango_layout(__property_line1);
  Pango::Rectangle rect1 = layout_ptr->get_pixel_logical_extents();
#if GTK_VERSION_GE(3,0)
  cr->move_to(cell_area.get_x() + x_offset + 2 * property_xpad(),
              cell_area.get_y() + y_offset + 2 * property_ypad());
  layout_ptr->show_in_cairo_context(cr);
#else
  widget.get_style()->paint_layout(win, text_state, true, cell_area,
				   widget, "cellrenderertext",
				   cell_area.get_x() + x_offset + 2 * property_xpad(),
				   cell_area.get_y() + y_offset + 2 * property_ypad(),
				   layout_ptr);
#endif

  if (__property_line2_enabled.get_value()) {
    Glib::RefPtr<Pango::Layout> layout2 =
      widget.create_pango_layout(__property_line2);
#if GTK_VERSION_GE(3,0)
    Pango::FontDescription font2("sans 10");
#else
    Glib::RefPtr<Gtk::Style> style = widget.get_style();
    Pango::FontDescription font2 = style->get_font();
#endif
    font2.set_size((int)roundf(Pango::SCALE_SMALL * font2.get_size()));
    layout2->set_font_description(font2);
    //Pango::Rectangle rect2 = layout2->get_pixel_logical_extents();
    layout2->set_ellipsize(Pango::ELLIPSIZE_END);
    layout2->set_width((cell_area.get_width() - property_xpad()) * Pango::SCALE);

#if GTK_VERSION_GE(3,0)
  cr->move_to(cell_area.get_x() + x_offset + property_xpad(),
              cell_area.get_y() + y_offset + property_ypad() +
             rect1.get_height() + 4);
  layout2->show_in_cairo_context(cr);
#else
    widget.get_style()->paint_layout (win, text_state, true, cell_area,
                                      widget, "cellrenderertext",
                                      cell_area.get_x() + x_offset + property_xpad(),
                                      cell_area.get_y() + y_offset + property_ypad() + rect1.get_height() + 4,
                                      layout2);
#endif
  }
#endif
}