wxPoint wxControl::GTKGetEntryMargins(GtkEntry* entry) const { wxPoint marg(0, 0); #ifndef __WXGTK3__ #if GTK_CHECK_VERSION(2,10,0) // The margins we have previously set const GtkBorder* border = NULL; if (gtk_check_version(2,10,0) == NULL) border = gtk_entry_get_inner_border(entry); if ( border ) { marg.x = border->left + border->right; marg.y = border->top + border->bottom; } #endif // GTK+ 2.10+ #else // GTK+ 3 // Gtk3 does not use inner border, but StyleContext and CSS // TODO: implement it, starting with wxTextEntry::DoSetMargins() #endif // GTK+ 2/3 int x, y; gtk_entry_get_layout_offsets(entry, &x, &y); // inner borders are included. Substract them so we can get other margins x -= marg.x; y -= marg.y; marg.x += 2 * x + 2; marg.y += 2 * y + 2; return marg; }
void updateLabelParams(OSG::Label* label, int idx) { OSG::Real32 orient = 0; OSG::Vec2f pixOffset = OSG::Vec2f(0,0); OSG::Color4f bgColor = OSG::Color4f(OSG::osgRand(), OSG::osgRand(), OSG::osgRand(), OSG::osgRand()); OSG::Vec2f marg(0,0); switch (idx) { case 0: orient = 45.0; bgColor = OSG::Color4f(0,0,0,0); break; case 1: orient = 15.0; marg = OSG::Vec2f(2,2); break; case 2: orient = 45.0; marg = OSG::Vec2f(4,4); break; case 3: orient = 85.0; marg = OSG::Vec2f(20,20); break; default: ; } label->setOrientation(orient); label->setPixelOffset(pixOffset); label->setBorderColor(OSG::Color4f(OSG::osgRand(), OSG::osgRand(), OSG::osgRand(), 1.0)); label->setBgColor(bgColor); label->setBorderOffset(OSG::Vec2f(0,0)); label->setShadowOffset(OSG::Vec2f(4,4)); label->setMargin(marg); }
wxSize wxComboBox::DoGetSizeFromTextSize(int xlen, int ylen) const { wxSize tsize( wxChoice::DoGetSizeFromTextSize(xlen, ylen) ); if ( !HasFlag(wxCB_READONLY) ) { // Add the margins we have previously set wxPoint marg( GetMargins() ); marg.x = wxMax(0, marg.x); marg.y = wxMax(0, marg.y); tsize.IncBy( marg ); } return tsize; }
void BP_dual::calcNewM( size_t i, size_t _I ) { // calculate updated message I->i const Neighbor &I = fg().nbV(i)[_I]; Prob prod( fg().factor(I).p() ); diaforeach( const Neighbor &j, fg().nbF(I) ) if( j != i ) { // for all j in I \ i Prob &n = msgN(j,j.dual); IndexFor ind( fg().var(j), fg().factor(I).vars() ); for( size_t x = 0; ind.valid(); x++, ++ind ) prod.set( x, prod[x] * n[ind] ); } // Marginalize onto i Prob marg( fg().var(i).states(), 0.0 ); // ind is the precalculated Index(i,I) i.e. to x_I == k corresponds x_i == ind[k] IndexFor ind( fg().var(i), fg().factor(I).vars() ); for( size_t x = 0; ind.valid(); x++, ++ind ) marg.set( ind, marg[ind] + prod[x] ); _msgs.Zm[i][_I] = marg.normalize(); _msgs.m[i][_I] = marg; }
void NewDoc::createNewDocPage() { newDocFrame = new QFrame(this); pageSizeGroupBox = new QGroupBox(newDocFrame ); pageSizeGroupBox->setTitle( tr( "Document Layout" ) ); pageSizeGroupBoxLayout = new QGridLayout( pageSizeGroupBox ); pageSizeGroupBoxLayout->setMargin(10); pageSizeGroupBoxLayout->setSpacing(5); pageSizeGroupBoxLayout->setAlignment( Qt::AlignTop ); layoutsView = new PageLayoutsWidget( pageSizeGroupBox ); layoutsView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); for (int pg = 0; pg < prefsManager->appPrefs.pageSets.count(); ++pg) { QListWidgetItem *ic; QString psname=CommonStrings::translatePageSetString(prefsManager->appPrefs.pageSets[pg].Name); if (pg == 0) { ic = new QListWidgetItem( QIcon(loadIcon("32/page-simple.png")), psname, layoutsView ); ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } else if (pg == 1) { ic = new QListWidgetItem( QIcon(loadIcon("32/page-doublesided.png")), psname, layoutsView ); ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } else if (pg == 2) { ic = new QListWidgetItem( QIcon(loadIcon("32/page-3fold.png")), psname, layoutsView ); ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } else if (pg == 3) { ic = new QListWidgetItem( QIcon(loadIcon("32/page-4fold.png")), psname, layoutsView ); ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } else { ic = new QListWidgetItem( QIcon(loadIcon("32/page-simple.png")), psname, layoutsView ); ic->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } } layoutsView->arrangeIcons(); pageSizeGroupBoxLayout->addWidget( layoutsView, 0, 0, 5, 1 ); layoutsView->arrangeIcons(); TextLabel1 = new QLabel( tr( "&Size:" ), pageSizeGroupBox ); pageSizeGroupBoxLayout->addWidget( TextLabel1, 0, 1 ); PageSize ps(prefsManager->appPrefs.pageSize); pageSizeComboBox = new QComboBox( pageSizeGroupBox ); pageSizeComboBox->addItems(ps.sizeTRList()); pageSizeComboBox->addItem( CommonStrings::trCustomPageSize ); pageSizeComboBox->setEditable(false); TextLabel1->setBuddy(pageSizeComboBox); pageSizeGroupBoxLayout->addWidget(pageSizeComboBox, 0, 2 ); TextLabel2 = new QLabel( tr( "Orie&ntation:" ), pageSizeGroupBox ); pageSizeGroupBoxLayout->addWidget( TextLabel2, 1, 1 ); pageOrientationComboBox = new QComboBox( pageSizeGroupBox ); pageOrientationComboBox->addItem( tr( "Portrait" ) ); pageOrientationComboBox->addItem( tr( "Landscape" ) ); pageOrientationComboBox->setEditable(false); pageOrientationComboBox->setCurrentIndex(prefsManager->appPrefs.pageOrientation); TextLabel2->setBuddy(pageOrientationComboBox); pageSizeGroupBoxLayout->addWidget( pageOrientationComboBox, 1, 2 ); TextLabel1_2 = new QLabel( tr( "&Width:" ), pageSizeGroupBox ); pageSizeGroupBoxLayout->addWidget(TextLabel1_2, 2, 1 ); widthSpinBox = new ScrSpinBox( 1, 16777215, pageSizeGroupBox, m_unitIndex ); widthSpinBox->setSuffix(m_unitSuffix); TextLabel1_2->setBuddy(widthSpinBox); pageSizeGroupBoxLayout->addWidget(widthSpinBox, 2, 2 ); TextLabel2_2 = new QLabel( tr( "&Height:" ), pageSizeGroupBox ); pageSizeGroupBoxLayout->addWidget(TextLabel2_2, 3, 1 ); heightSpinBox = new ScrSpinBox( 1, 16777215, pageSizeGroupBox, m_unitIndex ); heightSpinBox->setSuffix(m_unitSuffix); TextLabel2_2->setBuddy(heightSpinBox); pageSizeGroupBoxLayout->addWidget(heightSpinBox, 3, 2 ); layoutLabel1 = new QLabel( pageSizeGroupBox ); layoutLabel1->setText( tr( "First Page is:" ) ); pageSizeGroupBoxLayout->addWidget( layoutLabel1, 4, 1 ); firstPage = new ScComboBox( pageSizeGroupBox ); firstPage->clear(); pageSizeGroupBoxLayout->addWidget( firstPage, 4, 2 ); selectItem(prefsManager->appPrefs.FacingPages); firstPage->setCurrentIndex(prefsManager->appPrefs.pageSets[prefsManager->appPrefs.FacingPages].FirstPage); MarginStruct marg(prefsManager->appPrefs.margins); marginGroup = new MarginWidget(newDocFrame, tr( "Margin Guides" ), &marg, m_unitIndex ); marginGroup->setPageWidthHeight(prefsManager->appPrefs.PageWidth, prefsManager->appPrefs.PageHeight); marginGroup->setFacingPages(!(prefsManager->appPrefs.FacingPages == singlePage)); widthSpinBox->setValue(prefsManager->appPrefs.PageWidth * m_unitRatio); heightSpinBox->setValue(prefsManager->appPrefs.PageHeight * m_unitRatio); QStringList pageSizes=ps.sizeList(); int sizeIndex=pageSizes.indexOf(ps.nameTR()); if (sizeIndex!=-1) pageSizeComboBox->setCurrentIndex(sizeIndex); else pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count()-1); marginGroup->setPageSize(pageSizeComboBox->currentText()); setDocLayout(prefsManager->appPrefs.FacingPages); setSize(prefsManager->appPrefs.pageSize); setOrientation(prefsManager->appPrefs.pageOrientation); marginGroup->setNewBleeds(prefsManager->appPrefs.bleeds); marginGroup->setMarginPreset(prefsManager->appPrefs.marginPreset); optionsGroupBox = new QGroupBox( newDocFrame ); optionsGroupBox->setTitle( tr( "Options" ) ); optionsGroupBoxLayout = new QFormLayout( optionsGroupBox ); optionsGroupBoxLayout->setSpacing( 5 ); optionsGroupBoxLayout->setMargin( 10 ); optionsGroupBoxLayout->setAlignment( Qt::AlignTop ); optionsGroupBoxLayout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop); optionsGroupBoxLayout->setLabelAlignment(Qt::AlignLeft); pageCountLabel = new QLabel( tr( "N&umber of Pages:" ), optionsGroupBox ); pageCountSpinBox = new QSpinBox( optionsGroupBox ); pageCountSpinBox->setMaximum( 10000 ); pageCountSpinBox->setMinimum( 1 ); pageCountLabel->setBuddy(pageCountSpinBox); unitOfMeasureLabel = new QLabel( tr( "&Default Unit:" ), optionsGroupBox ); unitOfMeasureComboBox = new QComboBox( optionsGroupBox ); unitOfMeasureComboBox->addItems(unitGetTextUnitList()); unitOfMeasureComboBox->setCurrentIndex(m_unitIndex); unitOfMeasureComboBox->setEditable(false); unitOfMeasureLabel->setBuddy(unitOfMeasureComboBox); optionsGroupBoxLayout->addRow( pageCountLabel, pageCountSpinBox); optionsGroupBoxLayout->addRow( unitOfMeasureLabel, unitOfMeasureComboBox ); autoTextFrame = new QCheckBox( optionsGroupBox ); autoTextFrame->setText( tr( "&Automatic Text Frames" ) ); optionsGroupBoxLayout->addRow( autoTextFrame ); TextLabel3 = new QLabel( tr( "Colu&mns:" ), optionsGroupBox ); numberOfCols = new QSpinBox( optionsGroupBox ); numberOfCols->setButtonSymbols( QSpinBox::UpDownArrows ); numberOfCols->setMinimum( 1 ); numberOfCols->setValue( 1 ); TextLabel3->setBuddy(numberOfCols); optionsGroupBoxLayout->addRow( TextLabel3, numberOfCols ); TextLabel4 = new QLabel( tr( "&Gap:" ), optionsGroupBox ); Distance = new ScrSpinBox( 0, 1000, optionsGroupBox, m_unitIndex ); Distance->setValue(11 * m_unitRatio); m_distance = 11; optionsGroupBoxLayout->addRow( TextLabel4, Distance ); TextLabel4->setBuddy(Distance); TextLabel3->setEnabled(false); TextLabel4->setEnabled(false); Distance->setEnabled(false); numberOfCols->setEnabled(false); startDocSetup = new QCheckBox( optionsGroupBox ); startDocSetup->setText( tr( "Show Document Settings After Creation" ) ); startDocSetup->setChecked(false); optionsGroupBoxLayout->addRow( startDocSetup ); NewDocLayout = new QGridLayout( newDocFrame ); NewDocLayout->setMargin(10); NewDocLayout->setSpacing(5); NewDocLayout->addWidget( marginGroup, 1, 0 ); NewDocLayout->addWidget( optionsGroupBox, 1, 1 ); NewDocLayout->addWidget( pageSizeGroupBox, 0, 0, 1, 2); }