Пример #1
0
    def paint(self):

        attribute_normal = ckit.Attribute( fg=ckit.getColor("fg"))
        attribute_normal_selected = ckit.Attribute( fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg"))

        if self.focus==RenameWindow.FOCUS_FILENAME:
            attr = attribute_normal_selected
        else:
            attr = attribute_normal
        self.putString( 2, 1, self.width()-2, 1, attr, "名前" )

        self.filename_edit.enableCursor(self.focus==RenameWindow.FOCUS_FILENAME)
        self.filename_edit.paint()


        if self.focus==RenameWindow.FOCUS_TIMESTAMP:
            attr = attribute_normal_selected
        else:
            attr = attribute_normal
        self.putString( 2, 3, self.width()-2, 1, attr, "タイムスタンプ" )

        self.timestamp_edit.enableCursor(self.focus==RenameWindow.FOCUS_TIMESTAMP)
        self.timestamp_edit.paint()

        self.readonly_checkbox.enableCursor(self.focus==RenameWindow.FOCUS_READONLY)
        self.readonly_checkbox.paint()

        self.system_checkbox.enableCursor(self.focus==RenameWindow.FOCUS_SYSTEM)
        self.system_checkbox.paint()

        self.hidden_checkbox.enableCursor(self.focus==RenameWindow.FOCUS_HIDDEN)
        self.hidden_checkbox.paint()

        self.archive_checkbox.enableCursor(self.focus==RenameWindow.FOCUS_ARCHIVE)
        self.archive_checkbox.paint()
Пример #2
0
    def __init__( self, x, y, parent_window, ini, items ):

        self.ini = ini

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=42,
            height=9,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            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,
            char_handler = self.onChar,
            )

        self.setCursorPos( -1, -1 )

        self.items = items
        self.focus = BatchRenameWindow.FOCUS_OLD
        self.result = BatchRenameWindow.RESULT_CANCEL

        old = ini.get( "BATCHRENAME", "old" )
        new = ini.get( "BATCHRENAME", "new" )
        regexp = ini.getint( "BATCHRENAME", "regexp" )
        ignorecase = ini.getint( "BATCHRENAME", "ignorecase" )

        self.old_edit = ckit.EditWidget( self, 10, 1, self.width()-12, 1, old, [ 0, len(old) ] )
        self.new_edit = ckit.EditWidget( self, 10, 3, self.width()-12, 1, new, [ 0, len(new) ] )
        self.regexp_checkbox = ckit.CheckBoxWidget( self, 2, 5, self.width()-4, 1, "正規表現", regexp )
        self.ignorecase_checkbox = ckit.CheckBoxWidget( self, 2, 6, self.width()-4, 1, "大文字/小文字を無視", ignorecase )

        client_rect = self.getClientRect()
        offset_x, offset_y = self.charToClient( 0, 0 )
        char_w, char_h = self.getCharSize()
        self.plane_statusbar = ckit.ThemePlane3x3( self, 'statusbar.png' )
        self.plane_statusbar.setPosSize( 0, (self.height()-1)*char_h+offset_y, client_rect[2], client_rect[3]-(self.height()-1)*char_h+offset_y )
        self.status_bar = cfiler_statusbar.StatusBar()
        self.status_bar_layer = cfiler_statusbar.SimpleStatusBarLayer()
        self.status_bar.registerLayer(self.status_bar_layer)

        self.updateStatusBar()

        try:
            self.wallpaper = ckit.Wallpaper(self)
            self.wallpaper.copy( parent_window )
            self.wallpaper.adjust()
        except AttributeError:
            self.wallpaper = None

        self.paint()
Пример #3
0
    def paint(self):

        attribute_normal = ckit.Attribute( fg=ckit.getColor("fg") )
        attribute_normal_selected = ckit.Attribute( fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg") )

        message_width = self.getStringWidth(self.message)
        self.putString( (self.width()-message_width)//2, 1, message_width, 1, attribute_normal, self.message )

        if self.msgbox_type==MSGBOX_TYPE_OK:
            btn_string = " OK "
            btn_width = self.getStringWidth(btn_string)
            self.putString( (self.width()-btn_width)//2, 3, btn_width, 1, attribute_normal_selected, btn_string )

        elif self.msgbox_type==MSGBOX_TYPE_YESNO:

            btn1_string = "はい"
            btn1_width = self.getStringWidth(btn1_string)
            btn2_string = "いいえ"
            btn2_width = self.getStringWidth(btn2_string)

            if self.focus==MessageBox.BUTTON_YES:
                attr = attribute_normal_selected
            else:
                attr = attribute_normal

            self.putString( (self.width()-btn1_width-btn2_width-4)//2, 3, btn1_width, 1, attr, btn1_string )

            if self.focus==MessageBox.BUTTON_NO:
                attr = attribute_normal_selected
            else:
                attr = attribute_normal

            self.putString( (self.width()+btn1_width-btn2_width+4)//2, 3, btn2_width, 1, attr, btn2_string )
Пример #4
0
    def __init__( self, x, y, parent_window, name, file, param, directory ):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=80,
            height=9,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            bg_color = ckit.getColor("bg"),
            cursor0_color = ckit.getColor("cursor0"),
            cursor1_color = ckit.getColor("cursor1"),
            show = False,
            resizable = False,
            title = "Command",
            minimizebox = False,
            maximizebox = False,
            cursor = True,
            close_handler = self.onClose,
            keydown_handler = self.onKeyDown,
            char_handler = self.onChar,
            )

        self.setCursorPos( -1, -1 )

        self.focus = CommandWindow.FOCUS_NAME
        self.result = COMMANDWINDOW_RESULT_CANCEL

        self.name_edit      = ckit.EditWidget( self, 16, 1, self.width()-18, 1, name, [ 0, len(name) ] )
        self.file_edit      = ckit.EditWidget( self, 16, 3, self.width()-18, 1, file, [ 0, len(file) ] )
        self.param_edit     = ckit.EditWidget( self, 16, 5, self.width()-18, 1, param, [ 0, len(param) ] )
        self.directory_edit = ckit.EditWidget( self, 16, 7, self.width()-18, 1, directory, [ 0, len(directory) ] )

        self.paint()
Пример #5
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 = False,
            title = clnch_resource.clnch_appname + " Console",
            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()
Пример #6
0
    def paint(self):

        attribute_normal = ckit.Attribute( fg=ckit.getColor("fg"))
        attribute_normal_selected = ckit.Attribute( fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg"))

        if self.focus==BatchRenameWindow.FOCUS_OLD:
            attr = attribute_normal_selected
        else:
            attr = attribute_normal
        self.putString( 2, 1, self.width()-2, 1, attr, "置換前" )

        self.old_edit.enableCursor(self.focus==BatchRenameWindow.FOCUS_OLD)
        self.old_edit.paint()


        if self.focus==BatchRenameWindow.FOCUS_NEW:
            attr = attribute_normal_selected
        else:
            attr = attribute_normal
        self.putString( 2, 3, self.width()-2, 1, attr, "置換後" )

        self.new_edit.enableCursor(self.focus==BatchRenameWindow.FOCUS_NEW)
        self.new_edit.paint()

        self.regexp_checkbox.enableCursor(self.focus==BatchRenameWindow.FOCUS_REGEXP)
        self.regexp_checkbox.paint()

        self.ignorecase_checkbox.enableCursor(self.focus==BatchRenameWindow.FOCUS_IGNORECASE)
        self.ignorecase_checkbox.paint()

        self.status_bar.paint( self, 0, self.height()-1, self.width(), 1 )
Пример #7
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()
Пример #8
0
 def paint(self, window, x, y, width, height):
     s = " %s" % (self.message)
     s = ckit.adjustStringWidth(window, s, width - 1)
     if self.error:
         attr = ckit.Attribute(fg=ckit.getColor("bar_error_fg"))
     else:
         attr = ckit.Attribute(fg=ckit.getColor("bar_fg"))
     window.putString(x, y, width, height, attr, s)
Пример #9
0
 def paint( self, window, x, y, width, height ):
     s = " %s" % ( self.message )
     s = ckit.adjustStringWidth( window, s, width-1 )
     if self.error:
         attr = ckit.Attribute(fg=ckit.getColor("bar_error_fg"))
     else:
         attr = ckit.Attribute( fg=ckit.getColor("bar_fg") )
     window.putString( x, y, width, height, attr, s )
Пример #10
0
    def __init__(self,
                 x,
                 y,
                 parent_window,
                 show=True,
                 msgbox_type=MSGBOX_TYPE_OK,
                 title="",
                 message="",
                 return_modkey=False):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=5,
            height=5,
            origin=ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            bg_color=ckit.getColor("bg"),
            cursor0_color=ckit.getColor("cursor0"),
            cursor1_color=ckit.getColor("cursor1"),
            show=False,
            resizable=False,
            title=title,
            minimizebox=False,
            maximizebox=False,
            close_handler=self.onClose,
            keydown_handler=self.onKeyDown,
        )

        message_width = self.getStringWidth(message)

        window_width = message_width + 2
        if window_width < 20: window_width = 20

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

        self.msgbox_type = msgbox_type
        self.message = message
        self.return_modkey = return_modkey

        if self.msgbox_type == MSGBOX_TYPE_OK:
            self.focus = MessageBox.BUTTON_OK
        elif self.msgbox_type == MSGBOX_TYPE_YESNO:
            self.focus = MessageBox.BUTTON_YES
        else:
            assert (False)

        self.result = MSGBOX_RESULT_CANCEL
        self.result_mod = 0

        self.paint()
Пример #11
0
        def paint(self):

            if self.focus==AppNameWindow.FOCUS_EDIT:
                attr = ckit.Attribute( fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg"))
            else:
                attr = ckit.Attribute( fg=ckit.getColor("fg"))
            self.putString( 2, 1, self.width()-2, 1, attr, "アプリケーション名" )

            self.edit.enableCursor(self.focus==AppNameWindow.FOCUS_EDIT)
            self.edit.paint()
Пример #12
0
    def __init__( self, x, y, parent_window, ini, item ):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=42,
            height=10,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            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,
            char_handler = self.onChar,
            )

        self.setCursorPos( -1, -1 )

        self.item = item
        self.focus = RenameWindow.FOCUS_FILENAME
        self.result = RenameWindow.RESULT_CANCEL

        basename = os.path.basename( item.getNameNfc() )

        last_period_pos = basename.rfind(".")
        if last_period_pos>0 and last_period_pos>=len(basename)-5:
            selection = [ last_period_pos, last_period_pos ]
        else:
            selection = None

        self.filename_edit = ckit.EditWidget( self, 8, 1, self.width()-10, 1, basename, selection )

        self.timestamp_edit = ckit.TimeWidget( self, 18, 3, item.time() )

        self.original_attribute = item.attr()
        self.readonly_checkbox = ckit.CheckBoxWidget( self, 2, 5, self.width()-4, 1, "Read Only", self.original_attribute & ckit.FILE_ATTRIBUTE_READONLY )
        self.system_checkbox = ckit.CheckBoxWidget(   self, 2, 6, self.width()-4, 1, "System   ", self.original_attribute & ckit.FILE_ATTRIBUTE_SYSTEM )
        self.hidden_checkbox = ckit.CheckBoxWidget(   self, 2, 7, self.width()-4, 1, "Hidden   ", self.original_attribute & ckit.FILE_ATTRIBUTE_HIDDEN )
        self.archive_checkbox = ckit.CheckBoxWidget(  self, 2, 8, self.width()-4, 1, "Archive  ", self.original_attribute & ckit.FILE_ATTRIBUTE_ARCHIVE )

        try:
            self.wallpaper = ckit.Wallpaper(self)
            self.wallpaper.copy( parent_window )
            self.wallpaper.adjust()
        except AttributeError:
            self.wallpaper = None

        self.paint()
Пример #13
0
    def paint( self, window, x, y, width, cursor, itemformat, userdata ):

        if self.isdir():
            if self.ishidden():
                attr_fg=ckit.getColor("hidden_dir_fg")
            else:
                attr_fg=ckit.getColor("dir_fg")
        else:
            if self.ishidden():
                attr_fg=ckit.getColor("hidden_file_fg")
            else:
                attr_fg=ckit.getColor("file_fg")

        if self.selected():
            attr_bg_gradation=( ckit.getColor("select_file_bg1"), ckit.getColor("select_file_bg2"), ckit.getColor("select_file_bg1"), ckit.getColor("select_file_bg2"))
        elif self.bookmark():
            attr_bg_gradation=( ckit.getColor("bookmark_file_bg1"), ckit.getColor("bookmark_file_bg2"), ckit.getColor("bookmark_file_bg1"), ckit.getColor("bookmark_file_bg2"))
        else:
            attr_bg_gradation = None

        if cursor:
            line0=( LINE_BOTTOM, ckit.getColor("file_cursor") )
        else:
            line0=None
        
        attr = ckit.Attribute( fg=attr_fg, bg_gradation=attr_bg_gradation, line0=line0 )

        s = itemformat( window, self, width, userdata )
        window.putString( x, y, width, 1, attr, s )
Пример #14
0
    def paint( self, window, x, y, width, cursor, itemformat, userdata ):
        if cursor:
            line0=( LINE_BOTTOM, ckit.getColor("file_cursor") )
        else:
            line0=None

        attr = ckit.Attribute( fg=ckit.getColor("error_file_fg"), line0=line0 )

        s = "- no item -"
        s = ckit.adjustStringWidth(window,s,width,ckit.ALIGN_CENTER)
        window.putString( x, y, width, 1, attr, s )
Пример #15
0
    def __init__( self, x, y, width, height, parent_window, ini, title, items, selection, cursor_handler, select_handler ):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=width,
            height=height,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            bg_color = ckit.getColor("bg"),
            cursor0_color = ckit.getColor("cursor0"),
            cursor1_color = ckit.getColor("cursor1"),
            resizable = True,
            title = title,
            minimizebox = True,
            maximizebox = True,
            sysmenu = True,
            close_handler = self.onClose,
            size_handler = self.onSize,
            keydown_handler = self.onKeyDown,
            )

        self.ini = ini

        self.command = ckit.CommandMap(self)

        client_rect = self.getClientRect()
        offset_x, offset_y = self.charToClient( 0, 0 )
        char_w, char_h = self.getCharSize()
        self.plane_statusbar = ckit.ThemePlane3x3( self, 'statusbar.png' )
        self.status_bar = cfiler_statusbar.StatusBar()
        self.status_bar_layer = cfiler_statusbar.SimpleStatusBarLayer()
        self.status_bar.registerLayer(self.status_bar_layer)

        self.job_queue = ckit.JobQueue()
        self.items = items
        self.cursor = selection
        self.plane = None
        self.img = None
        self.zoom_policy = self.ini.get( "IMAGEVIEWER", "zoom_policy" ).lower()
        if self.zoom_policy=="fit":
            self.fit = True
        else:
            self.fit = False
        self.pos = [0,0]
        
        self.cursor_handler = cursor_handler
        self.select_handler = select_handler

        self.configure()

        self.decode()
Пример #16
0
    def __init__( self, x, y, parent_window, ini ):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=42,
            height=7,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            bg_color = ckit.getColor("bg"),
            cursor0_color = ckit.getColor("cursor0"),
            cursor1_color = ckit.getColor("cursor1"),
            resizable = False,
            title = 'Grep',
            minimizebox = False,
            maximizebox = False,
            cursor = True,
            close_handler = self.onClose,
            keydown_handler = self.onKeyDown,
            char_handler = self.onChar,
            )

        self.setCursorPos( -1, -1 )

        self.focus = GrepWindow.FOCUS_PATTERN
        self.result = GrepWindow.RESULT_CANCEL
        self.ini = ini

        self.grep_history = cfiler_history.History()
        self.grep_history.load( self.ini, "GREP" )

        if len(self.grep_history.items)>0:
            pattern = self.grep_history.items[0]
        else:
            pattern = ""
        recursive = ini.getint( "GREP", "recursive" )
        regexp = ini.getint( "GREP", "regexp" )
        ignorecase = ini.getint( "GREP", "ignorecase" )

        self.pattern_edit = ckit.EditWidget( self, 14, 1, self.width()-16, 1, pattern, [ 0, len(pattern) ], candidate_handler=self.grep_history.candidateHandler, candidate_remove_handler=self.grep_history.candidateRemoveHandler )
        self.recursive_checkbox = ckit.CheckBoxWidget( self, 2, 3, self.width()-4, 1, "サブディレクトリ", recursive )
        self.regexp_checkbox = ckit.CheckBoxWidget( self, 2, 4, self.width()-4, 1, "正規表現", regexp )
        self.ignorecase_checkbox = ckit.CheckBoxWidget( self, 2, 5, self.width()-4, 1, "大文字/小文字を無視", ignorecase )

        try:
            self.wallpaper = ckit.Wallpaper(self)
            self.wallpaper.copy( parent_window )
            self.wallpaper.adjust()
        except AttributeError:
            self.wallpaper = None

        self.paint()
Пример #17
0
    def __init__( self, x, y, parent_window, ini, items ):

        self.ini = ini

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=44,
            height=13,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            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,
            char_handler = self.onChar,
            )

        self.setCursorPos( -1, -1 )

        self.focus = MultiRenameWindow.FOCUS_RECURSIVE
        self.result = MultiRenameWindow.RESULT_CANCEL

        self.recursive_checkbox = ckit.CheckBoxWidget( self, 2, 1, self.width()-4, 1, "Recursive", True )

        timestamp = time.localtime( time.time() )[:6]
        self.timestamp_checkbox = ckit.CheckBoxWidget( self, 2, 3, self.width()-4, 1, "タイムスタンプ", False )
        self.timestamp_edit = ckit.TimeWidget( self, 20, 3, timestamp )

        self.allcase_choice  = ckit.ChoiceWidget( self, 2,  5, self.width()-4, 1, "全体     ", [ "小文字", "変更なし", "大文字" ], 1 )
        self.extcase_choice  = ckit.ChoiceWidget( self, 2,  6, self.width()-4, 1, "拡張子   ", [ "小文字", "変更なし", "大文字" ], 1 )
        self.readonly_choice = ckit.ChoiceWidget( self, 2,  8, self.width()-4, 1, "Read Only   ", [ "OFF", "変更なし", "ON" ], 1 )
        self.system_choice   = ckit.ChoiceWidget( self, 2,  9, self.width()-4, 1, "System      ", [ "OFF", "変更なし", "ON" ], 1 )
        self.hidden_choice   = ckit.ChoiceWidget( self, 2, 10, self.width()-4, 1, "Hidden      ", [ "OFF", "変更なし", "ON" ], 1 )
        self.archive_choice  = ckit.ChoiceWidget( self, 2, 11, self.width()-4, 1, "Archive     ", [ "OFF", "変更なし", "ON" ], 1 )

        self.items = items

        try:
            self.wallpaper = ckit.Wallpaper(self)
            self.wallpaper.copy( parent_window )
            self.wallpaper.adjust()
        except AttributeError:
            self.wallpaper = None

        self.paint()
Пример #18
0
    def __init__( self, x, y, parent_window, show=True, msgbox_type=MSGBOX_TYPE_OK, title="", message="", return_modkey=False ):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=5,
            height=5,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            bg_color = ckit.getColor("bg"),
            cursor0_color = ckit.getColor("cursor0"),
            cursor1_color = ckit.getColor("cursor1"),
            show = False,
            resizable = False,
            title = title,
            minimizebox = False,
            maximizebox = False,
            close_handler = self.onClose,
            keydown_handler = self.onKeyDown,
            )

        message_width = self.getStringWidth(message)

        window_width = message_width + 2
        if window_width<20 : window_width=20

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

        self.msgbox_type = msgbox_type
        self.message = message
        self.return_modkey = return_modkey

        if self.msgbox_type==MSGBOX_TYPE_OK:
            self.focus = MessageBox.BUTTON_OK
        elif self.msgbox_type==MSGBOX_TYPE_YESNO:
            self.focus = MessageBox.BUTTON_YES
        else:
            assert(False)

        self.result = MSGBOX_RESULT_CANCEL
        self.result_mod = 0

        self.paint()
Пример #19
0
    def paint(self):

        attribute_normal = ckit.Attribute( fg=ckit.getColor("fg"))
        attribute_normal_selected = ckit.Attribute( fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg"))

        if self.select==OverWriteWindow.RESULT_FORCE:
            attr = attribute_normal_selected
            self.setCursorPos( -1, -1 )
        else:
            attr = attribute_normal
        self.putString( 2, 1, self.width()-4, 1, attr, "F 上書き" )


        if self.select==OverWriteWindow.RESULT_TIMESTAMP:
            attr = attribute_normal_selected
            self.setCursorPos( -1, -1 )
        else:
            attr = attribute_normal
        self.putString( 2, 3, self.width()-4, 1, attr, "T 新しければ上書き" )


        if self.select==OverWriteWindow.RESULT_NO:
            attr = attribute_normal_selected
            self.setCursorPos( -1, -1 )
        else:
            attr = attribute_normal
        self.putString( 2, 5, self.width()-4, 1, attr, "N 複写しない" )


        if self.select==OverWriteWindow.RESULT_RENAME:
            attr = attribute_normal_selected
            self.setCursorPos( -1, -1 )
        else:
            attr = attribute_normal
        self.putString( 2, 7, self.width()-4, 1, attr, "R 改名" )

        self.edit.enableCursor(self.select==OverWriteWindow.RESULT_RENAME)
        self.edit.paint()

        attr = attribute_normal

        def strTime(t):
            return "%02d/%02d/%02d %02d:%02d:%02d" % ( t[0]%100, t[1], t[2], t[3], t[4], t[5] )

        self.putString( 2, 9, 18, 1, attr, "Src : %s" % ( self.src_item.getNameNfc(), ) )
        self.putString( 20, 9, self.width()-20, 1, attr, "%6s %s" % ( cfiler_misc.getFileSizeString(self.src_item.size()), strTime(self.src_item.time()) ) )

        self.putString( 2, 10, 18, 1, attr, "Dst : %s" % ( self.dst_item.getNameNfc(), ) )
        self.putString( 20, 10, self.width()-20, 1, attr, "%6s %s" % ( cfiler_misc.getFileSizeString(self.dst_item.size()), strTime(self.dst_item.time()) ) )
Пример #20
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()
Пример #21
0
        def __init__( self, x, y, parent_window, ini ):

            ckit.TextWindow.__init__(
                self,
                x=x,
                y=y,
                width=22,
                height=6,
                origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
                parent_window=parent_window,
                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.focus = ConfigConfirmWindow.FOCUS_COPY
            self.result = ConfigConfirmWindow.RESULT_CANCEL

            confirm_copy = main_window.ini.getint( "MISC", "confirm_copy" )
            confirm_move = main_window.ini.getint( "MISC", "confirm_move" )
            confirm_extract = main_window.ini.getint( "MISC", "confirm_extract" )
            confirm_quit = main_window.ini.getint( "MISC", "confirm_quit" )

            self.confirm_copy_checkbox    = ckit.CheckBoxWidget( self, 2, 1, self.width()-4, 1, "コピー",         confirm_copy )
            self.confirm_move_checkbox    = ckit.CheckBoxWidget( self, 2, 2, self.width()-4, 1, "移動",           confirm_move )
            self.confirm_extract_checkbox = ckit.CheckBoxWidget( self, 2, 3, self.width()-4, 1, "アーカイブ展開", confirm_extract )
            self.confirm_quit_checkbox    = ckit.CheckBoxWidget( self, 2, 4, self.width()-4, 1, "終了",           confirm_quit )

            try:
                self.wallpaper = ckit.Wallpaper(self)
                self.wallpaper.copy( parent_window )
                self.wallpaper.adjust()
            except AttributeError:
                self.wallpaper = None

            self.paint()
Пример #22
0
    def paint(self):

        x = 0
        y = 0
        width = self.width()
        height = self.itemsHeight()

        attribute_normal = ckit.Attribute(fg=ckit.getColor("fg"))
        attribute_normal_selected = ckit.Attribute(
            fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg"))

        for i in range(height):
            index = self.scroll_info.pos + i
            if index < len(self.items):

                item = self.items[index]
                if isinstance(item, list) or isinstance(item, tuple):
                    item = item[0]

                if self.select == index:
                    attr = attribute_normal_selected
                else:
                    attr = attribute_normal
                self.putString(x, y + i, width, 1, attr, " " * width)
                self.putString(x, y + i, width, 1, attr, item)
            else:
                self.putString(x, y + i, width, 1, attribute_normal,
                               " " * width)

        if self.status_bar:
            if self.isearch:
                attr = ckit.Attribute(fg=ckit.getColor("fg"))
                s = " Search : %s_" % (self.isearch.isearch_value)
                s = ckit.adjustStringWidth(self, s, width - 1)
                self.putString(0, self.height() - 1, width - 1, 1, attr, s)
            else:
                self.status_bar_layer.setMessage(
                    self.statusbar_handler(width, self.select))
                self.status_bar.paint(self, 0, self.height() - 1, width, 1)
        else:
            if self.isearch:
                s = " Search : %s_" % (self.isearch.isearch_value)
                self.setTitle(s)
            else:
                self.setTitle(self.title)
Пример #23
0
 def paint( self, window, x, y, width, height ):
     if self.music_player.position!=None and self.music_player.length!=None:
         right = " %s - %s " % ( _timeString(self.music_player.position), _timeString(self.music_player.length-self.music_player.position) )
     else:
         right = " "
     left = " [ Music %d/%d ] %s" % ( self.music_player.cursor+1, len(self.music_player.items), self.music_player.song_name )
     left = ckit.adjustStringWidth( window, left, width-len(right), ckit.ALIGN_LEFT, ckit.ELLIPSIS_RIGHT )
     attr = ckit.Attribute( fg=ckit.getColor("bar_fg"))
     window.putString( x, y, width, y, attr, left+right )
Пример #24
0
        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()
Пример #25
0
    def paint(self):

        if self.focus==GrepWindow.FOCUS_PATTERN:
            attr = ckit.Attribute( fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg"))
        else:
            attr = ckit.Attribute( fg=ckit.getColor("fg"))
        self.putString( 2, 1, self.width()-2, 1, attr, "検索文字列" )

        self.pattern_edit.enableCursor(self.focus==GrepWindow.FOCUS_PATTERN)
        self.pattern_edit.paint()

        self.recursive_checkbox.enableCursor(self.focus==GrepWindow.FOCUS_RECURSIVE)
        self.recursive_checkbox.paint()

        self.regexp_checkbox.enableCursor(self.focus==GrepWindow.FOCUS_REGEXP)
        self.regexp_checkbox.paint()

        self.ignorecase_checkbox.enableCursor(self.focus==GrepWindow.FOCUS_IGNORECASE)
        self.ignorecase_checkbox.paint()
Пример #26
0
    def __init__(self, x, y, parent_window, name, file, param, directory):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=80,
            height=9,
            origin=ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            bg_color=ckit.getColor("bg"),
            cursor0_color=ckit.getColor("cursor0"),
            cursor1_color=ckit.getColor("cursor1"),
            show=False,
            resizable=False,
            title="Command",
            minimizebox=False,
            maximizebox=False,
            cursor=True,
            close_handler=self.onClose,
            keydown_handler=self.onKeyDown,
            char_handler=self.onChar,
        )

        self.setCursorPos(-1, -1)

        self.focus = CommandWindow.FOCUS_NAME
        self.result = COMMANDWINDOW_RESULT_CANCEL

        self.name_edit = ckit.EditWidget(self, 16, 1,
                                         self.width() - 18, 1, name,
                                         [0, len(name)])
        self.file_edit = ckit.EditWidget(self, 16, 3,
                                         self.width() - 18, 1, file,
                                         [0, len(file)])
        self.param_edit = ckit.EditWidget(self, 16, 5,
                                          self.width() - 18, 1, param,
                                          [0, len(param)])
        self.directory_edit = ckit.EditWidget(self, 16, 7,
                                              self.width() - 18, 1, directory,
                                              [0, len(directory)])

        self.paint()
Пример #27
0
    def paint(self):

        x = 0
        y = 0
        width = self.width()
        height = self.itemsHeight()

        attribute_normal = ckit.Attribute(fg=ckit.getColor("fg"))
        attribute_normal_selected = ckit.Attribute(fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg"))

        for i in range(height):
            index = self.scroll_info.pos + i
            if index < len(self.items):

                item = self.items[index]
                if isinstance(item, list) or isinstance(item, tuple):
                    item = item[0]

                if self.active and self.select == index:
                    attr = attribute_normal_selected
                else:
                    attr = attribute_normal
                self.putString(x, y + i, width, 1, attr, " " * width)
                self.putString(x, y + i, width, 1, attr, item)
            else:
                self.putString(x, y + i, width, 1, attribute_normal, " " * width)

        if self.status_bar:
            if self.isearch:
                attr = ckit.Attribute(fg=ckit.getColor("fg"))
                s = " Search : %s_" % (self.isearch.isearch_value)
                s = ckit.adjustStringWidth(self, s, width - 1)
                self.putString(0, self.height() - 1, width - 1, 1, attr, s)
            else:
                self.status_bar_layer.setMessage(self.statusbar_handler(width, self.select))
                self.status_bar.paint(self, 0, self.height() - 1, width, 1)
        else:
            if self.isearch:
                s = " Search : %s_" % (self.isearch.isearch_value)
                self.setTitle(s)
            else:
                self.setTitle(self.title)
Пример #28
0
    def __init__( self, debug=False ):
    
        self.initialized = False
        
        self.loadState()

        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_size = 12,
            bg_color = ckit.getColor("bg"),
            border_size = 2,
            title_bar = True,
            title = "Keyhac",
            show = keyhac_ini.getint( "CONSOLE", "visible", 1 ),
            sysmenu=True,
            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.theme_enabled = False
        try:
            self.createThemePlane()
        except:
            traceback.print_exc()

        self.debug = debug

        self.log = Log()
        self.scroll_info = ckit.ScrollInfo()
        
        self.mouse_click_info = None
        self.selection = [ [ 0, 0 ], [ 0, 0 ] ]

        self.initialized = True
    
        self.paint()
Пример #29
0
    def __init__(self, debug=False):

        self.initialized = False

        self.loadState()

        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_size=12,
            bg_color=ckit.getColor("bg"),
            border_size=2,
            title_bar=True,
            title="Keyhac",
            show=keyhac_ini.getint("CONSOLE", "visible", 1),
            sysmenu=True,
            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.theme_enabled = False
        try:
            self.createThemePlane()
        except:
            traceback.print_exc()

        self.debug = debug

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

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

        self.initialized = True

        self.paint()
Пример #30
0
        def __init__( self, x, y, parent_window, ini ):

            ckit.TextWindow.__init__(
                self,
                x=x,
                y=y,
                width=48,
                height=3,
                origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
                parent_window=parent_window,
                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,
                char_handler = self.onChar,
                )

            self.setCursorPos( -1, -1 )

            self.focus = AppNameWindow.FOCUS_EDIT
            self.result = AppNameWindow.RESULT_CANCEL

            app_name = main_window.ini.get( "MISC", "app_name" )

            self.edit = ckit.EditWidget( self, 22, 1, self.width()-24, 1, app_name, [0,len(app_name)] )

            try:
                self.wallpaper = ckit.Wallpaper(self)
                self.wallpaper.copy( parent_window )
                self.wallpaper.adjust()
            except AttributeError:
                self.wallpaper = None

            self.paint()
Пример #31
0
    def __init__( self, x, y, parent_window, ini, src_item, dst_item, default_result=RESULT_TIMESTAMP, filename='' ):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=46,
            height=12,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            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,
            char_handler = self.onChar,
            )

        self.setCursorPos( -1, -1 )

        self.edit = ckit.EditWidget( self, 10, 7, self.width()-12, 1, filename )

        self.src_item = src_item
        self.dst_item = dst_item
        self.select = default_result
        self.shift = False

        try:
            self.wallpaper = ckit.Wallpaper(self)
            self.wallpaper.copy( parent_window )
            self.wallpaper.adjust()
        except AttributeError:
            self.wallpaper = None

        self.paint()
Пример #32
0
    def __init__( self, x, y, width, height, parent_window, ini, title, keydown_hook=None ):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=width,
            height=height,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            bg_color = ckit.getColor("bg"),
            cursor0_color = ckit.getColor("cursor0"),
            cursor1_color = ckit.getColor("cursor1"),
            resizable = True,
            title = title,
            minimizebox = True,
            maximizebox = True,
            close_handler = self.onClose,
            size_handler = self._onSize,
            keydown_handler = self.onKeyDown,
            )

        self.lines = [""]
        self.last_line_terminated = False

        self.keydown_hook = keydown_hook

        self.scroll_info = ckit.ScrollInfo()

        self.scroll_info.makeVisible( 0, self.height() )

        try:
            self.wallpaper = ckit.Wallpaper(self)
            self.wallpaper.copy( parent_window )
            self.wallpaper.adjust()
        except AttributeError:
            self.wallpaper = None

        self.paint()
Пример #33
0
    def paint(self):

        attribute_normal = ckit.Attribute(fg=ckit.getColor("fg"))
        attribute_normal_selected = ckit.Attribute(
            fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg"))

        message_width = self.getStringWidth(self.message)
        self.putString((self.width() - message_width) // 2, 1, message_width,
                       1, attribute_normal, self.message)

        if self.msgbox_type == MSGBOX_TYPE_OK:
            btn_string = " OK "
            btn_width = self.getStringWidth(btn_string)
            self.putString((self.width() - btn_width) // 2, 3, btn_width, 1,
                           attribute_normal_selected, btn_string)

        elif self.msgbox_type == MSGBOX_TYPE_YESNO:

            btn1_string = "はい"
            btn1_width = self.getStringWidth(btn1_string)
            btn2_string = "いいえ"
            btn2_width = self.getStringWidth(btn2_string)

            if self.focus == MessageBox.BUTTON_YES:
                attr = attribute_normal_selected
            else:
                attr = attribute_normal

            self.putString((self.width() - btn1_width - btn2_width - 4) // 2,
                           3, btn1_width, 1, attr, btn1_string)

            if self.focus == MessageBox.BUTTON_NO:
                attr = attribute_normal_selected
            else:
                attr = attribute_normal

            self.putString((self.width() + btn1_width - btn2_width + 4) // 2,
                           3, btn2_width, 1, attr, btn2_string)
Пример #34
0
 def paint(self, window, x, y, width, height):
     if self.music_player.position != None and self.music_player.length != None:
         right = " %s - %s " % (_timeString(self.music_player.position),
                                _timeString(self.music_player.length -
                                            self.music_player.position))
     else:
         right = " "
     left = " [ Music %d/%d ] %s" % (self.music_player.cursor + 1,
                                     len(self.music_player.items),
                                     self.music_player.song_name)
     left = ckit.adjustStringWidth(window, left, width - len(right),
                                   ckit.ALIGN_LEFT, ckit.ELLIPSIS_RIGHT)
     attr = ckit.Attribute(fg=ckit.getColor("bar_fg"))
     window.putString(x, y, width, y, attr, left + right)
Пример #35
0
    def paint(self):

        y=0
        width=self.width()
        height=self.height()

        client_rect = self.getClientRect()
        char_w, char_h = self.getCharSize()

        attribute_normal = ckit.Attribute( fg=ckit.getColor("fg"))

        for i in range(height):
            index = self.scroll_info.pos+i
            self.putString( 0, y+i, width, 1, attribute_normal, " " * width )
            if index < len(self.lines):
                self.putString( 0, y+i, width, 1, attribute_normal, self.lines[index] )
Пример #36
0
    def paint(self):

        width = self.width()
        height = self.height()

        client_rect = self.getClientRect()
        offset_x, offset_y = self.charToClient( 0, 0 )
        char_w, char_h = self.getCharSize()

        area_size = ( client_rect[2]-client_rect[0], (height-1)*char_h+offset_y )
        
        if not self.img : return

        img_size = self.img.getSize()
        plane_size = ( int(img_size[0]*self._zoom), int(img_size[1]*self._zoom) )
        plane_topleft = [ (area_size[0]-plane_size[0])//2+self.pos[0], (area_size[1]-plane_size[1])//2+self.pos[1] ]

        if self.plane:
            self.plane.destroy()

        self.plane = ckit.ImagePlane( self, plane_topleft, plane_size, 4 )
        self.plane.setImage(self.img)

        self.setTitle( "%s - [ %s ]" % ( cfiler_resource.cfiler_appname, self.items[self.cursor].name ) )

        attribute_normal = ckit.Attribute( fg=ckit.getColor("fg"))
        for i in range(height-1):
            self.putString( 0, i, width, 1, attribute_normal, " " * width )

        self.plane_statusbar.setPosSize( 0, (height-1)*char_h+offset_y, client_rect[2], client_rect[3]-(height-1)*char_h+offset_y )
        
        if self.info:
            status_message_right = ":  %d%%  :  %s-mode  :  %s" % ( self._zoom*100, self.zoom_policy, self.info )
            error = False
        else:
            status_message_right = ": デコードエラー"
            error = True
        status_message_left = "[%d/%d]  %s" % ( self.cursor+1, len(self.items), self.items[self.cursor].name )
        status_message_left = ckit.adjustStringWidth( self, status_message_left, width-2-self.getStringWidth(status_message_right), ckit.ALIGN_LEFT, ckit.ELLIPSIS_RIGHT )
        self.status_bar_layer.setMessage( status_message_left + status_message_right, error )
        self.status_bar.paint( self, 0, height-1, width, 1 )
Пример #37
0
 def updateColor(self):
     self.setBGColor(ckit.getColor("bg"))
     self.setCursorColor(ckit.getColor("cursor0"), ckit.getColor("cursor1"))
     self.paint()
Пример #38
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=ckit.getColor("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.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 = keyhac_statusbar.StatusBar()
            self.status_bar_layer = keyhac_statusbar.SimpleStatusBarLayer()
            self.status_bar.registerLayer(self.status_bar_layer)

            self.skin_statusbar = ckit.ThemePlane3x3(self, 'bar.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, 'edit.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()
Пример #39
0
    def paint(self):
    
        # テキスト
        if 1:
            x, y, width, height = self.rectText()
    
            attr = ckit.Attribute( fg=ckit.getColor("fg") )
            attr_selected = ckit.Attribute( fg=ckit.getColor("select_fg"), bg=ckit.getColor("select_bg") )
        
            selection_left, selection_right = self.selection 
            if selection_left > selection_right:
                selection_left, selection_right = selection_right, selection_left
        
            for i in range(height):

                if self.scroll_info.pos+i < self.log.numLines():
            
                    if selection_left[0] <= self.scroll_info.pos+i <= selection_right[0]:
                    
                        s = self.log.getLine( self.scroll_info.pos + i )
                    
                        if selection_left[0]==self.scroll_info.pos+i:
                            left = selection_left[1]
                        else:
                            left = 0

                        if selection_right[0]==self.scroll_info.pos+i:
                            right = selection_right[1]
                        else:
                            right = len(s)
                    
                        s = [ s[0:left], s[left:right], s[right:len(s)] ]
                    
                        line_x = x

                        self.putString( line_x, y+i, width-line_x, 1, attr, s[0] )
                        line_x += self.getStringWidth(s[0])

                        self.putString( line_x, y+i, width-line_x, 1, attr_selected, s[1] )
                        line_x += self.getStringWidth(s[1])
                    
                        self.putString( line_x, y+i, width-line_x, 1, attr, s[2] )
                        line_x += self.getStringWidth(s[2])

                        self.putString( line_x, y+i, width-line_x, 1, attr, " " * (width-line_x) )
                    
                    else:
                        s = self.log.getLine( self.scroll_info.pos + i )
                        self.putString( x, y+i, width, 1, attr, s )
                        w = self.getStringWidth(s)
                        space_x = x + w
                        space_width = width - w
                        self.putString( space_x, y+i, space_width, 1, attr, " " * space_width )
                else:
                    self.putString( x, y+i, width, 1, attr, " " * width )

        # スクロールバー
        if 1:
            x, y, width, height = self.rectScrollbar()

            for i in range(height):
                self.putString( x, y+i, width, 1, attr, " " * width )

            client_rect = self.getClientRect()
            scrollbar_left, tmp = self.charToClient( self.width()-2, 0 )
            
            scrollbar0_rect = [ scrollbar_left, 0, client_rect[2]-scrollbar_left, client_rect[3]-0 ]
            
            scrollbar1_height = client_rect[3] * self.height() // self.log.numLines()
            scrollbar1_height = min( scrollbar1_height, client_rect[3] )
            scrollbar1_height = max( scrollbar1_height, 12 )
            
            scrollbar1_pos = (client_rect[3]-scrollbar1_height) * self.scroll_info.pos // max((self.log.numLines()-self.height()),1)
            
            scrollbar1_rect = [ scrollbar_left, scrollbar1_pos, client_rect[2]-scrollbar_left, scrollbar1_height ]

            self.plane_scrollbar0.setPosSize( *scrollbar0_rect )
            self.plane_scrollbar1.setPosSize( *scrollbar1_rect )
Пример #40
0
 def updateColor(self):
     self.setBGColor( ckit.getColor("bg") )
     self.setCursorColor( ckit.getColor("cursor0"), ckit.getColor("cursor1") )
     self.paint()
Пример #41
0
    def __init__( self, 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_name = self.font_name,
            font_size = scaled_font_size,
            bg_color = ckit.getColor("bg"),
            border_size = 2,
            title_bar = True,
            title = "Keyhac",
            show = keyhac_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,

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

        # モニター境界付近でウインドウが作成された場合を考慮して、DPIを再確認する
        dpi_scale2 = self.getDisplayScaling()
        if dpi_scale2 != dpi_scale:
            self._updateFont( x_center = True )

        self.theme_enabled = False
        try:
            self.createThemePlane()
        except:
            traceback.print_exc()

        self.debug = debug

        self.log = Log()
        self.scroll_info = ckit.ScrollInfo()
        
        self.mouse_click_info = None
        self.selection = [ [ 0, 0 ], [ 0, 0 ] ]

        self.initialized = True
    
        self.paint()
Пример #42
0
 def paint(self, window, x, y, width, height):
     attr = ckit.Attribute(fg=ckit.getColor("bar_fg"))
     window.putString(x, y, width, height, attr, " " * width)
Пример #43
0
 def paint(self, window, x, y, width, height):
     if len(self.layer_list) > 0:
         self.layer_list[0].paint(window, x, y, width, height)
     else:
         attr = ckit.Attribute(fg=ckit.getColor("bar_fg"))
         window.putString(x, y, width, height, attr, " " * width)
Пример #44
0
    def paint(self):

        if self.focus == CommandWindow.FOCUS_NAME:
            attr = ckit.Attribute(fg=ckit.getColor("select_fg"),
                                  bg=ckit.getColor("select_bg"))
        else:
            attr = ckit.Attribute(fg=ckit.getColor("fg"))
        self.putString(2, 1, self.width() - 2, 1, attr, "名前")

        self.name_edit.enableCursor(self.focus == CommandWindow.FOCUS_NAME)
        self.name_edit.paint()

        if self.focus == CommandWindow.FOCUS_FILE:
            attr = ckit.Attribute(fg=ckit.getColor("select_fg"),
                                  bg=ckit.getColor("select_bg"))
        else:
            attr = ckit.Attribute(fg=ckit.getColor("fg"))
        self.putString(2, 3, self.width() - 2, 1, attr, "ファイル")

        self.file_edit.enableCursor(self.focus == CommandWindow.FOCUS_FILE)
        self.file_edit.paint()

        if self.focus == CommandWindow.FOCUS_PARAM:
            attr = ckit.Attribute(fg=ckit.getColor("select_fg"),
                                  bg=ckit.getColor("select_bg"))
        else:
            attr = ckit.Attribute(fg=ckit.getColor("fg"))
        self.putString(2, 5, self.width() - 2, 1, attr, "パラメタ")

        self.param_edit.enableCursor(self.focus == CommandWindow.FOCUS_PARAM)
        self.param_edit.paint()

        if self.focus == CommandWindow.FOCUS_DIRECTORY:
            attr = ckit.Attribute(fg=ckit.getColor("select_fg"),
                                  bg=ckit.getColor("select_bg"))
        else:
            attr = ckit.Attribute(fg=ckit.getColor("fg"))
        self.putString(2, 7, self.width() - 2, 1, attr, "ディレクトリ")

        self.directory_edit.enableCursor(
            self.focus == CommandWindow.FOCUS_DIRECTORY)
        self.directory_edit.paint()
Пример #45
0
    def paint(self):

        # テキスト
        if 1:
            x, y, width, height = self.rectText()

            attr = ckit.Attribute(fg=ckit.getColor("fg"))
            attr_selected = ckit.Attribute(fg=ckit.getColor("select_fg"),
                                           bg=ckit.getColor("select_bg"))

            selection_left, selection_right = self.selection
            if selection_left > selection_right:
                selection_left, selection_right = selection_right, selection_left

            for i in range(height):

                if self.scroll_info.pos + i < self.log.numLines():

                    if selection_left[
                            0] <= self.scroll_info.pos + i <= selection_right[
                                0]:

                        s = self.log.getLine(self.scroll_info.pos + i)

                        if selection_left[0] == self.scroll_info.pos + i:
                            left = selection_left[1]
                        else:
                            left = 0

                        if selection_right[0] == self.scroll_info.pos + i:
                            right = selection_right[1]
                        else:
                            right = len(s)

                        s = [s[0:left], s[left:right], s[right:len(s)]]

                        line_x = x

                        self.putString(line_x, y + i, width - line_x, 1, attr,
                                       s[0])
                        line_x += self.getStringWidth(s[0])

                        self.putString(line_x, y + i, width - line_x, 1,
                                       attr_selected, s[1])
                        line_x += self.getStringWidth(s[1])

                        self.putString(line_x, y + i, width - line_x, 1, attr,
                                       s[2])
                        line_x += self.getStringWidth(s[2])

                        self.putString(line_x, y + i, width - line_x, 1, attr,
                                       " " * (width - line_x))

                    else:
                        s = self.log.getLine(self.scroll_info.pos + i)
                        self.putString(x, y + i, width, 1, attr, s)
                        w = self.getStringWidth(s)
                        space_x = x + w
                        space_width = width - w
                        self.putString(space_x, y + i, space_width, 1, attr,
                                       " " * space_width)
                else:
                    self.putString(x, y + i, width, 1, attr, " " * width)

        # スクロールバー
        if 1:
            x, y, width, height = self.rectScrollbar()

            for i in range(height):
                self.putString(x, y + i, width, 1, attr, " " * width)

            client_rect = self.getClientRect()
            scrollbar_left, tmp = self.charToClient(self.width() - 2, 0)

            scrollbar0_rect = [
                scrollbar_left, 0, client_rect[2] - scrollbar_left,
                client_rect[3] - 0
            ]

            scrollbar1_height = client_rect[3] * self.height(
            ) // self.log.numLines()
            scrollbar1_height = min(scrollbar1_height, client_rect[3])
            scrollbar1_height = max(scrollbar1_height, 12)

            scrollbar1_pos = (client_rect[3] -
                              scrollbar1_height) * self.scroll_info.pos // max(
                                  (self.log.numLines() - self.height()), 1)

            scrollbar1_rect = [
                scrollbar_left, scrollbar1_pos,
                client_rect[2] - scrollbar_left, scrollbar1_height
            ]

            if self.theme_enabled:
                self.plane_scrollbar0.setPosSize(*scrollbar0_rect)
                self.plane_scrollbar1.setPosSize(*scrollbar1_rect)
Пример #46
0
 def reloadTheme(self):
     self.destroyThemePlane()
     self.createThemePlane()
     self.setBGColor(ckit.getColor("bg"))
     self.paint()
Пример #47
0
    def __init__( self, x, y, width, height, parent_window, ini, title, left_item, right_item, edit_handler=None ):

        ckit.TextWindow.__init__(
            self,
            x=x,
            y=y,
            width=width,
            height=height,
            origin= ORIGIN_X_CENTER | ORIGIN_Y_CENTER,
            parent_window=parent_window,
            bg_color = ckit.getColor("bg"),
            cursor0_color = ckit.getColor("cursor0"),
            cursor1_color = ckit.getColor("cursor1"),
            resizable = True,
            title = title,
            show = False,
            minimizebox = True,
            maximizebox = True,
            sysmenu=True,
            close_handler = self.onClose,
            size_handler = self._onSize,
            keydown_handler = self.onKeyDown,
            )

        self.command = ckit.CommandMap(self)

        class Pane:
            pass

        self.left = Pane()
        self.right = Pane()

        self.img = ckit.createThemeImage('lineno.png')
        
        client_rect = self.getClientRect()
        offset_x, offset_y = self.charToClient( 0, 0 )
        char_w, char_h = self.getCharSize()
        self.plane_statusbar = ckit.ThemePlane3x3( self, 'statusbar.png' )
        self.status_bar = cfiler_statusbar.StatusBar()
        self.status_bar_layer = cfiler_statusbar.SimpleStatusBarLayer()
        self.status_bar.registerLayer(self.status_bar_layer)

        self.job_queue = ckit.JobQueue()
        self.edit_handler = edit_handler
        
        def initializePane( pane, item ):
        
            pane.plane = ckit.ImagePlane( self, (0,0), (10,10), 1 )
            pane.plane.setImage(self.img)

            pane.item = item

            def jobLoad( job_item ):

                try:
                    pane.data = item.open().read()
                except MemoryError:
                    print( "ERROR : メモリ不足" )
                    pane.data = ""
                except Exception as e:
                    cfiler_debug.printErrorInfo()
                    print( e )
                    pane.data = ""

                text_encoding = ckit.detectTextEncoding(pane.data)
                pane.encoding = text_encoding.encoding
                if text_encoding.bom:
                    pane.data = pane.data[len(text_encoding.bom):]
                if pane.encoding==None:
                    pane.lines = []
                else:
                    unicode_data = pane.data.decode( encoding=pane.encoding, errors='replace' )
                    pane.lines = unicode_data.splitlines()

            def jobLoadFinished( job_item ):
                pass

            job_item = ckit.JobItem( jobLoad, jobLoadFinished )
            self.job_queue.enqueue(job_item)
        
            pane.scroll_info = ckit.ScrollInfo()
            pane.scroll_info.makeVisible( 0, self.height() )

            pane.diff = []

        initializePane( self.left, left_item )
        initializePane( self.right, right_item )

        try:
            self.wallpaper = ckit.Wallpaper(self)
            self.wallpaper.copy( parent_window )
            self.wallpaper.adjust()
        except AttributeError:
            self.wallpaper = None

        self.load_finished = False

        def jobDiff( job_item ):

            diff_object = difflib.unified_diff( self.left.lines, self.right.lines, n=0 )
        
            color = 0

            re_pattern = re.compile( "@@ -([0-9]+)(,([0-9]+))? \+([0-9]+)(,([0-9]+))? @@" )
            for line in diff_object:
                if line.startswith("@@"):

                    re_result = re_pattern.match(line)

                    begin1 = int(re_result.group(1))
                    if not re_result.group(3):
                        delta1 = 1
                    elif re_result.group(3)=='0':
                        begin1 += 1
                        delta1 = 0
                    else:
                        delta1 = int(re_result.group(3))

                    self.left.diff.append( ( begin1, delta1, color ) )

                    begin2 = int(re_result.group(4))
                    if not re_result.group(6):
                        delta2 = 1
                    elif re_result.group(6)=='0':
                        begin2 += 1
                        delta2 = 0
                    else:
                        delta2 = int(re_result.group(6))
                        
                    self.right.diff.append( ( begin2, delta2, color ) )

                    color += 1
                    if color>=3:
                        color=0

        def jobDiffFinished( job_item ):
            if job_item.isCanceled() : return
            self.load_finished = True
            self.paint()
            
            if self.left.encoding==None or self.right.encoding==None:
                
                self.destroy()

                if self.left.data == self.right.data:
                    cfiler_msgbox.popMessageBox( parent_window, MessageBox.TYPE_OK, "ファイル比較", "ファイルの内容は同一です。" )
                else:
                    cfiler_msgbox.popMessageBox( parent_window, MessageBox.TYPE_OK, "ファイル比較", "ファイルの内容には差異があります。" )
                
            else:
                self.setTitle( "%s - [ %s : %s ]" % ( cfiler_resource.cfiler_appname, self.left.item.name, self.right.item.name ) )
                self.show(True)

        job_item = ckit.JobItem( jobDiff, jobDiffFinished )
        self.job_queue.enqueue(job_item)

        self.configure()