1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.VarScrollHelperBase:
==========================================================================================================================================
|phoenix_title| **wx.VarScrollHelperBase**
==========================================================================================================================================
This class provides all common base functionality for scroll calculations shared among all variable scrolled window implementations as well as automatic scrollbar functionality, saved scroll positions, controlling target windows to be scrolled, as well as defining all required virtual functions that need to be implemented for any orientation specific work.
Documentation of this class is provided specifically for referencing use of the functions provided by this class for use with the variable scrolled windows that derive from here. You will likely want to derive your window from one of the already implemented variable scrolled windows rather than from :ref:`wx.VarScrollHelperBase` directly.
.. seealso:: :ref:`wx.HScrolledWindow`, :ref:`wx.HVScrolledWindow`, :ref:`wx.VScrolledWindow`
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>VarScrollHelperBase</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.VarScrollHelperBase_inheritance.png" alt="Inheritance diagram of VarScrollHelperBase" usemap="#dummy" class="inheritance"/></center>
</div>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.VarScrollHelperBase.html" title="wx.VarScrollHelperBase" alt="" coords="5,5,176,35"/> </map>
</p>
|
|sub_classes| Known Subclasses
==============================
:ref:`wx.VarHScrollHelper`, :ref:`wx.VarVScrollHelper`
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.VarScrollHelperBase.__init__` Constructor taking the target window to be scrolled by this helper class.
:meth:`~wx.VarScrollHelperBase.CalcScrolledPosition` Translates the logical coordinate given to the current device coordinate.
:meth:`~wx.VarScrollHelperBase.CalcUnscrolledPosition` Translates the device coordinate given to the corresponding logical coordinate.
:meth:`~wx.VarScrollHelperBase.EnablePhysicalScrolling` With physical scrolling on (when this is ``True``), the device origin is changed properly when a :ref:`wx.PaintDC` is prepared, children are actually moved and laid out properly, and the contents of the window (pixels) are actually moved.
:meth:`~wx.VarScrollHelperBase.EstimateTotalSize` When the number of scroll units change, we try to estimate the total size of all units when the full window size is needed (i.e.
:meth:`~wx.VarScrollHelperBase.GetNonOrientationTargetSize` This function needs to be overridden in the in the derived class to return the window size with respect to the opposing orientation.
:meth:`~wx.VarScrollHelperBase.GetOrientation` This function need to be overridden to return the orientation that this helper is working with, either ``HORIZONTAL`` or ``VERTICAL`` .
:meth:`~wx.VarScrollHelperBase.GetOrientationTargetSize` This function needs to be overridden in the in the derived class to return the window size with respect to the orientation this helper is working with.
:meth:`~wx.VarScrollHelperBase.GetTargetWindow` This function will return the target window this helper class is currently scrolling.
:meth:`~wx.VarScrollHelperBase.GetVisibleBegin` Returns the index of the first visible unit based on the scroll position.
:meth:`~wx.VarScrollHelperBase.GetVisibleEnd` Returns the index of the last visible unit based on the scroll position.
:meth:`~wx.VarScrollHelperBase.IsVisible` Returns ``True`` if the given scroll unit is currently visible (even if only partially visible) or ``False`` otherwise.
:meth:`~wx.VarScrollHelperBase.OnGetUnitSize` This function must be overridden in the derived class, and should return the size of the given unit in pixels.
:meth:`~wx.VarScrollHelperBase.OnGetUnitsSizeHint` This function doesn't have to be overridden but it may be useful to do so if calculating the units' sizes is a relatively expensive operation as it gives your code a chance to calculate several of them at once and cache the result if necessary.
:meth:`~wx.VarScrollHelperBase.RefreshAll` Recalculate all parameters and repaint all units.
:meth:`~wx.VarScrollHelperBase.SetTargetWindow` Normally the window will scroll itself, but in some rare occasions you might want it to scroll (part of) another window (e.g.
:meth:`~wx.VarScrollHelperBase.UpdateScrollbar` Update the thumb size shown by the scrollbar.
:meth:`~wx.VarScrollHelperBase.VirtualHitTest` Returns the virtual scroll unit under the device unit given accounting for scroll position or ``NOT_FOUND`` if none (i.e.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.VarScrollHelperBase.NonOrientationTargetSize` See :meth:`~wx.VarScrollHelperBase.GetNonOrientationTargetSize`
:attr:`~wx.VarScrollHelperBase.Orientation` See :meth:`~wx.VarScrollHelperBase.GetOrientation`
:attr:`~wx.VarScrollHelperBase.OrientationTargetSize` See :meth:`~wx.VarScrollHelperBase.GetOrientationTargetSize`
:attr:`~wx.VarScrollHelperBase.TargetWindow` See :meth:`~wx.VarScrollHelperBase.GetTargetWindow` and :meth:`~wx.VarScrollHelperBase.SetTargetWindow`
:attr:`~wx.VarScrollHelperBase.VisibleBegin` See :meth:`~wx.VarScrollHelperBase.GetVisibleBegin`
:attr:`~wx.VarScrollHelperBase.VisibleEnd` See :meth:`~wx.VarScrollHelperBase.GetVisibleEnd`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.VarScrollHelperBase(object)
**Possible constructors**::
VarScrollHelperBase(winToScroll)
This class provides all common base functionality for scroll
calculations shared among all variable scrolled window implementations
as well as automatic scrollbar functionality, saved scroll positions,
controlling target windows to be scrolled, as well as defining all
required virtual functions that need to be implemented for any
orientation specific work.
.. method:: __init__(self, winToScroll)
Constructor taking the target window to be scrolled by this helper class.
This will attach scroll event handlers to the target window to catch and handle scroll events appropriately.
:param `winToScroll`:
:type `winToScroll`: wx.Window
.. method:: CalcScrolledPosition(self, coord)
Translates the logical coordinate given to the current device coordinate.
For example, if the window is scrolled 10 units and each scroll unit represents 10 device units (which may not be the case since this class allows for variable scroll unit sizes), a call to this function with a coordinate of 15 will return -85.
:param `coord`:
:type `coord`: int
:rtype: `int`
.. seealso:: :meth:`CalcUnscrolledPosition`
.. method:: CalcUnscrolledPosition(self, coord)
Translates the device coordinate given to the corresponding logical coordinate.
For example, if the window is scrolled 10 units and each scroll unit represents 10 device units (which may not be the case since this class allows for variable scroll unit sizes), a call to this function with a coordinate of 15 will return 115.
:param `coord`:
:type `coord`: int
:rtype: `int`
.. seealso:: :meth:`CalcScrolledPosition`
.. method:: EnablePhysicalScrolling(self, scrolling=True)
With physical scrolling on (when this is ``True``), the device origin is changed properly when a :ref:`wx.PaintDC` is prepared, children are actually moved and laid out properly, and the contents of the window (pixels) are actually moved.
When this is ``False``, you are responsible for repainting any invalidated areas of the window yourself to account for the new scroll position.
:param `scrolling`:
:type `scrolling`: bool
.. method:: EstimateTotalSize(self)
When the number of scroll units change, we try to estimate the total size of all units when the full window size is needed (i.e.
to calculate the scrollbar thumb size). This is a rather expensive operation in terms of unit access, so if the user code may estimate the average size better or faster than we do, it should override this function to implement its own logic. This function should return the best guess for the total virtual window size.
:rtype: :ref:`wx.Coord`
.. note::
Although returning a totally wrong value would still work, it risks resulting in very strange scrollbar behaviour so this function should really try to make the best guess possible.
.. method:: GetNonOrientationTargetSize(self)
This function needs to be overridden in the in the derived class to return the window size with respect to the opposing orientation.
If this is a vertical scrolled window, it should return the height.
:rtype: `int`
.. seealso:: :meth:`GetOrientationTargetSize`
.. method:: GetOrientation(self)
This function need to be overridden to return the orientation that this helper is working with, either ``HORIZONTAL`` or ``VERTICAL`` .
:rtype: :ref:`wx.Orientation`
.. method:: GetOrientationTargetSize(self)
This function needs to be overridden in the in the derived class to return the window size with respect to the orientation this helper is working with.
If this is a vertical scrolled window, it should return the width.
:rtype: `int`
.. seealso:: :meth:`GetNonOrientationTargetSize`
.. method:: GetTargetWindow(self)
This function will return the target window this helper class is currently scrolling.
:rtype: :ref:`wx.Window`
.. seealso:: :meth:`SetTargetWindow`
.. method:: GetVisibleBegin(self)
Returns the index of the first visible unit based on the scroll position.
:rtype: `int`
.. method:: GetVisibleEnd(self)
Returns the index of the last visible unit based on the scroll position.
This includes the last unit even if it is only partially visible.
:rtype: `int`
.. method:: IsVisible(self, unit)
Returns ``True`` if the given scroll unit is currently visible (even if only partially visible) or ``False`` otherwise.
:param `unit`:
:type `unit`: int
:rtype: `bool`
.. method:: OnGetUnitSize(self, unit)
This function must be overridden in the derived class, and should return the size of the given unit in pixels.
:param `unit`:
:type `unit`: int
:rtype: :ref:`wx.Coord`
.. method:: OnGetUnitsSizeHint(self, unitMin, unitMax)
This function doesn't have to be overridden but it may be useful to do so if calculating the units' sizes is a relatively expensive operation as it gives your code a chance to calculate several of them at once and cache the result if necessary.
:meth:`OnGetUnitsSizeHint` is normally called just before :meth:`OnGetUnitSize` but you shouldn't rely on the latter being called for all units in the interval specified here. It is also possible that :meth:`OnGetUnitSize` will be called for units outside of this interval, so this is really just a hint, not a promise.
Finally, note that `unitMin` is inclusive, while `unitMax` is exclusive.
:param `unitMin`:
:type `unitMin`: int
:param `unitMax`:
:type `unitMax`: int
.. method:: RefreshAll(self)
Recalculate all parameters and repaint all units.
.. method:: SetTargetWindow(self, target)
Normally the window will scroll itself, but in some rare occasions you might want it to scroll (part of) another window (e.g.
a child of it in order to scroll only a portion the area between the scrollbars like a spreadsheet where only the cell area will move).
:param `target`:
:type `target`: wx.Window
.. seealso:: :meth:`GetTargetWindow`
.. method:: UpdateScrollbar(self)
Update the thumb size shown by the scrollbar.
.. method:: VirtualHitTest(self, coord)
Returns the virtual scroll unit under the device unit given accounting for scroll position or ``NOT_FOUND`` if none (i.e.
if it is below the last item).
:param `coord`:
:type `coord`: int
:rtype: `int`
.. attribute:: NonOrientationTargetSize
See :meth:`~wx.VarScrollHelperBase.GetNonOrientationTargetSize`
.. attribute:: Orientation
See :meth:`~wx.VarScrollHelperBase.GetOrientation`
.. attribute:: OrientationTargetSize
See :meth:`~wx.VarScrollHelperBase.GetOrientationTargetSize`
.. attribute:: TargetWindow
See :meth:`~wx.VarScrollHelperBase.GetTargetWindow` and :meth:`~wx.VarScrollHelperBase.SetTargetWindow`
.. attribute:: VisibleBegin
See :meth:`~wx.VarScrollHelperBase.GetVisibleBegin`
.. attribute:: VisibleEnd
See :meth:`~wx.VarScrollHelperBase.GetVisibleEnd`
|