Ejemplo n.º 1
0
  sp<Retval> GdMonCpustat::draw(int num, sp<info>& info, sp<MonBase>& dest
                        , const char* path)
  {
      sp<Retval> retval;
      if( DFW_RET(retval, MonCpustat::draw(num, info, dest, path)) )
          return DFW_RETVAL_D(retval);
      if( DFW_RET(retval, baseInit()) )
          return DFW_RETVAL_D(retval);

      struct max_st  max;
      struct data_st dt;
      getMax(&max, info, m_g.cs.w);
      setData(&dt);

      drawHead(dest->m_sec, info->m_sec);

      uint64_t first_sec;
      uint64_t last_sec = dest->m_sec;
      for(int k=info->m_aLists.size(), dx=m_g.cr.ex; ((k>0)&&(dx>m_g.cr.sx));)
      {
          sp<GdMonCpustat> p  = info->m_aLists.get(k-1);
          sp<GdMonCpustat> pp = info->m_aLists.get(k-2);
          procData(dx, &max, &dt, p, pp);
          drawData(dx, &dt);
          k--;
          dx--;
          first_sec = p->m_sec;
      }

      drawBottom(dest, &max, &dt);
      drawLast(first_sec, last_sec);
      if( DFW_RET(retval, savePng(path, savename(), 0)) )
          return DFW_RETVAL_D(retval);
      return NULL;
  }
Ejemplo n.º 2
0
void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
{
    LOGFONT logFont;
    logFont.lfCharSet = DEFAULT_CHARSET;
    unsigned familyLength = std::min(familyName.length(), static_cast<unsigned>(LF_FACESIZE - 1));
    memcpy(logFont.lfFaceName, familyName.characters(), familyLength * sizeof(UChar));
    logFont.lfFaceName[familyLength] = 0;
    logFont.lfPitchAndFamily = 0;

    TraitsInFamilyProcData procData(familyName);
    EnumFontFamiliesEx(g_screenDC, &logFont, traitsInFamilyEnumProc, reinterpret_cast<LPARAM>(&procData), 0);
    copyToVector(procData.m_traitsMasks, traitsMasks);
}
Ejemplo n.º 3
0
SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& description, ShouldRetain shouldRetain)
{
    FontDescription::GenericFamilyType generic = description.genericFamily();

    // FIXME: Would be even better to somehow get the user's default font here.
    // For now we'll pick the default that the user would get without changing
    // any prefs.
    static AtomicString timesStr("Times New Roman");
    static AtomicString courierStr("Courier New");
    static AtomicString arialStr("Arial");

    AtomicString& fontStr = timesStr;
    if (generic == FontDescription::SansSerifFamily)
        fontStr = arialStr;
    else if (generic == FontDescription::MonospaceFamily)
        fontStr = courierStr;

    SimpleFontData* simpleFont = getCachedFontData(description, fontStr, false, shouldRetain);
    if (simpleFont)
        return simpleFont;

    // Fall back to system fonts as Win Safari does because this function must
    // return a valid font. Once we find a valid system font, we save its name
    // to a static variable and use it to prevent trying system fonts again.
    static wchar_t fallbackFontName[LF_FACESIZE] = {0};
    if (fallbackFontName[0])
        return getCachedFontData(description, fallbackFontName, false, shouldRetain);

    // Fall back to the DEFAULT_GUI_FONT if no known Unicode fonts are available.
    if (HFONT defaultGUIFont = static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT))) {
        LOGFONT defaultGUILogFont;
        GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont);
        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, defaultGUILogFont, fallbackFontName))
            return simpleFont;
    }

    // Fall back to Non-client metrics fonts.
    NONCLIENTMETRICS nonClientMetrics = {0};
    nonClientMetrics.cbSize = sizeof(nonClientMetrics);
    if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) {
        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfMessageFont, fallbackFontName))
            return simpleFont;
        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfMenuFont, fallbackFontName))
            return simpleFont;
        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfStatusFont, fallbackFontName))
            return simpleFont;
        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfCaptionFont, fallbackFontName))
            return simpleFont;
        if (simpleFont = fontDataFromDescriptionAndLogFont(description, shouldRetain, nonClientMetrics.lfSmCaptionFont, fallbackFontName))
            return simpleFont;
    }

    // Fall back to all the fonts installed in this PC. When a font has a
    // localized name according to the system locale as well as an English name,
    // both GetTextFace() and EnumFontFamilies() return the localized name. So,
    // FontCache::createFontPlatformData() does not filter out the fonts
    // returned by this EnumFontFamilies() call.
    HDC dc = GetDC(0);
    if (dc) {
        GetLastResortFallbackFontProcData procData(this, &description, shouldRetain, fallbackFontName);
        EnumFontFamilies(dc, 0, getLastResortFallbackFontProc, reinterpret_cast<LPARAM>(&procData));
        ReleaseDC(0, dc);

        if (procData.m_fontData)
            return procData.m_fontData;
    }

    ASSERT_NOT_REACHED();
    return 0;
}
Ejemplo n.º 4
0
void Foam::PrintTable<KeyType, DataType>::print
(
    Ostream& os,
    const bool printSum,
    const bool printAverage
) const
{
    HashTable<HashTable<DataType, label>, KeyType> combinedTable;

    List<HashTableData> procData(Pstream::nProcs(), HashTableData());

    procData[Pstream::myProcNo()] = table_;

    Pstream::gatherList(procData);

    if (Pstream::master())
    {
        label largestKeyLength = 6;
        label largestDataLength = 0;

        List<label> largestProcSize(Pstream::nProcs(), 0);

        forAll(procData, procI)
        {
            const HashTableData& procIData = procData[procI];

            for
            (
                typename HashTableData::const_iterator iter = procIData.begin();
                iter != procIData.end();
                ++iter
            )
            {
                if (!combinedTable.found(iter.key()))
                {
                    combinedTable.insert
                    (
                        iter.key(),
                        HashTable<DataType, label>()
                    );
                }

                HashTable<DataType, label>& key = combinedTable[iter.key()];

                key.insert(procI, iter());

                for
                (
                    typename HashTable<DataType, label>
                        ::const_iterator dataIter = key.begin();
                    dataIter != key.end();
                    ++dataIter
                )
                {
                    std::ostringstream buf;
                    buf << dataIter();

                    largestDataLength = max
                    (
                        largestDataLength,
                        label(buf.str().length())
                    );
                }

                std::ostringstream buf;
                buf << iter.key();

                largestKeyLength = max
                (
                    largestKeyLength,
                    label(buf.str().length())
                );
            }
        }

        os.width(largestKeyLength);
        os  << nl << indent << tab << "# " << title_.c_str() << endl;

        os.width(largestKeyLength);
        os  << indent << "# Proc";

        forAll(procData, procI)
        {
            os  << tab;
            os.width(largestDataLength);
            os  << procI;
        }

        if (printSum)
        {
            os  << tab;
            os.width(largestDataLength);
            os  << "Sum";
        }

        if (printAverage)
        {
            os  << tab;
            os.width(largestDataLength);
            os  << "Average";
        }

        os  << endl;

        const List<KeyType>& sortedTable = combinedTable.sortedToc();

        forAll(sortedTable, keyI)
        {
            const HashTable<DataType, label>& procDataList
                = combinedTable[sortedTable[keyI]];

            os.width(largestKeyLength);
            os  << indent << sortedTable[keyI];

            forAll(procDataList, elemI)
            {
                os  << tab;
                os.width(largestDataLength);
                os  << procDataList[elemI];
            }

            if (printSum)
            {
                DataType sum = 0;
                forAll(procDataList, elemI)
                {
                    sum += procDataList[elemI];
                }

                os  << tab;
                os.width(largestDataLength);
                os  << sum;

                if (printAverage)
                {
                    os  << tab;
                    os.width(largestDataLength);
                    os  << sum/Pstream::nProcs();
                }
            }

            os  << endl;
        }