from PyQt4.QtGui import QDockWidget, QWidget, QGraphicsItem, QMessageBox, QTextCursor, QTextCharFormat, QTextBlock\
                        , QTextBlockFormat, QTextFormat, QColor, qRgba, QScrollArea
from PyQt4.QtCore import Qt, pyqtSignal, QRect
from Ui_ToolBox import Ui_ToolBox

class ToolBoxDockWidget(QDockWidget):
    def __init__(self, parent = None):
        QDockWidget.__init__(self, 'Tool Box', parent)
        self.parent = parent
        self.setFeatures(QDockWidget.NoDockWidgetFeatures)#QDockWidget.DockWidgetMovable|QDockWidget.DockWidgetFloatable)
        self.setAllowedAreas(Qt.LeftDockWidgetArea)
        self.setMaximumWidth(280)
        self.setMinimumWidth(280)
        
    def resizeEvent(self, event):
        self.parent.resizeViews()
  
class ToolBox(QWidget):
    
    def __init__(self, main, parent = None):
        QWidget.__init__(self, parent)
        self.scene = main.scene
        self.main = main
        self.parent = parent
        self.ui = Ui_ToolBox()
        self.ui.setupUi(self, main)
        self.scroll = QScrollArea(self)
        self.scroll.setWidget(self.ui.gridWidget)
        self.scroll.setWidgetResizable(True)
        
    def resizeEvent(self, event):
        self.scroll.setGeometry(0, 0, self.geometry().width(), self.geometry().height())

    def enableNormalMode(self):
        self.scene.main.mode = self.scene.main.NORMAL_MODE

    def enableHighlightMode(self):
        self.scene.main.mode = self.scene.main.HIGHLIGHT_MODE
            