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/Select.pas

    r50 r69  
    1818    kChooseETech, kChooseModel, kChooseEModel, kChooseCity, kChooseECity,
    1919    kStealTech, kGov, kMission);
     20
     21  { TListDlg }
    2022
    2123  TListDlg = class(TFramedDlg)
     
    2628    ToggleBtn: TButtonB;
    2729    Popup: TPopupMenu;
     30    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
     31      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    2832    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    2933      x, y: integer);
     
    4044    procedure PlayerClick(Sender: TObject);
    4145    procedure FormDestroy(Sender: TObject);
    42 
     46  private
     47    Kind: TListKind;
     48    LineDistance, MaxLines, cixProject, pView, Sel, DispLines, Layer, nColumn,
     49      TechNameSpace, ScienceNation: integer;
     50    sb: TPVScrollbar;
     51    Lines, FirstShrinkedLine: array [0 .. MaxLayer - 1] of integer;
     52    code: array [0 .. MaxLayer - 1, 0 .. 4095] of integer;
     53    Column: array [0 .. nPl - 1] of integer;
     54    Closable, MultiPage: boolean;
     55    ScienceNationDot: TBitmap;
     56    procedure ScrollBarUpdate(Sender: TObject);
     57    procedure InitLines;
     58    procedure line(ca: TCanvas; l: integer; NonText, lit: boolean);
     59    function RenameCity(cix: integer): boolean;
     60    function RenameModel(mix: integer): boolean;
     61    procedure OnScroll(var m: TMessage); message WM_VSCROLL;
     62    procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
    4363  public
    4464    result: integer;
     
    5373    procedure AddCity;
    5474    procedure RemoveUnit;
    55 
    56   private
    57     Kind: TListKind;
    58     LineDistance, MaxLines, cixProject, pView, Sel, DispLines, Layer, nColumn,
    59       TechNameSpace, ScienceNation: integer;
    60     sb: TPVScrollbar;
    61     Lines, FirstShrinkedLine: array [0 .. MaxLayer - 1] of integer;
    62     code: array [0 .. MaxLayer - 1, 0 .. 4095] of integer;
    63     Column: array [0 .. nPl - 1] of integer;
    64     Closable, MultiPage: boolean;
    65     ScienceNationDot: TBitmap;
    66     procedure InitLines;
    67     procedure line(ca: TCanvas; l: integer; NonText, lit: boolean);
    68     function RenameCity(cix: integer): boolean;
    69     function RenameModel(mix: integer): boolean;
    70     procedure OnScroll(var m: TMessage); message WM_VSCROLL;
    71     procedure OnMouseWheel(var m: TMessage); message LM_MOUSEWHEEL;
    72     procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
    7375  end;
    7476
     
    101103  Canvas.Font.Assign(UniFont[ftNormal]);
    102104  sb := TPVScrollbar.Create;
    103   CreatePVSB(sb, Handle, 2, 361, 2 + 422);
     105  sb.Setup(36, 10, 36, Self);
     106  sb.OnUpdate := ScrollBarUpdate;
    104107  InitButtons();
    105108  Kind := kMission;
     
    132135procedure TListDlg.OnScroll(var m: TMessage);
    133136begin
    134   if ProcessPVSB(sb, m) then
    135   begin
     137  if sb.Process(m) then  begin
    136138    Sel := -2;
    137139    SmartUpdateContent(true);
    138   end;
    139 end;
    140 
    141 procedure TListDlg.OnMouseWheel(var m: TMessage);
    142 begin
    143   if ProcessMouseWheel(sb, m) then
    144   begin
    145     Sel := -2;
    146     SmartUpdateContent(true);
    147     PaintBox1MouseMove(nil, [], m.lParam and $FFFF - Left,
    148       m.lParam shr 16 - Top);
    149140  end;
    150141end;
     
    834825end;
    835826
     827procedure TListDlg.FormMouseWheel(Sender: TObject; Shift: TShiftState;
     828  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
     829begin
     830  if sb.ProcessMouseWheel(WheelDelta) then begin
     831    PaintBox1MouseMove(nil, [], MousePos.X - Left,
     832      MousePos.Y - Top);
     833  end;
     834end;
     835
    836836function TListDlg.RenameCity(cix: integer): boolean;
    837837var
     
    15991599  CaptionLeft := ToggleBtn.Left + ToggleBtn.Width;
    16001600  CaptionRight := CloseBtn.Left;
    1601   SetWindowPos(sb.h, 0, SideFrame + InnerWidth - GetSystemMetrics(SM_CXVSCROLL),
     1601  SetWindowPos(sb.ScrollBar.Handle, 0, SideFrame + InnerWidth - GetSystemMetrics(SM_CXVSCROLL),
    16021602    TitleHeight, GetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48,
    16031603    SWP_NOZORDER or SWP_NOREDRAW);
     
    16331633  Sel := -2;
    16341634  ScienceNation := -1;
    1635   InitPVSB(sb, Lines[Layer] - 1, DispLines);
     1635  sb.Init(Lines[Layer] - 1, DispLines);
    16361636
    16371637  OffscreenPaint;
     
    17491749  InitLines;
    17501750  Sel := -2;
    1751   InitPVSB(sb, Lines[Layer] - 1, DispLines);
     1751  sb.Init(Lines[Layer] - 1, DispLines);
    17521752  OffscreenPaint;
    17531753  Invalidate
     
    17621762
    17631763  Sel := -2;
    1764   InitPVSB(sb, Lines[Layer] - 1, DispLines);
     1764  sb.Init(Lines[Layer] - 1, DispLines);
    17651765  SmartUpdateContent
    17661766end;
     
    18631863end;
    18641864
     1865procedure TListDlg.ScrollBarUpdate(Sender: TObject);
     1866begin
     1867  Sel := -2;
     1868  SmartUpdateContent(true);
     1869end;
     1870
    18651871end.
Note: See TracChangeset for help on using the changeset viewer.