Changeset 90 for trunk/LocalPlayer


Ignore:
Timestamp:
Jan 19, 2017, 9:04:16 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: To work scrollbar correctly again on Linux where Max behaves differently when on Windows.
Location:
trunk/LocalPlayer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/PVSB.pas

    r89 r90  
    1919    FOnUpdate: TNotifyEvent;
    2020    ScrollBar: TScrollBar;
     21    FMax: Integer;
    2122    function GetMax: Integer;
    2223    function GetPageSize: Integer;
     
    2930    constructor Create(Parent: TWinControl);
    3031    destructor Destroy; override;
    31     procedure Init(Max, Page: Integer);
     32    procedure Init(Max, PageSize: Integer);
    3233    procedure SetPos(Pos: Integer);
    3334    function Process(const m: TMessage): boolean;
     
    4849  Count: Integer = 0;
    4950
    50 procedure TPVScrollBar.Init(Max, Page: Integer);
     51procedure TPVScrollBar.Init(Max, PageSize: Integer);
    5152begin
     53  ScrollBar.PageSize := PageSize;
    5254  ScrollBar.Min := 0;
    53   ScrollBar.Max := Max;
    54   ScrollBar.PageSize := Page;
     55  Self.Max := Max;
    5556  ScrollBar.Position := 0;
    56   ScrollBar.Visible := ScrollBar.Max >= ScrollBar.PageSize;
     57  ScrollBar.Visible := Max >= ScrollBar.PageSize;
    5758end;
    5859
     
    6869  NewPos: integer;
    6970begin
    70     if ScrollBar.Max < ScrollBar.PageSize then
     71    if Max < ScrollBar.PageSize then
    7172      result := false
    7273    else
     
    9192        if NewPos < 0 then
    9293          NewPos := 0;
    93         if NewPos > ScrollBar.Max - ScrollBar.PageSize + 1 then
    94           NewPos := ScrollBar.Max - ScrollBar.PageSize + 1;
     94        if NewPos > Max - ScrollBar.PageSize + 1 then
     95          NewPos := Max - ScrollBar.PageSize + 1;
    9596        result := NewPos <> ScrollBar.Position;
    9697        if (NewPos <> ScrollBar.Position) or ((m.wParam and $ffff) = SB_ENDSCROLL) then
     
    106107  NewPos: integer;
    107108begin
    108     if ScrollBar.Max < ScrollBar.PageSize then Result := False
     109    if Max < ScrollBar.PageSize then Result := False
    109110    else begin
    110111      NewPos := ScrollBar.Position - Delta div 300;
    111112      if NewPos < 0 then NewPos := 0;
    112       if NewPos > ScrollBar.Max - ScrollBar.PageSize + 1 then
    113         NewPos := ScrollBar.Max - ScrollBar.PageSize + 1;
     113      if NewPos > Max - ScrollBar.PageSize + 1 then
     114        NewPos := Max - ScrollBar.PageSize + 1;
    114115      Result := NewPos <> ScrollBar.Position;
    115116      if NewPos <> ScrollBar.Position then begin
     
    121122procedure TPVScrollBar.Show(Visible: boolean);
    122123begin
    123   if not Visible or (ScrollBar.Max < ScrollBar.PageSize) then
     124  if not Visible or (Max < ScrollBar.PageSize) then
    124125    ScrollBar.Visible := False
    125126    else ScrollBar.Visible := True;
     
    128129procedure TPVScrollBar.EndSB;
    129130begin
    130   if ScrollBar.Max < ScrollBar.PageSize then
     131  if Max < ScrollBar.PageSize then
    131132    ScrollBar.Position := 0 // hidden
    132133  else begin
    133     ScrollBar.Position := ScrollBar.Max - ScrollBar.PageSize + 1;
     134    ScrollBar.Position := Max - ScrollBar.PageSize + 1;
    134135  end;
    135136end;
     
    151152procedure TPVScrollBar.SetMax(AValue: Integer);
    152153begin
    153   ScrollBar.Max := AValue;
     154  FMax := AValue;
     155  ScrollBar.Max := Max{$IFDEF LINUX} - PageSize + 1{$ENDIF};
    154156end;
    155157
     
    166168function TPVScrollBar.GetMax: Integer;
    167169begin
    168   Result := ScrollBar.Max;
     170  Result := FMax;
    169171end;
    170172
  • trunk/LocalPlayer/Term.lfm

    r66 r90  
    2525  OnMouseMove = FormMouseMove
    2626  OnMouseUp = FormMouseUp
     27  OnMouseWheel = FormMouseWheel
    2728  OnPaint = FormPaint
    2829  OnResize = FormResize
    2930  OnShow = FormShow
    3031  Position = poDefault
    31   LCLVersion = '1.6.2.0'
     32  LCLVersion = '1.6.0.4'
    3233  WindowState = wsMaximized
    3334  object UnitBtn: TButtonB
  • trunk/LocalPlayer/Term.pas

    r89 r90  
    1313  Protocol, Tribes, PVSB, ClientTools, ScreenTools, BaseWin, Messg, ButtonBase,
    1414  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls,
    15   Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area;
     15  Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area, Types;
    1616
    1717const
     
    173173    procedure FormCreate(Sender: TObject);
    174174    procedure FormDestroy(Sender: TObject);
     175    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
     176      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    175177    procedure Timer1Timer(Sender: TObject);
    176178    procedure MapBoxMouseDown(Sender: TObject; Button: TMouseButton;
     
    35173519    if AILogo[i] <> nil then
    35183520      FreeAndNil(AILogo[i]);
     3521end;
     3522
     3523procedure TMainScreen.FormMouseWheel(Sender: TObject; Shift: TShiftState;
     3524  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
     3525begin
     3526  if sb.ProcessMouseWheel(WheelDelta) then begin
     3527    PanelPaint;
     3528    Update;
     3529  end;
    35193530end;
    35203531
Note: See TracChangeset for help on using the changeset viewer.