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

📄 sstyleedits.pas

📁 AlphaControls是一个Delphi标准控件的集合
💻 PAS
📖 第 1 页 / 共 4 页
字号:
        end;
      end;
    end;
  end;
  if s1 <> '' then Result := '(' + s1 + ') values (' + s2 + ')';
  List.Free;
end;

function GetUpdateText(Panel : TWinControl) : string;
var
  List : TList;
  i : integer;
  s : string;
  mStyle : TsStyle;
begin
  List := TList.Create;
  Panel.GetTabOrderList(List);
  if List.Count>0 then begin
    s := '';
    for i:=0 to List.Count-1 do begin
      if (GetStyleInfo(List[i]) = 5) then begin
        mStyle := TsStyle(GetsStyle(TWinControl(List[i])));
        if StyleIsActive(mStyle) and mStyle.Data.Allowing.Update and TControl(List[i]).Enabled then begin
          s := iff((s = ''), '', s + ', ');

          if Between(GetsStyle(List[i]).COC, COC_TsEdit, COC_TsMemo) then begin
            if TWinControl(List[i]) is TsMemo then
              s := s + mStyle.Data.Field.FieldName + '=' +
                   iff(TsMemo(List[i]).sStyle.Data.IsNumber, '0' + CorrectString(TsMemo(List[i]).Text), '''' + CorrectString(TsMemo(List[i]).Text) + '''')
            else
              s := s + mStyle.Data.Field.FieldName + '=' +
                   iff(TsEdit(List[i]).sStyle.Data.IsNumber, '0' + CorrectString(TsEdit(List[i]).Text), '''' + CorrectString(TsEdit(List[i]).Text) + '''');
          end else

          if Between(GetsStyle(List[i]).COC, COC_TsCustomComboBox, COC_TsBDEComboBox) then begin
            s := s + mStyle.Data.Field.FieldName + '=';
            if mStyle.Data.IsNumber then begin
              if TsCustomComboBox(List[i]).CharsInCode > 0 then begin
                s := s + IntToStr(TsCustomComboBox(List[i]).GetCurrentKod);
              end
              else if TsCustomComboBox(List[i]).UseItemIndex then begin
                s := s + IntToStr(TsCustomComboBox(List[i]).ItemIndex);
              end
              else begin
                s := s + '''' + CorrectString(TsCustomComboBox(List[i]).Text) + '''';
              end;
            end
            else begin
              s := s + '''' + CorrectString(TsCustomComboBox(List[i]).Text) + '''';
            end
          end else

          if Between(GetsStyle(List[i]).COC, COC_TsDateEdit, COC_TsDateEdit) then begin
            s := s + mStyle.Data.Field.FieldName + '=' +
                   iff(TsDateEdit(List[i]).Text='  .  .    ', 'NULL', '''' + TsDateEdit(List[i]).Text + '''');
          end else

          if Between(GetsStyle(List[i]).COC, COC_TsCheckedControl, COC_TsRadioButton) then begin
            s := s + mStyle.Data.Field.FieldName + '=' +
                   iff(TsCheckedControl(List[i]).Checked, '1', '0');
          end else

          if Between(GetsStyle(List[i]).COC, COC_TsCurrencyEdit, COC_TsCurrencyEdit) then begin
            s := s + mStyle.Data.Field.FieldName + '=' +
                   iff(TsCurrencyEdit(List[i]).sStyle.Data.IsNumber, '0' + FloatToStr(TsCurrencyEdit(List[i]).Value), '''' + TsCurrencyEdit(List[i]).Text + '''');
          end else

{          if Between(GetsStyle(List[i]).COC, COC_TsPanel, COC_TsCustomPanel) then begin
              s := s + mStyle.Data.Field.FieldName + '=' +
                   iff(TsCustomPanel(List[i]).sStyle.Data.IsNumber, '0' + CorrectString(TsCustomPanel(List[i]).Caption), '''' + CorrectString(TsCustomPanel(List[i]).Caption) + '''');
          end;}
        end;
      end;
    end;
  end;
  if s <> '' then Result := s;
  List.Free;
end;
{$ENDIF}

{ TsEditorBorder }

constructor TsEditorBorder.Create(AOwner: TPersistent);
begin
  FBevel := ebAsBottomBorder;
  FOwner := AOwner;
  FWidth := 2;
end;

procedure TsEditorBorder.SetWidth(const Value: integer);
begin
  if FWidth <> Value then begin
    FWidth := Value;
  end;
end;

{ TsEditorSelection }

constructor TsEditorSelection.Create(AOwner: TPersistent);
begin
  FOwner := AOwner;
  FMode := [msBorder, msColor];
  FBorder := TsEditorBorder.Create(Self);
  FColor := clWindow;
end;

destructor TsEditorSelection.destroy;
begin
  FreeAndNil(FBorder);
  inherited;
end;

{ TAllowing }

{$IFDEF USEDB}
constructor TsAllowing.Create(AOwner : TsStyle);
begin
  inherited Create;
  FOwner    := TsStyle(AOwner);
  FAutoInit := True;
  FInsert   := True;
  FUpdate   := True;
end;

procedure TsAllowing.SetInsert(const Value: boolean);
begin
  if Assigned(FOwner.Data.FField) then begin
    case FOwner.Data.FField.FieldKind of 
      fkData: begin
        if FInsert <> Value then FInsert := Value;
      end;
      fkCalculated, fkLookup: begin
        FInsert := False;
      end;
    end;
  end;
end;

procedure TsAllowing.SetUpdate(const Value: boolean);
begin
  if Assigned(FOwner.Data.FField) then begin
    case FOwner.Data.FField.FieldKind of
      fkData: begin
        if FUpdate <> Value then FUpdate := Value;
      end;
      fkCalculated, fkLookup: begin
        FUpdate := False;
      end;
    end;
  end;
end;
{$ENDIF}


procedure TsEditorSelection.SetColor(const Value: TColor);
begin
  FColor := Value;
end;

procedure TsEditorSelection.SetMode(const Value: TModeSelection);
begin
  if (FMode <> Value) then begin
    FMode := Value;
  end;
end;

{ TsEditorStyle }

constructor TsEditorStyle.Create(AOwner : TControl);
begin
  inherited Create(AOwner);

  FPainting := TsPainting.Create(Self);
  FSelection := TsEditorSelection.Create(Self);

  FBorderWidth := 2;
{$IFNDEF ALITE}
  sC := GetsEditorsManager(GetOwnerForm(AOwner), GroupIndex);
  if not Assigned(sC) then begin
    FGroupIndex := 0;
  end
  else begin
    Painting.ParentColor := False;
    FGroupIndex := sC.GroupIndex;

    Painting.FColor := sC.Painting.Color;
    Painting.FColorBorderTop := sC.Painting.ColorBorderTop;
    Painting.FColorBorderBottom := sC.Painting.ColorBorderBottom;

    Selection.FColor := sC.Selection.Color;

    Effects.Shadow.FEnabled := not Effects.Shadow.FDontUse and sC.Shadow.Enabled;
    Effects.Shadow.FColor := sC.Shadow.Color;
    Effects.Shadow.FBlur := sC.Shadow.Blur;
    Effects.Shadow.FOffset := sC.Shadow.Offset;
    Effects.Shadow.Transparency := sC.Shadow.Transparency;
  end;
{$ENDIF}
//  FEditEffects := TsEditEffects.Create(Self);
end;

destructor TsEditorStyle.Destroy;
begin
//  FreeAndNil(FEditEffects);
  FreeAndNil(FPainting);
  FreeAndNil(FSelection);
  inherited Destroy;
end;

function TsEditorStyle.GetActiveColor: TColor;
begin
  if ControlIsActive and (msColor in GetSelMode) then begin
    Result := ColorToRGB(Selection.FColor);
    if SkinIndex > -1 then begin
      Result := gd[SkinIndex].SelectionColor;
    end;
  end
  else begin
    Result := ColorToRGB(Painting.FColor);
    if SkinIndex > -1 then begin
      Result := gd[SkinIndex].PaintingColor;
    end;
  end;
end;

procedure TsEditorStyle.PaintBorder(DC : hWnd; aRect : TsRect);
var
  R: TRect;
  i, bw : integer;
  Color1, Color2, ct, cb : TColor;
  eb : TsEditorBevel;
  procedure DrawRect; begin
    DrawRectangleOnDC(DC, R, ColorToRGB(Color1), ColorToRGB(Color2), i);
  end;
begin
  if Painting.Bevel = ebNone then Exit;
  if IsValidSkinIndex(SkinIndex) then begin
    ct := ColorToRGB(gd[SkinIndex].PaintingColorBorderTop);
    cb := ColorToRGB(gd[SkinIndex].PaintingColorBorderBottom);
  end
  else begin
    ct := ColorToRGB(Painting.ColorBorderTop);
    cb := ColorToRGB(Painting.ColorBorderBottom);
  end;
  Color1 := ct;
  Color2 := cb;
  R := aRect;
  if ControlIsActive and (msBorder in Selection.Mode) then begin
    if SkinIndex > -1 then begin
      eb := gd[SkinIndex].SelectionBorderBevel;
      bw := gd[SkinIndex].SelectionBorderWidth;
    end
    else begin
      eb := Selection.Border.Bevel;
      bw := Selection.Border.Width;
    end;
    if (eb = ebNone) then Exit;
    BeveledBorder(DC, Color1,
                    Color2,
                    GetActiveColor, R,
                    bw,
                    eb, SoftControl);
    if (bw > 1) and (eb = ebLowered) then begin
      i := 1;
      Color1 := clBtnShadow;
      Color2 := clWhite;
      DrawRect;
      i := 1;
      Color1 := cl3DDkShadow;
      Color2 := cl3DLight;
      R := aRect;
      InflateRect(R, - 1, - 1);
      DrawRect;
    end;
  end
  else begin
    if SkinIndex > -1 then begin
      eb := aEditorBevels[ord(gd[SkinIndex].PaintingBevel)];
      bw := gd[SkinIndex].PaintingBevelWidth;
    end
    else begin
      eb := Painting.Bevel;
      bw := Painting.BevelWidth;
    end;
    BeveledBorder(dc, ct, cb, GetActiveColor, R, bw, eb, SoftControl);
  end;
end;

procedure TsEditorStyle.RedrawBorder;
var
  DC: HDC;
  R, aRect: TRect;
  width : integer;
  ActiveColor : TColor;
  Mode : integer;
begin
  ActiveColor := GetActiveColor;
  DC := GetWindowDC(TWinControl(FOwner).Handle);
  try
{$IFNDEF ALITE}
      if ((COC = COC_TsMemo) or (COC = COC_TsDBMemo)) then begin
        if (TsMemo(FOwner).ScrollBars = ssBoth) then begin
          if sSkinData.Active then begin
            R := Rect(FOwner.Width - 19, 3, FOwner.Width - 3, FOwner.Height - 3);
            Width := 9;
            DrawRectangleOnDC(DC, R, ActiveColor, ActiveColor, Width);
            R := Rect(3, FOwner.Height - 19, FOwner.Width - 19, FOwner.Height - 3);
            Width := 9;
            DrawRectangleOnDC(DC, R, ActiveColor, ActiveColor, Width);
          end
          else begin
            R := Rect(FOwner.Width - 19, FOwner.Height - 19, FOwner.Width - 3, FOwner.Height - 3);
            Width := 9;
            DrawRectangleOnDC(DC, R, ActiveColor, ActiveColor, Width);
          end;
        end
        else if (TsMemo(FOwner).ScrollBars = ssHorizontal) and sSkinData.Active then begin
          R := Rect(3, FOwner.Height - 19, FOwner.Width - 3, FOwner.Height - 3);
          Width := 9;
          DrawRectangleOnDC(DC, R, ActiveColor, ActiveColor, Width);
        end
        else if (TsMemo(FOwner).ScrollBars = ssVertical) and sSkinData.Active then begin
          R := Rect(FOwner.Width - 19, 3, FOwner.Width - 3, FOwner.Height - 3);
          Width := 9;
          DrawRectangleOnDC(DC, R, ActiveColor, ActiveColor, Width);
        end;
      end else
      if (COC = COC_TsCustomListBox) then begin
        if TsListBox(FOwner).VSBar <> nil then begin
          R := Rect(FOwner.Width - 19, 3, FOwner.Width - 3, FOwner.Height - 3);
          Width := 9;
          DrawRectangleOnDC(DC, R, ActiveColor, ActiveColor, Width);
        end;
      end;
{$ENDIF}


    width := BorderIndex;// GetMaskIndex(SkinIndex, SkinSection, BordersMask);
    if IsValidImgIndex(width) and (ma[Width].Bmp.Width > 0) then begin
      FCacheBmp.Width := FOwner.Width;
      FCacheBmp.Height := FOwner.Height;
      FCacheBmp.PixelFormat := pf24bit;
      FCacheBmp.Canvas.Brush.Color := ActiveColor;
      FCacheBmp.Canvas.FillRect(Rect(0, 0, FOwner.Width, FOwner.Height));

      if FFocused then begin
        Mode := 2;
      end
      else if ControlIsActive then begin
        Mode := 1;
      end
      else begin
        Mode := 0;
      end;

//      if RegionChanged then begin
        FRegion := 0;
        FRegion := CreateRectRgn(0,
                                0,
                                FOwner.Width,
                                FOwner.Height);
//      end;

      PaintRasterBorder(FCacheBmp, ma[Width].Bmp, Mode, FRegion, ma[Width].TransparentColor, False);

      BitBlt(DC, 0, 0, FOwner.Width, 3, FCacheBmp.Canvas.Handle, 0, 0, SRCCOPY);
      BitBlt(DC, 0, 3, 3, FOwner.Height, FCacheBmp.Canvas.Handle, 0, 3, SRCCOPY);
      BitBlt(DC, 3, FOwner.Height - 3, FOwner.Width, FOwner.Height, FCacheBmp.Canvas.Handle, 3, FOwner.Height - 3, SRCCOPY);
      BitBlt(DC, FOwner.Width - 3, 3, FOwner.Width, FOwner.Height - 3, FCacheBmp.Canvas.Handle, FOwner.Width - 3, 3, SRCCOPY);

//      if RegionChanged then begin
        SetWindowRgn(TWinControl(FOwner).Handle, FRegion, True);
        RegionChanged := False;
//      end;

    end
    else begin

    try
      aRect := Rect(0, 0, FOwner.Width, FOwner.Height);
      R := aRect;
      width := 3;
      DrawRectangleOnDC(DC, R, ActiveColor, ActiveColor, Width);

      PaintBorder(DC, aRect);
      except
//        ;
      end;

    end;

  finally
    ReleaseDC(TWinControl(FOwner).Handle, DC);
  end;
end;

{
procedure TsEditorStyle.RedrawBorder(DC: longint);

⌨️ 快捷键说明

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