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

    r68 r69  
    4747  end;
    4848
     49  { THelpDlg }
     50
    4951  THelpDlg = class(TFramedDlg)
    5052    CloseBtn: TButtonB;
     
    5456    procedure FormCreate(Sender: TObject);
    5557    procedure FormDestroy(Sender: TObject);
     58    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
     59      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    5660    procedure FormPaint(Sender: TObject);
    5761    procedure CloseBtnClick(Sender: TObject);
     
    6569    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    6670    procedure SearchBtnClick(Sender: TObject);
    67   public
    68     Difficulty: integer;
    69     procedure ShowNewContent(NewMode, Category, Index: integer);
    70     procedure ClearHistory;
    71     function TextIndex(Item: string): integer;
    7271  protected
    7372    procedure OffscreenPaint; override;
     
    8786    HistPos: array [0 .. MaxHist - 1] of integer;
    8887    HistSearchContent: array [0 .. MaxHist - 1] of shortstring;
     88    procedure ScrollBarUpdate(Sender: TObject);
    8989    procedure line(ca: TCanvas; i: integer; lit: boolean);
    9090    procedure Prepare(sbPos: integer = 0);
     
    9292    procedure Search(SearchString: string);
    9393    procedure OnScroll(var m: TMessage); message WM_VSCROLL;
    94     procedure OnMouseWheel(var m: TMessage); message LM_MOUSEWHEEL;
    9594    procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
     95  public
     96    Difficulty: integer;
     97    procedure ShowNewContent(NewMode, Category, Index: integer);
     98    procedure ClearHistory;
     99    function TextIndex(Item: string): integer;
    96100  end;
    97101
     
    202206  SearchResult.OwnsObjects := True;
    203207  sb := TPVScrollbar.Create;
    204   CreatePVSB(sb, Handle, 36, 551, 36 + 432);
     208  sb.Setup(36, 9, 11, Self);
     209  sb.OnUpdate := ScrollBarUpdate;
    205210
    206211  HelpText := TStringTable.Create;
     
    247252end;
    248253
     254procedure THelpDlg.FormMouseWheel(Sender: TObject; Shift: TShiftState;
     255  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
     256begin
     257  if sb.ProcessMouseWheel(WheelDelta) then begin
     258    PaintBox1MouseMove(nil, [], MousePos.X - Left,
     259      MousePos.Y - Top);
     260  end;
     261end;
     262
    249263procedure THelpDlg.CloseBtnClick(Sender: TObject);
    250264begin
    251   Close
     265  Close;
    252266end;
    253267
    254268procedure THelpDlg.OnScroll(var m: TMessage);
    255269begin
    256   if ProcessPVSB(sb, m) then
    257   begin
     270  if sb.Process(m) then begin
    258271    Sel := -1;
    259272    SmartUpdateContent(true)
     
    261274end;
    262275
    263 procedure THelpDlg.OnMouseWheel(var m: TMessage);
    264 begin
    265   if ProcessMouseWheel(sb, m) then
    266   begin
    267     Sel := -1;
    268     SmartUpdateContent(true);
    269     PaintBox1MouseMove(nil, [], m.lParam and $FFFF - Left,
    270       m.lParam shr 16 - Top);
    271   end
    272 end;
    273 
    274276procedure THelpDlg.OnMouseLeave(var Msg: TMessage);
    275277begin
    276   if Sel <> -1 then
    277   begin
     278  if Sel <> -1 then begin
    278279    line(Canvas, Sel, false);
    279280    Sel := -1
     
    771772  MarkUsedOffscreen(InnerWidth, InnerHeight + 13 + 48);
    772773end; { OffscreenPaint }
     774
     775procedure THelpDlg.ScrollBarUpdate(Sender: TObject);
     776begin
     777  Sel := -1;
     778  SmartUpdateContent(true)
     779end;
    773780
    774781procedure THelpDlg.Prepare(sbPos: integer = 0);
     
    18351842      LF;
    18361843
    1837     InitPVSB(sb, Count - 1, InnerHeight div 24);
    1838     if sbPos <> 0 then
    1839     begin
    1840       sb.si.npos := sbPos;
    1841       sb.si.FMask := SIF_POS;
    1842       SetScrollInfo(sb.h, SB_CTL, sb.si, true);
    1843     end;
     1844    //Self.Show;
     1845    sb.Init(Count - 1, InnerHeight div 24);
     1846    sb.SetPos(sbPos);
    18441847    BackBtn.Visible := nHist > 0;
    18451848    TopBtn.Visible := (nHist > 0) or (Kind <> hkMisc) or (no <> miscMain);
Note: See TracChangeset for help on using the changeset viewer.