# eric7.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.
IconEditorTool | Class defining the edit tools.

### 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 (string)
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(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(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
zoomChanged(int)
  emitted to signal a change of the zoom value

### Derived from

QWidget

### Class Attributes

MarkColor
NoMarkColor
ZoomDefault
ZoomMaximum
ZoomMinimum
ZoomPercent
ZoomStep

### 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 | Private 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.
compositingMode | Public method to get the compositing mode.
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.
setCompositingMode | Public method to set the compositing mode.
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 in percent.
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 in percent.

### 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.

Return:
  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)

Private 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)

Return:
  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)

Return:
  image of the selection (QImage)

#### IconEditorGrid.__imageCoordinates

__imageCoordinates(pos)

Private method to convert from widget to image coordinates.

pos
  widget coordinate (QPoint)

Return:
  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)

Return:
  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.

Return:
  flag indicating availability of paste (boolean)

#### IconEditorGrid.canRedo

canRedo()

Public method to return the redo status.

Return:
  flag indicating the availability of redo (boolean)

#### IconEditorGrid.canUndo

canUndo()

Public method to return the undo status.

Return:
  flag indicating the availability of undo (boolean)

#### IconEditorGrid.compositingMode

compositingMode()

Public method to get the compositing mode.

Return:
  compositing mode (QPainter.CompositionMode)

#### 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.

Return:
  copy of the icon image (QImage)

#### IconEditorGrid.iconSize

iconSize()

Public method to get the size of the icon.

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

#### IconEditorGrid.isDirty

isDirty()

Public method to check the dirty status.

Return:
  flag indicating a modified status (boolean)

#### IconEditorGrid.isGridEnabled

isGridEnabled()

Public method to get the grid lines status.

Return:
  enabled status of the grid lines (boolean)

#### IconEditorGrid.isSelectionAvailable

isSelectionAvailable()

Public method to check the availability of a selection.

Return:
  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.

Return:
  current drawing color (QColor)

#### IconEditorGrid.previewPixmap

previewPixmap()

Public method to generate a preview pixmap.

Return:
  preview pixmap (QPixmap)

#### IconEditorGrid.setCompositingMode

setCompositingMode(mode)

Public method to set the compositing mode.

mode
  compositing mode to set (QPainter.CompositionMode)

#### 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 (IconEditorTool)
  drawing tool to be used

#### IconEditorGrid.setZoomFactor

setZoomFactor(newZoom)

Public method to set the zoom factor in percent.

newZoom
  zoom factor (integer >= 100)

#### IconEditorGrid.shutdown

shutdown()

Public slot to perform some shutdown actions.

#### IconEditorGrid.sizeHint

sizeHint()

Public method to report the size hint.

Return:
  size hint (QSize)

#### IconEditorGrid.tool

tool()

Public method to get the current drawing tool.

Return:
  current drawing tool

Return Type:
  IconEditorTool

#### IconEditorGrid.zoomFactor

zoomFactor()

Public method to get the current zoom factor in percent.

Return:
  zoom factor (integer)

Up

## IconEditorTool

Class defining the edit tools.

### Derived from

enum.IntEnum

### Class Attributes

CIRCLE
COLOR_PICKER
ELLIPSE
FILL
FILLED_CIRCLE
FILLED_ELLIPSE
FILLED_RECTANGLE
LINE
PENCIL
RECTANGLE
RUBBER
SELECT_CIRCLE
SELECT_RECTANGLE

### Class Methods

None

### Methods

None

### Static Methods

None

Up