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

📄 aclfpainter.pas

📁 Alpha Controls 界面控件包
💻 PAS
📖 第 1 页 / 共 3 页
字号:
      BitBlt(ACanvas.Handle, R.Left, R.Top, TmpBmp.Width, TmpBmp.Height, TmpBmp.Canvas.Handle, 0, 0, SRCCOPY);

      if State = 0
        then ACanvas.Font.Color := DefaultManager.gd[i].FontColor[1]
        else ACanvas.Font.Color := DefaultManager.gd[i].HotFontColor[1];
      ACanvas.Brush.Style := bsClear;
      DrawText(ACanvas.Handle, PAnsiChar(ACaption), Length(ACaption), R, DT_EXPANDTABS + DT_VCENTER + DT_CENTER + DT_SINGLELINE);
      FreeAndNil(TmpBmp);
    end;
  end else inherited DrawButton(ACanvas, R, ACaption, AState, ADrawBorder, AColor, ATextColor)
end;

class procedure TcxACLookAndFeelPainter.DrawCheckButton(ACanvas: TcxCanvas; R: TRect; AState: TcxButtonState; AChecked: Boolean{$IFDEF VER628}; AGrayed: Boolean{$ENDIF});
var
  State, i, w, h, {x, y,} NewLeft, NewTop : integer;
  TmpBmp : TBitmap;
begin
  if Skinned then begin
{$IFDEF VER628}
    if AGrayed then
      else i := DefaultManager.GetMaskIndex(DefaultManager.ConstData.IndexGLobalInfo, s_GLobalInfo, s_SmallBoxGrayed);
{$ENDIF}
    if AChecked
      then i := DefaultManager.GetMaskIndex(DefaultManager.ConstData.IndexGLobalInfo, s_GLobalInfo, s_SmallBoxChecked)
      else i := DefaultManager.GetMaskIndex(DefaultManager.ConstData.IndexGLobalInfo, s_GLobalInfo, s_SmallBoxUnChecked);
    if DefaultManager.IsValidImgIndex(i) then begin
      TmpBmp := CreateBmp24(WidthOf(R), HeightOf(R));

      FillDC(TmpBmp.Canvas.Handle, Rect(0, 0, TmpBmp.Width, TmpBmp.Height), DefaultManager.GetGlobalColor);
      case AState of cxbsHot : State := 1; cxbsPressed : State := 2; else State := 0 end;

      w := WidthOf(DefaultManager.ma[i].R) div DefaultManager.ma[i].ImageCount;
      h := HeightOf(DefaultManager.ma[i].R) div (1 + DefaultManager.ma[i].MaskType);
      if State > DefaultManager.ma[i].ImageCount - 1 then State := DefaultManager.ma[i].ImageCount - 1;

      NewLeft := {R.Left +} (WidthOf(R) - w) div 2;
      Newtop := {R.Top +} (HeightOf(R) - h) div 2;
      DrawSkinGlyph(TmpBmp, Point(NewLeft, NewTop), State, 1, DefaultManager.ma[i]);

      BitBlt(ACanvas.Handle, R.Left, R.Top, w, h, TmpBmp.Canvas.Handle, 0, 0, SRCCOPY);

      FreeAndNil(TmpBmp);
    end;
  end else inherited DrawCheckButton(ACanvas, R, AState, AChecked)
end;

class procedure TcxACLookAndFeelPainter.DrawFilterCloseButton(ACanvas: TcxCanvas; R: TRect; AState: TcxButtonState);
var
  i : integer;
  TmpBmp : TBitmap;
  State : integer;
//  fs : TFontStyles;
  CI : TCacheInfo;
begin
  if Skinned then begin
    i := DefaultManager.GetSkinIndex(s_GlobalInfo);
    i := DefaultManager.GetMaskIndex(i, s_GlobalInfo, s_BorderIconClose);
    if DefaultManager.IsValidImgIndex(i) then begin
      case AState of cxbsHot : State := 1; cxbsPressed : State := 2; else State := 0 end;
      TmpBmp := CreateBmp24(WidthOf(R), HeightOf(R));

      FillDC(TmpBmp.Canvas.Handle, Rect(0, 0, TmpBmp.Width, TmpBmp.Height), DefaultManager.GetGlobalColor);

      CI := MakeCacheInfo(TmpBmp);

      DrawSkinGlyph(TmpBmp, Point(0, 0), State, 1, DefaultManager.ma[i]);

      BitBlt(ACanvas.Handle, R.Left, R.Top, TmpBmp.Width, TmpBmp.Height, TmpBmp.Canvas.Handle, 0, 0, SRCCOPY);
      FreeAndNil(TmpBmp);
    end;
  end else inherited DrawFilterCloseButton(ACanvas, R, AState)
end;

class procedure TcxACLookAndFeelPainter.DrawFilterDropDownButton(ACanvas: TcxCanvas; R: TRect; AState: TcxButtonState; AIsFilterActive: Boolean);
var
  i : integer;
  TmpBmp : TBitmap;
  State : integer;
  CI : TCacheInfo;
begin
  if Skinned then begin
    i := DefaultManager.GetSkinIndex(s_ComboBox);
    i := DefaultManager.GetMaskIndex(i, s_ComboBox, s_ItemGlyph);
    if DefaultManager.IsValidImgIndex(i) then begin
      case AState of cxbsHot : State := 1; cxbsPressed : State := 2; else State := 0 end;
      TmpBmp := CreateBmp24(WidthOf(R), HeightOf(R));

      FillDC(TmpBmp.Canvas.Handle, Rect(0, 0, TmpBmp.Width, TmpBmp.Height), DefaultManager.GetGlobalColor);
      BitBlt(TmpBmp.Canvas.Handle, 0, 0, TmpBmp.Width, TmpBmp.Height, ACanvas.Handle, R.Left, R.Top, SRCCOPY);

      CI := MakeCacheInfo(TmpBmp);

      DrawSkinGlyph(TmpBmp, Point(0, 0), State, 1, DefaultManager.ma[i]);

      BitBlt(ACanvas.Handle, R.Left, R.Top, TmpBmp.Width, TmpBmp.Height, TmpBmp.Canvas.Handle, 0, 0, SRCCOPY);
      FreeAndNil(TmpBmp);
    end;
  end else inherited DrawFilterCloseButton(ACanvas, R, AState)
end;

class procedure TcxACLookAndFeelPainter.DrawFooterBorder(ACanvas: TcxCanvas; const R: TRect);
const
  Section = 'BUTTON';
var
  i : integer;
  TmpBmp : TBitmap;
  CI : TCacheInfo;
begin
  if Skinned then begin
    ACanvas.FrameRect(R, DefaultManager.GetActiveEditColor, 1);
Exit;
    i := DefaultManager.GetSkinIndex(Section);
    if DefaultManager.IsValidSkinIndex(i) then begin
      TmpBmp := TBitmap.Create; TmpBmp.PixelFormat := pf24bit; TmpBmp.Width := WidthOf(R); TmpBmp.Height := HeightOf(R);
      FillDC(TmpBmp.Canvas.Handle, Rect(0, 0, TmpBmp.Width, TmpBmp.Height), DefaultManager.GetGlobalColor);
      CI.Bmp := TmpBmp;
      CI.X := 0;
      CI.Y := 0;
      CI.Ready := True;
      PaintItem(i, Section, CI, True, 0, Rect(0, 0, TmpBmp.Width, TmpBmp.Height), Point(0, 0), TmpBmp, DefaultManager);

      BitBlt(ACanvas.Handle, R.Left, R.Top, TmpBmp.Width, TmpBmp.Height, TmpBmp.Canvas.Handle, 0, 0, SRCCOPY);
      FreeAndNil(TmpBmp);
    end;
  end else inherited DrawFooterBorder(ACanvas, R)
end;

class procedure TcxACLookAndFeelPainter.DrawFooterCellBorder(ACanvas: TcxCanvas; const R: TRect);
const
  Section = 'BUTTON';
var
  i : integer;
  TmpBmp : TBitmap;
  CI : TCacheInfo;
begin
  if Skinned then begin
    ACanvas.FrameRect(R, DefaultManager.GetGlobalColor, 1);
Exit;
    i := DefaultManager.GetSkinIndex(Section);
    if DefaultManager.IsValidSkinIndex(i) then begin
      TmpBmp := TBitmap.Create; TmpBmp.PixelFormat := pf24bit; TmpBmp.Width := WidthOf(R); TmpBmp.Height := HeightOf(R);
      FillDC(TmpBmp.Canvas.Handle, Rect(0, 0, TmpBmp.Width, TmpBmp.Height), DefaultManager.GetGlobalColor);
      CI.Bmp := TmpBmp;
      CI.X := 0;
      CI.Y := 0;
      CI.Ready := True;
      PaintItem(i, Section, CI, True, 0, Rect(0, 0, TmpBmp.Width, TmpBmp.Height), Point(0, 0), TmpBmp, DefaultManager);

      BitBlt(ACanvas.Handle, R.Left, R.Top, TmpBmp.Width, TmpBmp.Height, TmpBmp.Canvas.Handle, 0, 0, SRCCOPY);
      FreeAndNil(TmpBmp);
    end;
  end else inherited DrawFooterBorder(ACanvas, R)
end;

class procedure TcxACLookAndFeelPainter.DrawHeader;
const
 AlignmentsHorz: array[TAlignment] of Integer = (cxAlignLeft, cxAlignRight, cxAlignHCenter);
 AlignmentsVert: array[TcxAlignmentVert] of Integer = (cxAlignTop, cxAlignBottom, cxAlignVCenter);
 MultiLines: array[Boolean] of Integer = (cxSingleLine, cxWordBreak);
 ShowEndEllipsises: array[Boolean] of Integer = (0, cxShowEndEllipsis);
var
 i : integer;
 State : integer;
 Section : string;
 R : TRect;
 TmpBmp : TBitmap;
 CI : TCacheInfo;
begin
 if Skinned then begin
   if AState in [cxbsDefault, cxbsNormal, cxbsHot, cxbsPressed]{AIsLast} then begin
     Section := s_ColHeader;
     AOnDrawBackground := nil;
     i := DefaultManager.GetSkinIndex(Section);
     if not DefaultManager.IsValidSkinIndex(i) then begin Section := s_Button; i := DefaultManager.GetSkinIndex(Section) end; // For compatibility
     if DefaultManager.IsValidSkinIndex(i) then begin
       case AState of cxbsHot : State := 1; cxbsPressed : State := 2; else State := 0 end;

       TmpBmp := CreateBmp24(WidthOf(ABounds), HeightOf(ABounds));
       CI := MakeCacheInfo(TmpBmp);

       ParentCenterColor := DefaultManager.GetGlobalColor;
       CtrlParentColor := ParentCenterColor;
       FillDC(TmpBmp.Canvas.Handle, ABounds, ParentCenterColor);
       PaintItem(i, Section, EmptyCI, True, State, Rect(0, 0, TmpBmp.Width, TmpBmp.Height), Point(0, 0), TmpBmp.Canvas.Handle, DefaultManager);
       ParentCenterColor := clFuchsia;
       CtrlParentColor := clFuchsia;
       BitBlt(ACanvas.Handle, ABounds.Left, ABounds.Top, TmpBmp.Width, TmpBmp.Height, TmpBmp.Canvas.Handle, 0, 0, SRCCOPY);

       FreeAndnil(TmpBmp);

       if AFont <> nil then ACanvas.Font.Assign(AFont);
       ACanvas.Font.Color := DefaultManager.gd[i].FontColor[1];
       ACanvas.Brush.Style := bsClear;
       R := ATextAreaBounds;
       ACanvas.DrawTexT(AText, ATextAreaBounds, AlignmentsHorz[AAlignmentHorz] or
         AlignmentsVert[AAlignmentVert] or MultiLines[AMultiLine] or
         ShowEndEllipsises[AShowEndEllipsis]);
//        DrawText(ACanvas.Handle, PChar(AText), Length(AText), R, DT_EXPANDTABS + AlignToInt[AAlignmentHorz]);
     end;
   end;
 end else inherited
end;

class procedure TcxACLookAndFeelPainter.DrawHeaderBorder(ACanvas: TcxCanvas; const R: TRect; ANeighbors: TcxNeighbors; ABorders: TcxBorders);
begin
  if not Skinned then inherited;
end;

class procedure TcxACLookAndFeelPainter.DrawHeaderControlSection(
  ACanvas: TcxCanvas; const ABounds, ATextAreaBounds: TRect;
  ANeighbors: TcxNeighbors; ABorders: TcxBorders; AState: TcxButtonState;
  AAlignmentHorz: TAlignment; AAlignmentVert: TcxAlignmentVert; AMultiLine,
  AShowEndEllipsis: Boolean; const AText: string; AFont: TFont; ATextColor,
  ABkColor: TColor);
begin
{  if Skinned
    then FillDC(ACanvas.Handle, ABounds, clYellow)//!!!
    else}
  inherited
end;

class procedure TcxACLookAndFeelPainter.DrawHeaderControlSectionBorder(
  ACanvas: TcxCanvas; const R: TRect; ABorders: TcxBorders;
  AState: TcxButtonState);
begin
  inherited;
end;

class procedure TcxACLookAndFeelPainter.DrawHeaderEx(ACanvas: TcxCanvas;
  const ABounds, ATextAreaBounds: TRect; ANeighbors: TcxNeighbors;
  ABorders: TcxBorders; AState: TcxButtonState; AAlignmentHorz: TAlignment;
  AAlignmentVert: TcxAlignmentVert; AMultiLine, AShowEndEllipsis: Boolean;
  const AText: string; AFont: TFont; ATextColor, ABkColor: TColor;
  AOnDrawBackground: TcxDrawBackgroundEvent);
begin
  if Skinned then DrawHeader(ACanvas, ABounds, ATextAreaBounds, ANeighbors, ABorders, AState,
      AAlignmentHorz, AAlignmentVert, AMultiLine, AShowEndEllipsis, AText, AFont, ATextColor, ABkColor,
      AOnDrawBackground, False)
  else inherited
end;

class procedure TcxACLookAndFeelPainter.DrawHeaderPressed(ACanvas: TcxCanvas; const ABounds: TRect);
begin
  if not Skinned then inherited
end;

class procedure TcxACLookAndFeelPainter.DrawMonthHeader(ACanvas: TcxCanvas;
  const ABounds: TRect; const AText: string; ANeighbors: TcxNeighbors;
  const AViewParams: TcxViewParams; AArrows: TcxHeaderArrows;
  ASideWidth: Integer; AOnDrawBackground: TcxDrawBackgroundEvent);
begin
//  inherited;
end;

class procedure TcxACLookAndFeelPainter.DrawScrollBarPart(ACanvas: TcxCanvas; AHorizontal: Boolean; R: TRect; APart: TcxScrollBarPart; AState: TcxButtonState);
var
  State : integer;
  TmpBmp, BGBmp : TBitmap;
  CI : TCacheInfo;
  procedure PaintGlyph(MaskIndex : integer);
  var
    p : TPoint;
  begin
    if DefaultManager.IsValidImgIndex(MaskIndex) then with DefaultManager do begin
      if ma[MaskIndex].Bmp = nil then begin
        p.x := (WidthOf(R) - WidthOf(ma[MaskIndex].R) div ma[MaskIndex].ImageCount) div 2;
        p.y := (HeightOf(R) - HeightOf(ma[MaskIndex].R) div (1 + ma[MaskIndex].MaskType)) div 2;
      end
      else if (ma[MaskIndex].Bmp.Height div 2 < HeightOf(R)) then begin
        p.x := (WidthOf(R) - ma[MaskIndex].Bmp.Width div 3) div 2;
        p.y := (HeightOf(R) - ma[MaskIndex].Bmp.Height div 2) div 2;
      end;
      if (p.x < 0) or (p.y < 0) then Exit;
      DrawSkinGlyph(TmpBmp, p, State, 1, ma[MaskIndex]);
    end;
  end;
  procedure PaintPage(APart: TcxScrollBarPart; w, h : integer; NewBmp : TBitmap = nil);
  begin
    if NewBmp = nil then NewBmp := TmpBmp;
    with DefaultManager.ConstData do if APart = sbpPageUp then begin
      if AHorizontal then begin
        PaintItemFast(IndexScrollBar2H, MaskScrollBar2H, BGScrollBar2H, BGHotScrollBar2H,
                        s_ScrollSliderH, EmptyCI, True,
                        State, Rect(0, 0, w, NewBmp.Height), Point(0, 0), NewBmp, DefaultManager);
      end
      else begin
        PaintItemFast(IndexScrollBar2V, MaskScrollBar2V, BGScrollBar2V, BGHotScrollBar2V,
                        s_ScrollSliderV, EmptyCI, True,
                        State, Rect(0, 0, NewBmp.Width, h), Point(0, 0), NewBmp, DefaultManager);
      end;
    end
    else begin
      if AHorizontal then begin
        PaintItemFast(IndexScrollBar1H, MaskScrollBar1H, BGScrollBar1H, BGHotScrollBar1H,
                        s_ScrollSliderH, EmptyCI, True,
                        State, Rect(NewBmp.Width - w, 0, NewBmp.Width, NewBmp.Height), Point(NewBmp.Width - w, 0), NewBmp, DefaultManager);
      end
      else begin
        PaintItemFast(IndexScrollBar1V, MaskScrollBar1V, BGScrollBar1V, BGHotScrollBar1V,
                        s_ScrollSliderV, EmptyCI, True,
                        State, Rect(0, NewBmp.Height - h, NewBmp.Width, NewBmp.Height), Point(0, NewBmp.Height - h), NewBmp, DefaultManager);
      end;

⌨️ 快捷键说明

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