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

📄 sxskinregionmanager.pas

📁 skin components for design of your applicastions
💻 PAS
📖 第 1 页 / 共 3 页
字号:
                                begin
                                 if CurParamN=1 then
                                  SetLength(Coords,4);
                                 Coords[CurParamN-1]:=D;
                                 if CurParamN=4 then
                                  begin
                                   ParserState:=psNeedType;
                                   TmpRgn:=CreateRectRgn(Coords[0],Coords[1],Coords[2],Coords[3]);
                                  end;
                                end else
                               if ParserState=psNeedRoundRectCoord then
                                begin
                                 if CurParamN=1 then
                                  SetLength(Coords,5);
                                 Coords[CurParamN-1]:=D;
                                 if CurParamN=5 then
                                  begin
                                   ParserState:=psNeedType;
                                   TmpRgn:=CreateRoundRectRgn(Coords[0],Coords[1],Coords[2],Coords[3],Coords[4]*2,Coords[4]*2);
                                  end;
                                end else
                               if ParserState=psNeedEllipseCoord then
                                begin
                                 if CurParamN=1 then
                                  SetLength(Coords,4);
                                 Coords[CurParamN-1]:=D;
                                 if CurParamN=4 then
                                  begin
                                   ParserState:=psNeedType;
                                   TmpRgn:=CreateEllipticRgn(Coords[0],Coords[1],Coords[2],Coords[3]);
                                  end;
                                end;
                               Inc(CurParamN);
                              end;
     psNeedImagePath:         begin
                               ImagePath:=S2;
                               ParserState:=psNeedImageWidth;
                              end;
     psNeedImagePathOffset:   begin
                               ImagePath:=S2;
                               ParserState:=psNeedImageOffsetX;
                              end;
     psNeedImageOffsetX:      begin
                               ImageOffsetX:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then ImageOffsetX:=0;
                               ParserState:=psNeedImageOffsetY;
                              end;
     psNeedImageOffsetY:      begin
                               ImageOffsetY:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then ImageOffsetY:=0;
                               ParserState:=psNeedImageWidth;
                              end;
     psNeedImageWidth:        begin
                               ImageWidth:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then ImageWidth:=0;
                               ParserState:=psNeedImageHeight;
                              end;
     psNeedImageHeight:       begin
                               ImageHeight:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then ImageHeight:=0;
                               ParserState:=psNeedImageColor;
                              end;
     psNeedImageColor:        begin
                               Color:=GetColorFromString(S2);
                               ParserState:=psNeedImageColorMask;
                              end;
     psNeedImageColorMask:    begin
                               ColorMask:=GetColorFromString(S2);
                               ParserState:=psNeedType;
                               if not ExtractZipPath(ImagePath,S) then
                                ImagePath:=GetFullPath(ImagePath,SkinFilePath) else
                                 ZipFilePath:=S;
                               TmpRgn:=CreateRectRgn(0,0,0,0);
                               CombineRgn(TmpRgn,GetPreloadedRegion(SkinLibrary,False,ImagePath,ZipFilePath,
                                                        (ImageWidth<>0) or (ImageHeight<>0),ImageWidth,
                                                        ImageHeight,SaveResized,Color,ColorMask),
                                          0,RGN_COPY);
                               if (ImageOffsetX<>0) or (ImageOffsetY<>0) then
                                OffsetRgn(TmpRgn,ImageOffsetX,ImageOffsetY);
                              end;
     psNeedBoxTilePathOffset: begin
                               ImagePath:=S2;
                               ParserState:=psNeedBoxTileRSMOffset;
                              end;
     psNeedBoxTilePath:       begin
                               ImagePath:=S2;
                               ParserState:=psNeedBoxTileRSM;
                              end;
     psNeedBoxTileRSMOffset:  begin
                               RSMIsTile:=SameText(S2,'Tile');
                               ParserState:=psNeedBoxTileOffsetX;
                              end;
     psNeedBoxTileRSM:        begin
                               RSMIsTile:=SameText(S2,'Tile');
                               ParserState:=psNeedBoxTileWidth;
                              end;
     psNeedBoxTileOffsetX:    begin
                               ImageOffsetX:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then ImageOffsetX:=0;
                               ParserState:=psNeedBoxTileOffsetY;
                              end;
     psNeedBoxTileOffsetY:    begin
                               ImageOffsetY:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then ImageOffsetY:=0;
                               ParserState:=psNeedBoxTileWidth;
                              end;
     psNeedBoxTileWidth:      begin
                               ImageWidth:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then ImageWidth:=0;
                               ParserState:=psNeedBoxTileHeight;
                              end;
     psNeedBoxTileHeight:     begin
                               ImageHeight:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then ImageHeight:=0;
                               ParserState:=psNeedBoxTileColor;
                              end;
     psNeedBoxTileColor:      begin
                               Color:=GetColorFromString(S2);
                               ParserState:=psNeedBoxTileColorMask;
                              end;
     psNeedBoxTileColorMask:  begin
                               ColorMask:=GetColorFromString(S2);
                               ParserState:=psNeedBoxTileLeft;
                              end;
     psNeedBoxTileLeft:       begin
                               BTLeft:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then BTLeft:=0;
                               ParserState:=psNeedBoxTileRight;
                              end;
     psNeedBoxTileRight:      begin
                               BTRight:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then BTRight:=0;
                               ParserState:=psNeedBoxTileTop;
                              end;
     psNeedBoxTileTop:        begin
                               BTTop:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then BTTop:=0;
                               ParserState:=psNeedBoxTileBottom;
                              end;
     psNeedBoxTileBottom:     begin
                               BTBottom:=round(SXEvalMathString(S2,AOnGetVariable,E));
                               if E then BTBottom:=0;
                               ParserState:=psNeedType;
                               if not ExtractZipPath(ImagePath,S) then
                                ImagePath:=GetFullPath(ImagePath,SkinFilePath) else
                                 ZipFilePath:=S;
                               BTCenterW:=ImageWidth-BTLeft-BTRight;
                               BTCenterH:=ImageHeight-BTTop-BTBottom;
                               if BTCenterW<0 then
                                begin
                                 Inc(BTLeft,BTCenterW div 2);
                                 Inc(BTRight,BTCenterW-(BTCenterW div 2));
                                 BTCenterW:=0;
                                 if BTRight<0 then
                                  begin
                                   Inc(BTLeft,BTRight);
                                   BTRight:=0;
                                  end;
                                end;
                               if BTCenterH<0 then
                                begin
                                 Inc(BTTop,BTCenterH div 2);
                                 Inc(BTBottom,BTCenterH-(BTCenterH div 2));
                                 BTCenterH:=0;
                                 if BTBottom<0 then
                                  begin
                                   Inc(BTTop,BTBottom);
                                   BTBottom:=0;
                                  end;
                                end;
                               TmpRgn:=CreateRectRgn(0,0,0,0);
                               for C:=1 to 9 do
                                begin
                                 TmpRgn2:=0;
                                 case C of
                                  1: begin
                                      //Top Left
                                      if (BTTop>0) and (BTLeft>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,False,
                                           StringReplace(ImagePath,'*','topleft',[]),
                                           ZipFilePath,True,BTLeft,BTTop,SaveResized,
                                           Color,ColorMask);
                                     end;
                                  2: begin
                                      //Top
                                      if (BTTop>0) and (BTCenterW>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,RSMIsTile,
                                           StringReplace(ImagePath,'*','top',[]),
                                           ZipFilePath,True,BTCenterW,BTTop,SaveResized,
                                           Color,ColorMask);
                                      OffsetRgn(TmpRgn2,BTLeft,0);
                                     end;
                                  3: begin
                                      //Top Right
                                      if (BTTop>0) and (BTRight>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,False,
                                           StringReplace(ImagePath,'*','topright',[]),
                                           ZipFilePath,True,BTRight,BTTop,SaveResized,
                                           Color,ColorMask);
                                      OffsetRgn(TmpRgn2,BTLeft+BTCenterW,0);
                                     end;
                                  4: begin
                                      //Left
                                      if (BTCenterH>0) and (BTLeft>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,RSMIsTile,
                                           StringReplace(ImagePath,'*','left',[]),
                                           ZipFilePath,True,BTLeft,BTCenterH,SaveResized,
                                           Color,ColorMask);
                                      OffsetRgn(TmpRgn2,0,BTTop);
                                     end;
                                  5: begin
                                      //Center
                                      if (BTCenterH>0) and (BTCenterW>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,RSMIsTile,
                                           StringReplace(ImagePath,'*','center',[]),
                                           ZipFilePath,True,BTCenterW,BTCenterH,SaveResized,
                                           Color,ColorMask);
                                      OffsetRgn(TmpRgn2,BTLeft,BTTop);
                                     end;
                                  6: begin
                                      //Right
                                      if (BTCenterH>0) and (BTRight>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,RSMIsTile,
                                           StringReplace(ImagePath,'*','right',[]),
                                           ZipFilePath,True,BTRight,BTCenterH,SaveResized,
                                           Color,ColorMask);
                                      OffsetRgn(TmpRgn2,BTLeft+BTCenterW,BTTop);
                                     end;
                                  7: begin
                                      //Bottom Left
                                      if (BTBottom>0) and (BTLeft>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,False,
                                           StringReplace(ImagePath,'*','bottomleft',[]),
                                           ZipFilePath,True,BTLeft,BTBottom,SaveResized,
                                           Color,ColorMask);
                                      OffsetRgn(TmpRgn2,0,BTTop+BTCenterH);
                                     end;
                                  8: begin
                                      //Bottom
                                      if (BTBottom>0) and (BTCenterW>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,RSMIsTile,
                                           StringReplace(ImagePath,'*','bottom',[]),
                                           ZipFilePath,True,BTCenterW,BTBottom,SaveResized,
                                           Color,ColorMask);
                                      OffsetRgn(TmpRgn2,BTLeft,BTTop+BTCenterH);
                                     end;
                                  9: begin
                                      //Bottom Right
                                      if (BTBottom>0) and (BTRight>0) then
                                       TmpRgn2:=GetPreloadedRegion(SkinLibrary,False,
                                           StringReplace(ImagePath,'*','bottomright',[]),
                                           ZipFilePath,True,BTRight,BTBottom,SaveResized,
                                           Color,ColorMask);
                                      OffsetRgn(TmpRgn2,BTLeft+BTCenterW,BTTop+BTCenterH);
                                     end;
                                 end;
                                 if TmpRgn2<>0 then
                                  begin
                                   CombineRgn(TmpRgn,TmpRgn,TmpRgn2,RGN_OR);
                                   DeleteObject(TmpRgn2);
                                  end;
                                end;
                               if (ImageOffsetX<>0) or (ImageOffsetY<>0) then
                                OffsetRgn(TmpRgn,ImageOffsetX,ImageOffsetY);
                              end;
    end;
    if ParserState=psNeedType then
     begin
      if Inverse then
       begin
        R2:=CreateRectRgn(0,0,Width,Height);
        CombineRgn(TmpRgn,R2,TmpRgn,RGN_DIFF);
        DeleteObject(R2);
       end;
      case Operation of
       opIntersect:   CM:=RGN_AND;
       opCombine:     CM:=RGN_OR;
       opDifference:  CM:=RGN_DIFF;
       opExclusiveOr: CM:=RGN_XOR;
       else           CM:=0;
      end;
      CombineRgn(Result,Result,TmpRgn,CM);
      DeleteObject(TmpRgn);
     end;
   end;
 end;

begin
 ParserState:=psNeedType;
 CurParamN:=0;
 Result:=CreateRectRgn(0,0,0,0);
 A:=1; B:=1;
 while B<=length(Region) do
  begin
   if Region[B]=',' then
    begin
     SetWhatGot;
     Inc(B);
     A:=B;
    end else Inc(B);
  end;
 SetWhatGot;
end;

initialization

 PreloadedRegions:=TSXSkinPreloadedRegionList.Create;

finalization

 PreloadedRegions.Free;

end.

⌨️ 快捷键说明

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