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

📄 wwcombobutton.pas

📁 InfoPower_Studio 2007 v5.0.1.3 banben
💻 PAS
📖 第 1 页 / 共 4 页
字号:
end;
{$endif}


function TwwComboButton.IsVistaComboNonEditable: boolean;
begin
   result:= false;
end;

function TwwComboButton.IsVistaTransparentButton: boolean;
begin
   result:= false;
end;

function TwwComboButton.ParentMouseInControl: boolean;
begin
  result:=false;
end;

function TwwComboButton.ParentDroppedDown: boolean;
begin
  result:=false;
end;
{
procedure InvalidateTransparentArea(control : TControl; Canvas: TCanvas);
var r: TRect;
   pc, oldpc: TControl;
   pt: TPoint;
   clearBackground: boolean;
begin
   with Control do  r:= Rect(Left, Top, Left+Width, Top+Height);
   r:= Control.ClientRect;
   pc:= control;
   if pc.parent=nil then exit;

   // If parent is not transparent then just return
//   if not fcIsTransparentParent(control) then exit;
   pc:= Control;
   While (pc.parent<>nil) do begin
     oldpc:= pc;
     pc:= pc.Parent;
     pt:= Point(0,0);
     // Don't invalidate area outside of control
     if Control.Left<0 then pt.x:= pt.x - Control.Left;
     if Control.Top<0 then pt.y:= pt.y - Control.Top;

     pt:= Control.ClientToScreen(pt);
     ScreenToClient(TWinControl(pc).handle, pt);
     r:= Rect(pt.X, pt.y, pt.x+Control.Width, pt.y+Control.Height);

     // Don't invalidate area outside of control
     if Control.Left<0 then r.Right:= r.Right - Control.Left;
     if Control.Top<0 then r.Top:= r.Top - Control.Top;


     ThemeServices.DrawParentBackground(TWinControl(pc).handle, Canvas.handle, nil, false);
     if (not wwIsTransparentParent(oldpc)) and not wwIsClass(pc.ClassType, 'TTabSheet') then exit;
   end;
end;

}
// Should likely support button style as well as combobutton
// 10/20/04 - If Assigned Glyph, then treat as ellipsis style background
procedure TwwComboButton.Paint;
const
  DownStyles: array[Boolean] of Integer = (BDR_RAISEDINNER, BDR_SUNKENOUTER);
  FillStyles: array[Boolean] of Integer = (BF_MIDDLE, 0);
  CP_DROPDOWNBUTTONRIGHT = 6;

//enum DROPDOWNBUTTONRIGHTSTATES fix alt0
 CBXSR_NORMAL = 1;
 CBXSR_HOT = 2;
 CBXSR_PRESSED = 3;
 CBXSR_DISABLED = 4;

var
  PaintRect, PaintClipRect: TRect;
  DrawFlags: Integer;
  Offset: TPoint;
  {$ifdef wwUseThemeManager}
  ComboBox: TThemedCombobox;
  Details: TThemedElementDetails;
  W, X, Y: Integer;
  R: TRect;
  Pressed: boolean;
  {$endif}
  haveClipRect: boolean;
begin
  haveClipRect:= false;

  if not Enabled then
  begin
    FState := bsDisabled;
    FDragging := False;
  end
  else if FState = bsDisabled then
    if FDown and (GroupIndex <> 0) then
      FState := bsExclusive
    else
      FState := bsUp;
  Canvas.Font := Self.Font;

  if wwUseThemes(self) then
  begin
    {$ifdef wwUseThemeManager}
    if IsVistaComboNonEditable then
       PerformEraseBackground(Self, Canvas.Handle);

    if Ellipsis or (not Glyph.Empty) then begin
       Pressed:= FState in [bsDown, bsExclusive];
       if Pressed then
          Details := ThemeServices.GetElementDetails(tbPushButtonPressed)
       else
          if MouseInControl or (ParentMouseInControl and IsVistaComboNonEditable) then
             Details := ThemeServices.GetElementDetails(tbPushButtonHot)
          else
             Details := ThemeServices.GetElementDetails(tbPushButtonNormal);
       PaintRect := ClientRect;

       ThemeServices.DrawElement(Canvas.Handle, Details, PaintRect);


       R:= PaintRect;
       X := R.Left + ((R.Right - R.Left) shr 1) - 1;
       Y := R.Top + ((R.Bottom - R.Top) shr 1) - 1;
       W := ClientWidth shr 3;
       if W = 0 then W := 1;
       if Glyph.Empty then
       begin
         PatBlt(Canvas.Handle, X, Y, W, W, BLACKNESS);
         PatBlt(Canvas.handle, X - (W * 2), Y, W, W, BLACKNESS);
         PatBlt(Canvas.Handle, X + (W * 2), Y, W, W, BLACKNESS);
       end
    end;

    ComboBox:= tcDropDownButtonNormal; // Make compiler happy

    if (not Ellipsis) or (not Glyph.Empty) then begin
       if not Enabled then // Not ellpisis
         ComboBox:= tcDropDownButtonDisabled
       else
         if (FState in [bsDown, bsExclusive]) or (ParentDroppedDown and IsVistaComboNonEditable) then
//         if (FState in [bsDown, bsExclusive]) or (ParentDroppedDown and IsVista) then
           ComboBox:= tcDropDownButtonPressed
         else
           if MouseInControl or (ParentMouseInControl and IsVistaComboNonEditable) then
//           if MouseInControl or (ParentMouseInControl and IsVista) then
             ComboBox:= tcDropDownButtonHot
           else
              ComboBox:= tcDropDownButtonNormal;
       PaintRect := ClientRect;
       PaintClipRect:= Rect(0, 0, 0, 0);

       if (parent.parent<>nil) and (parent.parent.parent<>nil) and
          not wwIsClass(parent.parent.parent.classtype, 'TCustomGrid') then
       begin
         PaintRect.Top:= PaintRect.Top-1;
         PaintRect.Bottom:= PaintRect.Bottom+1;
         PaintRect.Right:= PaintRect.Right+1;
         PaintRect.Left:= PaintRect.Left+1;
         if IsVista then // Themes in vista for combo buttons are offset differntly
            PaintRect.Left:= PaintRect.Left-2; // vista support
       end
       else begin  // parent of combo is grid
         PaintRect.Bottom:= PaintRect.Bottom+1;
         if IsVista then // Themes in vista for combo buttons are offset differntly
            PaintRect.Left:= PaintRect.Left-1; // vista support
       end;

       if Glyph.Empty then
       begin
         if wwUseThemes(self) and IsVista then
         begin
            InflateRect(PaintRect, 1, 1);
            PaintRect.Left:= PaintRect.Left+0;
            PaintRect.Right:= PaintRect.Right + 4;
            PaintClipRect:= PaintRect;

            if not IsVistaComboNonEditable then
            begin
              PaintClipRect.Left:= PaintClipRect.Left + 5;
              haveClipRect:= true;
            end;
         end;


         Details := ThemeServices.GetElementDetails(ComboBox);

         // 5/31/07 - Paint combo button using Vista dropdownbuttonright theme
         if IsVistaTransparentButton then
         begin
            Details.Part:= CP_DROPDOWNBUTTONRIGHT;
            InflateRect(PaintRect, 1, 1);
            if (not Enabled) then
               Details.State:= CBXSR_DISABLED
            else if (FState in [bsDown, bsExclusive]) then
            begin
               Details.State:= CBXSR_PRESSED
            end
            else if MouseInControl then
            begin
               Details.State:= CBXSR_HOT
            end
            else begin
               Details.State:= CBXSR_NORMAL;
            end;
         end;
//         ThemeServices.DrawParentBackground(Parent.Parent.Parent.Parent.Handle, Canvas.handle, nil, false);
//         ThemeServices.DrawParentBackground(Parent.Handle, Canvas.handle, nil, false);

//         InvalidateTransparentArea(Parent, Canvas);
         if haveClipRect then
            ThemeServices.DrawElement(Canvas.Handle, Details, PaintRect, @PaintClipRect)
         else
            ThemeServices.DrawElement(Canvas.Handle, Details, PaintRect)
       end;
    end;

    if not Glyph.Empty then
    begin
       PaintRect := ThemeServices.ContentRect(Canvas.Handle, Details, PaintRect);

       if ComboBox = tcDropDownButtonPressed then
       begin
         Offset := Point(0, 0);
       end
       else
         Offset := Point(0, 0);

       TwwComboButtonGlyph(FGlyph).Draw(Canvas, PaintRect, Offset, Caption, FLayout, FMargin, FSpacing, FState, Transparent,
         DrawTextBiDiModeFlags(0));
     end
    {$endif}
  end
  else
  begin
    PaintRect := Rect(0, 0, Width, Height);
    if not FFlat then
    begin
      DrawFlags := DFCS_BUTTONPUSH or DFCS_ADJUSTRECT;
      if FState in [bsDown, bsExclusive] then
        DrawFlags := DrawFlags or DFCS_PUSHED;
      DrawFrameControl(Canvas.Handle, PaintRect, DFC_BUTTON, DrawFlags);
    end
    else
    begin
      if (FState in [bsDown, bsExclusive]) or
        (FMouseInControl and (FState <> bsDisabled)) or
        (csDesigning in ComponentState) then
        DrawEdge(Canvas.Handle, PaintRect, DownStyles[FState in [bsDown, bsExclusive]],
          FillStyles[Transparent] or BF_RECT)
      else if not Transparent then
      begin
        Canvas.Brush.Color := Color;
        Canvas.FillRect(PaintRect);
      end;
      InflateRect(PaintRect, -1, -1);
    end;
    if FState in [bsDown, bsExclusive] then
    begin
      if (FState = bsExclusive) and (not FFlat or not FMouseInControl) then
      begin
        Canvas.Brush.Bitmap := AllocPatternBitmap(clBtnFace, clBtnHighlight);
        Canvas.FillRect(PaintRect);
      end;
      Offset.X := 1;
      Offset.Y := 1;
    end
    else
    begin
      Offset.X := 0;
      Offset.Y := 0;
    end;
    TwwComboButtonGlyph(FGlyph).Draw(Canvas, PaintRect, Offset, Caption, FLayout, FMargin,
      FSpacing, FState, Transparent, DrawTextBiDiModeFlags(0));
  end;
end;

procedure TwwSpinControlButton.Paint;
const
  DownStyles: array[Boolean] of Integer = (BDR_RAISEDINNER, BDR_SUNKENOUTER);
  FillStyles: array[Boolean] of Integer = (BF_MIDDLE, 0);
var
  PaintRect: TRect;
  DrawFlags: Integer;
  Offset: TPoint;
  {$ifdef wwUseThemeManager}
  ScrollBox: TThemedSpin;
  Details: TThemedElementDetails;
  {$endif}
begin
  if not Enabled then
  begin
    FState := bsDisabled;
    FDragging := False;
  end
  else if FState = bsDisabled then
    if FDown and (GroupIndex <> 0) then
      FState := bsExclusive
    else
      FState := bsUp;
  Canvas.Font := Self.Font;

  if wwUseThemes(self) then
  begin
    {$ifdef wwUseThemeManager}
    PerformEraseBackground(Self, Canvas.Handle);

    if ScrollDirection = wwsdUp then
    begin
       if not Enabled then
          Scrollbox:= tsUpDisabled
       else
         if FState in [bsDown, bsExclusive] then
           Scrollbox:= tsUpPressed
         else
           if MouseInControl then
             Scrollbox:= tsUpHot
           else
//              Scrollbox:= tsArrowBtnUpNormal;
              Scrollbox:= tsUpNormal;
    end
    else if ScrollDirection = wwsdDown then
    begin
       if not Enabled then
          Scrollbox:= tsDownDisabled
       else
         if FState in [bsDown, bsExclusive] then
           Scrollbox:= tsDownPressed
         else
           if MouseInControl then
             Scrollbox:= tsDownHot
           else
              Scrollbox:= tsDownNormal;
    end
    else Scrollbox:= tsUpNormal;

    PaintRect := ClientRect;

    if (parent.parent<>nil) and (parent.parent.parent<>nil) and
       not wwIsClass(parent.parent.parent.classtype, 'TCustomGrid') then
    begin
      if ScrollDirection = wwsdUp then
      begin
         PaintRect.Top:= PaintRect.Top-1;
         PaintRect.Bottom:= PaintRect.Bottom-1;
      end;
      PaintRect.Left:= PaintRect.Left - 1;
      PaintRect.Right:= PaintRect.Right + 2;
    end
    else begin  // parent of combo is grid
      if ScrollDirection = wwsdUp then
      begin
         PaintRect.Top:= PaintRect.Top-1;
         PaintRect.Bottom:= PaintRect.Bottom-1;
      end;
      if ScrollDirection = wwsdDown then
         PaintRect.Bottom:= PaintRect.Bottom+1;
      PaintRect.Left:= PaintRect.Left-1;
      PaintRect.Right:= PaintRect.Right+1;
//      PaintRect.Bottom:= PaintRect.Bottom+1;
    end;

    Details := ThemeServices.GetElementDetails(Scrollbox);
    ThemeServices.DrawElement(Canvas.Handle, Details, PaintRect);
    {$endif}
  end
  else
  begin
    PaintRect := Rect(0, 0, Width, Height);
    if not FFlat then
    begin
      DrawFlags := DFCS_BUTTONPUSH or DFCS_ADJUSTRECT;
      if FState in [bsDown, bsExclusive] then
        DrawFlags := DrawFlags or DFCS_PUSHED;
      DrawFrameControl(Canvas.Handle, PaintRect, DFC_BUTTON, DrawFlags);
    end
    else
    begin
      if (FState in [bsDown, bsExclusive]) or
        (FMouseInControl and (FState <> bsDisabled)) or
        (csDesigning in ComponentState) then
        DrawEdge(Canvas.Handle, PaintRect, DownStyles[FState in [bsDown, bsExclusive]],
          FillStyles[Transparent] or BF_RECT)
      else if not Transparent then
      begin
        Canvas.Brush.Color := Color;
        Canvas.FillRect(PaintRect);
      end;
      InflateRect(PaintRect, -1, -1);
    end;
    if FState in [bsDown, bsExclusive] then
    begin
      if (FState = bsExclusive) and (not FFlat or not FMouseInControl) then
      begin
        Canvas.Brush.Bitmap := AllocPatternBitmap(clBtnFace, clBtnHighlight);
        Canvas.FillRect(PaintRect);
      end;

⌨️ 快捷键说明

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