#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：UiController.py
@Description：
@Author：XSH
@Time：2025/11/17 18:50
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from PyQt5                              import Qt
from AppSettings.Settings               import *
from AppCore.Levels                     import *
from AppUtils.UiUtils                   import UiUtils
from AppInterfaces.UiInterface          import UiInterface, AppUiProperty, AppUtils, AppConvert
from AppInterfaces.ReaderInterfaces     import *
from AppInterfaces.ImplInterfaces       import *
from AppBackEnd.AppBusinessInterface    import AppBusinessInterface
from AppHeadEnd.ControllerFrames.ControlFrameInterface  import ControlFrameInterface

class UiController(Qt.QScrollArea, UiInterface):
    AreaFrame: QWidget
    def __init__(self, widget: Qt.QWidget, parent: Qt.QObject = None):
        super(UiController, self).__init__(parent=parent)
        self.AreaFrame = widget if isinstance(widget, Qt.QWidget) else None
        self.Initialization('UiController', self, parent)
        self.initWidgetStyle()

    def initValue(self):
        super(UiController, self).initValue()

    def initProperty(self):
        super(UiController, self).initProperty()
        self.setFixedSize(1440, 900)

    def initLayouts(self):
        if self.hasWindowLayouts:
            return

        main_layout: Qt.QGridLayout = Qt.QGridLayout()
        main_layout.setSpacing(1)
        main_layout.setContentsMargins(5, 5, 20, 20)
        main_layout.addWidget(self.AreaFrame)
        self.setLayout(main_layout)
        self.setWidget(self.AreaFrame)


    @property
    def hasAreaFrame(self) -> bool:
        return hasattr(self, 'AreaFrame') and isinstance(self.AreaFrame, QWidget)

    @property
    def manipulator(self) -> QWidget:
        return None if not self.hasAreaFrame else self.AreaFrame


