void test_gemm(const std::string &name, int M, int N, int K, float alpha, float beta) { Halide::Buffer<int32_t> sizes(3); Halide::Buffer<float> params(3); Halide::Buffer<float> A(K, M); Halide::Buffer<float> B(N, K); Halide::Buffer<float> C(N, M); Halide::Buffer<float> C_ref(N, M); sizes(0) = M; sizes(1) = N; sizes(2) = K; params(0) = alpha; params(1) = beta; for (int i = 0; i < K; i++) for (int j = 0; j < M; j++) A(i, j) = std::rand() % 10 - 5; for (int i = 0; i < N; i++) for (int j = 0; j < K; j++) B(i, j) = std::rand() % 10 - 5; for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) C(i, j) = std::rand() % 10 - 5; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { C_ref(i, j) = beta * C(i, j); for (int k = 0; k < K; k++) { C_ref(i, j) += alpha * A(k, j) * B(i, k); } } } test_162(sizes.raw_buffer(), params.raw_buffer(), A.raw_buffer(), B.raw_buffer(), C.raw_buffer()); compare_buffers(name, C, C_ref); }
inline int Blob::xsize(int axis) const { if (axis < -dims() || axis >= dims()) return 1; return sizes()[(axis < 0) ? axis + dims() : axis]; }
Splitter::Splitter(QWidget *parent) : QWidget(parent) { QHBoxLayout *hbox = new QHBoxLayout(this); QFrame *topleft = new QFrame(this); topleft->setFrameShape(QFrame::StyledPanel); QFrame *topright = new QFrame(this); topright->setFrameShape(QFrame::StyledPanel); QSplitter *splitter1 = new QSplitter(Qt::Horizontal, this); splitter1->addWidget(topleft); splitter1->addWidget(topright); QFrame *bottom = new QFrame(this); bottom->setFrameShape(QFrame::StyledPanel); QSplitter *splitter2 = new QSplitter(Qt::Vertical, this); splitter2->addWidget(splitter1); splitter2->addWidget(bottom); QList<int> sizes({50, 100}); splitter2->setSizes(sizes); hbox->addWidget(splitter2); }
int Splitter::getRightChildrenSize() const { QList<int> list = sizes(); assert(list.size() == 2); return list.back(); }
int Splitter::getLeftChildrenSize() const { QList<int> list = sizes(); assert(list.size() == 2); return list.front(); }
void sf_out(sf_file out /* output file */, int axis /* join axis */, const char *iname /* name of the input file */) /*< prepare output >*/ { char *oname, cmdline[SF_CMDLEN]; int ndim; off_t n[SF_MAX_DIM]; sf_file inp; FILE *ofile=NULL; ofile = sf_tempfile(&oname,"w+b"); fclose(ofile); snprintf(cmdline,SF_CMDLEN,"%s %s --dryrun=y < %s > %s", command,splitcommand,iname,oname); sf_system(cmdline); inp = sf_input(oname); ndim = sf_largefiledims (inp,n); if (axis > ndim) axis=ndim; snprintf(nkey,5,"n%d",axis); axis--; sizes(inp,axis,ndim,n,&size1,&size2); sf_setformat(out,sf_histstring(inp,"data_format")); sf_fileflush(out,inp); sf_setform(out,SF_NATIVE); sf_rm(oname,true,false,false); }
void Desktopwidget::closing (void) { QList<int> size = sizes (); setSettingsSizes ("desktopwidget/", size); _page->closing (); }
void AnimatedSplitter::setActiveWidgetWidth(int width) { if (mActiveIndex >=0 && mActiveIndex < count()) { qDebug() << "w" << width; // We have to explicitly redistribute the sizes, otherwise // any additional/missing space is distributed amongst the widgets // according to the relative weight of the sizes. see. setSizes() documentation QList<int> sz(sizes()); int delta = width - sz.at(mActiveIndex); // < 0 for shrinking if (mActiveIndex < count()-1 && sz.at(mActiveIndex+1) > delta) { // take place from right sz.replace(mActiveIndex, width); sz.replace(mActiveIndex+1, sz.at(mActiveIndex+1) - delta); } else if (mActiveIndex > 0 && sz.at(mActiveIndex-1) > delta) { // take place from left sz.replace(mActiveIndex, width); sz.replace(mActiveIndex-1, sz.at(mActiveIndex-1) - delta); } else { // fallback: // TODO: the widget likely will not have the final width "width", because of space redistribution sz.replace(mActiveIndex, width); qDebug() << "AnimatedSplitter fallback: no cannot take space from adjacent widgets"; } setSizes(sz); } }
void BarChartWidget::drawBars(QPainter &painter) { std::vector<int> sizes(BAR_COUNT, 0); fillSizes(sizes); QRect baseRectangle = rect(); int activeWidth = (int) std::floor( baseRectangle.width() * (1 - 2 * PADDING) ); int singleBarWidth = (int) std::floor((activeWidth - (BAR_COUNT + 1) * SPACING) / BAR_COUNT); int baseLineY = (int) std::floor(baseRectangle.bottom() - PADDING_BOTTOM); int currX = (int) std::floor(baseRectangle.left() + baseRectangle.width() * PADDING); currX += SPACING; for (int i = 0; i < BAR_COUNT; i++) { QPoint pointTopLeft(currX, baseLineY - sizes.at((unsigned long) i)); QPoint pointBottomRight(currX + singleBarWidth, baseLineY - 1); QRect bar(pointTopLeft, pointBottomRight); painter.setPen(mainColor); painter.drawRect(bar); painter.fillRect(bar, barColor); QPoint textTopLeft(currX, baseLineY); QPoint textBottomRight(currX + singleBarWidth, baseRectangle.bottom()); QRect textRect(textTopLeft, textBottomRight); painter.setPen(mainColor); painter.drawText(textRect, Qt::AlignCenter, labels->at((unsigned long) i)); QPoint valueTopLeft(currX, baseLineY - sizes.at((unsigned long) i) - VALUE_LABEL_HEIGHT); QPoint valueBottomRight(currX + singleBarWidth, baseLineY); QRect valueLabelRect(valueTopLeft, valueBottomRight); QString textValue = QString::number(values->at((unsigned long) i)); painter.drawText(valueLabelRect, Qt::AlignHCenter | Qt::AlignTop, textValue); currX += singleBarWidth + SPACING; } }
std::array<uint64_t, 3> nrrd_impl::dimensions() { std::istringstream sizes(this->value("sizes")); std::array<uint64_t, 3> dims; sizes >> dims[0] >> dims[1] >> dims[2]; return dims; }
int main(int argc,char* argv[]){ // Create some type shortcuts typedef Optizelle::Rm <double> X; typedef Optizelle::SQL <double> Z; typedef X::Vector X_Vector; typedef Z::Vector Z_Vector; // Read in the name for the input file if(argc!=2) { std::cerr << "simple_quadratic_cone <parameters>" << std::endl; exit(EXIT_FAILURE); } std::string fname(argv[1]); // Generate an initial guess for the primal X_Vector x(2); x[0]=1.2; x[1]=3.1; // Generate an initial guess for the dual std::vector <Optizelle::Natural> sizes(1); sizes[0]=2; std::vector <Optizelle::Cone::t> types(1); types[0]=Optizelle::Cone::Quadratic; Z_Vector z(types,sizes); // Create an optimization state Optizelle::InequalityConstrained <double,Optizelle::Rm,Optizelle::SQL> ::State::t state(x,z); // Read the parameters from file Optizelle::json::InequalityConstrained <double,Optizelle::Rm,Optizelle::SQL> ::read(Optizelle::Messaging(),fname,state); // Create a bundle of functions Optizelle::InequalityConstrained<double,Optizelle::Rm,Optizelle::SQL> ::Functions::t fns; fns.f.reset(new MyObj); fns.h.reset(new MyIneq); // Solve the optimization problem Optizelle::InequalityConstrained <double,Optizelle::Rm,Optizelle::SQL> ::Algorithms::getMin(Optizelle::Messaging(),fns,state); // Print out the reason for convergence std::cout << "The algorithm converged due to: " << Optizelle::StoppingCondition::to_string(state.opt_stop) << std::endl; // Print out the final answer std::cout << std::setprecision(16) << std::scientific << "The optimal point is: (" << state.x[0] << ',' << state.x[1] << ')' << std::endl; // Write out the final answer to file Optizelle::json::InequalityConstrained <double,Optizelle::Rm,Optizelle::SQL> ::write_restart(Optizelle::Messaging(),"solution.json",state); // Successful termination return EXIT_SUCCESS; }
// Unsqueezes src `before` times at the front and `after` times at the end static Tensor unsqueezeN(const Tensor & src, int64_t before, int64_t after) { auto srcSizes = src.sizes(); auto nDim = src.dim(); std::vector<int64_t> sizes(nDim + before + after, 1); for (int64_t i = 0; i < nDim; i++) { sizes[i + before] = srcSizes[i]; } return src.view(sizes); }
/** * Returns number of synapses formed. * Fills it in transpose form, because we need to count and index the * number of synapses on the target, so we need to iterate over the sources * in the inner loop. Once full, does the transpose. * Should really have a seed argument for the random number. * Later need a way to fast-forward mtrand to just the entries we * need to fill. */ unsigned int SparseMsg::randomConnect( double probability ) { unsigned int nRows = matrix_.nRows(); // Sources unsigned int nCols = matrix_.nColumns(); // Destinations matrix_.clear(); unsigned int totalSynapses = 0; vector< unsigned int > sizes( nCols, 0 ); unsigned int totSynNum = 0; Element* syn = e2_; unsigned int startData = syn->localDataStart(); unsigned int endData = startData + syn->numLocalData(); assert( nCols == syn->numData() ); matrix_.transpose(); for ( unsigned int i = 0; i < nCols; ++i ) { vector< unsigned int > synIndex; // This needs to be obtained from current size of syn array. // unsigned int synNum = sizes[ i ]; unsigned int synNum = 0; for ( unsigned int j = 0; j < nRows; ++j ) { double r = mtrand(); // Want to ensure it is called each time round the loop. if ( r < probability ) { synIndex.push_back( synNum ); ++synNum; ++totSynNum; } else { synIndex.push_back( ~0 ); } } if ( i >= startData && i < endData ) { e2_->resizeField( i - startData, synNum ); } totalSynapses += synNum; matrix_.addRow( i, synIndex ); /* * This is the correct form, but I need to implement something * to check up for target nodes in order to use this. if ( i >= startData && i < endData ) { e2_->resizeField( i - startData, synNum ); totalSynapses += synNum; matrix_.addRow( i, synIndex ); } else { synIndex.resize( 0 ); synIndex.assign( nRows, ~0 ); matrix_.addRow( i, synIndex ); } */ } matrix_.transpose(); // cout << Shell::myNode() << ": sizes.size() = " << sizes.size() << ", ncols = " << nCols << ", startSynapse = " << startSynapse << endl; e1()->markRewired(); e2()->markRewired(); return totalSynapses; }
bool Kernel::NDRange::divisible (NDRange& range) const { if (range.dims() != dims()) return false; for (int i = 0; i < dims(); i++) if (sizes()[i] % range.sizes()[i] != 0) return false; return true; }
SparseMatrix::SparseMatrix(std::string env, std::string stif) { // std::string filename("/home/popka/kursach/simple1_out_model/ENV.bin"); std::ifstream env_stream; env_stream.open(env.c_str(), std::ios::binary); if (env_stream.bad()) std::cout << "wrong file name " << env; env_stream.seekg(0, std::ios_base::end); const size_t count_of_elements(env_stream.tellg() / sizeof(int)); env_stream.seekg(0, std::ios_base::beg); std::vector<size_t> sizes(count_of_elements); int* buf(new int[count_of_elements]); env_stream.read(static_cast<char*>(static_cast<void*>(buf)), count_of_elements * sizeof(int)); env_stream.close(); for (size_t i(0); i != sizes.size(); ++i) { sizes[i] = buf[i]; } delete[] buf; table.resize(sizes.size()); size = sizes.size(); std::ifstream stif_stream; stif_stream.open(stif.c_str(), std::ios::binary); size_t fullSize(0); stif_stream.seekg(0, std::ios_base::end); fullSize = stif_stream.tellg(); stif_stream.seekg(0, std::ios_base::beg); real* buf_m(new real[fullSize]); stif_stream.read(static_cast<char*>(static_cast<void*>(buf_m)), fullSize); stif_stream.close(); size_t sum(0); for (size_t i=0 ;i<sizes.size(); ++i) { std::vector<real> tmpl(sizes[i]); for (size_t j=0; j<sizes[i]; ++j) { tmpl[sizes[i]-j-1] = buf_m[sum+j]; if (abs(buf_m[sum+j]) >1e+40) std::cout << "BIG MATRIX "; } /* size_t k = i- (sizes[i] - 1); std::cout << "\n sizes[i] = " << sizes[i] << " i=" << i <<" первый ненулевой" << k << std::endl; std::cout << "\n SparseArray \n ============= \n "; for (size_t m=0; m<tmpl.size(); m++) { std::cout << tmpl[m] << " "; } std::cout << "\n Buf \n ============= \n "; for (size_t m=0; m<tmpl.size(); m++) { std::cout << buf_m[sum+m] << " "; } int as; std::cin >> as;*/ table[i] = new SparseArray(tmpl, i - (sizes[i] - 1)); sum+=sizes[i]; } delete[] buf_m; }
int main() { sizes(); { A* pB = new B; delete pB; } std::cin.get(); return 0; }
int main() { char ch = 'a'; int i = 100; int* p; *p = 10; bool b = true; double d = 10.0; sizes(ch, i, p, b, d); }
QString Splitter::serializeNatron() const { QMutexLocker l(&_lock); QList<int> list = sizes(); if (list.size() == 2) { return QString::fromUtf8("%1 %2").arg(list[0]).arg(list[1]); } return QString(); }
void InlineCacheRegistry::print_stats(STATE) { SYNC(state); int total = 0; std::vector<int> sizes(cTrackedICHits + 1); int overflow = 0; for(CacheHash::iterator hi = caches_.begin(); hi != caches_.end(); ++hi) { for(CacheVector::iterator vi = hi->second.begin(); vi != hi->second.end(); ++vi) { InlineCache* ic = *vi; int seen = ic->classes_seen(); if(ic->seen_classes_overflow() > 0) { total++; overflow++; } else if(seen > 0) { total++; sizes[seen]++; } } } std::cerr << "IC Stats:\n"; for(int i = 1; i < cTrackedICHits + 1; i++) { std::cerr << " " << i << ": " << sizes[i] << " " << ratio(sizes[i], total) << "%\n"; } std::cerr << cTrackedICHits << "+: " << overflow << " " << ratio(overflow, total) << "%\n"; // print out the mega-morphic ones std::cerr << "\nMegamorphic call sites:\n"; for(CacheHash::iterator hi = caches_.begin(); hi != caches_.end(); ++hi) { for(CacheVector::iterator vi = hi->second.begin(); vi != hi->second.end(); ++vi) { InlineCache* ic = *vi; if(ic->seen_classes_overflow() > 0) { ic->print(state, std::cerr); std::cerr << "location: "; ic->print_location(state, std::cerr); std::cerr << "\n\n"; } } } }
void AutohidingSplitter::setAutoHideEnabled(bool ah) { if (ah==autoHideEnabled) { return; } autoHideEnabled=ah; if (autoHideEnabled) { expandedSizes = sizes(); connect(this, SIGNAL(splitterMoved(int, int)), this, SLOT(updateAfterSplitterMoved(int, int))); } else { for(int i = 0; i < widgetAutohidden.count() ; ++i) {
void TraceGfx::DoRender(graph::Engine& engine) { //Отрисовка путей for (Trace::Points::const_iterator iter = _trace->GetPoints().begin(); iter != _trace->GetPoints().end(); ++iter) { _libMat->material.SetDiffuse(*iter == _selPoint ? clrGreen : clrRed); _wayPnt->SetPos((*iter)->GetPos()); _wayPnt->SetScale((*iter)->GetSize()); _wayPnt->Render(engine); } //Отрисовка связей между путями Vec3Range resColor(D3DXVECTOR3(clrWhite / 2.0f), D3DXVECTOR3(clrWhite), Vec3Range::vdVolume); D3DXVECTOR3 upVec = engine.GetContext().GetCamera().GetDesc().dir; float iPath = 0.0f; float pathCnt = static_cast<float>(_trace->GetPathes().size()); for (Trace::Pathes::const_iterator iter = _trace->GetPathes().begin(); iter != _trace->GetPathes().end(); ++iter, ++iPath) { WayPath* path = *iter; D3DXCOLOR pathColor = path == _selPath ? clrGreen : D3DXCOLOR(resColor.GetValue(iPath / (pathCnt - 1.0f))); res::VertexData vBuf; path->GetTriStripVBuf(vBuf, &upVec); if (vBuf.IsInit()) DrawNodes(engine, vBuf.begin().Pos3(), vBuf.GetVertexCount() - 2, pathColor); } //Для выделенного узла свой цикл отрисовки if (_selNode && _selNode->GetNext()) { D3DXVECTOR3 vBuf[4]; _selNode->GetTile().GetVBuf(vBuf, 4, &upVec); DrawNodes(engine, vBuf, 4 - 2, clrGreen); } //Отрисовка связи выделения if (_pointLink) { D3DXVECTOR3 pos1 = _pointLink->GetPoint()->GetPos(); D3DXVECTOR3 pos2 = _pointLink->GetPos(); D3DXVECTOR3 dir = pos1 - pos2; D3DXVECTOR2 sizes(D3DXVec3Length(&dir), _pointLink->GetPoint()->GetSize()); D3DXVec3Normalize(&dir, &dir); _sprite->SetPos((pos1 + pos2) / 2.0f); _sprite->SetDir(dir); _sprite->sizes = sizes; _libMat->material.SetDiffuse(clrGreen); _sprite->Render(engine); } }
bool Shader::compile() { CORRADE_ASSERT(sources.size() > 1, "Shader::compile(): no files added", false); /* Array of source string pointers and their lengths */ /** @todo Use `Containers::ArrayTuple` to avoid one allocation if it ever gets to be implemented (we need properly aligned memory too) */ Containers::Array<const GLchar*> pointers(sources.size()); Containers::Array<GLint> sizes(sources.size()); for(std::size_t i = 0; i != sources.size(); ++i) { pointers[i] = static_cast<const GLchar*>(sources[i].data()); sizes[i] = sources[i].size(); } /* Create shader and set its source */ glShaderSource(_id, sources.size(), pointers, sizes); /* Compile shader */ glCompileShader(_id); /* Check compilation status */ GLint success, logLength; glGetShaderiv(_id, GL_COMPILE_STATUS, &success); glGetShaderiv(_id, GL_INFO_LOG_LENGTH, &logLength); /* Error or warning message. The string is returned null-terminated, scrap the \0 at the end afterwards */ std::string message(logLength, '\0'); if(message.size() > 1) glGetShaderInfoLog(_id, message.size(), nullptr, &message[0]); message.resize(std::max(logLength, 1)-1); /* Show error log */ if(!success) { Error out; out.setFlag(Debug::NewLineAtTheEnd, false); out.setFlag(Debug::SpaceAfterEachValue, false); out << "Shader: " << shaderName(_type) << " shader failed to compile with the following message:\n" << message; /* Or just message, if any */ } else if(!message.empty()) { Error out; out.setFlag(Debug::NewLineAtTheEnd, false); out.setFlag(Debug::SpaceAfterEachValue, false); out << "Shader: " << shaderName(_type) << " shader was successfully compiled with the following message:\n" << message; } return success; }
size_t UidStatistics::sizes(pid_t pid) { if (pid == pid_all) { return sizes(); } PidStatisticsCollection::iterator it; for (it = begin(); it != end(); ++it) { PidStatistics *p = *it; if (pid == p->getPid()) { return p->sizes(); } } return 0; }
SingleCellSimulationViewGraphPanelWidget * SingleCellSimulationViewGraphPanelsWidget::addGraphPanel() { // Keep track of the graph panels' original size QList<int> origSizes = sizes(); // Create a new graph panel SingleCellSimulationViewGraphPanelWidget *res = new SingleCellSimulationViewGraphPanelWidget(this); // Add the graph panel to ourselves addWidget(res); // Resize the graph panels, thus making sure that their size is what it // should be (see issue #58) double scalingFactor = double(count()-1)/count(); for (int i = 0, iMax = origSizes.count(); i < iMax; ++i) origSizes[i] *= scalingFactor; setSizes(origSizes << height()/count()); // Create a connection to keep track of whenever the graph panel gets // activated connect(res, SIGNAL(activated(SingleCellSimulationViewGraphPanelWidget *)), this, SLOT(graphPanelActivated(SingleCellSimulationViewGraphPanelWidget *))); // Activate the graph panel res->setActive(true); // Keep track of our new sizes splitterMoved(); // Let people know that we have added a graph panel emit grapPanelAdded(res); // Let people know whether graph panels can be removed emit removeGraphPanelsEnabled(count() > 1); // Return our newly created graph panel return res; }
void MyFrame::InitAboutBox() { wxPanel* pArea = new wxPanel(); pArea->Create( &mAboutBox, wxID_ANY ); new wxStaticText(pArea, wxID_ANY, _("This is wxFrameLayout contribution demo."), wxPoint(10, 10) ); new wxStaticText(pArea, wxID_ANY, _("Aleksandras Gluchovas (c) 1998"), wxPoint(10, 30) ); new wxStaticText(pArea, wxID_ANY, _("<mailto:[email protected]>"), wxPoint(10, 50) ); mpAboutBoxLayout = new wxFrameLayout( &mAboutBox, pArea, true ); wxFrameLayout& layout = *mpAboutBoxLayout; cbDimInfo sizes( 90,40, // when docked horizontally 45,55, // when docked vertically 90,40, // when floated true, 4, 4 // true - bar is fixed-size ); wxButton* pYes = CreateButton(_("&Yes"), &mAboutBox, ID_SAY_ITSOK ); wxButton* pNo = CreateButton(_("&No"), &mAboutBox, ID_BTN_NO ); wxButton* pEsc = CreateButton(_("Cancel"), &mAboutBox, ID_BTN_ESC ); layout.AddBar( pEsc, sizes, FL_ALIGN_BOTTOM, 0, 20, _("cancel button")); layout.AddBar( pNo, sizes, FL_ALIGN_BOTTOM, 0, 20, _("no button")); layout.AddBar( pYes, sizes, FL_ALIGN_BOTTOM, 0, 20, _("yes button")); layout.mBorderPen.SetColour( 192, 192, 192 ); layout.SetMargins( 15, 15, 15, 15, wxALL_PANES ); cbCommonPaneProperties props; layout.GetPaneProperties( props, FL_ALIGN_TOP ); props.mShow3DPaneBorderOn = false; layout.SetPaneProperties( props, wxALL_PANES ); layout.Activate(); pYes->SetDefault(); pYes->SetFocus(); }
std::vector<std::size_t> mask_components(marks_t &mask, const std::vector<int> &components) { std::vector<std::size_t> sizes(components.size(),0); for( auto & m : mask ) { if( m!=0 ) { m = components.at(m); ++(sizes.at(m)); } } return sizes; }
/*===========================================================================*/ void SphereGlyph::attach_point( const kvs::PointObject* point ) { m_point = point; const size_t nvertices = point->numberOfVertices(); BaseClass::setCoords( point->coords() ); if ( BaseClass::directionMode() == BaseClass::DirectionByNormal ) { if ( point->numberOfNormals() != 0 ) { BaseClass::setDirections( point->normals() ); } } if ( point->numberOfSizes() == 1 ) { const kvs::Real32 size = point->size(); kvs::ValueArray<kvs::Real32> sizes( nvertices ); for ( size_t i = 0; i < nvertices; i++ ) sizes[i] = size; BaseClass::setSizes( sizes ); } else { BaseClass::setSizes( point->sizes() ); } if ( point->numberOfColors() == 1 ) { const kvs::RGBColor color = point->color(); kvs::ValueArray<kvs::UInt8> colors( nvertices * 3 ); for ( size_t i = 0, j = 0; i < nvertices; i++, j += 3 ) { colors[j] = color.r(); colors[j+1] = color.g(); colors[j+2] = color.b(); } BaseClass::setColors( colors ); } else { BaseClass::setColors( point->colors() ); } const kvs::UInt8 opacity = static_cast<kvs::UInt8>( 255 ); kvs::ValueArray<kvs::UInt8> opacities( nvertices ); for ( size_t i = 0; i < nvertices; i++ ) opacities[i] = opacity; BaseClass::setOpacities( opacities ); }
void SyncSplitter::syncingSplitterMoved(int pos, int index) { Q_UNUSED(pos); Q_UNUSED(index); // Affect only when changed QList<int> otherSizes = m_syncingSplitter->sizes(); if (sizes() == otherSizes) return; // Pass synchronizing splitter moves to this splitter setSizes(otherSizes); }
ReaderViewNative::ReaderViewNative() { _docview = new LVDocView(16); //16bpp LVRefVec<LVImageSource> icons = getBatteryIcons( 0x000000 ); _docview->setBatteryIcons( icons ); LVArray<int> sizes( cr_font_sizes, sizeof(cr_font_sizes)/sizeof(int) ); _docview->setShowCover( true ); _docview->setFontSizes( sizes, true ); _docview->setFontSize(24); _docview->setBatteryFont( fontMan->GetFont( 16, 600, false, css_ff_sans_serif, lString8("Droid Sans") )); _docview->createDefaultDocument(lString16("Welcome to CoolReader"), lString16("Please select file to open")); }
static int adjustFontSizes(lua_State *L) { CreDocument *doc = (CreDocument*) luaL_checkudata(L, 1, "credocument"); int dpi = luaL_checkint(L, 2); static int fontSizes[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 48, 52, 56, 60, 64, 68, 72}; LVArray<int> sizes( fontSizes, sizeof(fontSizes)/sizeof(int) ); doc->text_view->setFontSizes(sizes, false); // text if (dpi < 170) { doc->text_view->setStatusFontSize(20); // header } else if (dpi > 250) { doc->text_view->setStatusFontSize(28); } else { doc->text_view->setStatusFontSize(24); } return 0; }