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

📄 dynamic_text_ins.c.svn-base

📁 A Flash Player with ActionScript support. Write in C and C++. It have two part, one is Player and an
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
    chg->MoveDeltaX = floatify(to->x,Globle_VarP) ;    chg->MoveDeltaY = floatify(to->y,Globle_VarP) *Globle_VarP->yAxis;    chg->Flags = StateMoveTo|StateFillStyle1|StateLineStyle;    chg->FillStyle1 = 1;    chg->LineStyle = 0;    (struct StyleChangeRecord*)Globle_VarP->MyRecA[Globle_VarP->Mytmp] = (struct StyleChangeRecord*)malloc(sizeof(struct StyleChangeRecord));    bzero((void *)(Globle_VarP->MyRecA[Globle_VarP->Mytmp]),sizeof(struct StyleChangeRecord));    memcpy(Globle_VarP->MyRecA[Globle_VarP->Mytmp],chg,sizeof(struct StyleChangeRecord));    if (Globle_VarP->headRec==NULL)        Globle_VarP->headRec = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    else        Globle_VarP->endRec->NextP = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    Globle_VarP->endRec = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    return 0;}inthandle_line_to (FT_Vector *to, void *user) {    struct StraightEdgeRecord *chg ;    struct Globle_Var *Globle_VarP = (struct Globle_Var *)user;    double x = floatify(to->x,Globle_VarP), y = floatify(to->y,Globle_VarP);    chg = (struct StraightEdgeRecord*)malloc(sizeof(struct StraightEdgeRecord));    bzero((void *)chg,sizeof(struct StraightEdgeRecord));    chg->StraightLineFlag = 1;    chg->StraightLineDeltaX = x - Globle_VarP->Gx;    chg->StraightLineDeltaY = y*Globle_VarP->yAxis - Globle_VarP->Gy;    chg->Flags = TStraightEdge;    chg->VertLineFlag = 0;    chg->HorLineDeltaX = 0;    chg->VertLineDeltaY =0;    (struct StraightEdgeRecord*)Globle_VarP->MyRecA[Globle_VarP->Mytmp] = (struct StraightEdgeRecord*)malloc(sizeof(struct StraightEdgeRecord));    bzero((void *)(Globle_VarP->MyRecA[Globle_VarP->Mytmp]),sizeof(struct StraightEdgeRecord));    memcpy(Globle_VarP->MyRecA[Globle_VarP->Mytmp],chg,sizeof(struct StraightEdgeRecord));    if (Globle_VarP->headRec==NULL)        Globle_VarP->headRec = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    else        Globle_VarP->endRec->NextP = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    Globle_VarP->endRec = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    Globle_VarP->Gx = floatify(to->x,Globle_VarP) ;    Globle_VarP->Gy = floatify(to->y,Globle_VarP) *Globle_VarP->yAxis;    return 0;}inthandle_conic_to (FT_Vector *control, FT_Vector *to, void *user) {    /* These conic curves have only one control point, which we use     * (together with the start and end points) to generate the two     * control points needed for the PostScript curveto operator.     * I don't know how this stuff works, but stole the formulae     * from SFontTTF.cpp in Yudit.  The results look right.  */    struct Globle_Var *Globle_VarP = (struct Globle_Var *)user;    double x = floatify(to->x,Globle_VarP), y = floatify(to->y,Globle_VarP);    double cx = floatify(control->x,Globle_VarP), cy = floatify(control->y,Globle_VarP);    struct CurvedEdgeRecord *chg ;    chg = (struct CurvedEdgeRecord*)malloc(sizeof(struct CurvedEdgeRecord));    bzero((void *)chg,sizeof(struct CurvedEdgeRecord));    chg->ControlDeltaX = cx -Globle_VarP->Gx;    chg->ControlDeltaY = cy*Globle_VarP->yAxis -Globle_VarP->Gy;    chg->AnchorDeltaX = x -Globle_VarP->Gx;    chg->AnchorDeltaY = y*Globle_VarP->yAxis -Globle_VarP->Gy;    chg->AnchorDeltaX = chg->AnchorDeltaX -chg->ControlDeltaX;    chg->AnchorDeltaY = chg->AnchorDeltaY -chg->ControlDeltaY;    chg->Flags = TCurvedEdge;    (struct CurvedEdgeRecord*)Globle_VarP->MyRecA[Globle_VarP->Mytmp] = (struct CurvedEdgeRecord*)malloc(sizeof(struct CurvedEdgeRecord));    bzero((void *)(Globle_VarP->MyRecA[Globle_VarP->Mytmp]),sizeof(struct CurvedEdgeRecord));    memcpy(Globle_VarP->MyRecA[Globle_VarP->Mytmp],chg,sizeof(struct CurvedEdgeRecord));    if (Globle_VarP->headRec==NULL)        Globle_VarP->headRec = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    else        Globle_VarP->endRec->NextP = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    Globle_VarP->endRec = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    Globle_VarP->Gx = floatify(to->x,Globle_VarP) ;    Globle_VarP->Gy = floatify(to->y,Globle_VarP) *Globle_VarP->yAxis;    return 0;}inthandle_cubic_to (FT_Vector *control1, FT_Vector *control2, FT_Vector *to,                 void *user) {    /* This should work, but I haven't seen it used. */    struct Globle_Var *Globle_VarP = (struct Globle_Var *)user;    double cx,cy;    double x = floatify(to->x,Globle_VarP), y = floatify(to->y,Globle_VarP);    double c2x = floatify(control2->x,Globle_VarP), c2y = floatify(control2->y,Globle_VarP);    struct CurvedEdgeRecord *chg ;    chg = (struct CurvedEdgeRecord*)malloc(sizeof(struct CurvedEdgeRecord));    bzero((void *)chg,sizeof(struct CurvedEdgeRecord));    cx = (3*c2x-x)/2;    cy = (3*c2y-y)/2;    chg->ControlDeltaX = cx -Globle_VarP->Gx;    chg->ControlDeltaY = cy*Globle_VarP->yAxis -Globle_VarP->Gy;    chg->AnchorDeltaX = x -Globle_VarP->Gx;    chg->AnchorDeltaY = y*Globle_VarP->yAxis -Globle_VarP->Gy;    chg->AnchorDeltaX = chg->AnchorDeltaX -chg->ControlDeltaX;    chg->AnchorDeltaY = chg->AnchorDeltaY -chg->ControlDeltaY;    chg->Flags = TCurvedEdge;    (struct CurvedEdgeRecord*)Globle_VarP->MyRecA[Globle_VarP->Mytmp] = (struct CurvedEdgeRecord*)malloc(sizeof(struct CurvedEdgeRecord));    bzero((void *)(Globle_VarP->MyRecA[Globle_VarP->Mytmp]),sizeof(struct CurvedEdgeRecord));    memcpy(Globle_VarP->MyRecA[Globle_VarP->Mytmp],chg,sizeof(struct CurvedEdgeRecord));    if (Globle_VarP->headRec==NULL)        Globle_VarP->headRec = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    else        Globle_VarP->endRec->NextP = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    Globle_VarP->endRec = Globle_VarP->MyRecA[Globle_VarP->Mytmp];    Globle_VarP->Gx = floatify(to->x,Globle_VarP) ;    Globle_VarP->Gy = floatify(to->y,Globle_VarP)*Globle_VarP->yAxis ;    return 0;}void initRec(struct Globle_Var *Globle_VarP) {    Globle_VarP->headRec = NULL;    Globle_VarP->endRec = NULL;}void initMyRecA(struct Globle_Var *Globle_VarP) {    Globle_VarP->MyRecA = (struct ShapeRecord**)malloc(sizeof(struct ShapeRecord*)*Globle_VarP->MyNum);    bzero((void *)(Globle_VarP->MyRecA),sizeof(struct ShapeRecord*)*Globle_VarP->MyNum);}void freeMyRecA(struct Globle_Var *Globle_VarP) {    struct ShapeRecord *tempShape;    int i;    for(i=0;i<Globle_VarP->MyNum-1;i++) {        tempShape = Globle_VarP->MyRecA[i];        while(Globle_VarP->MyRecA[i]) {            tempShape =Globle_VarP->MyRecA[i]->NextP;            free(Globle_VarP->MyRecA[i]);            Globle_VarP->MyRecA[i] = tempShape;        }    }}int code_convert(char *from_charset,char *to_charset,char *inbuf,int inlen,char *outbuf,int outlen) {    iconv_t cd;    char **pin = &inbuf;    char **pout = &outbuf;    cd = iconv_open(to_charset,from_charset);    if (cd==0)        return -1;    memset(outbuf,0,outlen);    if (iconv(cd,(const char* *)pin,&inlen,pout,&outlen)==-1)        return -1;    iconv_close(cd);    return 0;}int DevicetoShape(GNode* node_p,struct Globle_Var *Globle_VarP) {    dtx_ins_t    *data_p   = (dtx_ins_t*)(node_p->data);    struct  DefineFont *Font;    struct TextRecord *headTextRecordP,*endTextRecordP;    struct TextRecord *TextRecordP;    struct TextRecord *tmpHeadTextRecordP;    //    struct TextRecord *TextBoundP;    struct TextRecord *CursorP;    //    struct ShapeArray *p;    struct GlyphEntry *g_p ;    struct Matrix TextMatrix;    struct Matrix FontMatrix;    long x,y;    int CurPos =0;    long CurX,CurY;    int showCur = 1;    int row = 0,rownum = 0;    long Textlen = 0;    long *TextAlign;    long FontHeight=0;    int i;    struct  DefineEditText *Text;    x=y=0;    showCur = data_p->focusd;    Text = data_p->define_p;    Font = (struct  DefineFont *)data_p->swf_p->dict_p->dict[Text->FontID];    headTextRecordP = NULL;    endTextRecordP = NULL;    if(Globle_VarP->MyNum ==0) {        //        Globle_VarP->GlobleText.TextRecordsP = NULL;        return 0;    }    bzero((void *)(&TextMatrix),sizeof(struct Matrix));    MatrixPrepare(&TextMatrix);    bzero((void *)(&FontMatrix),sizeof(struct Matrix));    FontHeight=Text->FontHeight;    FontMatrix.HasScale=1;    FontMatrix.ScaleX=FontHeight/1024.0;    FontMatrix.ScaleY=FontHeight/1024.0;    TextRecordP = (struct TextRecord*)malloc(sizeof(struct TextRecord)+sizeof(struct GlyphEntry)*(Globle_VarP->MyNum-1));    bzero((void *)(TextRecordP),sizeof(struct TextRecord)+sizeof(struct GlyphEntry)*(Globle_VarP->MyNum-1));    TextRecordP->Flags =StyleFlagsHasColor;    TextRecordP->FontID =Text->FontID;    TextRecordP->TextColor = Text->TextColor;    TextRecordP->TextHeight = Text->FontHeight;    TextRecordP->GlyphCount = Globle_VarP->MyNum-1;    //get text rows    for(i=1;i<Globle_VarP->MyNum-1;i++) {        if(Text->Flags&EditTextMultiline) {            if(Globle_VarP->tmpCode[i]=='\r') {                x=0;                rownum++;            }        }        if(Text->Flags&EditTextWordWrap)            if((x+Globle_VarP->Gadvance[i]*(FontMatrix.ScaleX))>Text->Bounds.Xmax) {                x=0;                rownum++;            }        x+=Globle_VarP->Gadvance[i]*(FontMatrix.ScaleX);    }    TextAlign = (long *)malloc(sizeof(long)*(rownum+1));    bzero((void*)TextAlign,sizeof(long)*(rownum+1));    TextAlign[0] = 0;    row = 0;    if(Text->Flags&EditTextHasLayout) {        for(i=1;i<Globle_VarP->MyNum-1;i++) {            switch(Text->Align) {            case 0:                TextAlign[row] = 0;                break;            case 1:                TextAlign[row] = Text->Bounds.Xmax - Textlen - 500*(FontMatrix.ScaleX);                break;            case 2:                TextAlign[row] = (Text->Bounds.Xmax - Textlen)/2;                break;            case 3:                TextAlign[row] = 0;                break;            }            if(Text->Flags&EditTextMultiline) {                if(Globle_VarP->tmpCode[i]=='\r') {                    Textlen = 0;                    row++;                }            }            if(Text->Flags&EditTextWordWrap)                if((Textlen+Globle_VarP->Gadvance[i]*(FontMatrix.ScaleX))>Text->Bounds.Xmax) {                    Textlen = 0;                    row++;                }            Textlen+=Globle_VarP->Gadvance[i]*(FontMatrix.ScaleX);        }    }    switch(Text->Align) {    case 0:        TextAlign[row] = 0;        break;    case 1:        TextAlign[row] = Text->Bounds.Xmax - Textlen - 500*(FontMatrix.ScaleX);        break;    case 2:        TextAlign[row] = (Text->Bounds.Xmax - Textlen)/2;        break;    case 3:        TextAlign[row] = 0;        break;    }    row = 0;    y=Text->FontHeight;    x=TextAlign[row];    CurPos = i+1;    CurY=Text->FontHeight;    CurX=TextAlign[row];    for(i=0;i<Globle_VarP->MyNum-1;i++) {        if(Text->Flags&EditTextMultiline) {            if(Globle_VarP->tmpCode[i]=='\r') {                row++;                x=TextAlign[row];                y+=Text->FontHeight;                if(i<CurPos) {                    CurY+=Text->FontHeight;                    CurX=TextAlign[row];                }            }        }        if(Text->Flags&EditTextWordWrap)            if((x+Globle_VarP->Gadvance[i]*(FontMatrix.ScaleX))>Text->Bounds.Xmax) {                row++;                x=TextAlign[row];                y+=Text->FontHeight;                if(i<CurPos) {                    CurY+=Text->FontHeight;                    CurX=TextAlign[row];                }            }        g_p = &(TextRecordP->GlyphEntries[i]);        mat_new(&(g_p->GlyphMatrix));        g_p->GlyphMatrix.TranslateX	= x;        g_p->GlyphMatrix.TranslateY	= y;        g_p->GlyphMatrix.ScaleX	= FontHeight/1024.0;        g_p->GlyphMatrix.ScaleY	= FontHeight/1024.0;        g_p->Shape.CharacterType	= CharShape;        g_p->Shape.ShapeBounds	= Text->Bounds;        g_p->Shape.ShapeRecordsP	= Globle_VarP->MyRecA[i];        x+=Globle_VarP->Gadvance[i]*(FontMatrix.ScaleX);        if(i<CurPos) {            CurX+=Globle_VarP->Gadvance[i]*(FontMatrix.ScaleX);        }    }    headTextRecordP = TextRecordP;    TextRecordP->NextP = NULL;    endTextRecordP = TextRecordP;    /*        if(Text->Flags&EditTextBorder) {            TextBoundP = (struct TextRecord*)malloc(sizeof(struct TextRecord));            bzero((void *)TextBoundP,(sizeof(struct TextRecord)));            TextBoundP->Flags =StyleFlagsHasColor;            TextBoundP->FontID =Text->FontID;            TextBoundP->TextColor = Text->TextColor;            TextBoundP->TextHeight = Text->FontHeight;            TextBoundP->GlyphCount = 1;    		TextBoundP->GlyphEntries[0].Shape.FillStylesP = NULL;    		TextBoundP->GlyphEntries[0].Shape.LineStylesP = NULL;            getTextBounds(node_p,TextBoundP);            TextBoundP->NextP = NULL;            endTextRecordP->NextP = TextBoundP;            endTextRecordP = TextBoundP;        }    */    if(showCur) {        CursorP = (struct TextRecord*)malloc(sizeof(struct TextRecord));        bzero((void *)CursorP,(sizeof(struct TextRecord)));        CursorP->Flags =StyleFlagsHasColor;        CursorP->FontID =Text->FontID;        CursorP->TextColor = Text->TextColor;        CursorP->TextHeight = Text->FontHeight;        CursorP->GlyphCount = 1;#ifdef PRINT_DG        fprintf(stderr,"FontToShape start   --- CursorP->GlyphEntries[0].Shape.FillStylesP =%p\n",CursorP->GlyphEntries[0].Shape.FillStylesP);#endif        CursorP->GlyphEntries[0].Shape.FillStylesP = NULL;        CursorP->GlyphEntries[0].Shape.LineStylesP = NULL;        getCursor(node_p,CursorP,CurX,CurY);        CursorP->NextP = NULL;        endTextRecordP->NextP = CursorP;        endTextRecordP = CursorP;    }    endTextRecordP->NextP = NULL;

⌨️ 快捷键说明

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