def popCommandWindow( parent_window, name, file, param, directory ): pos = parent_window.centerOfWindowInPixel() command_window = CommandWindow( pos[0], pos[1], parent_window, name, file, param, directory ) clnch_misc.adjustWindowPosition( parent_window, command_window, default_up=True ) command_window.show(True) parent_window.enable(False) command_window.messageLoop() result = command_window.getResult() parent_window.enable(True) parent_window.activate() command_window.destroy() return result
def popMenu( main_window, max_width=None, max_height=None, title="", items=[], initial_select=0, onekey_search=True, onekey_decide=False, return_modkey=False, keydown_hook=None, statusbar_handler=None ): pos = main_window.centerOfWindowInPixel() list_window = ListWindow( pos[0], pos[1], 5, 1, max_width, max_height, main_window, False, title, items, initial_select=initial_select, onekey_search=onekey_search, onekey_decide=onekey_decide, return_modkey=return_modkey, keydown_hook=keydown_hook, statusbar_handler=statusbar_handler ) clnch_misc.adjustWindowPosition( main_window, list_window, default_up=False ) list_window.show(True) main_window.enable(False) list_window.messageLoop() result = list_window.getResult() main_window.enable(True) main_window.activate() list_window.destroy() return result
def popMessageBox( main_window, msgbox_type, title, message, return_modkey=False ): main_window_rect = main_window.getWindowRect() pos = ( (main_window_rect[0]+main_window_rect[2])//2, (main_window_rect[1]+main_window_rect[3])//2 ) msgbox = MessageBox( pos[0], pos[1], main_window, False, msgbox_type, title, message, return_modkey ) clnch_misc.adjustWindowPosition( main_window, msgbox, default_up=False ) msgbox.show(True) main_window.enable(False) msgbox.messageLoop() result = msgbox.getResult() main_window.enable(True) main_window.activate() msgbox.destroy() return result
def popCommandWindow(parent_window, name, file, param, directory): pos = parent_window.centerOfWindowInPixel() command_window = CommandWindow(pos[0], pos[1], parent_window, name, file, param, directory) clnch_misc.adjustWindowPosition(parent_window, command_window, default_up=True) command_window.show(True) parent_window.enable(False) command_window.messageLoop() result = command_window.getResult() parent_window.enable(True) parent_window.activate() command_window.destroy() return result
def popMessageBox(main_window, msgbox_type, title, message, return_modkey=False): main_window_rect = main_window.getWindowRect() pos = ((main_window_rect[0] + main_window_rect[2]) // 2, (main_window_rect[1] + main_window_rect[3]) // 2) msgbox = MessageBox(pos[0], pos[1], main_window, False, msgbox_type, title, message, return_modkey) clnch_misc.adjustWindowPosition(main_window, msgbox, default_up=False) msgbox.show(True) main_window.enable(False) msgbox.messageLoop() result = msgbox.getResult() main_window.enable(True) main_window.activate() msgbox.destroy() return result
def popMenu(main_window, max_width=None, max_height=None, title="", items=[], initial_select=0, onekey_search=True, onekey_decide=False, return_modkey=False, keydown_hook=None, statusbar_handler=None): pos = main_window.centerOfWindowInPixel() list_window = ListWindow(pos[0], pos[1], 5, 1, max_width, max_height, main_window, False, title, items, initial_select=initial_select, onekey_search=onekey_search, onekey_decide=onekey_decide, return_modkey=return_modkey, keydown_hook=keydown_hook, statusbar_handler=statusbar_handler) clnch_misc.adjustWindowPosition(main_window, list_window, default_up=False) list_window.show(True) main_window.enable(False) list_window.messageLoop() result = list_window.getResult() main_window.enable(True) main_window.activate() list_window.destroy() return result
def show( self, show, activate=True ): clnch_misc.adjustWindowPosition( self.parent_window, self, default_up=True ) ckit.TextWindow.show( self, show, activate )
def _configHotKeyAssign(main_window): RESULT_CANCEL = 0 RESULT_OK = 1 class HotKeyWindow(ckit.TextWindow): 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() def onClose(self): self.result = RESULT_CANCEL self.quit() def onEnter(self): self.result = RESULT_OK self.quit() def onKeyDown(self, vk, mod): if mod == 0 and vk == VK_ESCAPE: self.result = RESULT_CANCEL self.quit() elif mod == 0 and vk == VK_RETURN: self.result = RESULT_OK self.quit() else: self.activate_hotkey.onKeyDown(vk, mod) def updateStatusBar(self): self.status_bar_layer.setMessage("Return:決定 Esc:キャンセル") def paint(self): self.activate_hotkey.enableCursor(True) self.activate_hotkey.paint() self.status_bar.paint(self, 0, self.height() - 1, self.width(), 1) def getResult(self): if self.result: return [self.activate_hotkey.getValue()] else: return None pos = main_window.centerOfWindowInPixel() hotkey_window = HotKeyWindow(pos[0], pos[1], main_window, show=False) clnch_misc.adjustWindowPosition(main_window, hotkey_window, default_up=False) hotkey_window.show(True) main_window.enable(False) hotkey_window.messageLoop() result = hotkey_window.getResult() main_window.enable(True) main_window.activate() hotkey_window.destroy() if result == None: return clnch_ini.set("HOTKEY", "activate_vk", str(result[0][0])) clnch_ini.set("HOTKEY", "activate_mod", str(result[0][1])) main_window.updateHotKey()
def _configHotKeyAssign(main_window): RESULT_CANCEL = 0 RESULT_OK = 1 class HotKeyWindow(ckit.Window): def __init__(self, x, y, parent_window, show=True): ckit.Window.__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() def onClose(self): self.result = RESULT_CANCEL self.quit() def onEnter(self): self.result = RESULT_OK self.quit() def onKeyDown(self, vk, mod): if mod == 0 and vk == VK_ESCAPE: self.result = RESULT_CANCEL self.quit() elif mod == 0 and vk == VK_RETURN: self.result = RESULT_OK self.quit() else: self.activate_hotkey.onKeyDown(vk, mod) def updateStatusBar(self): self.status_bar_layer.setMessage("Return:決定 Esc:キャンセル") def paint(self): self.activate_hotkey.enableCursor(True) self.activate_hotkey.paint() self.status_bar.paint(self, 0, self.height() - 1, self.width(), 1) def getResult(self): if self.result: return [self.activate_hotkey.getValue()] else: return None pos = main_window.centerOfWindowInPixel() hotkey_window = HotKeyWindow(pos[0], pos[1], main_window, show=False) clnch_misc.adjustWindowPosition(main_window, hotkey_window, default_up=False) hotkey_window.show(True) main_window.enable(False) hotkey_window.messageLoop() result = hotkey_window.getResult() main_window.enable(True) main_window.activate() hotkey_window.destroy() if result == None: return clnch_ini.set("HOTKEY", "activate_vk", str(result[0][0])) clnch_ini.set("HOTKEY", "activate_mod", str(result[0][1])) main_window.updateHotKey()
def show(self, show, activate=True): clnch_misc.adjustWindowPosition(self.parent_window, self, default_up=True) ckit.TextWindow.show(self, show, activate)