# eric4.IconEditor.IconEditorGrid

Module implementing the icon editor grid.

### Global Attributes

None

### Classes

IconEditCommand | Class implementing an undo command for the icon editor.
IconEditorGrid | Class implementing the icon editor grid.

### Functions

None

## IconEditCommand

Class implementing an undo command for the icon editor.

### Derived from

QUndoCommand

### Class Attributes

None

### Class Methods

None

### Methods

IconEditCommand | Constructor
redo | Public method to perform the redo.
setAfterImage | Public method to set the image after the changes were applied.
undo | Public method to perform the undo.

### Static Methods

None

#### IconEditCommand (Constructor)

IconEditCommand(grid, text, oldImage, parent = None)

Constructor

grid
  reference to the icon editor grid (IconEditorGrid)
text
  text for the undo command (QString)
oldImage
  copy of the icon before the changes were applied (QImage)
parent
  reference to the parent command (QUndoCommand)

#### IconEditCommand.redo

redo()

Public method to perform the redo.

#### IconEditCommand.setAfterImage

setAfterImage(image)

Public method to set the image after the changes were applied.

image
  copy of the icon after the changes were applied (QImage)

#### IconEditCommand.undo

undo()

Public method to perform the undo.

Up

## IconEditorGrid

Class implementing the icon editor grid.

### Signals

canRedoChanged(bool)
  emitted after the redo status has changed
canUndoChanged(bool)
  emitted after the undo status has changed
clipboardImageAvailable(bool)
  emitted to signal the availability of an image to be pasted
colorChanged(const QColor&)
  emitted after the drawing color was changed
imageChanged(bool)
  emitted after the image was modified
positionChanged(int, int)
  emitted after the cursor poition was changed
previewChanged(const QPixmap&)
  emitted to signal a new preview pixmap
selectionAvailable(bool)
  emitted to signal a change of the selection
sizeChanged(int, int)
  emitted after the size has been changed

### Derived from

QWidget

### Class Attributes

Circle
CircleSelection
ColorPicker
Ellipse
Fill
FilledCircle
FilledEllipse
FilledRectangle
Line
MarkColor
NoMarkColor
Pencil
Rectangle
RectangleSelection
Rubber

### Class Methods

None

### Methods

IconEditorGrid | Constructor
__checkClipboard | Private slot to check, if the clipboard contains a valid image, and signal the result.
__cleanChanged | Private slot to handle the undo stack clean state change.
__clipboardImage | Private method to get an image from the clipboard.
__drawFlood | Private method to perform a flood fill operation.
__drawPasteRect | Private slot to draw a rectangle for signaling a paste operation.
__drawTool | Public method to perform a draw operation depending of the current tool.
__getSelectionImage | Private method to get an image from the selection.
__imageCoordinates | Private method to convert from widget to image coordinates.
__initCursors | Private method to initialize the various cursors.
__initUndoTexts | Private method to initialize texts to be associated with undo commands for the various drawing tools.
__isMarked | Private method to check, if a pixel is marked.
__pixelRect | Private method to determine the rectangle for a given pixel coordinate.
__setImagePixel | Private slot to set or erase a pixel.
__unMark | Private slot to remove the mark indicator.
__updateImageRect | Private slot to update parts of the widget.
__updatePreviewPixmap | Private slot to generate and signal an updated preview pixmap.
__updateRect | Private slot to update parts of the widget.
canPaste | Public slot to check the availability of the paste operation.
canRedo | Public method to return the redo status.
canUndo | Public method to return the undo status.
editClear | Public slot to clear the image.
editCopy | Public slot to copy the selection.
editCut | Public slot to cut the selection.
editNew | Public slot to generate a new, empty image.
editPaste | Public slot to paste an image from the clipboard.
editPasteAsNew | Public slot to paste the clipboard as a new image.
editRedo | Public slot to perform a redo operation.
editResize | Public slot to resize the image.
editSelectAll | Public slot to select the complete image.
editUndo | Public slot to perform an undo operation.
grayScale | Public slot to convert the image to gray preserving transparency.
iconImage | Public method to get a copy of the icon image.
iconSize | Public method to get the size of the icon.
isDirty | Public method to check the dirty status.
isGridEnabled | Public method to get the grid lines status.
isSelectionAvailable | Public method to check the availability of a selection.
mouseMoveEvent | Protected method to handle mouse move events.
mousePressEvent | Protected method to handle mouse button press events.
mouseReleaseEvent | Protected method to handle mouse button release events.
paintEvent | Protected method called to repaint some of the widget.
penColor | Public method to get the current drawing color.
previewPixmap | Public method to generate a preview pixmap.
setDirty | Public slot to set the dirty flag.
setGridEnabled | Public method to enable the display of grid lines.
setIconImage | Public method to set a new icon image.
setPenColor | Public method to set the drawing color.
setTool | Public method to set the current drawing tool.
setZoomFactor | Public method to set the zoom factor.
shutdown | Public slot to perform some shutdown actions.
sizeHint | Public method to report the size hint.
tool | Public method to get the current drawing tool.
zoomFactor | Public method to get the current zoom factor.

### Static Methods

None

#### IconEditorGrid (Constructor)

IconEditorGrid(parent = None)

Constructor

parent
  reference to the parent widget (QWidget)

#### IconEditorGrid.__checkClipboard

__checkClipboard()

Private slot to check, if the clipboard contains a valid image, and signal the result.

#### IconEditorGrid.__cleanChanged

__cleanChanged(clean)

Private slot to handle the undo stack clean state change.

clean
  flag indicating the clean state (boolean)

#### IconEditorGrid.__clipboardImage

__clipboardImage()

Private method to get an image from the clipboard.

Returns:
  tuple with the image (QImage) and a flag indicating a valid image (boolean)

#### IconEditorGrid.__drawFlood

__drawFlood(i, j, oldColor, doUpdate = True)

Private method to perform a flood fill operation.

i
  x-value in image coordinates (integer)
j
  y-value in image coordinates (integer)
oldColor
  reference to the color at position i, j (QColor)
doUpdate
  flag indicating an update is requested (boolean) (used for speed optimizations)

#### IconEditorGrid.__drawPasteRect

__drawPasteRect(pos)

Private slot to draw a rectangle for signaling a paste operation.

pos
  widget position of the paste rectangle (QPoint)

#### IconEditorGrid.__drawTool

__drawTool(pos, mark)

Public method to perform a draw operation depending of the current tool.

pos
  widget coordinate to perform the draw operation at (QPoint)
mark
  flag indicating a mark operation (boolean)
flag
  indicating a successful draw (boolean)

#### IconEditorGrid.__getSelectionImage

__getSelectionImage(cut)

Private method to get an image from the selection.

cut
  flag indicating to cut the selection (boolean)

Returns:
  image of the selection (QImage)

#### IconEditorGrid.__imageCoordinates

__imageCoordinates(pos)

Private method to convert from widget to image coordinates.

pos
  widget coordinate (QPoint)

Returns:
  tuple with the image coordinates (tuple of two integers)

#### IconEditorGrid.__initCursors

__initCursors()

Private method to initialize the various cursors.

#### IconEditorGrid.__initUndoTexts

__initUndoTexts()

Private method to initialize texts to be associated with undo commands for the various drawing tools.

#### IconEditorGrid.__isMarked

__isMarked(i, j)

Private method to check, if a pixel is marked.

i
  x-value in image coordinates (integer)
j
  y-value in image coordinates (integer)

Returns:
  flag indicating a marked pixel (boolean)

#### IconEditorGrid.__pixelRect

__pixelRect(i, j)

Private method to determine the rectangle for a given pixel coordinate.

i
  x-coordinate of the pixel in the image (integer)
j
  y-coordinate of the pixel in the image (integer) return rectangle for the given pixel coordinates (QRect)

#### IconEditorGrid.__setImagePixel

__setImagePixel(pos, opaque)

Private slot to set or erase a pixel.

pos
  position of the pixel in the widget (QPoint)
opaque
  flag indicating a set operation (boolean)

#### IconEditorGrid.__unMark

__unMark()

Private slot to remove the mark indicator.

#### IconEditorGrid.__updateImageRect

__updateImageRect(ipos1, ipos2)

Private slot to update parts of the widget.

ipos1
  top, left position for the update in image coordinates (QPoint)
ipos2
  bottom, right position for the update in image coordinates (QPoint)

#### IconEditorGrid.__updatePreviewPixmap

__updatePreviewPixmap()

Private slot to generate and signal an updated preview pixmap.

#### IconEditorGrid.__updateRect

__updateRect(pos1, pos2)

Private slot to update parts of the widget.

pos1
  top, left position for the update in widget coordinates (QPoint)
pos2
  bottom, right position for the update in widget coordinates (QPoint)

#### IconEditorGrid.canPaste

canPaste()

Public slot to check the availability of the paste operation.

Returns:
  flag indicating availability of paste (boolean)

#### IconEditorGrid.canRedo

canRedo()

Public method to return the redo status.

Returns:
  flag indicating the availability of redo (boolean)

#### IconEditorGrid.canUndo

canUndo()

Public method to return the undo status.

Returns:
  flag indicating the availability of undo (boolean)

#### IconEditorGrid.editClear

editClear()

Public slot to clear the image.

#### IconEditorGrid.editCopy

editCopy()

Public slot to copy the selection.

#### IconEditorGrid.editCut

editCut()

Public slot to cut the selection.

#### IconEditorGrid.editNew

editNew()

Public slot to generate a new, empty image.

#### IconEditorGrid.editPaste

editPaste(pasting = False)

Public slot to paste an image from the clipboard.

pasting
  flag indicating part two of the paste operation (boolean)

#### IconEditorGrid.editPasteAsNew

editPasteAsNew()

Public slot to paste the clipboard as a new image.

#### IconEditorGrid.editRedo

editRedo()

Public slot to perform a redo operation.

#### IconEditorGrid.editResize

editResize()

Public slot to resize the image.

#### IconEditorGrid.editSelectAll

editSelectAll()

Public slot to select the complete image.

#### IconEditorGrid.editUndo

editUndo()

Public slot to perform an undo operation.

#### IconEditorGrid.grayScale

grayScale()

Public slot to convert the image to gray preserving transparency.

#### IconEditorGrid.iconImage

iconImage()

Public method to get a copy of the icon image.

Returns:
  copy of the icon image (QImage)

#### IconEditorGrid.iconSize

iconSize()

Public method to get the size of the icon.

Returns:
  width and height of the image as a tuple (integer, integer)

#### IconEditorGrid.isDirty

isDirty()

Public method to check the dirty status.

Returns:
  flag indicating a modified status (boolean)

#### IconEditorGrid.isGridEnabled

isGridEnabled()

Public method to get the grid lines status.

Returns:
  enabled status of the grid lines (boolean)

#### IconEditorGrid.isSelectionAvailable

isSelectionAvailable()

Public method to check the availability of a selection.

Returns:
  flag indicating the availability of a selection (boolean)

#### IconEditorGrid.mouseMoveEvent

mouseMoveEvent(evt)

Protected method to handle mouse move events.

evt
  reference to the mouse event object (QMouseEvent)

#### IconEditorGrid.mousePressEvent

mousePressEvent(evt)

Protected method to handle mouse button press events.

evt
  reference to the mouse event object (QMouseEvent)

#### IconEditorGrid.mouseReleaseEvent

mouseReleaseEvent(evt)

Protected method to handle mouse button release events.

evt
  reference to the mouse event object (QMouseEvent)

#### IconEditorGrid.paintEvent

paintEvent(evt)

Protected method called to repaint some of the widget.

evt
  reference to the paint event object (QPaintEvent)

#### IconEditorGrid.penColor

penColor()

Public method to get the current drawing color.

Returns:
  current drawing color (QColor)

#### IconEditorGrid.previewPixmap

previewPixmap()

Public method to generate a preview pixmap.

Returns:
  preview pixmap (QPixmap)

#### IconEditorGrid.setDirty

setDirty(dirty, setCleanState = False)

Public slot to set the dirty flag.

dirty
  flag indicating the new modification status (boolean)
setCleanState
  flag indicating to set the undo stack to clean (boolean)

#### IconEditorGrid.setGridEnabled

setGridEnabled(enable)

Public method to enable the display of grid lines.

enable
  enabled status of the grid lines (boolean)

#### IconEditorGrid.setIconImage

setIconImage(newImage, undoRedo = False, clearUndo = False)

Public method to set a new icon image.

newImage
  reference to the new image (QImage)
undoRedo=
  flag indicating an undo or redo operation (boolean)
clearUndo=
  flag indicating to clear the undo stack (boolean)

#### IconEditorGrid.setPenColor

setPenColor(newColor)

Public method to set the drawing color.

newColor
  reference to the new color (QColor)

#### IconEditorGrid.setTool

setTool(tool)

Public method to set the current drawing tool.

tool
  drawing tool to be used (IconEditorGrid.Pencil ... IconEditorGrid.CircleSelection)

#### IconEditorGrid.setZoomFactor

setZoomFactor(newZoom)

Public method to set the zoom factor.

newZoom
  zoom factor (integer >= 1)

#### IconEditorGrid.shutdown

shutdown()

Public slot to perform some shutdown actions.

#### IconEditorGrid.sizeHint

sizeHint()

Public method to report the size hint.

Returns:
  size hint (QSize)

#### IconEditorGrid.tool

tool()

Public method to get the current drawing tool.

Returns:
  current drawing tool (IconEditorGrid.Pencil ... IconEditorGrid.CircleSelection)

#### IconEditorGrid.zoomFactor

zoomFactor()

Public method to get the current zoom factor.

Returns:
  zoom factor (integer)

Up