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

📄 sdbnavigator.pas

📁 alpha db da sa pouzit na vsetky druhy coho len chcete
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    Inc(J);
  end;
end;

procedure TsDBNavigator.KeyDown(var Key: Word; Shift: TShiftState);
var
  NewFocus: TNavigateBtn;
  OldFocus: TNavigateBtn;
begin
  OldFocus := FocusedButton;
  case Key of
    VK_RIGHT:
      begin
        NewFocus := FocusedButton;
        repeat
          if NewFocus < High(Buttons) then
            NewFocus := Succ(NewFocus);
        until (NewFocus = High(Buttons)) or (Buttons[NewFocus].Visible);
        if NewFocus <> FocusedButton then
        begin
          FocusedButton := NewFocus;
          Buttons[OldFocus].Invalidate;
          Buttons[FocusedButton].Invalidate;
        end;
      end;
    VK_LEFT:
      begin
        NewFocus := FocusedButton;
        repeat
          if NewFocus > Low(Buttons) then
            NewFocus := Pred(NewFocus);
        until (NewFocus = Low(Buttons)) or (Buttons[NewFocus].Visible);
        if NewFocus <> FocusedButton then
        begin
          FocusedButton := NewFocus;
          Buttons[OldFocus].Invalidate;
          Buttons[FocusedButton].Invalidate;
        end;
      end;
    VK_SPACE:
      begin
        if Buttons[FocusedButton].Enabled then
          Buttons[FocusedButton].Click;
      end;
  end;
end;

procedure TsDBNavigator.Loaded;
var
  W, H, n: Integer;
  I: TNavigateBtn;
begin
  inherited Loaded;
  n := 0;
    for I := Low(Buttons) to High(Buttons) do begin
      if Assigned(Images) then Buttons[I].ImageIndex := FFirstImageIndex + n;
      Buttons[I].SkinData.SkinManager := SkinData.SkinManager;

      inc(n);
    end;
  W := Width;
  H := Height;
  SetSize(W, H);
  InitHints;
  ActiveChanged;
end;

function TsDBNavigator.MarginWidth: integer;
begin
  Result := integer(BorderStyle = bsSingle) * (1 + 3 * integer(Ctl3d)) + BorderWidth +
            integer(BevelOuter <> bvNone) * BevelWidth +
            integer(BevelInner <> bvNone) * BevelWidth;
end;

procedure TsDBNavigator.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) then begin
    if (FDataLink <> nil) and (AComponent = DataSource) then DataSource := nil
    else if AComponent = Images then Images := nil;
  end;
end;

procedure TsDBNavigator.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
  W, H: Integer;
begin
  W := AWidth;
  H := AHeight;
  if not HandleAllocated then begin
    SetSize(W, H);
  end;
  inherited SetBounds(ALeft, ATop, aWidth, aHeight);
end;

procedure TsDBNavigator.SetDataSource(Value: TDataSource);
begin
  FDataLink.DataSource := Value;
  if not (csLoading in ComponentState) then
    ActiveChanged;
  if Value <> nil then Value.FreeNotification(Self);
end;

procedure TsDBNavigator.SetFirstImageIndex(const Value: integer);
var
  I: TNavigateBtn;
  Index : integer;
begin
  if FFirstImageIndex <> Value then begin
    FFirstImageIndex := Value;
    Index := Value;
    for I := Low(Buttons) to High(Buttons) do begin
      Buttons[I].ImageIndex := Index;
      Inc(Index);
    end;
  end;
end;

procedure TsDBNavigator.SetHints(Value: TStrings);
begin
  if Value.Text = FDefHints.Text then
    FHints.Clear else
    FHints.Assign(Value);
end;

procedure TsDBNavigator.SetImages(const Value: TCustomImageList);
var
  I: TNavigateBtn;
begin
  if FImages <> Value then begin
    FImages := Value;
    for I := Low(Buttons) to High(Buttons) do begin
      Buttons[I].Images := Value;
      if Value <> nil then begin
        Buttons[I].Glyph.Assign(nil);
        Buttons[I].NumGlyphs := 1;
      end
      else begin
        LoadGlyph(Buttons[I], BtnTypeName[I]);
      end;
    end;
  end;
end;

procedure TsDBNavigator.SetNumGlyphs(const Value: integer);
var
  I: TNavigateBtn;
begin
  if FNumGlyphs <> Value then begin
    FNumGlyphs := Value;//max(1, Value);
    for I := Low(Buttons) to High(Buttons) do begin
      Buttons[I].NumGlyphs := Value;
    end;
  end;
end;

procedure TsDBNavigator.SetSize(var W, H: Integer);
var
  I: TNavigateBtn;
  Space, Temp, Remain: Integer;
  X: Integer;
begin
  if (csLoading in ComponentState) or (Parent = nil) then Exit;
  if Buttons[nbFirst] = nil then Exit;

  Temp := ButtonsCount * ButtonWidth;
  if Align = alNone then W := Temp + 2 * MarginWidth;

  X := MarginWidth;
  Remain := Width - 2 * MarginWidth - Temp;
  Temp := ButtonsCount div 2;
  for I := Low(Buttons) to High(Buttons) do begin
    if Buttons[I].Visible then begin
      Space := 0;
      if Remain <> 0 then begin
        Dec(Temp, Remain);
        if Temp < 0 then begin
          Inc(Temp, ButtonsCount);
          Space := 1;
        end;
      end;
      Buttons[I].SetBounds(X, MarginWidth, ButtonWidth + Space, Height - 2 * MarginWidth - 1);
      Inc(X, ButtonWidth + Space);
    end
    else
      Buttons[I].SetBounds(Width + 1, MarginWidth, ButtonWidth, Height - 2 * MarginWidth - 1);
  end;
end;

procedure TsDBNavigator.SetVisible(Value: TButtonSet);
var
  I: TNavigateBtn;
  W, H: Integer;
begin
  W := Width;
  H := Height;
  FVisibleButtons := Value;
  for I := Low(Buttons) to High(Buttons) do Buttons[I].Visible := I in FVisibleButtons;
  SetSize(W, H);
  Invalidate;
end;

procedure TsDBNavigator.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
  Message.Result := DLGC_WANTARROWS;
end;

procedure TsDBNavigator.WMKillFocus(var Message: TWMKillFocus);
begin
  Buttons[FocusedButton].Invalidate;
end;

procedure TsDBNavigator.WMSetFocus(var Message: TWMSetFocus);
begin
  Buttons[FocusedButton].Invalidate;
end;

procedure TsDBNavigator.WMSize(var Message: TWMSize);
var
  W, H: Integer;
begin
  inherited;
  W := Width;
  H := Height;
  SetSize(W, H);
//  if csDesigning in ComponentState then SkinData.Invalidate;
end;

procedure TsDBNavigator.WMWindowPosChanging(var Message: TWMWindowPosChanging);
begin
  inherited;
  if (SWP_NOSIZE and Message.WindowPos.Flags) = 0 then
    CalcMinSize(Message.WindowPos.cx, Message.WindowPos.cy);
end;

procedure TsDBNavigator.WndProc(var Message: TMessage);
var
  i : TNavigateBtn;
begin
  inherited;
  if Message.Msg = SM_ALPHACMD then case Message.WParamHi of
    AC_SETNEWSKIN, AC_REFRESH, AC_REMOVESKIN : for i := Low(Buttons) to High(Buttons) do begin
      Buttons[i].Perform(Message.Msg, Message.WParam, Message.LParam);
    end;
  end;
end;

{ TsNavButton }

constructor TsNavButton.Create(AOwner: TComponent);
begin
  inherited;
  ShowCaption := False;
  SkinData.SkinManager := TsPanel(AOwner).SkinData.FSkinManager;
  SkinData.SkinSection := s_TOOLBUTTON;
  Self.DisabledGlyphKind := Self.DisabledGlyphKind + [dgBlended];
  Self.DisabledKind := Self.DisabledKind + [dkBlended];
end;

destructor TsNavButton.Destroy;
begin
  if FRepeatTimer <> nil then FRepeatTimer.Free;
  inherited Destroy;
end;

procedure TsNavButton.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Integer);
begin
  inherited MouseDown (Button, Shift, X, Y);
  if nsAllowTimer in FNavStyle then begin
    if FRepeatTimer = nil then FRepeatTimer := TTimer.Create(Self);

    FRepeatTimer.OnTimer := TimerExpired;
    FRepeatTimer.Interval := InitRepeatPause;
    FRepeatTimer.Enabled  := True;
  end;
end;

procedure TsNavButton.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  inherited MouseUp (Button, Shift, X, Y);
  if FRepeatTimer <> nil then FRepeatTimer.Enabled  := False;
end;

procedure TsNavButton.Paint;
begin
  if (csDestroying in ComponentState) or (csLoading in ComponentState) then Exit;
  if (GetFocus = Parent.Handle) and (FIndex = TsDBNavigator (Parent).FocusedButton) then SkinData.FFocused := True;
  inherited Paint;
  SkinData.FFocused := False;
end;

procedure TsNavButton.TimerExpired(Sender: TObject);
begin
  FRepeatTimer.Interval := RepeatPause;
  if Down and MouseCapture then begin
    try
      Click;
    except
      FRepeatTimer.Enabled := False;
      raise;
    end;
  end;
end;

{ TsNavDataLink }

procedure TsNavDataLink.ActiveChanged;
begin
  if FNavigator <> nil then FNavigator.ActiveChanged;
end;

constructor TsNavDataLink.Create(ANav: TsDBNavigator);
begin
  inherited Create;
  FNavigator := ANav;
  VisualControl := True;
end;

procedure TsNavDataLink.DataSetChanged;
begin
  if FNavigator <> nil then FNavigator.DataChanged;
end;

destructor TsNavDataLink.Destroy;
begin
  FNavigator := nil;
  inherited Destroy;
end;

procedure TsNavDataLink.EditingChanged;
begin
  if FNavigator <> nil then FNavigator.EditingChanged;
end;

initialization
  SDBN_FIRST := TBitmap.Create; SDBN_FIRST.LoadFromResourceName(hInstance, 'SDBN_FIRST');
  SDBN_PRIOR := TBitmap.Create; SDBN_PRIOR.LoadFromResourceName(hInstance, 'SDBN_PRIOR');
  SDBN_NEXT := TBitmap.Create; SDBN_NEXT.LoadFromResourceName(hInstance, 'SDBN_NEXT');
  SDBN_LAST := TBitmap.Create; SDBN_LAST.LoadFromResourceName(hInstance, 'SDBN_LAST');
  SDBN_INSERT := TBitmap.Create; SDBN_INSERT.LoadFromResourceName(hInstance, 'SDBN_INSERT');
  SDBN_DELETE := TBitmap.Create; SDBN_DELETE.LoadFromResourceName(hInstance, 'SDBN_DELETE');
  SDBN_EDIT := TBitmap.Create; SDBN_EDIT.LoadFromResourceName(hInstance, 'SDBN_EDIT');
  SDBN_POST := TBitmap.Create; SDBN_POST.LoadFromResourceName(hInstance, 'SDBN_POST');
  SDBN_CANCEL := TBitmap.Create; SDBN_CANCEL.LoadFromResourceName(hInstance, 'SDBN_CANCEL');
  SDBN_REFRESH := TBitmap.Create; SDBN_REFRESH.LoadFromResourceName(hInstance, 'SDBN_REFRESH');

finalization
  FreeAndNil(SDBN_FIRST );
  FreeAndNil(SDBN_PRIOR );
  FreeAndNil(SDBN_NEXT  );
  FreeAndNil(SDBN_LAST  );
  FreeAndNil(SDBN_INSERT);
  FreeAndNil(SDBN_DELETE);
  FreeAndNil(SDBN_EDIT  );
  FreeAndNil(SDBN_POST  );
  FreeAndNil(SDBN_CANCEL);
  FreeAndNil(SDBN_REFRESH);
end.










⌨️ 快捷键说明

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