# eric7.EricWidgets.EricMapWidget

Module implementing a base class for showing a document map.

### Global Attributes

None

### Classes

EricMapWidget | Class implementing a base class for showing a document map.

### Functions

None

## EricMapWidget

Class implementing a base class for showing a document map.

### Derived from

QWidget

### Class Attributes

None

### Class Methods

None

### Methods

EricMapWidget | Constructor
__generateSliderRange | Private method to generate the slider rectangle.
__setSliderColor | Private method to set the slider color depending upon the background color.
__updateControllerViewportWidth | Private method to update the controller's viewport width.
_paintIt | Protected method for painting the widget's indicators.
backgroundColor | Public method to get the background color.
calculateGeometry | Public method to recalculate the map widget's geometry.
generateIndicatorRect | Public method to generate an indicator rectangle.
isEnabled | Public method to check the enabled state.
isOnRightSide | Public method to test, if the map is shown on the right side of the controller widget.
lineDimensions | Public method to get the line (indicator) dimensions.
mouseMoveEvent | Protected method to handle a mouse moves.
mousePressEvent | Protected method to handle a mouse button press.
paintEvent | Protected method to handle a paint event.
position2Value | Public method to convert a position into a scrollbar value.
scaleFactor | Public method to determine the scrollbar's scale factor.
setBackgroundColor | Public method to set the widget background color.
setController | Public method to set the map controller widget.
setEnabled | Public method to set the enabled state.
setLineDimensions | Public method to set the line (indicator) dimensions.
setMapPosition | Public method to set, whether the map should be shown to the right or left of the controller widget.
setWidth | Public method to set the widget width.
sizeHint | Public method to give an indication about the preferred size.
value2Position | Public method to convert a scrollbar value into a position.
wheelEvent | Protected slot handling mouse wheel events.
width | Public method to get the widget's width.

### Static Methods

None

#### EricMapWidget (Constructor)

EricMapWidget(parent=None)

Constructor

parent (QWidget)
  reference to the parent widget

#### EricMapWidget.__generateSliderRange

__generateSliderRange(scrollbar)

Private method to generate the slider rectangle.

scrollbar (QScrollBar)
  reference to the vertical scrollbar

Return:
  slider rectangle

Return Type:
  QRect

#### EricMapWidget.__setSliderColor

__setSliderColor()

Private method to set the slider color depending upon the background color.

#### EricMapWidget.__updateControllerViewportWidth

__updateControllerViewportWidth()

Private method to update the controller's viewport width.

#### EricMapWidget._paintIt

_paintIt(painter)

Protected method for painting the widget's indicators.

Note: This method should be implemented by subclasses.

painter (QPainter)
  reference to the painter object

#### EricMapWidget.backgroundColor

backgroundColor()

Public method to get the background color.

Return:
  background color

Return Type:
  QColor

#### EricMapWidget.calculateGeometry

calculateGeometry()

Public method to recalculate the map widget's geometry.

#### EricMapWidget.generateIndicatorRect

generateIndicatorRect(position)

Public method to generate an indicator rectangle.

position (int)
  indicator position

Return:
  indicator rectangle

Return Type:
  QRect

#### EricMapWidget.isEnabled

isEnabled()

Public method to check the enabled state.

Return:
  flag indicating the enabled state

Return Type:
  bool

#### EricMapWidget.isOnRightSide

isOnRightSide()

Public method to test, if the map is shown on the right side of the controller widget.

Return:
  flag indicating that the map is to the right of the controller widget

Return Type:
  bool

#### EricMapWidget.lineDimensions

lineDimensions()

Public method to get the line (indicator) dimensions.

Return:
  tuple with border width (integer) and line height

Return Type:
  int

#### EricMapWidget.mouseMoveEvent

mouseMoveEvent(event)

Protected method to handle a mouse moves.

event (QMouseEvent)
  reference to the mouse event

#### EricMapWidget.mousePressEvent

mousePressEvent(event)

Protected method to handle a mouse button press.

event (QMouseEvent)
  reference to the mouse event

#### EricMapWidget.paintEvent

paintEvent(event)

Protected method to handle a paint event.

event (QPaintEvent)
  paint event

#### EricMapWidget.position2Value

position2Value(position, slider=False)

Public method to convert a position into a scrollbar value.

position (int)
  scrollbar position to convert
slider (bool)
  flag indicating to calculate the result for the slider

Return:
  scrollbar value

Return Type:
  int

#### EricMapWidget.scaleFactor

scaleFactor(slider=False)

Public method to determine the scrollbar's scale factor.

slider (bool)
  flag indicating to calculate the result for the slider

Return:
  scale factor

Return Type:
  float

#### EricMapWidget.setBackgroundColor

setBackgroundColor(color)

Public method to set the widget background color.

color (QColor)
  color for the background

#### EricMapWidget.setController

setController(controller)

Public method to set the map controller widget.

controller (QAbstractScrollArea)
  map controller widget

#### EricMapWidget.setEnabled

setEnabled(enable)

Public method to set the enabled state.

enable (bool)
  flag indicating the enabled state

#### EricMapWidget.setLineDimensions

setLineDimensions(border, height)

Public method to set the line (indicator) dimensions.

border (int)
  border width on each side in x-direction
height (int)
  height of the line in pixels

#### EricMapWidget.setMapPosition

setMapPosition(onRight)

Public method to set, whether the map should be shown to the right or left of the controller widget.

onRight (bool)
  flag indicating to show the map on the right side of the controller widget

#### EricMapWidget.setWidth

setWidth(width)

Public method to set the widget width.

width (int)
  widget width

#### EricMapWidget.sizeHint

sizeHint()

Public method to give an indication about the preferred size.

Return:
  preferred size

Return Type:
  QSize

#### EricMapWidget.value2Position

value2Position(value, slider=False)

Public method to convert a scrollbar value into a position.

value (int)
  value to convert
slider (bool)
  flag indicating to calculate the result for the slider

Return:
  position

Return Type:
  int

#### EricMapWidget.wheelEvent

wheelEvent(event)

Protected slot handling mouse wheel events.

event (QWheelEvent)
  reference to the wheel event

#### EricMapWidget.width

width()

Public method to get the widget's width.

Return:
  widget width

Return Type:
  int

Up