Changeset 89
- Timestamp:
- Jan 19, 2017, 8:40:22 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Integrated.lpi
r72 r89 15 15 <UseAppBundle Value="False"/> 16 16 <ResourceType Value="res"/> 17 <UseXPManifest Value="True"/> 17 18 <Icon Value="0"/> 18 19 </General> … … 450 451 <StackChecks Value="True"/> 451 452 </Checks> 453 <VerifyObjMethodCallValidity Value="True"/> 452 454 </CodeGeneration> 453 455 <Linking> -
trunk/LocalPlayer/Help.pas
r73 r89 205 205 SearchResult := THyperText.Create; 206 206 SearchResult.OwnsObjects := True; 207 sb := TPVScrollbar.Create ;208 sb.Set up(36, 9, 11, Self);207 sb := TPVScrollbar.Create(Self); 208 sb.SetBorderSpacing(36, 9, 11); 209 209 sb.OnUpdate := ScrollBarUpdate; 210 210 … … 268 268 procedure THelpDlg.OnScroll(var m: TMessage); 269 269 begin 270 { TODO: Handled by MouseWheel event 270 271 if sb.Process(m) then begin 271 272 Sel := -1; 272 273 SmartUpdateContent(true) 273 end 274 end; 275 } 274 276 end; 275 277 … … 294 296 s: string; 295 297 begin 296 s := MainText[sb. si.npos+ i];298 s := MainText[sb.Position + i]; 297 299 if s = '' then 298 300 exit; … … 304 306 y := y + WideFrame 305 307 end; 306 if THelpLineInfo(MainText.Objects[sb. si.npos+ i]).Format308 if THelpLineInfo(MainText.Objects[sb.Position + i]).Format 307 309 in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then 308 310 begin … … 320 322 ca.Font.Assign(UniFont[ftNormal]); 321 323 end 322 else if THelpLineInfo(MainText.Objects[sb. si.npos+ i]).Format = pkSection324 else if THelpLineInfo(MainText.Objects[sb.Position + i]).Format = pkSection 323 325 then 324 326 begin … … 339 341 TextSize.cy := WideFrame + InnerHeight - y; 340 342 FillSeamless(ca, x, y, TextSize.cx, TextSize.cy, -SideFrame, 341 sb. si.npos* 24 - WideFrame, Paper);343 sb.Position * 24 - WideFrame, Paper); 342 344 end; 343 345 BiColorTextOut(ca, TextColor, $7F007F, x, y, s); … … 441 443 CaptionColor := Colors.Canvas.Pixels[clkMisc, cliPaperCaption]; 442 444 FillSeamless(OffScreen.Canvas, 0, 0, InnerWidth, InnerHeight, 0, 443 sb. si.npos* 24, Paper);445 sb.Position * 24, Paper); 444 446 with OffScreen.Canvas do 445 447 begin 446 448 Font.Assign(UniFont[ftNormal]); 447 for i := -sb. si.nposto InnerHeight div 24 do448 if sb. si.npos+ i < MainText.Count then449 for i := -sb.Position to InnerHeight div 24 do 450 if sb.Position + i < MainText.Count then 449 451 begin 450 HelpLineInfo := THelpLineInfo(MainText.Objects[sb. si.npos+ i]);452 HelpLineInfo := THelpLineInfo(MainText.Objects[sb.Position + i]); 451 453 if HelpLineInfo.Format = pkExternal then 452 454 begin … … 459 461 end; 460 462 for i := -2 to InnerHeight div 24 do 461 if (sb. si.npos + i >= 0) and (sb.si.npos+ i < MainText.Count) then463 if (sb.Position + i >= 0) and (sb.Position + i < MainText.Count) then 462 464 begin 463 HelpLineInfo := THelpLineInfo(MainText.Objects[sb. si.npos+ i]);465 HelpLineInfo := THelpLineInfo(MainText.Objects[sb.Position + i]); 464 466 if HelpLineInfo.Link <> 0 then 465 467 begin … … 1870 1872 HistKind[nHist - 1] := Kind; 1871 1873 HistNo[nHist - 1] := no; 1872 HistPos[nHist - 1] := sb. si.npos;1874 HistPos[nHist - 1] := sb.Position; 1873 1875 HistSearchContent[nHist - 1] := SearchContent 1874 1876 end … … 1888 1890 begin 1889 1891 y := y - WideFrame; 1890 i0 := sb. si.npos;1892 i0 := sb.Position; 1891 1893 Sel0 := Sel; 1892 1894 if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and … … 1911 1913 begin 1912 1914 if Sel >= 0 then 1913 with THelpLineInfo(MainText.Objects[Sel + sb. si.npos]) do1915 with THelpLineInfo(MainText.Objects[Sel + sb.Position]) do 1914 1916 if Link shr 8 and $3F = hkInternet then 1915 1917 case Link and $FF of -
trunk/LocalPlayer/PVSB.pas
r70 r89 18 18 private 19 19 FOnUpdate: TNotifyEvent; 20 ScrollBar: TScrollBar; 21 function GetMax: Integer; 22 function GetPageSize: Integer; 23 function GetPosition: Integer; 20 24 procedure ScrollBarChanged(Sender: TObject); 25 procedure SetMax(AValue: Integer); 26 procedure SetPageSize(AValue: Integer); 27 procedure SetPosition(AValue: Integer); 21 28 public 22 ScrollBar: TScrollBar; 23 si: TScrollInfo; 29 constructor Create(Parent: TWinControl); 24 30 destructor Destroy; override; 25 procedure Setup(TopSpacing, RightSpacing, BottomSpacing: integer; Parent: TWinControl); 26 procedure Init(max, Page: integer); 31 procedure Init(Max, Page: Integer); 27 32 procedure SetPos(Pos: Integer); 28 33 function Process(const m: TMessage): boolean; 29 function ProcessMouseWheel(Delta: Integer) : boolean;34 function ProcessMouseWheel(Delta: Integer): Boolean; 30 35 procedure Show(Visible: boolean); 31 36 procedure EndSB; 32 procedure UpdateScrollBar;37 procedure SetBorderSpacing(Top, Right, Bottom: Integer); 33 38 property OnUpdate: TNotifyEvent read FOnUpdate write FOnUpdate; 39 property Position: Integer read GetPosition write SetPosition; 40 property Max: Integer read GetMax write SetMax; 41 property PageSize: Integer read GetPageSize write SetPageSize; 34 42 end; 35 43 … … 38 46 39 47 const 40 Count: integer = 0;48 Count: Integer = 0; 41 49 42 procedure TPVScrollBar.Setup(TopSpacing, RightSpacing, BottomSpacing: integer; 43 Parent: TWinControl); 50 procedure TPVScrollBar.Init(Max, Page: Integer); 44 51 begin 45 inc(Count); 46 //{$IFDEF LINUX} 47 // sb.Form := TForm.Create(nil); 48 // sb.Form.SetBounds(x1 - 100, y0, 100, y1 - y0); 49 // sb.Form.Name := 'PVSB' + IntToStr(Count); 50 ScrollBar := TScrollBar.Create(Parent); 51 ScrollBar.Kind := sbVertical; 52 ScrollBar.Name := 'PVSB' + IntToStr(Count); 53 ScrollBar.Parent := Parent; 54 ScrollBar.BorderSpacing.Top := TopSpacing; 55 ScrollBar.BorderSpacing.Right := RightSpacing; 56 ScrollBar.BorderSpacing.Bottom := BottomSpacing; 57 ScrollBar.Align := alRight; 58 ScrollBar.OnChange := ScrollBarChanged; 59 //sb.h := sb.ScrollBar.Handle; 60 (* 61 {$ENDIF} 62 {$IFDEF WINDOWS} 63 sb.h := CreateWindowEx(0, 'SCROLLBAR', pchar('PVSB' + IntToStr(Count)), 64 SBS_VERT or WS_CHILD or SBS_RIGHTALIGN, x1 - 100, y0, 100, y1 - y0, 65 Handle, 0, 0, nil); 66 {$ENDIF} 67 *) 68 si.cbSize := 28; 69 end; 70 71 procedure TPVScrollBar.Init(max, Page: integer); 72 begin 73 with si do begin 74 nMin := 0; 75 nMax := max; 76 npos := 0; 77 nPage := Page; 78 FMask := SIF_PAGE or SIF_POS or SIF_RANGE; 79 end; 80 UpdateScrollBar; 81 //SetScrollInfo(sb.ScrollBar.Handle, SB_CTL, sb.si, true); 82 if max < Page then ScrollBar.Visible := False 83 else ScrollBar.Visible := True; 52 ScrollBar.Min := 0; 53 ScrollBar.Max := Max; 54 ScrollBar.PageSize := Page; 55 ScrollBar.Position := 0; 56 ScrollBar.Visible := ScrollBar.Max >= ScrollBar.PageSize; 84 57 end; 85 58 … … 87 60 begin 88 61 if Pos <> 0 then begin 89 si.npos := Pos; 90 si.FMask := SIF_POS; 91 //SetScrollInfo(sb.ScrollBar.Handle, SB_CTL, sb.si, true); 92 UpdateScrollBar; 62 ScrollBar.Position := Pos; 93 63 end; 94 64 end; … … 98 68 NewPos: integer; 99 69 begin 100 with si do 101 if nMax < integer(nPage) then 70 if ScrollBar.Max < ScrollBar.PageSize then 102 71 result := false 103 72 else … … 105 74 if (m.wParam and $ffff) in [SB_THUMBPOSITION, SB_THUMBTRACK] then 106 75 begin 107 result := ((m.wParam shr 16) and $ffff) <> npos; 108 npos := (m.wParam shr 16) and $ffff; 109 end 110 else 111 begin 76 result := ((m.wParam shr 16) and $ffff) <> ScrollBar.Position; 77 ScrollBar.Position := (m.wParam shr 16) and $ffff; 78 end else begin 112 79 case (m.wParam and $ffff) of 113 80 SB_LINEUP: 114 NewPos := npos- 1;81 NewPos := ScrollBar.Position - 1; 115 82 SB_LINEDOWN: 116 NewPos := npos+ 1;83 NewPos := ScrollBar.Position + 1; 117 84 SB_PAGEUP: 118 NewPos := npos - integer(nPage);85 NewPos := ScrollBar.Position - ScrollBar.PageSize; 119 86 SB_PAGEDOWN: 120 NewPos := npos + integer(nPage);87 NewPos := ScrollBar.Position + ScrollBar.PageSize; 121 88 else 122 NewPos := npos89 NewPos := ScrollBar.Position 123 90 end; 124 91 if NewPos < 0 then 125 92 NewPos := 0; 126 if NewPos > nMax - integer(nPage)+ 1 then127 NewPos := nMax - integer(nPage)+ 1;128 result := NewPos <> npos;129 if (NewPos <> npos) or ((m.wParam and $ffff) = SB_ENDSCROLL) then93 if NewPos > ScrollBar.Max - ScrollBar.PageSize + 1 then 94 NewPos := ScrollBar.Max - ScrollBar.PageSize + 1; 95 result := NewPos <> ScrollBar.Position; 96 if (NewPos <> ScrollBar.Position) or ((m.wParam and $ffff) = SB_ENDSCROLL) then 130 97 begin 131 npos := NewPos; 132 FMask := SIF_POS; 133 UpdateScrollBar; 134 //SetScrollInfo(sb.ScrollBar.Handle, SB_CTL, sb.si, true); 98 ScrollBar.Position := NewPos; 135 99 end; 136 end 137 end 100 end; 101 end; 138 102 end; 139 103 140 function TPVScrollBar.ProcessMouseWheel(Delta: Integer 141 ): boolean; 104 function TPVScrollBar.ProcessMouseWheel(Delta: Integer): Boolean; 142 105 var 143 106 NewPos: integer; 144 107 begin 145 with si do 146 if nMax < integer(nPage) then 147 result := false 148 else 149 begin 150 NewPos := npos - Delta div 300; 151 if NewPos < 0 then 152 NewPos := 0; 153 if NewPos > nMax - integer(nPage) + 1 then 154 NewPos := nMax - integer(nPage) + 1; 155 result := NewPos <> npos; 156 if NewPos <> npos then 157 begin 158 npos := NewPos; 159 FMask := SIF_POS; 160 UpdateScrollBar; 161 //SetScrollInfo(sb.ScrollBar.Handle, SB_CTL, sb.si, true); 162 end 163 end 108 if ScrollBar.Max < ScrollBar.PageSize then Result := False 109 else begin 110 NewPos := ScrollBar.Position - Delta div 300; 111 if NewPos < 0 then NewPos := 0; 112 if NewPos > ScrollBar.Max - ScrollBar.PageSize + 1 then 113 NewPos := ScrollBar.Max - ScrollBar.PageSize + 1; 114 Result := NewPos <> ScrollBar.Position; 115 if NewPos <> ScrollBar.Position then begin 116 ScrollBar.Position := NewPos; 117 end; 118 end; 164 119 end; 165 120 166 121 procedure TPVScrollBar.Show(Visible: boolean); 167 122 begin 168 if not Visible or ( si.nMax < integer(si.nPage)) then123 if not Visible or (ScrollBar.Max < ScrollBar.PageSize) then 169 124 ScrollBar.Visible := False 170 125 else ScrollBar.Visible := True; … … 173 128 procedure TPVScrollBar.EndSB; 174 129 begin 175 with si do begin 176 if nMax < integer(nPage) then 177 npos := 0 // hidden 178 else begin 179 si.npos := nMax - integer(nPage) + 1; 180 si.FMask := SIF_POS; 181 UpdateScrollBar; 182 //SetScrollInfo(sb.ScrollBar.Handle, SB_CTL, sb.si, true); 183 end 184 end 130 if ScrollBar.Max < ScrollBar.PageSize then 131 ScrollBar.Position := 0 // hidden 132 else begin 133 ScrollBar.Position := ScrollBar.Max - ScrollBar.PageSize + 1; 134 end; 185 135 end; 186 136 187 procedure TPVScrollBar. UpdateScrollBar;137 procedure TPVScrollBar.SetBorderSpacing(Top, Right, Bottom: Integer); 188 138 begin 189 ScrollBar.Min := si.nMin; 190 ScrollBar.Max := Max(si.nMax{$IFDEF LINUX} - si.nPage + 1{$ENDIF}, 0); 191 ScrollBar.PageSize := si.nPage; 192 ScrollBar.Position := si.nPos; 139 ScrollBar.BorderSpacing.Top := Top; 140 ScrollBar.BorderSpacing.Right := Right; 141 ScrollBar.BorderSpacing.Bottom := Bottom; 193 142 end; 194 143 … … 197 146 procedure TPVScrollBar.ScrollBarChanged(Sender: TObject); 198 147 begin 199 si.npos := ScrollBar.Position;200 148 if Assigned(FOnUpdate) then FOnUpdate(Self); 149 end; 150 151 procedure TPVScrollBar.SetMax(AValue: Integer); 152 begin 153 ScrollBar.Max := AValue; 154 end; 155 156 procedure TPVScrollBar.SetPageSize(AValue: Integer); 157 begin 158 ScrollBar.PageSize := AValue; 159 end; 160 161 function TPVScrollBar.GetPosition: Integer; 162 begin 163 Result := ScrollBar.Position; 164 end; 165 166 function TPVScrollBar.GetMax: Integer; 167 begin 168 Result := ScrollBar.Max; 169 end; 170 171 function TPVScrollBar.GetPageSize: Integer; 172 begin 173 Result := ScrollBar.PageSize; 174 end; 175 176 procedure TPVScrollBar.SetPosition(AValue: Integer); 177 begin 178 ScrollBar.Position := AValue; 179 end; 180 181 constructor TPVScrollBar.Create(Parent: TWinControl); 182 begin 183 Inc(Count); 184 ScrollBar := TScrollBar.Create(Parent); 185 ScrollBar.Kind := sbVertical; 186 ScrollBar.Name := 'PVSB' + IntToStr(Count); 187 ScrollBar.Align := alRight; 188 ScrollBar.OnChange := ScrollBarChanged; 189 ScrollBar.Parent := Parent; 201 190 end; 202 191 203 192 destructor TPVScrollBar.Destroy; 204 193 begin 205 //h := 0;206 si.cbSize := 0;207 194 FreeAndNil(ScrollBar); 208 195 end; -
trunk/LocalPlayer/Select.pas
r71 r89 102 102 inherited; 103 103 Canvas.Font.Assign(UniFont[ftNormal]); 104 sb := TPVScrollbar.Create ;105 sb.Set up(36, 10, 36, Self);104 sb := TPVScrollbar.Create(Self); 105 sb.SetBorderSpacing(36, 10, 36); 106 106 sb.OnUpdate := ScrollBarUpdate; 107 107 InitButtons(); … … 135 135 procedure TListDlg.OnScroll(var m: TMessage); 136 136 begin 137 { TODO: Handled by MouseWheel event 137 138 if sb.Process(m) then begin 138 139 Sel := -2; 139 140 SmartUpdateContent(true); 140 141 end; 142 } 141 143 end; 142 144 … … 234 236 CanGrow: boolean; 235 237 begin 236 lix := code[Layer, sb. si.npos+ l];238 lix := code[Layer, sb.Position + l]; 237 239 y0 := 2 + (l + 1) * LineDistance; 238 if sb. si.npos+ l >= FirstShrinkedLine[Layer] then239 ofs := (sb. si.npos+ l - FirstShrinkedLine[Layer]) and 1 * 33240 if sb.Position + l >= FirstShrinkedLine[Layer] then 241 ofs := (sb.Position + l - FirstShrinkedLine[Layer]) and 1 * 33 240 242 else { if FirstShrinkedLine[Layer]<Lines[Layer] then } 241 243 ofs := 33; … … 468 470 begin 469 471 s := Tribe[mox.Owner].ModelName[mox.mix]; 470 if (Kind = kAllEModels) and (code[1, sb. si.npos+ l] = 0) then472 if (Kind = kAllEModels) and (code[1, sb.Position + l] = 0) then 471 473 s := Format(Tribe[mox.Owner].TPhrase('OWNED'), [s]); 472 474 end … … 753 755 end; 754 756 for i := -1 to DispLines do 755 if (i + sb. si.npos >= 0) and (i + sb.si.npos< Lines[Layer]) then757 if (i + sb.Position >= 0) and (i + sb.Position < Lines[Layer]) then 756 758 Self.line(offscreen.Canvas, i, true, false) 757 759 end; … … 766 768 begin 767 769 y := y - TitleHeight; 768 i0 := sb. si.npos;770 i0 := sb.Position; 769 771 Sel0 := Sel; 770 772 if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and … … 891 893 lix: integer; 892 894 begin 893 if sb. si.npos+ Sel >= 0 then894 lix := code[Layer, sb. si.npos+ Sel];895 if sb.Position + Sel >= 0 then 896 lix := code[Layer, sb.Position + Sel]; 895 897 if Kind in [kScience, kCities, kCityEvents, kModels, kEModels, kAllEModels] 896 898 then … … 920 922 kEModels: 921 923 UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or wmPersistent, 922 code[1, sb. si.npos+ Sel]);924 code[1, sb.Position + Sel]); 923 925 kAllEModels, kChooseEModel: 924 926 if lix <> mixAll then … … 1599 1601 CaptionLeft := ToggleBtn.Left + ToggleBtn.Width; 1600 1602 CaptionRight := CloseBtn.Left; 1603 { TODO: 1601 1604 SetWindowPos(sb.ScrollBar.Handle, 0, SideFrame + InnerWidth - GetSystemMetrics(SM_CXVSCROLL), 1602 1605 TitleHeight, GetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48, 1603 1606 SWP_NOZORDER or SWP_NOREDRAW); 1607 } 1604 1608 1605 1609 if WindowMode = wmModal then -
trunk/LocalPlayer/Term.pas
r88 r89 1474 1474 StayOnTop_Ensured := false; 1475 1475 1476 sb .Setup(0, 0, 0,Self);1476 sb := TPVScrollbar.Create(Self); 1477 1477 sb.OnUpdate := ScrollBarUpdate; 1478 1478 end; { InitModule } … … 3435 3435 SoundMode := smOn; 3436 3436 3437 sb := TPVScrollbar.Create;3438 3437 {$IFDEF WINDOWS}{ TODO } 3439 3438 Screen.Cursors[crImpDrag] := LoadCursor(HInstance, 'DRAG'); … … 3576 3575 EOT.Top := ClientHeight - 64; 3577 3576 EOT.Left := ClientWidth - 62; 3578 sb.ScrollBar.BorderSpacing.Top := ClientHeight - yTroop - 24; 3579 sb.ScrollBar.BorderSpacing.Right := ClientWidth - xRightPanel + 8; 3580 sb.ScrollBar.BorderSpacing.Bottom := 8; 3577 sb.SetBorderSpacing(ClientHeight - yTroop - 24, ClientWidth - xRightPanel + 8, 8); 3578 {TODO: 3581 3579 SetWindowPos(sb.ScrollBar.Handle, 0, xRightPanel + 10 - 14 - GetSystemMetrics(SM_CXVSCROLL), 3582 3580 ClientHeight - MidPanelHeight + 8, 0, 0, SWP_NOSIZE or SWP_NOZORDER); 3581 } 3583 3582 MapBtn0.Left := xMini + G.lx - 44; 3584 3583 MapBtn0.Top := ClientHeight - 15; … … 4414 4413 for i := 0 to nBrushTypes - 1 do 4415 4414 begin // display terrain types 4416 if (Count >= TrRow * sb. si.npos) and (Count < TrRow * (sb.si.npos+ 1))4415 if (Count >= TrRow * sb.Position) and (Count < TrRow * (sb.Position + 1)) 4417 4416 then 4418 4417 begin 4419 trix[Count - TrRow * sb. si.npos] := BrushTypes[i];4420 x := (Count - TrRow * sb. si.npos) * TrPitch;4418 trix[Count - TrRow * sb.Position] := BrushTypes[i]; 4419 x := (Count - TrRow * sb.Position) * TrPitch; 4421 4420 xSrcBase := -1; 4422 4421 case BrushTypes[i] of … … 4646 4645 if unx.Loc = TroopLoc then 4647 4646 begin 4648 if (Count >= TrRow * sb. si.npos) and4649 (Count < TrRow * (sb. si.npos+ 1)) then4647 if (Count >= TrRow * sb.Position) and 4648 (Count < TrRow * (sb.Position + 1)) then 4650 4649 begin 4651 trix[Count - TrRow * sb. si.npos] := uix;4650 trix[Count - TrRow * sb.Position] := uix; 4652 4651 MakeUnitInfo(me, unx, UnitInfo); 4653 x := (Count - TrRow * sb. si.npos) * TrPitch;4652 x := (Count - TrRow * sb.Position) * TrPitch; 4654 4653 if uix = UnFocus then 4655 4654 begin … … 4700 4699 Server(sGetUnits, me, TroopLoc, Count); 4701 4700 for i := 0 to Count - 1 do 4702 if (i >= TrRow * sb. si.npos) and (i < TrRow * (sb.si.npos+ 1)) then4701 if (i >= TrRow * sb.Position) and (i < TrRow * (sb.Position + 1)) then 4703 4702 begin // display enemy units 4704 trix[i - TrRow * sb. si.npos] := i;4705 x := (i - TrRow * sb. si.npos) * TrPitch;4703 trix[i - TrRow * sb.Position] := i; 4704 x := (i - TrRow * sb.Position) * TrPitch; 4706 4705 NoMap.SetOutput(Panel); 4707 4706 NoMap.PaintUnit(xTroop + 2 + x, yTroop + 1, … … 6348 6347 begin 6349 6348 sb.Init((TrCnt + TrRow - 1) div TrRow - 1, 1); 6350 with sb.si do 6351 if (nMax >= integer(nPage)) and (trixFocus >= 0) then 6352 begin 6353 sb.si.npos := trixFocus div TrRow; 6354 sb.si.FMask := SIF_POS; 6355 SetScrollInfo(sb.ScrollBar.Handle, SB_CTL, sb.si, true); 6356 end 6357 end 6349 if (sb.Max >= sb.PageSize) and (trixFocus >= 0) then 6350 sb.Position := trixFocus div TrRow; 6351 end; 6358 6352 end; 6359 6353
Note:
See TracChangeset
for help on using the changeset viewer.