/** * Constructor. */ QG_GraphicView::QG_GraphicView(QWidget* parent, Qt::WindowFlags f, RS_Document* doc) :RS_GraphicView(parent, f) ,device("Mouse") ,curCad(new QCursor(QPixmap(":ui/cur_cad_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curDel(new QCursor(QPixmap(":ui/cur_del_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curSelect(new QCursor(QPixmap(":ui/cur_select_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curMagnifier(new QCursor(QPixmap(":ui/cur_glass_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curHand(new QCursor(QPixmap(":ui/cur_hand_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,redrawMethod(RS2::RedrawAll) ,isSmoothScrolling(false) { RS_DEBUG->print("QG_GraphicView::QG_GraphicView().."); if (doc) { setContainer(doc); doc->setGraphicView(this); setDefaultAction(new RS_ActionDefault(*doc, *this)); } setFactorX(4.0); setFactorY(4.0); setBorders(10, 10, 10, 10); setMouseTracking(true); setFocusPolicy(Qt::NoFocus); // SourceForge issue 45 (Left-mouse drag shrinks window) setAttribute(Qt::WA_NoMousePropagation); view_rect = LC_Rect(toGraph(0, 0), toGraph(getWidth(), getHeight())); }
/** * Constructor. * * @param w Width * @param h Height */ RS_StaticGraphicView::RS_StaticGraphicView(int w, int h, RS_Painter* p, QSize b) { setBackground(RS_Color(255,255,255)); width = w; height = h; painter = p; setBorders(b.width(), b.height(), b.width(), b.height()); }
void SpectrumWidget::mouseReleaseEvent( QMouseEvent *e ) { if ( e->button() == QMouseEvent::LeftButton ) { int left = (int)Wavelength( ( double )m_LMBPointPress.x()/width() ); int right = (int)Wavelength( ( double )e->pos().x()/width() ); if ( left == right ) return; if ( left > right ) setBorders( right, left ); else setBorders( left, right ); } m_LMBPointPress.setX( -1 ); m_LMBPointCurrent.setX( -1 ); }
/** * Constructor. * * @param w Width * @param h Height */ RS_StaticGraphicView::RS_StaticGraphicView(int w, int h, RS_Painter* p, QSize const* pb): width(w) ,height(h) ,painter(p) { setBackground({255,255,255}); QSize b{5, 5}; if (pb) b = *pb; setBorders(b.width(), b.height(), b.width(), b.height()); }
MScalableImage::MScalableImage(const QPixmap *pixmap, int left, int right, int top, int bottom, const QString &pixmapId) : d_ptr(new MScalableImagePrivate()) { Q_D(MScalableImage); d->q_ptr = this; setBorders(left, right, top, bottom); d->m_image = pixmap; d->pixmapId = pixmapId; d->validateSize(); }
void HelperPanel::setupRest() { _Layout = SpringLayout::create(); _Layout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _InfoTabPanel, 5, SpringLayoutConstraints::NORTH_EDGE, this); _Layout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _InfoTabPanel, -5, SpringLayoutConstraints::SOUTH_EDGE, this); _Layout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _InfoTabPanel, -5, SpringLayoutConstraints::EAST_EDGE, this); _Layout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _InfoTabPanel, 5, SpringLayoutConstraints::WEST_EDGE, this); pushToChildren(_InfoTabPanel); setLayout(_Layout); setBorders(NULL); }
void SpectrumWidget::slotZoomIn() { kdDebug() << "SpectrumWidget::slotZoomIn() "<< startValue << ":: "<< endValue << endl; double diff = endValue - startValue; double offset = diff * 0.05; endValue = endValue - offset; startValue = startValue + offset; setBorders( ( int ) startValue, ( int )endValue ); kdDebug() << "SpectrumWidget::slotZoomIn() "<< startValue << ":: "<< endValue << endl; }
void ContentPanel::init() { //Create the Lua Code Editing Panel createLuaEditorSplitPanel(); setIsSplit(false); //Create the Scene Graph Editing Panel createSceneEditorPanel(); //Add the Editing Panels in a card layout to this panel _MainCardLayout = CardLayout::create(); pushToChildren(_SceneEditorPanel); pushToChildren(_LuaEditorSplitPanel); setLayout(_MainCardLayout); setBackgrounds(NULL); setBorders(NULL); }
void SpectrumWidget::slotZoomOut() { kdDebug() << "SpectrumWidget::slotZoomOut() "<< startValue << ":: "<< endValue << endl; double diff = endValue - startValue; double offset = diff * 0.05; endValue = endValue + offset; startValue = startValue - offset; //check for invalid values if ( startValue < 0.0 ) startValue = 0.0; if ( endValue > 800.0 ) endValue = 800.0; setBorders( ( int ) startValue, ( int )endValue ); kdDebug() << "SpectrumWidget::slotZoomOut() "<< startValue << ":: "<< endValue << endl; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// @brief Changes the size of the borders. /// /// @param width Width of the left and right borders /// @param height Height of the top and bottom borders /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setBorders(float width, float height) { setBorders({width, height}); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// @brief Changes the size of the borders. /// /// @param leftBorder Width of the left border /// @param topBorder Height of the top border /// @param rightBorder Width of the right border /// @param bottomBorder Height of the bottom border /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setBorders(float leftBorder, float topBorder, float rightBorder, float bottomBorder) { setBorders({leftBorder, topBorder, rightBorder, bottomBorder}); }
/** * Constructor. */ QG_GraphicView::QG_GraphicView(QWidget* parent, Qt::WindowFlags f, RS_Document* doc) :RS_GraphicView(parent, f) ,hScrollBar(new QG_ScrollBar(Qt::Horizontal, this)) ,vScrollBar(new QG_ScrollBar(Qt::Vertical, this)) ,layout(new QGridLayout(this)) ,gridStatus(new QLabel("-", this)) ,curCad(new QCursor(QPixmap(":ui/cur_cad_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curDel(new QCursor(QPixmap(":ui/cur_del_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curSelect(new QCursor(QPixmap(":ui/cur_select_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curMagnifier(new QCursor(QPixmap(":ui/cur_glass_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,curHand(new QCursor(QPixmap(":ui/cur_hand_bmp.png"), CURSOR_SIZE, CURSOR_SIZE)) ,redrawMethod(RS2::RedrawAll) ,isSmoothScrolling(false) { RS_DEBUG->print("QG_GraphicView::QG_GraphicView().."); RS_DEBUG->print(" Setting Container.."); if (doc) { setContainer(doc); doc->setGraphicView(this); } RS_DEBUG->print(" container set."); setFactorX(4.0); setFactorY(4.0); setOffset(50, 50); setBorders(10, 10, 10, 10); if (doc) { setDefaultAction(new RS_ActionDefault(*doc, *this)); } layout->setMargin(0); layout->setSpacing(0); layout->setColumnStretch(0, 1); layout->setColumnStretch(1, 0); layout->setColumnStretch(2, 0); layout->setRowStretch(0, 1); layout->setRowStretch(1, 0); hScrollBar->setSingleStep(50); hScrollBar->setCursor(Qt::ArrowCursor); layout->addWidget(hScrollBar, 1, 0); layout->addItem(new QSpacerItem(0, hScrollBar->sizeHint().height()), 1, 0); connect(hScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotHScrolled(int))); vScrollBar->setSingleStep(50); vScrollBar->setCursor(Qt::ArrowCursor); layout->addWidget(vScrollBar, 0, 2); layout->addItem(new QSpacerItem(vScrollBar->sizeHint().width(), 0), 0, 2); connect(vScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotVScrolled(int))); // Dummy widgets for scrollbar corners: //layout->addWidget(new QWidget(this), 1, 1); //QWidget* w = new QWidget(this); //w->setEraseColor(QColor(255,0,0)); gridStatus->setAlignment(Qt::AlignRight); layout->addWidget(gridStatus, 1, 1, 1, 2); layout->addItem(new QSpacerItem(50, 0), 0, 1); setMouseTracking(true); // flickering under win: //setFocusPolicy(WheelFocus); setFocusPolicy(Qt::NoFocus); // See https://sourceforge.net/tracker/?func=detail&aid=3289298&group_id=342582&atid=1433844 (Left-mouse drag shrinks window) setAttribute(Qt::WA_NoMousePropagation); int aa = RS_SETTINGS->readNumEntry("/Appearance/Antialiasing"); set_antialiasing(aa?true:false); }
void Borders::setAllBorders(int border) { setBorders(border); setTitle(border); }
void __fastcall TForm1::actCalcClassificationExecute(TObject *Sender) { if(!MakeBackup()) { Log->Lines->Add("Не удалось создать резервную копию файла"); return; } Variant app = Variant::CreateObject("Excel.Application"); app.OlePropertySet("Visible", true); Variant excel = app.OlePropertyGet("Workbooks").OleFunction("Open", WideString(m_strFileName.c_str())); Variant vSheets = excel.OlePropertyGet("Worksheets"); Variant vSheet = vSheets.OlePropertyGet("Item",m_nPageClassification); UnicodeString strPageName = vSheet.OlePropertyGet("Name"); if (strPageName.UpperCase() != UnicodeString("классификации").UpperCase()) { app.OleProcedure("Quit"); MessageBox (Handle, UnicodeString(L"Не верное имя страницы").c_str(), L"prompt", MB_OK); return; }; std::vector<exlClass> classes; ReadClassifications(vSheet, classes); std::vector<exlMonth> months; Variant vSheetMonth; double fSumSum = 0; for (unsigned int i = 0; i < m_vMonth.size(); i++) { if (cmbMonth->Text == m_vMonth[i].Name) { int nMonthPage = m_vMonth[i].Number; vSheetMonth = vSheets.OlePropertyGet("Item", nMonthPage); ReadMonth(vSheetMonth, months); ReadMonthSum(vSheetMonth, fSumSum); } } Log->Lines->Add("Произвожу расчет..."); ProgressBar1->Max = months.size(); ProgressBar1->Min = 0; double nSumHand = 0; std::vector<exlSumClass> vSumClasses; for (unsigned int i = 0; i < months.size(); i++) { ProgressBar1->Position = i; int nFound = 0; nSumHand += months[i].Price; for (unsigned int iC = 0; iC < classes.size(); iC++) { if (nFound == 0 && classes[iC].Name.UpperCase() == months[i].Name.UpperCase()) { months[i].Class = classes[iC].Class; months[i].LinkToClassification = createHyperLinkToClassification(classes, iC); nFound++; } } if (nFound == 0) { months[i].Class = m_sUnknownClass; } nFound = 0; for (unsigned int iC = 0; iC < vSumClasses.size(); iC++) { if (vSumClasses[iC].Name.UpperCase() == months[i].Class.UpperCase()) { vSumClasses[iC].Sum += months[i].Price; nFound++; } } if (nFound == 0) { exlSumClass sm; sm.Name = months[i].Class; sm.Sum = months[i].Price; vSumClasses.push_back(sm); } } /*for (unsigned int i = 0; i < vSumClasses.size(); i++) { Log->Lines->Add(vSumClasses[i].Name + " = " + FloatToStr(vSumClasses[i].Sum)); }*/ Log->Lines->Add("Готово."); Log->Lines->Add("Сортирую классификации..."); ProgressBar1->Max = 100; ProgressBar1->Min = 0; { int nPermutation = 1; while (nPermutation > 0) { nPermutation = 0; for (unsigned int iC = 0; iC < vSumClasses.size()-1; iC++) { ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max; Application->ProcessMessages(); if (vSumClasses[iC].Name.UpperCase() > vSumClasses[iC+1].Name.UpperCase()) { exlSumClass buf = vSumClasses[iC]; vSumClasses[iC] = vSumClasses[iC+1]; vSumClasses[iC+1] = buf; nPermutation++; } } } ProgressBar1->Position = 0; } Log->Lines->Add("Готово."); Log->Lines->Add("Очистка старых данных"); ProgressBar1->Max = 100; ProgressBar1->Min = 0; // clear sum classes, 11,12 { bool b = true; int nRow = 1; while (b) { b = false; nRow++; ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max; Application->ProcessMessages(); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OleProcedure("ClearFormats"); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OleProcedure("ClearFormats"); UnicodeString sValue11 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertyGet("Value"); UnicodeString sValue12 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertyGet("Value"); clearCell(vSheetMonth, nRow, 11); clearCell(vSheetMonth, nRow, 12); if (sValue12.Trim().Length() > 0 || sValue11.Trim().Length() > 0) { b = true; } } ProgressBar1->Position = 0; } // clear 14,15,16,17 { bool b = true; int nRow = 1; while (b) { b = false; nRow++; ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max; Application->ProcessMessages(); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OleProcedure("ClearFormats"); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OleProcedure("ClearFormats"); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OleProcedure("ClearFormats"); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OleProcedure("ClearFormats"); UnicodeString sValue14 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertyGet("Value"); UnicodeString sValue15 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertyGet("Value"); UnicodeString sValue16 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertyGet("Value"); UnicodeString sValue17 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertyGet("Value"); clearCell(vSheetMonth, nRow, 14); clearCell(vSheetMonth, nRow, 15); clearCell(vSheetMonth, nRow, 16); clearCell(vSheetMonth, nRow, 17); if ( sValue14.Trim().Length() > 0 || sValue15.Trim().Length() > 0 || sValue16.Trim().Length() > 0 || sValue17.Trim().Length() > 0 ) { b = true; } } ProgressBar1->Position = 0; } Log->Lines->Add("Запись новых данных"); { double nSum = 0; int nRow = 2; vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Класс")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString("Сумма")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertyGet("Font").OlePropertySet("Bold", true); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertyGet("Font").OlePropertySet("Bold", true); vSheetMonth.OlePropertyGet("Columns", WideString("K")).OlePropertySet("ColumnWidth", 20); vSheetMonth.OlePropertyGet("Columns", WideString("L")).OlePropertySet("ColumnWidth", 15); setBorders(vSheetMonth, nRow, 11); setBorders(vSheetMonth, nRow, 12); setColor(vSheetMonth, nRow, 11, RGBToInt(240, 230, 140)); setColor(vSheetMonth, nRow, 12, RGBToInt(240, 230, 140)); ProgressBar1->Max = vSumClasses.size(); ProgressBar1->Min = 0; for (unsigned int i = 0; i < vSumClasses.size(); i++) { nRow++; ProgressBar1->Position = i; nSum += vSumClasses[i].Sum; vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString(vSumClasses[i].Name)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(vSumClasses[i].Sum)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat)); setBorders(vSheetMonth, nRow, 11); setBorders(vSheetMonth, nRow, 12); } nRow++; ProgressBar1->Position = 0; vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Итого:")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(nSum)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat)); nRow++; vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Сумма сумм по дням:")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(fSumSum)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat)); } { double nSum = 0; int nRow = 2; vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString("Класс")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertySet("Value", WideString("Наименование")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString("Цена")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("Value", WideString("Ссылка")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertyGet("Font").OlePropertySet("Bold", true); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertyGet("Font").OlePropertySet("Bold", true); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertyGet("Font").OlePropertySet("Bold", true); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertyGet("Font").OlePropertySet("Bold", true); vSheetMonth.OlePropertyGet("Columns", WideString("N")).OlePropertySet("ColumnWidth", 20); vSheetMonth.OlePropertyGet("Columns", WideString("O")).OlePropertySet("ColumnWidth", 50); vSheetMonth.OlePropertyGet("Columns", WideString("P")).OlePropertySet("ColumnWidth", 15); vSheetMonth.OlePropertyGet("Columns", WideString("Q")).OlePropertySet("ColumnWidth", 50); setBorders(vSheetMonth, nRow, 14); setBorders(vSheetMonth, nRow, 15); setBorders(vSheetMonth, nRow, 16); setBorders(vSheetMonth, nRow, 17); setColor(vSheetMonth, nRow, 14, RGBToInt(240, 230, 140)); setColor(vSheetMonth, nRow, 15, RGBToInt(240, 230, 140)); setColor(vSheetMonth, nRow, 16, RGBToInt(240, 230, 140)); setColor(vSheetMonth, nRow, 17, RGBToInt(240, 230, 140)); ProgressBar1->Max = months.size(); ProgressBar1->Min = 0; for (unsigned int i = 0; i < months.size(); i++) { nRow++; ProgressBar1->Position = i; nSum += months[i].Price; vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString(months[i].Class)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertySet("Value", WideString(months[i].Name)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString(months[i].Price)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("NumberFormat", WideString(m_strNumberFormat)); if (months[i].Price < 0) { setColor(vSheetMonth, nRow, 16, RGBToInt(240, 230, 140)); } // TODO: check linkt to classification // vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("Value", WideString(months[i].LinkToClassification.c_str())); setBorders(vSheetMonth, nRow, 14); setBorders(vSheetMonth, nRow, 15); setBorders(vSheetMonth, nRow, 16); setBorders(vSheetMonth, nRow, 17); } nRow++; ProgressBar1->Position = 0; vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString("Итого:")); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString(nSum)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("NumberFormat", WideString(m_strNumberFormat)); vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("NumberFormat", WideString(m_strNumberFormat)); } Log->Lines->Add("Сохраняю файл..."); try { app.OlePropertySet("DisplayAlerts",false); excel.OleProcedure("SaveAs", WideString(m_strFileName.c_str())); Log->Lines->Add("Данные сохранены!"); } catch (...) { Log->Lines->Add("Ошибка: Пожалуйста закройте все открытые копии файла и повторите операцию"); } ProgressBar1->Position = 0; app.OleProcedure("Quit"); }