Ignore:
Timestamp:
Jan 14, 2017, 10:33:42 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: Implemented platform independent scrollbars usage. Tested on Linux.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Term.pas

    r67 r69  
    2222
    2323type
     24
     25  { TMainScreen }
     26
    2427  TMainScreen = class(TDrawDlg)
    2528    Timer1: TTimer;
     
    216219    procedure BareBtnDownChanged(Sender: TObject);
    217220    procedure MovieSpeedBtnClick(Sender: TObject);
    218 
    219   public
    220     procedure CreateParams(var p: TCreateParams); override;
    221     procedure Client(Command, NewPlayer: integer; var Data);
    222     procedure SetAIName(p: integer; Name: string);
    223     function ZoomToCity(Loc: integer; NextUnitOnClose: boolean = false;
    224       ShowEvent: integer = 0): boolean;
    225     procedure CityClosed(Activateuix: integer; StepFocus: boolean = false;
    226       SelectFocus: boolean = false);
    227     function DipCall(Command: integer): integer;
    228     function OfferCall(var Offer: TOffer): integer;
    229     procedure UpdateViews(UpdateCityScreen: boolean = false);
    230     function ContactRefused(p: integer; Item: String): boolean;
    231 
    232221  private
    233222    xw, yw, xwd, ywd, xwMini, ywMini, xMidPanel, xRightPanel, xTroop, xTerrain,
     
    242231    Closable, RepaintOnResize, Tracking, TurnComplete, Edited, GoOnPhase,
    243232      HaveStrategyAdvice, FirstMovieTurn: boolean;
     233    procedure ScrollBarUpdate(Sender: TObject);
    244234    procedure ArrangeMidPanel;
    245235    procedure MainOffscreenPaint;
     
    282272    procedure OnScroll(var m: TMessage); message WM_VSCROLL;
    283273    procedure OnEOT(var Msg: TMessage); message WM_EOT;
     274  public
     275    procedure CreateParams(var p: TCreateParams); override;
     276    procedure Client(Command, NewPlayer: integer; var Data);
     277    procedure SetAIName(p: integer; Name: string);
     278    function ZoomToCity(Loc: integer; NextUnitOnClose: boolean = false;
     279      ShowEvent: integer = 0): boolean;
     280    procedure CityClosed(Activateuix: integer; StepFocus: boolean = false;
     281      SelectFocus: boolean = false);
     282    function DipCall(Command: integer): integer;
     283    function OfferCall(var Offer: TOffer): integer;
     284    procedure UpdateViews(UpdateCityScreen: boolean = false);
     285    function ContactRefused(p: integer; Item: String): boolean;
    284286  end;
    285287
     
    14731475    StayOnTop_Ensured := false;
    14741476
    1475     CreatePVSB(sb, Handle, 100 - 200, 122, 100 + MidPanelHeight - 16 - 200);
     1477    sb.Setup(0, 0, 0, Self);
     1478    sb.OnUpdate := ScrollBarUpdate;
    14761479  end; { InitModule }
    14771480
     
    26562659          if Controls[i] is TButtonC then
    26572660            Controls[i].Visible := false;
    2658         InitPVSB(sb, 0, 1);
     2661        sb.Init(0, 1);
    26592662        for p1 := 0 to nPl - 1 do
    26602663          if Tribe[p1] <> nil then
     
    35773580  EOT.Top := ClientHeight - 64;
    35783581  EOT.Left := ClientWidth - 62;
    3579   SetWindowPos(sb.h, 0, xRightPanel + 10 - 14 - GetSystemMetrics(SM_CXVSCROLL),
     3582  sb.ScrollBar.BorderSpacing.Top := ClientHeight - yTroop - 24;
     3583  sb.ScrollBar.BorderSpacing.Right := ClientWidth - xRightPanel + 8;
     3584  sb.ScrollBar.BorderSpacing.Bottom := 8;
     3585  SetWindowPos(sb.ScrollBar.Handle, 0, xRightPanel + 10 - 14 - GetSystemMetrics(SM_CXVSCROLL),
    35803586    ClientHeight - MidPanelHeight + 8, 0, 0, SWP_NOSIZE or SWP_NOZORDER);
    35813587  MapBtn0.Left := xMini + G.lx - 44;
     
    36153621procedure TMainScreen.OnScroll(var m: TMessage);
    36163622begin
    3617   if ProcessPVSB(sb, m) then
    3618   begin
     3623  if sb.Process(m) then begin
    36193624    PanelPaint;
    3620     Update
    3621   end
     3625    Update;
     3626  end;
    36223627end;
    36233628
     
    39623967end;
    39633968
    3964 procedure TMainScreen.PaintLocTemp(Loc, Style: integer);
     3969procedure TMainScreen.PaintLocTemp(Loc: integer; Style: integer);
    39653970var
    39663971  y0, x0, xMap, yMap: integer;
     
    63416346      Server(sGetUnits, me, Loc, TrCnt);
    63426347  if TrCnt = 0 then
    6343     InitPVSB(sb, 0, 1)
     6348    sb.Init(0, 1)
    63446349  else
    63456350  begin
    6346     InitPVSB(sb, (TrCnt + TrRow - 1) div TrRow - 1, 1);
     6351    sb.Init((TrCnt + TrRow - 1) div TrRow - 1, 1);
    63476352    with sb.si do
    63486353      if (nMax >= integer(nPage)) and (trixFocus >= 0) then
     
    63506355        sb.si.npos := trixFocus div TrRow;
    63516356        sb.si.FMask := SIF_POS;
    6352         SetScrollInfo(sb.h, SB_CTL, sb.si, true);
     6357        SetScrollInfo(sb.ScrollBar.Handle, SB_CTL, sb.si, true);
    63536358      end
    63546359  end
     
    80058010end;
    80068011
     8012procedure TMainScreen.ScrollBarUpdate(Sender: TObject);
     8013begin
     8014  PanelPaint;
     8015  Update;
     8016end;
     8017
    80078018initialization
    80088019
Note: See TracChangeset for help on using the changeset viewer.