⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfutils.cpp

📁 Wxpython Implemented on Windows CE, Source code
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        rec->param3 = getint(handle);   // COLORREF
        metaRecords.Append(rec);
        break;
      }
//      case META_OFFSETCLIPRGN:
      case META_TEXTOUT:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_TEXTOUT);
        int count = getshort(handle);
        rec->stringParam = new wxChar[count+1];
        fread((void *)rec->stringParam, sizeof(wxChar), count, handle);
        rec->stringParam[count] = 0;
        rec->param2 = getshort(handle); // Y
        rec->param1 = getshort(handle); // X
        metaRecords.Append(rec);
        break;
      }
/*
      case META_EXTTEXTOUT:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_EXTTEXTOUT);
        int cellSpacing = getshort(handle);
        int count = getshort(handle);
        rec->stringParam = new char[count+1];
        fread((void *)rec->stringParam, sizeof(char), count, handle);
        rec->stringParam[count] = 0;
        // Rectangle
        int rectY2 = getshort(handle);
        int rectX2 = getshort(handle);
        int rectY1 = getshort(handle);
        int rectX1 = getshort(handle);
        int rectType = getshort(handle);
        rec->param2 = getshort(handle); // Y
        rec->param1 = getshort(handle); // X
        metaRecords.Append(rec);
        break;
      }
*/
//      case META_BITBLT:
//      case META_STRETCHBLT:
      case META_POLYGON:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_POLYGON);
        rec->param1 = getshort(handle);
        rec->points = new wxRealPoint[(int)rec->param1];
        for (int i = 0; i < rec->param1; i++)
        {
          rec->points[i].x = getshort(handle);
          rec->points[i].y = getshort(handle);
        }

        metaRecords.Append(rec);
        break;
      }
      case META_POLYLINE:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_POLYLINE);
        rec->param1 = (long)getshort(handle);
        rec->points = new wxRealPoint[(int)rec->param1];
        for (int i = 0; i < rec->param1; i++)
        {
          rec->points[i].x = getshort(handle);
          rec->points[i].y = getshort(handle);
        }

        metaRecords.Append(rec);
        break;
      }
//      case META_ESCAPE:
//      case META_RESTOREDC:
//      case META_FILLREGION:
//      case META_FRAMEREGION:
//      case META_INVERTREGION:
//      case META_PAINTREGION:
//      case META_SELECTCLIPREGION: // DO THIS!
      case META_SELECTOBJECT:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_SELECTOBJECT);
        rec->param1 = (long)getshort(handle); // Position of object in gdiObjects list
        metaRecords.Append(rec);
        // param2 gives the index into gdiObjects, which is different from
        // the index into the handle table.
        rec->param2 = HandleTable[(int)rec->param1]->param2;
        break;
      }
//      case META_SETTEXTALIGN:
//      case META_DRAWTEXT:
//      case META_CHORD:
//      case META_SETMAPPERFLAGS:
//      case META_EXTTEXTOUT:
//      case META_SETDIBTODEV:
//      case META_SELECTPALETTE:
//      case META_REALIZEPALETTE:
//      case META_ANIMATEPALETTE:
//      case META_SETPALENTRIES:
//      case META_POLYPOLYGON:
//      case META_RESIZEPALETTE:
//      case META_DIBBITBLT:
//      case META_DIBSTRETCHBLT:
      case META_DIBCREATEPATTERNBRUSH:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_DIBCREATEPATTERNBRUSH);
        fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle);

        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
//      case META_STRETCHDIB:
//      case META_EXTFLOODFILL:
//      case META_RESETDC:
//      case META_STARTDOC:
//      case META_STARTPAGE:
//      case META_ENDPAGE:
//      case META_ABORTDOC:
//      case META_ENDDOC:
      case META_DELETEOBJECT:
      {
        int index = getshort(handle);
        DeleteMetaRecordHandle(index);
        break;
      }
      case META_CREATEPALETTE:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEPALETTE);
        fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle);

        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
      case META_CREATEBRUSH:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEBRUSH);
        fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle);
        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
      case META_CREATEPATTERNBRUSH:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEPATTERNBRUSH);
        fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle);
        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
      case META_CREATEPENINDIRECT:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEPENINDIRECT);
        int msStyle = getshort(handle); // Style: 2 bytes
        int x = getshort(handle); // X:     2 bytes
        /* int y = */ getshort(handle); // Y:     2 bytes
        long colorref = getint(handle); // COLORREF 4 bytes

        int style;
        if (msStyle == PS_DOT)
          style = wxDOT;
        else if (msStyle == PS_DASH)
          style = wxSHORT_DASH;
        else if (msStyle == PS_NULL)
          style = wxTRANSPARENT;
        else style = wxSOLID;

        wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
        rec->param1 = (long)wxThePenList->FindOrCreatePen(colour, x, style);
        metaRecords.Append(rec);
        gdiObjects.Append(rec);

        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);

        // For some reason, the size of this record is sometimes 9 words!!!
        // instead of the usual 8. So read 2 characters extra.
        if (rdSize == 9)
        {
          (void) getshort(handle);
        }
        break;
      }
      case META_CREATEFONTINDIRECT:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEFONTINDIRECT);
        int lfHeight = getshort(handle);    // 2 bytes
        /* int lfWidth = */ getshort(handle);     // 2 bytes
        /* int lfEsc = */ getshort(handle);       // 2 bytes
        /* int lfOrient = */ getshort(handle);    // 2 bytes
        int lfWeight = getshort(handle);    // 2 bytes
        char lfItalic = (char)getc(handle);       // 1 byte
        char lfUnderline = (char)getc(handle);    // 1 byte
        /* char lfStrikeout = */ getc(handle);    // 1 byte
        /* char lfCharSet = */ getc(handle);      // 1 byte
        /* char lfOutPrecision = */ getc(handle); // 1 byte
        /* char lfClipPrecision = */ getc(handle); // 1 byte
        /* char lfQuality = */ getc(handle);      // 1 byte
        char lfPitchAndFamily = (char)getc(handle);   // 1 byte (18th)
        char lfFacename[32];
        // Read the rest of the record, which is total record size
        // minus the number of bytes already read (18 record, 6 metarecord
        // header)
        fread((void *)lfFacename, sizeof(char), (int)((2*rdSize) - 18 - 6), handle);

        int family;
        if (lfPitchAndFamily & FF_MODERN)
          family = wxMODERN;
        else if (lfPitchAndFamily & FF_MODERN)
          family = wxMODERN;
        else if (lfPitchAndFamily & FF_ROMAN)
          family = wxROMAN;
        else if (lfPitchAndFamily & FF_SWISS)
          family = wxSWISS;
        else if (lfPitchAndFamily & FF_DECORATIVE)
          family = wxDECORATIVE;
        else
          family = wxDEFAULT;

        int weight;
        if (lfWeight == 300)
          weight = wxLIGHT;
        else if (lfWeight == 400)
          weight = wxNORMAL;
        else if (lfWeight == 900)
          weight = wxBOLD;
        else weight = wxNORMAL;

        int style;
        if (lfItalic != 0)
          style = wxITALIC;
        else
          style = wxNORMAL;

        // About how many pixels per inch???
        int logPixelsY = 100;
        int pointSize = (int)(lfHeight*72.0/logPixelsY);

        wxFont *theFont =
          wxTheFontList->FindOrCreateFont(pointSize, family, style, weight, (lfUnderline != 0));

        rec->param1 = (long) theFont;
        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
      case META_CREATEBRUSHINDIRECT:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEBRUSHINDIRECT);
        int msStyle = getshort(handle); // Style: 2 bytes
        long colorref = getint(handle);   // COLORREF: 4 bytes
        int hatchStyle = getshort(handle); // Hatch style 2 bytes

        int style;
        switch (msStyle)
        {
          case BS_HATCHED:
          {
            switch (hatchStyle)
            {
              case HS_BDIAGONAL:
                style = wxBDIAGONAL_HATCH;
                break;
              case HS_DIAGCROSS:
                style = wxCROSSDIAG_HATCH;
                break;
              case HS_FDIAGONAL:
                style = wxFDIAGONAL_HATCH;
                break;
              case HS_HORIZONTAL:
                style = wxHORIZONTAL_HATCH;
                break;
              case HS_VERTICAL:
                style = wxVERTICAL_HATCH;
                break;
              default:
              case HS_CROSS:
                style = wxCROSS_HATCH;
                break;
            }
            break;
          }
#if PS_DOT != BS_HATCHED
          /* ABX 30.12.2003                                   */
          /* in microsoft/include/wingdi.h  both are the same */
          /* in fact I'm not sure  why pen related PS_XXX and */
          /* BS_XXX constants are all mixed into single style */
          case PS_DOT:
            style = wxDOT;
            break;
#endif
          case PS_DASH:
            style = wxSHORT_DASH;
            break;
          case PS_NULL:
            style = wxTRANSPARENT;
            break;
          case BS_SOLID:
          default:
            style = wxSOLID;
            break;
        }

        wxColour colour(GetRValue(colorref), GetGValue(colorref), GetBValue(colorref));
        rec->param1 = (long)wxTheBrushList->FindOrCreateBrush(colour, style);
        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
      case META_CREATEBITMAPINDIRECT:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEBITMAPINDIRECT);
        fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle);

        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
      case META_CREATEBITMAP:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEBITMAP);
        fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle);

        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
      case META_CREATEREGION:
      {
        wxMetaRecord *rec = new wxMetaRecord(META_CREATEREGION);
        fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle);

        metaRecords.Append(rec);
        gdiObjects.Append(rec);
        AddMetaRecordHandle(rec);
        rec->param2 = (long)(gdiObjects.GetCount() - 1);
        break;
      }
      default:
      {
        fread((void *)_buf, sizeof(char), (int)((2*rdSize) - 6), handle);
        break;
      }
    }
  }
  fclose(handle);
  return true;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -