Ejemplo n.º 1
0
    def __init__(self, parent_window, debug=False):

        self.initialized = False

        self.loadState()

        self.parent_window = parent_window

        self.active = False

        ckit.TextWindow.__init__(
            self,
            x=self.window_normal_x,
            y=self.window_normal_y,
            width=self.window_normal_width,
            height=self.window_normal_height,
            parent_window=parent_window,
            bg_color=ckit.getColor("bg"),
            cursor0_color=ckit.getColor("cursor0"),
            cursor1_color=ckit.getColor("cursor1"),
            border_size=2,
            title_bar=True,
            title=clnch_resource.clnch_appname,
            show=False,
            activate_handler=self._onActivate,
            close_handler=self._onClose,
            move_handler=self._onMove,
            size_handler=self._onSize,
            keydown_handler=self._onKeyDown,
            #char_handler = self._onChar,
            lbuttondown_handler=self._onLeftButtonDown,
            lbuttonup_handler=self._onLeftButtonUp,
            mbuttondown_handler=self._onMiddleButtonDown,
            mbuttonup_handler=self._onMiddleButtonUp,
            rbuttondown_handler=self._onRightButtonDown,
            rbuttonup_handler=self._onRightButtonUp,
            lbuttondoubleclick_handler=self._onLeftButtonDoubleClick,
            mousemove_handler=self._onMouseMove,
            mousewheel_handler=self._onMouseWheel,
        )

        self.plane_scrollbar0 = ckit.ThemePlane3x3(self, 'scrollbar0.png', 2)
        self.plane_scrollbar1 = ckit.ThemePlane3x3(self, 'scrollbar1.png', 1)

        self.debug = debug

        self.log = Log()
        self.scroll_info = ckit.ScrollInfo()

        self.mouse_click_info = None
        self.selection = [[0, 0], [0, 0]]

        self.auto_show = False
        self.auto_show_required = False
        self.setTimer(self.onTimerAutoShow, 10)

        self.initialized = True

        self.paint()
Ejemplo n.º 2
0
        def __init__(self, x, y, parent_window, show=True):

            ckit.TextWindow.__init__(
                self,
                x=x,
                y=y,
                width=29,
                height=2,
                origin=ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
                parent_window=parent_window,
                show=show,
                bg_color=ckit.getColor("bg"),
                cursor0_color=ckit.getColor("cursor0"),
                cursor1_color=ckit.getColor("cursor1"),
                resizable=False,
                title="ホットキー",
                minimizebox=False,
                maximizebox=False,
                cursor=True,
                close_handler=self.onClose,
                keydown_handler=self.onKeyDown,
            )

            self.setCursorPos(-1, -1)

            self.result = RESULT_CANCEL

            activate_vk = clnch_ini.getint("HOTKEY", "activate_vk", 0)
            activate_mod = clnch_ini.getint("HOTKEY", "activate_mod", 0)

            self.activate_hotkey = ckit.HotKeyWidget(self, 0, 0, self.width(),
                                                     1, activate_vk,
                                                     activate_mod)

            self.plane_statusbar = ckit.ThemePlane3x3(self, 'bar.png', 2)
            client_rect = self.getClientRect()
            tmp, statusbar_top = self.charToClient(0, self.height() - 1)
            self.plane_statusbar.setPosSize(0, statusbar_top,
                                            client_rect[2] - 0,
                                            client_rect[3] - statusbar_top)
            self.status_bar = clnch_statusbar.StatusBar()
            self.status_bar_layer = clnch_statusbar.SimpleStatusBarLayer()
            self.status_bar.registerLayer(self.status_bar_layer)

            self.updateStatusBar()

            self.paint()
Ejemplo n.º 3
0
    def __init__(self, desktop, debug=False):

        self.initialized = False

        self.loadState()

        self.font_name = "MS Gothic"
        self.font_size = 12

        # ウインドウの左上位置のDPIによってをフォントサイズ決定する
        dpi_scale = ckit.TextWindow.getDisplayScalingFromPosition(
            self.window_normal_x, self.window_normal_y)
        scaled_font_size = round(self.font_size * dpi_scale)

        ckit.TextWindow.__init__(
            self,
            x=self.window_normal_x,
            y=self.window_normal_y,
            width=self.window_normal_width,
            height=self.window_normal_height,
            font=ckit.getStockedFont(self.font_name, scaled_font_size),
            bg_color=(0, 0, 0),
            border_size=2,
            title_bar=True,
            title="CraftMemo",
            show=cmemo_ini.getint("CONSOLE", "visible", 1),
            sysmenu=True,
            #activate_handler = self._onActivate,
            close_handler=self._onClose,
            move_handler=self._onMove,
            size_handler=self._onSize,
            dpi_handler=self._onDpi,
            keydown_handler=self._onKeyDown,
            #char_handler = self._onChar,
            lbuttondown_handler=self._onLeftButtonDown,
            lbuttonup_handler=self._onLeftButtonUp,
            mbuttondown_handler=self._onMiddleButtonDown,
            mbuttonup_handler=self._onMiddleButtonUp,
            rbuttondown_handler=self._onRightButtonDown,
            rbuttonup_handler=self._onRightButtonUp,
            lbuttondoubleclick_handler=self._onLeftButtonDoubleClick,
            mousemove_handler=self._onMouseMove,
            mousewheel_handler=self._onMouseWheel,
        )

        self.plane_scrollbar0 = ckit.ThemePlane3x3(self, 'scrollbar0.png', 2)
        self.plane_scrollbar1 = ckit.ThemePlane3x3(self, 'scrollbar1.png', 1)

        self.debug = debug

        self.log = Log()
        self.scroll_info = ckit.ScrollInfo()

        self.mouse_click_info = None
        self.selection = [[0, 0], [0, 0]]

        self.setTimer(self._onTimerJob, 10)

        self.initialized = True

        self.paint()

        # モニター境界付近でウインドウが作成された場合を考慮して、DPIを再確認する
        dpi_scale2 = self.getDisplayScaling()
        if dpi_scale2 != dpi_scale:
            self._updateFont(x_center=True)
Ejemplo n.º 4
0
 def createThemePlane(self):
     self.plane_scrollbar0 = ckit.ThemePlane3x3(self, 'scrollbar0.png', 2)
     self.plane_scrollbar1 = ckit.ThemePlane3x3(self, 'scrollbar1.png', 1)
     self.theme_enabled = True
Ejemplo n.º 5
0
    def __init__(self,
                 x,
                 y,
                 min_width,
                 min_height,
                 max_width,
                 max_height,
                 parent_window,
                 font,
                 show=True,
                 title="",
                 items=[],
                 initial_select=0,
                 onekey_search=True,
                 onekey_decide=False,
                 return_modkey=False,
                 keydown_hook=None,
                 statusbar_handler=None):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=5,
            height=5,
            origin=ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,  # 要る?
            font=font,
            bg_color=cmemo_colortable.bg,
            show=False,
            resizable=False,
            title=title,
            minimizebox=False,
            maximizebox=False,
            close_handler=self.onClose,
            keydown_handler=self.onKeyDown,
            char_handler=self.onChar,
        )

        max_item_width = 0
        for item in items:
            if isinstance(item, list) or isinstance(item, tuple):
                item = item[0]
            item_width = self.getStringWidth(item)
            if item_width > max_item_width:
                max_item_width = item_width

        window_width = max_item_width
        window_height = len(items)

        if statusbar_handler:
            window_height += 1

        window_width = min(window_width, max_width)
        window_height = min(window_height, max_height)

        window_width = max(window_width, min_width)
        window_height = max(window_height, min_height)

        self.setPosSize(x=x,
                        y=y,
                        width=window_width,
                        height=window_height,
                        origin=ORIGIN_X_CENTER | ORIGIN_Y_CENTER)
        self.show(show)

        self.command = ckit.CommandMap(self)

        self.title = title
        self.items = items
        self.scroll_info = ckit.ScrollInfo()
        self.select = initial_select
        self.result_mod = 0
        self.onekey_search = onekey_search
        self.onekey_decide = onekey_decide
        self.return_modkey = return_modkey
        self.keydown_hook = keydown_hook
        self.statusbar_handler = statusbar_handler

        self.status_bar = None
        self.status_bar_layer = None
        self.skin_statusbar = None

        self.isearch = None
        self.skin_isearch = None

        if statusbar_handler:
            self.status_bar = cmemo_statusbar.StatusBar()
            self.status_bar_layer = cmemo_statusbar.SimpleStatusBarLayer()
            self.status_bar.registerLayer(self.status_bar_layer)

            self.skin_statusbar = ckit.ThemePlane3x3(self, 'statusbar.png')
            client_rect = self.getClientRect()
            pos1 = self.charToClient(0, self.height() - 1)
            char_w, char_h = self.getCharSize()
            self.skin_statusbar.setPosSize(pos1[0] - char_w // 2, pos1[1],
                                           self.width() * char_w + char_w,
                                           client_rect[3] - pos1[1])
            self.skin_statusbar.show(True)

            self.skin_isearch = ckit.ThemePlane3x3(self, 'isearch.png', 1)
            self.skin_isearch.setPosSize(pos1[0] - char_w // 2, pos1[1],
                                         self.width() * char_w + char_w,
                                         client_rect[3] - pos1[1])
            self.skin_isearch.show(False)

        self.scroll_info.makeVisible(self.select, self.itemsHeight())

        self.configure()

        self.paint()