Ejemplo n.º 1
0
void CBrowserView::OnSaveLinkAs()
{
    if(! mCtxMenuLinkUrl.Length())
        return;

    // Try to get the file name part from the URL
    // To do that we first construct an obj which supports
    // nsIRUI interface. Makes it easy to extract portions
    // of a URL like the filename, scheme etc. + We'll also
    // use it while saving this link to a file
    nsresult rv   = NS_OK;
    nsCOMPtr<nsIURI> linkURI;
    rv = NS_NewURI(getter_AddRefs(linkURI), mCtxMenuLinkUrl);
    if (NS_FAILED(rv))
        return;

    // Get the "path" portion (see nsIURI.h for more info
    // on various parts of a URI)
    nsCAutoString fileName;
    linkURI->GetPath(fileName);

    // The path may have the "/" char in it - strip those
    fileName.StripChars("\\/");

    // Now, use this file name in a File Save As dlg...

    char *lpszFilter =
        "HTML Files (*.htm;*.html)|*.htm;*.html|"
        "Text Files (*.txt)|*.txt|"
        "All Files (*.*)|*.*||";

    const char *pFileName = fileName.Length() ? fileName.get() : NULL;

    CFileDialog cf(FALSE, "htm", pFileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
                   lpszFilter, this);
    if(cf.DoModal() == IDOK)
    {
        CString strFullPath = cf.GetPathName();

        nsCOMPtr<nsIWebBrowserPersist> persist(do_QueryInterface(mWebBrowser));
//		if(persist)
//			persist->SaveURI(linkURI, nsnull, strFullPath.GetBuffer(0));
    }
}
    virtual void onDraw(SkCanvas* canvas) {
        void (*drawProc[])(SkCanvas*, const SkRect&, SkImageFilter*) = {
            draw_sprite, draw_bitmap, draw_path, draw_paint, draw_text
        };

        SkAutoTUnref<SkColorFilter> cf(
            SkColorFilter::CreateModeFilter(SK_ColorMAGENTA, SkXfermode::kSrcIn_Mode));
        SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get()));
        SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
                                         SkImageFilter::CropRect::kHasAll_CropEdge);
        SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -100, 10, 10)),
                                          SkImageFilter::CropRect::kHasAll_CropEdge);

        SkImageFilter* filters[] = {
            NULL,
            new SkDropShadowImageFilter(7.0f, 0.0f, 0.0f, 3.0f, SK_ColorBLUE),
            new SkDropShadowImageFilter(0.0f, 7.0f, 3.0f, 0.0f, SK_ColorBLUE),
            new SkDropShadowImageFilter(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE),
            new SkDropShadowImageFilter(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, cfif),
            new SkDropShadowImageFilter(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, NULL, &cropRect),
            new SkDropShadowImageFilter(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, NULL, &bogusRect),
        };

        SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
        SkScalar MARGIN = SkIntToScalar(16);
        SkScalar DX = r.width() + MARGIN;
        SkScalar DY = r.height() + MARGIN;

        canvas->translate(MARGIN, MARGIN);
        for (size_t j = 0; j < SK_ARRAY_COUNT(drawProc); ++j) {
            canvas->save();
            for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
                drawProc[j](canvas, r, filters[i]);
                canvas->translate(0, DY);
            }
            canvas->restore();
            canvas->translate(DX, 0);
        }

        for(size_t j = 0; j < SK_ARRAY_COUNT(filters); ++j) {
            SkSafeUnref(filters[j]);
        }
    }
Ejemplo n.º 3
0
void QxrdImagePlot::setProcessor(QxrdDataProcessorWPtr proc)
{
  m_DataProcessor = proc;

  QxrdDataProcessorPtr dp(m_DataProcessor);

  if (dp) {
    QxrdCenterFinderPtr cf(dp->centerFinder());

    if (cf) {
      connect(m_CenterFinderPicker, SIGNAL(selected(QPointF)),
              cf.data(), SLOT(onCenterChanged(QPointF)));

      connect(m_Circles, SIGNAL(selected(QRectF)),
              dp.data(), SLOT(maskCircle(QRectF)));

      connect(m_Polygons, SIGNAL(selected(QVector<QPointF>)),
              dp.data(), SLOT(maskPolygon(QVector<QPointF>)));

      connect(m_Measurer, SIGNAL(selected(QVector<QPointF>)),
              dp.data(), SLOT(measurePolygon(QVector<QPointF>)));

      //  connect(m_Slicer, SIGNAL(selected(QVector<QPointF>)),
    //          m_DataProcessor, SLOT(slicePolygon(QVector<QPointF>)));

      connect(m_PowderPointPicker, SIGNAL(selected(QPointF)),
              cf.data(), SLOT(onPointSelected(QPointF)));

      onCenterChanged(QPointF(cf->get_CenterX(), cf->get_CenterY()));

      connect(cf->prop_MarkedPoints(), SIGNAL(valueChanged(QxrdPowderPointVector,int)),
              this, SLOT(onMarkedPointsChanged()));

      onMarkedPointsChanged();
    }
  }

  connect(m_Slicer, SIGNAL(selected(QVector<QPointF>)),
          this, SIGNAL(slicePolygon(QVector<QPointF>)));

  connect(m_HistogramSelector, SIGNAL(selected(QRectF)),
          this, SIGNAL(selectHistogram(QRectF)));
}
Ejemplo n.º 4
0
void testMNISTConvolutionalNeuralNetworkDriver()
{
  MNISTDataFunction mnistdf;
  Config config;
  updateMNISTConfig(config);
  config.setValue("addBiasTerm", false);
  config.setValue("meanStddNormalize", false);
  SGDOptimizer sgd;

  const int imageDim = 28; // height/width of image
  const int filterDim = 9; // dimension of convolutional filter
  const int numFilters = 20; // number of convolutional filters
  const int poolDim = 2; // dimension of pooling area
  const int numClasses = 10; // number of classes to predict

  ConvolutionalNeuralNetworkCostFunction cf(imageDim, filterDim, numFilters, poolDim, numClasses);
  Driver drv(&config, &mnistdf, &cf, &sgd);
  drv.drive();
}
Ejemplo n.º 5
0
   /// <summary>Called when user selects a text colour.</summary>
   void LanguageEditView::OnCommandSelectColour()
   {
      CharFormat cf(CFM_COLOR, 0);

      // DEBUG:
      //Console << HERE << ENDL;

      // Get selected colour
      if (ColourMenu)
         if (auto dlg = (CMFCColorBar*)ColourMenu->GetMenuBar())
            cf.crTextColor = (dlg->GetColor() != -1 ? dlg->GetColor() : (COLORREF)RichTextColour::Default);

      // Highlight text
      RichEdit.SetSelectionCharFormat(cf);
      ColourMenu->CloseMenu();

      // Modify document
      GetDocument()->SetModifiedFlag(TRUE);
   }
Ejemplo n.º 6
0
CacheConfig::CacheConfig(const GMConfig& config):
    _cache_max(100),
    _cache_min(100),
    _log_file("/var/log/arc/cache-clean.log"),
    _log_level("INFO") ,
    _lifetime("0"),
    _clean_timeout(0) {
  // Load conf file
  std::ifstream cfile;
  if(!config_open(cfile,config.ConfigFile())) throw CacheConfigException("Can't open configuration file");
  
  /* detect type of file */
  switch(config_detect(cfile)) {
    case config_file_XML: {
      Arc::XMLNode cfg;
      if(!cfg.ReadFromStream(cfile)) {
        config_close(cfile);
        throw CacheConfigException("Can't interpret configuration file as XML");
      };
      config_close(cfile);
      try {
        parseXMLConf(cfg);
      } catch (CacheConfigException& e) {
        config_close(cfile);
        throw;
      }
    }; break;
    case config_file_INI: {
      ConfigSections cf(cfile);
      try {
        parseINIConf(cf);
      } catch (CacheConfigException& e) {
        config_close(cfile);
        throw;
      }
    }; break;
    default: {
      config_close(cfile);
      throw CacheConfigException("Can't recognize type of configuration file");
    }; break;
  };
  config_close(cfile);
}
Ejemplo n.º 7
0
bool CZipCompression::DecompressFile(const string& src_file,
                                     const string& dst_file,
                                     size_t        buf_size)
{
    CZipCompressionFile cf(GetLevel(), m_WindowBits, m_MemLevel, m_Strategy);
    cf.SetFlags(cf.GetFlags() | GetFlags());

    bool need_restore_attr = false;
    SFileInfo info;

    // Open compressed file, and define name of the destination file
    if ( F_ISSET(fRestoreFileAttr) ) {
        if ( !cf.Open(src_file, CCompressionFile::eMode_Read, &info) ) {
            SetError(cf.GetErrorCode(), cf.GetErrorDescription());
            return false;
        }
        if ( !info.name.empty() ) {
            need_restore_attr = true;
        }
    } else {
        if ( !cf.Open(src_file, CCompressionFile::eMode_Read, 0) ) {
            SetError(cf.GetErrorCode(), cf.GetErrorDescription());
            return false;
        }
    }
    // Decompress file
    if ( !CCompression::x_DecompressFile(cf, dst_file, buf_size) ) {
        if ( cf.GetErrorCode() ) {
            SetError(cf.GetErrorCode(), cf.GetErrorDescription());
        }
        cf.Close();
        return false;
    }
    // Close output file and return result
    bool status = cf.Close();
    SetError(cf.GetErrorCode(), cf.GetErrorDescription());
    // Restore time stamp if needed
    if ( status  &&  need_restore_attr ) {
        CFile(dst_file).SetTimeT(&info.mtime);
    }
    return status;
}
Ejemplo n.º 8
0
void decoration_formatter::format_postamble(std::ostream& s,
    const comment_styles& cs, const decoration_properties& dc) const {
    if (!dc.modeline())
        return;

    const auto m(*dc.modeline());
    if (m.location() == modeline_locations::bottom) {
        std::list<std::string> content;
        add_modeline(content, m);

        comment_formatter cf(
            !start_on_first_line,
            !use_documentation_tool_markup,
            !documenting_previous_identifier,
            cs,
            !last_line_is_blank);

        cf.format(s, content);
    }
}
Ejemplo n.º 9
0
GameInfo::GameInfo(string filename)
{
	ConfigFile cf(filename);

	display_X_Res = cf.Value("Display Settings", "displayWidth");
	display_Y_Res = cf.Value("Display Settings", "displayHeight");
	render_X_Res_ = cf.Value("Display Settings", "renderWidth");
	render_Y_Res_ = cf.Value("Display Settings", "renderHeight");
	fps = cf.Value("Display Settings", "fps");
	pollrate_ = cf.Value("Display Settings", "pollrate");
	viewWidth = cf.Value("Display Settings", "viewWidth");
	viewHeight = cf.Value("Display Settings", "viewHeight");

	viewWidth *= cf.Value("Display Settings", "viewScalar", 1.0);
	viewHeight *= cf.Value("Display Settings", "viewScalar", 1.0);

	string tempPath = cf.Value("Misc Settings", "defaultFont");
	if (!defaultFont_.loadFromFile(tempPath)) std::cout << "couldn't load font" << std::endl;
	tempPath = cf.Value("Misc Settings", "uiSheet");
	if (!UITex.loadFromFile(tempPath))std::cout << "couldn't load uiTex" << std::endl;
}
Ejemplo n.º 10
0
struct coord *
cf_rel (coord_f cf, struct frame *f, struct coord *c, int dx, int dy)
{
  int dir;

  if (cf == _mf || cf == _tf || cf == _bf)
    dir = (f->dir == LEFT) ? -1 : +1;
  else if (cf == _mba || cf == _tb || cf == _bb)
    dir = (f->dir == LEFT) ? +1 : -1;
  else if (cf == _ml || cf == _tl || cf == _bl)
    dir = -1;
  else if (cf == _mr || cf == _tr || cf == _br)
    dir = +1;
  else assert (false);

  cf (f, c);
  c->x += dir * dx;
  c->y += dy;

  return c;
}
Ejemplo n.º 11
0
void process_package_cmds_cfg( Plib::Package* pkg )
{
  // ConfigFile cf( (pkg->dir() + "cmds.cfg").c_str(), "Commands" );
  Clib::ConfigFile cf( GetPackageCfgPath( pkg, "cmds.cfg" ).c_str(), "Commands" );
  Clib::ConfigElem elem;
  while ( cf.read( elem ) )
  {
    CmdLevel* cmdlevel = find_cmdlevel( elem.rest() );
    if ( !cmdlevel )
    {
      elem.throw_error( std::string( "Command Level " ) + elem.rest() + " not found." );
    }

    std::string tmp;
    while ( elem.remove_prop( "DIR", &tmp ) )
    {
      Clib::mklower( tmp );
      cmdlevel->add_searchdir_front( pkg, Clib::normalized_dir_form( pkg->dir() + tmp ) );
    }
  }
}
Ejemplo n.º 12
0
void read_resources_dat()
{
  std::string resourcefile = Plib::systemstate.config.world_data_path + "resource.dat";

  if ( Clib::FileExists( resourcefile ) )
  {
    Clib::ConfigFile cf( resourcefile, "GLOBALRESOURCEPOOL REGIONALRESOURCEPOOL" );
    Clib::ConfigElem elem;
    while ( cf.read( elem ) )
    {
      if ( elem.type_is( "GlobalResourcePool" ) )
      {
        read_global_data( elem );
      }
      else
      {
        read_region_data( elem );
      }
    }
  }
}
Ejemplo n.º 13
0
void main ()
{
	int a[3] = {0,0,0};
	int arr[100];
	int i;
	int j;
	int sum;
	int cf ( int, int );
	for ( i = 0; i < 100; i++ )
		arr[i] = cf ( i+1, 3 );

//	for ( i = 0; i < 100; i++ )
//		cout<<i+1<<" "<<arr[i]<<endl;
	int n;
	cin>>n;
	for ( i = 1; i <= n; i++ )
	{
		a[0] = 1;
		a[1] = 1;
		a[2] = 1;
		while ( a[0] < i )
		{
			sum = arr[a[0]] + arr[a[1]] + arr[a[2]];
			if ( sum == arr[i-1] && a[0] <= a[1] && a[1] <= a[2])
				cout<<"Cube = "<<i<<", Triple = ("<<a[0] +1<<','<<a[1] + 1<<','<<a[2] + 1<<')'<<endl;
			a[2]++;
			j = 2;
			while ( a[j] == i )
			{
				a[j] = 0;
				j--;
				a[j]++;
				if ( a[0] == i )
					break;
			}
		
		}
	}

}
Ejemplo n.º 14
0
void VisualDebugger::onPvdConnected( PVD::PvdConnection* inFactory )
{
	PVD::PvdConnection* cf( inFactory );
	if(!cf)
		return;

	if(mPvdConnection && mPvdConnectionFactory)
		disconnect();

	mPvdConnectionFactory = cf;
	mPvdConnection = mPvdConnectionFactory->createDataStream();
	if(!mPvdConnection)
		return;

	mPvdConnectionFactory->addRef();
	mPvdConnection->addRef();
	mPvdConnection->setNamespace( getPhysxNamespace() );
	updateScenesPvdConnection();

	sendClassDescriptions();
	sendEntireSDK();
}
Ejemplo n.º 15
0
int main(int argc, char** argv) {
  try {
    RMF_ADD_INPUT_FILE("rmf");
    RMF_ADD_OUTPUT_FILE("pdb");
    RMF_ADD_FRAMES;
    process_options(argc, argv);

    RMF::FileConstHandle rh = RMF::open_rmf_file_read_only(input);
    std::ostream* out;
    std::ofstream fout;
    if (!output.empty()) {
      fout.open(output.c_str());
      if (!fout) {
        std::cerr << "Error opening file " << output << std::endl;
        return 1;
      }
      out = &fout;
    } else {
      out = &std::cout;
    }
    RMF::decorator::IntermediateParticleFactory ipf(rh);
    RMF::decorator::AtomFactory af(rh);
    RMF::decorator::ChainFactory cf(rh);
    RMF::decorator::ResidueFactory rf(rh);
    RMF::NodeConstHandle rn = rh.get_root_node();
    for (unsigned int input_frame = start_frame, output_frame = 0;
         input_frame < rh.get_number_of_frames();
         input_frame += step_frame, ++output_frame) {
      rh.set_current_frame(RMF::FrameID(input_frame));
      *out << (boost::format("MODEL%1$9d") % (output_frame + 1)) << std::endl;
      write_atoms(*out, 0, rn, ipf, af, cf, rf);
      *out << "ENDMDL" << output_frame + 1 << std::endl;
    }
    return 0;
  }
  catch (const std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
  }
}
Ejemplo n.º 16
0
void test_sort(size_t sz)
{
	unsigned i, a;
	int s1=0, s2=0, x1=0, x2=0;
	list_t* l;
	list_node_t* n;

	printf("test_sort(%d) ... ", sz);

	l = list_create();

	for (i = 0; i < sz; i++) {
		a = rnd() % 100;
		if (i % 2)
			list_append(l, (void*)a);
		else
			list_prepend(l, (void*)a);
		s1 += a;
		x1 ^= a;
	}

	list_sort(list_reverse(l), cf);

	for (i = 0, n = l->first; n != NULL; i++, n = n->next) {
		if (n->next)
			assert(cf(n->data, n->next->data) <= 0);

		s2 += (unsigned)n->data;
		x2 ^= (unsigned)n->data;
	}

	assert(s1 == s2);
	assert(x1 == x2);
	assert(i == l->len);

	list_destroy(l);

	printf("ok\n");
}
Ejemplo n.º 17
0
TEST(CallframeTestSuite, AddSingleFrame)
{
	Callframe cf(0xffffffff80cba260UL, "/boot/kernel/kernel");

	cf.addFrame("netinet/tcp_input.c", "tcp_input", "tcp_input",
		3015, 2693, 0xa45d2);

	ASSERT_TRUE(!cf.isUnmapped());

	const auto & frames = cf.getInlineFrames();
	ASSERT_EQ(frames.size(), 1);

	const auto & fr = frames.at(0);
	ASSERT_EQ(fr.getFile(), "netinet/tcp_input.c");
	ASSERT_EQ(fr.getFunc(), "tcp_input");
	ASSERT_EQ(fr.getDemangled(), "tcp_input");
	ASSERT_EQ(fr.getCodeLine(), 3015);
	ASSERT_EQ(fr.getFuncLine(), 2693);
	ASSERT_EQ(fr.getDieOffset(), 0xa45d2);
	ASSERT_EQ(fr.getOffset(), 0xffffffff80cba260UL);
	ASSERT_TRUE(fr.isMapped());
}
Ejemplo n.º 18
0
void TestListCounter::TestCreateListText()
{
	RTFfile theFile(new RTFFileContext);
	AutoDocFileReaderImpl4Tests reader(GET_TEST_FILE_PATH(_T("list_outline.doc")), &theFile);
	reader.Initialize();

	ListCounter lc(&theFile, 9, -1); // pick up the list for \ls9

	lc.StepLevel(9,0);
	RTFpn* pPn = lc.CreateListText(0);
	assertTest(pPn!=NULL);
	assertTest(pPn->GetCount()>0);

	RTFformatting form(theFile.GetFileContext());
	form.the_RTFpn = pPn;
	RTFchrfmt cf(theFile.GetFileContext());
	CWideString cws;
	assertTest (form.GetListNumber(&theFile, cws, cf));
	assertTest(cws == L"I.\t");


}
Ejemplo n.º 19
0
void read_resource_cfg( const char* resource )
{
  std::string filename = std::string( "regions/" ) + resource + std::string( ".cfg" );
  Clib::ConfigFile cf( filename.c_str(), "GLOBAL REGION" );
  Clib::ConfigElem elem;

  std::unique_ptr<ResourceDef> rd( new ResourceDef( resource ) );

  while ( cf.read( elem ) )
  {
    if ( elem.type_is( "global" ) )
    {
      rd->read_config( elem );
    }
    else
    {
      rd->read_region( elem );
    }
  }

  gamestate.resourcedefs[resource] = rd.release();
}
Ejemplo n.º 20
0
bool CompositeCutter::vertexPush(const Fiber& f, Interval& i, const Triangle& t) const {
    bool result = false;
    std::vector< std::pair<double, CCPoint> > contacts;
    for (unsigned int n=0; n<cutter.size(); ++n) {
        Interval ci;
        Fiber cf(f);
        cf.p1.z = f.p1.z + zoffset[n];
        cf.p2.z = f.p2.z + zoffset[n]; // raised/lowered fiber to push along
        if ( cutter[n]->vertexPush(cf,ci,t) ) {
            if ( ccValidHeight( n, ci.upper_cc, f ) )
                contacts.push_back( std::pair<double,CCPoint>(ci.upper, ci.upper_cc) );
            if ( ccValidHeight( n, ci.lower_cc, f ) )
                contacts.push_back( std::pair<double,CCPoint>(ci.lower, ci.lower_cc) );
        }
    }
    
    for( unsigned int n=0; n<contacts.size(); ++n ) {
        i.update( contacts[n].first, contacts[n].second );
        result = true;
    }
    return result;
}
Ejemplo n.º 21
0
void load_stacking_cfg()
{
  std::string main_cfg = "config/stacking.cfg";

  if ( Clib::FileExists( main_cfg.c_str() ) )
  {
    Clib::ConfigFile cf_main( main_cfg.c_str() );
    read_stacking_cfg( cf_main );
  }
  for ( Plib::Packages::iterator itr = Plib::systemstate.packages.begin();
        itr != Plib::systemstate.packages.end(); ++itr )
  {
    Plib::Package* pkg = ( *itr );
    // string filename = pkg->dir() + cfgname + ".cfg";
    std::string filename = Plib::GetPackageCfgPath( pkg, "stacking.cfg" );
    if ( Clib::FileExists( filename.c_str() ) )
    {
      Clib::ConfigFile cf( filename.c_str() );
      read_stacking_cfg( cf );
    }
  }
}
Ejemplo n.º 22
0
Archivo: misc.c Proyecto: iXit/wine
/*********************************************************************
 *		_lfind_s (MSVCRT.@)
 */
void* CDECL _lfind_s(const void* match, const void* start,
                   unsigned int* array_size, unsigned int elem_size,
                   int (CDECL *cf)(void*,const void*,const void*),
                   void* context)
{
  unsigned int size;
  if (!MSVCRT_CHECK_PMT(match != NULL)) return NULL;
  if (!MSVCRT_CHECK_PMT(array_size != NULL)) return NULL;
  if (!MSVCRT_CHECK_PMT(start != NULL || *array_size == 0)) return NULL;
  if (!MSVCRT_CHECK_PMT(cf != NULL)) return NULL;
  if (!MSVCRT_CHECK_PMT(elem_size != 0)) return NULL;

  size = *array_size;
  if (size)
    do
    {
      if (cf(context, match, start) == 0)
        return (void *)start; /* found */
      start = (const char *)start + elem_size;
    } while (--size);
  return NULL;
}
Ejemplo n.º 23
0
void load_resource_cfg()
{
  if ( !Clib::FileExists( "regions/resource.cfg" ) )
  {
    if ( Plib::systemstate.config.loglevel > 1 )
      INFO_PRINT << "File regions/resource.cfg not found, skipping.\n";
    return;
  }

  Clib::ConfigFile cf( "regions/resource.cfg", "ResourceSystem" );
  Clib::ConfigElem elem;
  while ( cf.read( elem ) )
  {
    std::string resourcename;
    while ( elem.remove_prop( "ResourceType", &resourcename ) )
    {
      read_resource_cfg( resourcename.c_str() );
    }
  }
  if ( Plib::systemstate.config.count_resource_tiles )
    count_resource_tiles();
}
Ejemplo n.º 24
0
//---------------------------------------------------------------------------
void InterfazGrafC4::muestraEstado(const Juego2JTab &EJ)const
{
        tBMP fichaA("fichaA.bmp");
        tBMP fichaB("fichaB.bmp"); 
        tBMP fichaC("fichaC.bmp");
        tBMP fichaN("fichaN.bmp");
        Turno aux;
        int  X, Y = 0;
        for(int i = 0;i < 6;i++)
        {
                X = 0;
                for(int j = 0; j < 7; j++)
                {
                        Casilla cf(j, i);
                        aux = EJ.valorCasilla(cf);
                        if (aux == Jn) lienzo->Draw(X,Y,fichaN.BMP());
                        if (aux == Ja) lienzo->Draw(X,Y,fichaA.BMP());
                        if (aux == Jb) lienzo->Draw(X,Y,fichaB.BMP());
                        if (aux == Jc) lienzo->Draw(X,Y,fichaC.BMP());
                        X += ladoCasilla;
                }
                Y += ladoCasilla;
        }
        lienzo->Font->Color = clRed;
        lienzo->Font->Height = 20;
        AnsiString turno;
        if(EJ.dameTurno() == Ja)
        {
                turno = "Mike";
        }
        else    if (EJ.dameTurno() == Jb)
                {
                        turno = "John";
                }
                else turno = "HAL  ";
        lienzo->TextOutA(20,320,"Turno: " + turno);
        lienzo->TextOutA(140,320,"Conecta 4");
};
Ejemplo n.º 25
0
// constructor
Config::Config()
{
    _settings = new QSettings(getConfigFile(), QSettings::IniFormat);

    _shortcuts = new ShortcutManager(_settings);

    // check existing config file
    if (!QFile::exists(getConfigFile()))
    {
        // creating conf file from set defaults
        QFile cf(getConfigFile());
        if (cf.open(QIODevice::WriteOnly))
        {
            cf.close();
        }

        setDefaultSettings();
        saveSettings();
    }

    _settings->setIniCodec("UTF-8");
    _scrNum = 0;
}
Ejemplo n.º 26
0
static int32_t
server_prepare_attr_value_pair(
		provider_p const provider, uint16_t attr,
		uint8_t *buf, uint8_t const * const eob)
{
	profile_attr_create_p	cf = profile_get_attr(provider->profile, attr);
	int32_t			len;

	if (cf == NULL)
		return (0); /* no attribute */

	if (buf + 3 > eob)
		return (-1);

	SDP_PUT8(SDP_DATA_UINT16, buf);
	SDP_PUT16(attr, buf);

	len = cf(buf, eob, (uint8_t const *) provider, sizeof(*provider));
	if (len < 0)
		return (-1);

	return (3 + len);
}
Ejemplo n.º 27
0
QString LprSettings::defaultRemoteHost()
{
    if(m_defaultremotehost.isEmpty())
    {
        m_defaultremotehost = "localhost";
        QFile cf(LPDCONF);
        if(cf.open(IO_ReadOnly))
        {
            QTextStream t(&cf);
            QString line;
            while(!t.atEnd())
            {
                line = t.readLine().stripWhiteSpace();
                if(line.startsWith("default_remote_host"))
                {
                    QString hostname = line.mid(20).stripWhiteSpace();
                    m_defaultremotehost = hostname;
                }
            }
        }
    }
    return m_defaultremotehost;
}
    virtual void onDraw(SkCanvas* canvas) {
        if (!fInitialized) {
            this->make_bitmap();
            fInitialized = true;
        }
        canvas->clear(0x00000000);
        {
            SkAutoTUnref<SkImageFilter> bitmapSource(new SkBitmapSource(fBitmap));
            SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
                                                         SkXfermode::kSrcIn_Mode));
            SkAutoTUnref<SkImageFilter> blur(new SkBlurImageFilter(4.0f, 4.0f, bitmapSource));
            SkAutoTUnref<SkImageFilter> erode(new SkErodeImageFilter(4, 4, blur));
            SkAutoTUnref<SkImageFilter> color(SkColorFilterImageFilter::Create(cf, erode));
            SkAutoTUnref<SkImageFilter> merge(new SkMergeImageFilter(blur, color));

            SkPaint paint;
            paint.setImageFilter(merge);
            canvas->drawPaint(paint);
        }
        {
            SkAutoTUnref<SkImageFilter> morph(new SkDilateImageFilter(5, 5));

            SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
                                    0, SK_Scalar1, 0, 0, 0,
                                    0, 0, SK_Scalar1, 0, 0,
                                    0, 0, 0, SkFloatToScalar(0.5f), 0 };

            SkAutoTUnref<SkColorFilter> matrixFilter(new SkColorMatrixFilter(matrix));
            SkAutoTUnref<SkImageFilter> colorMorph(SkColorFilterImageFilter::Create(matrixFilter, morph));
            SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOver_Mode));
            SkAutoTUnref<SkImageFilter> blendColor(new SkXfermodeImageFilter(mode, colorMorph));

            SkPaint paint;
            paint.setImageFilter(blendColor);
            canvas->drawBitmap(fBitmap, 100, 0, &paint);
        }
    }
Ejemplo n.º 29
0
void read_npc_templates( Plib::Package* pkg )
{
  std::string filename = GetPackageCfgPath( pkg, "npcdesc.cfg" );
  if ( !Clib::FileExists( filename ) )
    return;

  Clib::ConfigFile cf( filename.c_str() );
  Clib::ConfigElem elem;
  while ( cf.read( elem ) )
  {
    if ( elem.type_is( "NpcTemplate" ) )
    {
      // first determine the NPC template name.
      std::string namebase;
      const char* rest = elem.rest();
      if ( rest != NULL && *rest != '\0' )
      {
        namebase = rest;
      }
      else
      {
        namebase = elem.remove_string( "TemplateName" );
      }
      std::string descname;
      if ( pkg != NULL )
      {
        descname = ":" + pkg->name() + ":" + namebase;
        elem.set_rest( descname.c_str() );
      }
      else
        descname = namebase;

      gamestate.npc_template_elems[descname] = NpcTemplateElem( cf, elem );
    }
  }
}
Ejemplo n.º 30
0
void load_special_storedconfig( string cfgname )
{
	string main_cfg = "config/" + cfgname + ".cfg";
	
	CreateEmptyStoredConfigFile(main_cfg.c_str());
	ref_ptr<StoredConfigFile> scfg = FindConfigFile(main_cfg, "");
	if ( FileExists(main_cfg.c_str()) )
	{
		ConfigFile cf_main(main_cfg.c_str());
		scfg->load(cf_main);
	}

	for( Packages::iterator itr = packages.begin(); itr != packages.end(); ++itr )
	{
		Package* pkg = (*itr);
		//string filename = pkg->dir() + cfgname + ".cfg";
		string filename = GetPackageCfgPath(pkg, cfgname+".cfg");
		if ( FileExists(filename.c_str()) )
		{
			ConfigFile cf(filename.c_str());
			scfg->load(cf);
		}
	}
}