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

📄 tbxmacosxg32theme.pas

📁 这是整套横扫千军3D版游戏的源码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  AViewType: Integer);
var
  R: TRect;
begin
  if TBXLoColor then inherited
  else with Canvas do
    begin
      IntersectRect(R, ARect, AClipRect);
      {if not Transparent then
      begin
        Brush.Color := AColor;
        FillRect(R);
      end;}
      DrawStripeBG(Canvas, R, AColor);
    end;
end;

procedure TTBXMacOSXg32Theme.PaintButton(Canvas: TCanvas; const ARect: TRect;
  const ItemInfo: TTBXItemInfo);
var
//  DC: HDC;
  R: TRect;
//  C: TColor;
  ShowHover, Embedded: Boolean;
//  RL, RR: Integer;
  DrawStyle: TDrawStyle;
//  State: TBtnItemState;
  y, yInc, yStart: Integer;
  biRect:TRect;
begin
//  DC := Canvas.Handle;
  R := ARect;
  with ItemInfo, Canvas do
  begin
//    State:= bisNormal;
    DrawStyle:= bsDefault;
    If Not Enabled then
      DrawStyle:= bsDisabled
    Else If Pushed then
      DrawStyle:= bsPushed
    Else If (HoverKind <> hkNone) and (Not Selected) then
      DrawStyle:= bsHover
    Else If Selected then
      If (HoverKind <> hkNone) then
        DrawStyle:= bsSelectedHover
      Else
        DrawStyle:= bsSelected
    ;

    //Brush.Style:= bsClear;//bsSolid;//
//    graphic:= TGPgraphics.Create(Canvas.Handle);
    Embedded := (ViewType and VT_TOOLBAR = VT_TOOLBAR) and
      (ViewType and TVT_EMBEDDED = TVT_EMBEDDED);
    ShowHover := (Enabled and (HoverKind <> hkNone)) or
      (not Enabled and (HoverKind = hkKeyboardHover));
    If ((ViewType and TVT_MENUBAR) = TVT_MENUBAR) then
    Begin
      if ((Pushed or Selected) and Enabled) or ShowHover then
        //PaintBackgnd(Canvas, RECT(0,0,0,0), ARect, ARect, 0, False, VT_UNKNOWN);
        DrawStripeBG(Canvas, ARect, MenuItemColors[misHot, ipBody]);
    End else
    if ComboPart = cpSplitRight then
    Begin
      // DropDown Right
      yStart:= 0;
      yInc:= TOOLBARBUTTONSSPLITDROPDOWN.Height div 6;
      y:=0;
      Case DrawStyle of
        bsDefault:       If Embedded then  y:= 1 Else y:= 0;
        bsHover:         y:= 1;
        bsDisabled:      y:= 3;
        bsPushed:        y:= 5;
        bsSelected:      y:= 4;
        bsSelectedHover: y:= 5;
      End;//CASE
      biRect:= Rect(0,yStart+yInc*y,TOOLBARBUTTONSSPLITDROPDOWN.Width,yStart+yInc*(y+1));
      EnlargeBitmap(TOOLBARBUTTONSSPLITDROPDOWN, Canvas, biRect, R, 9, 5);
      //Canvas.Draw(R.Left, R.Top, StockBMP);
      PaintDropDownArrow(Canvas, R, ItemInfo);
      //EnlargeBitmap(BOTON, Canvas, biRect, R, 10, 12);
      //EnlargeBitmap(BOTON, Canvas, biRect, R, 12);
    End Else
    if ComboPart = cpSplitLeft then
    Begin
      // Dropdown Left
      yStart:= 0;
      yInc:= TOOLBARBUTTONSSPLIT.Height div 6;
      y:=0;
      Case DrawStyle of
        bsDefault:       If Embedded then  y:= 1 Else y:= 0;
        bsHover:         y:= 1;
        bsDisabled:      y:= 3;
        bsPushed:        y:= 5;
        bsSelected:      y:= 4;
        bsSelectedHover: y:= 5;
      End;//CASE
      biRect:= Rect(0,yStart+yInc*y,TOOLBARBUTTONSSPLIT.Width,yStart+yInc*(y+1));
      EnlargeBitmap(TOOLBARBUTTONSSPLIT, Canvas, biRect, R, 8, 3);
      //Canvas.Draw(R.Left, R.Top, StockBMP);
    End Else
    Begin
      If Embedded then
      Begin
        // Button
        yStart:= 0;
        yInc:= BOTON.Height div 5;
        y:=0;
        Case DrawStyle of
          bsDefault:  //Pen.Color:= clWhite;
            y:= 0;
          bsHover:    //Pen.Color:= clLime;
            y:= 1;
          bsDisabled: //Pen.Color:= clBlack;
            y:= 3;
          bsPushed:   //Pen.Color:= clRed;
            y:= 2;
          bsSelected: //Pen.Color:= clBlue;
            y:= 4;
          bsSelectedHover:
            y:= 1;
        End;//CASE
        biRect:= Rect(0,yStart+yInc*y,BOTON.Width,yStart+yInc*(y+1));
        EnlargeBitmap(BOTON, Canvas, biRect, R, 11, 11);
      End Else
      Begin
        // Tool Button
        yStart:= 0;
        yInc:= TOOLBARBUTTONS.Height div 6;
        y:=0;
        Case DrawStyle of
          bsDefault:      y:= 0;
          bsHover:        y:= 1;
          bsDisabled:     y:= 3;
          bsPushed:       y:= 2;
          bsSelected:     y:= 4;
          bsSelectedHover:y:= 5;
        End;//CASE
        biRect:= Rect(0,yStart+yInc*y,TOOLBARBUTTONS.Width,yStart+yInc*(y+1));
        EnlargeBitmap(TOOLBARBUTTONS, Canvas, biRect, R, 7, 5);
      End;
    End;
  end;
end;

procedure TTBXMacOSXg32Theme.PaintComboArrow(Canvas: TCanvas;
  const ARect: TRect; const ItemInfo: TTBXItemInfo);
var
  X, Y: Integer;
begin
  with ARect, Canvas, ItemInfo do
  begin
    X := (Left + Right) div 2 - 1;
    Y := (Top + Bottom) div 2 - 1;
    {If Not Enabled then
      Pen.Color := clLtGray
    Else
      Pen.Color := clBlack;//GetPartColor(ItemInfo, ipText);{}
    Pen.Color := GetPartColor(ItemInfo, ipText);
    Brush.Color := Pen.Color;
    if ItemInfo.IsVertical then
    Begin
      Polygon([Point(X, Y + 2), Point(X, Y - 2), Point(X - 2, Y)]);
      Polygon([Point(X, Y + 2), Point(X, Y - 2), Point(X - 2, Y)]);
    End else
    Begin
      Y:= Y-1;
      Polygon([Point(X - 2, Y), Point(X + 2, Y), Point(X, Y - 2)]);
      Y:= Y+3;
      Polygon([Point(X - 2, Y), Point(X + 2, Y), Point(X, Y + 2)]);
    End;
  end;
end;

procedure TTBXMacOSXg32Theme.PaintDock(Canvas: TCanvas; const ClientRect,
  DockRect: TRect; DockPosition: Integer);
begin
  DrawStripeBG(Canvas, DockRect, ToolbarColor);//MenuItemColors[misHot, ipBody]);//
end;

procedure TTBXMacOSXg32Theme.PaintDockPanelNCArea(Canvas: TCanvas; R: TRect;
  const DockPanelInfo: TTBXDockPanelInfo);
var
  DC: HDC;
  Sz: Integer;
  R2: TRect;
  biRect:TRect;
  Flags: Integer;
  y, yStart, yInc:Integer;
  CloseButtonDown, CloseButtonHover: Boolean;

  procedure CaptionFill(R: TRect);
  const
    GRAD: array [Boolean] of TGradientKind = (gkHorz, gkVert);
  begin
    if USE_THEMES then
      GradFill(DC, R, Lighten(ToolbarColor, 12), Lighten(ToolbarColor, -12), GRAD[DockPanelInfo.IsVertical])
    else
      FillRectEx(DC, R, ToolbarColor);
  end;

begin
  DC := Canvas.Handle;
  with Canvas, DockPanelInfo do
  begin
    Sz := GetSystemMetrics(SM_CYSMCAPTION);

    { Border }
    FrameRectEx(DC, R, ToolbarColor, True);
    R2 := R;
    if ShowCaption then
      if IsVertical then Inc(R2.Top, Sz)
      else Inc(R2.Left, Sz);
    FrameRectEx(DC, R2, clWindow, False);

    if not ShowCaption then Exit;

    { Caption area }
    if IsVertical then R.Bottom := R.Top + Sz
    else R.Right := R.Left + Sz;
    Windows.DrawEdge(Handle, R, BDR_RAISEDINNER, BF_RECT or BF_ADJUST);

    { Close button }
    if (CDBS_VISIBLE and CloseButtonState) <> 0 then
    begin
      CloseButtonDown := (CloseButtonState and CDBS_PRESSED) <> 0;
      CloseButtonHover := (CloseButtonState and CDBS_HOT) <> 0;
      R2 := R;
      Brush.Color := ToolbarColor;
      if IsVertical then
      begin
        R2.Left := R2.Right - Sz;
        R.Right := R2.Left;
        CaptionFill(R2);
        {InflateRect(R2, -1, -1);}
        Inc(R2.Left,2);
      end
      else
      begin
        R2.Top := R2.Bottom - Sz;
        R.Bottom := R2.Top;
        CaptionFill(R2);
        {InflateRect(R2, -1, -1);}
        Dec(R2.Bottom,2);
      end;

      Flags := TS_NORMAL;
      if CloseButtonDown then Flags := TS_PRESSED
      else if CloseButtonHover then Flags := TS_HOT;
      {DrawThemeBackground(TOOLBAR_THEME, DC, TP_BUTTON, Flags, R2, nil);
      if CloseButtonDown then OffsetRect(R2, 1, 1);
      InflateRect(R2, -2, -2);}

      yStart:= 0;
      yInc:= MDICLOSE.Height div 4;
//      y:=0;
      Case Flags of
        TS_NORMAL : y:=0;
        TS_PRESSED: y:=2;
        TS_HOT    : y:=1;
        Else        y:=3;
      End;//CASE
      biRect:= Rect(0,yStart+yInc*y,MDICLOSE.Width,yStart+yInc*(y+1));
      InflateRect(R2, (((biRect.Right-biRect.Left)-(R2.Right-R2.Left)) div 2), (((biRect.Bottom-biRect.Top)-(R2.Bottom-R2.Top)) div 2));
      OffsetRect(R2, 0, -1);
      //EnlargeBitmap(MDICLOSE, Canvas, biRect, R2, 8,8);
      DrawImage(MDICLOSE, Canvas, biRect, R2.Left, R2.Top);
//      DrawButtonBitmap(Canvas, R2);
    end;

    { Caption }
    CaptionFill(R);
    if IsVertical then InflateRect(R, -2, 0)
    else Inflaterect(R, 0, -2);
    Font.Assign(SmCaptionFont);
    Font.Color := clBtnText;
    Brush.Style := bsClear;
    Flags := DT_SINGLELINE or DT_VCENTER or DT_END_ELLIPSIS or DT_NOPREFIX;
    if IsVertical then DrawText(Canvas.Handle, Caption, -1, R, Flags)
    else DrawRotatedText(Canvas.Handle, string(Caption), R, Flags);
    Brush.Style := bsSolid;
  end;
end;

procedure TTBXMacOSXg32Theme.PaintDropDownArrow(Canvas: TCanvas;
  const ARect: TRect; const ItemInfo: TTBXItemInfo);
var
  X, Y: Integer;

  procedure Draw(AColor: TColor);
  begin
    Canvas.Pen.Color := AColor;
    Canvas.Brush.Color := AColor;
    if ItemInfo.IsVertical then Canvas.Polygon([Point(X, Y + 2), Point(X, Y - 2), Point(X - 2, Y)])
    else Canvas.Polygon([Point(X - 2, Y), Point(X + 2, Y), Point(X, Y + 2)]);
  end;

begin
  with ItemInfo, ARect do
  begin
    X := (Left + Right) div 2;
    Y := (Top + Bottom) div 2 - 1;

    if (Pushed or Selected) and (ComboPart <> cpSplitRight) then
    begin
      Inc(X); Inc(Y);
    end;

    if Enabled then
    begin
      {if Boolean(ItemOptions and IO_TOOLBARSTYLE) then Draw(clPopupText)
      else Draw(GetPartColor(ItemInfo, ipText));}
      Draw(GetPartColor(ItemInfo, ipText));
    end
    else
    begin
      //Inc(X); Inc(Y);
      Draw(GetPartColor(ItemInfo, ipText));//clBtnHighlight);
      {Dec(X); Dec(Y);
      Draw(GetPartColor(ItemInfo, ipText));//clBtnHighlight);}
    end;
  end;
end;

procedure TTBXMacOSXg32Theme.PaintEditButton(Canvas: TCanvas;
  const ARect: TRect; var ItemInfo: TTBXItemInfo;
  ButtonInfo: TTBXEditBtnInfo);
var
//  DC: HDC;
  BtnDisabled, BtnHot, BtnPressed, Embedded: Boolean;
//  StateFlags: Integer;
  R, BR, biRect: TRect;
//  C: TColor;
  X, Y, yInc: Integer;
begin
//  DC := Canvas.Handle;
  R := ARect;
  with Canvas, ItemInfo do
  begin
    Embedded := ((ViewType and VT_TOOLBAR) = VT_TOOLBAR) and
      ((ViewType and TVT_EMBEDDED) = TVT_EMBEDDED);

    if ButtonInfo.ButtonType = EBT_DROPDOWN then
    begin
      { DropDown button }
      BtnDisabled := (ButtonInfo.ButtonState and EBDS_DISABLED) <> 0;
      BtnHot := (ButtonInfo.ButtonState and EBDS_HOT) <> 0;
      BtnPressed := (ButtonInfo.ButtonState and EBDS_PRESSED) <> 0;

      // Combo BOX
      yInc:= SPINBUTTONBACKGROUNDRIGHT.Height div 4;
      if BtnDisabled then y:=3
      else if BtnPressed then y:=2
      else if BtnHot then y:=1
      else if Embedded then y:= 1
      else y:= 0;
      biRect:= Rect(0,yInc*y,SPINBUTTONBACKGROUNDRIGHT.Width,yInc*(y+1));

      if BtnHot or BtnPressed then InflateRect(R, -1, -1)
      else InflateRect(R, -2, -2);
      EnlargeBitmap(SPINBUTTONBACKGROUNDRIGHT, Canvas, biRect, R, 7, 5);
      PaintComboArrow(Canvas, R, ItemInfo);
    end
    else if ButtonInfo.ButtonType = EBT_SPIN then
    begin
      { Paint spin buttons }

⌨️ 快捷键说明

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