controls/CustomTree.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Mon, 09 Oct 2017 16:04:39 +0300
changeset 1852 70c1cc354a8f
parent 1847 6198190bc121
child 1881 091005ec69c4
permissions -rw-r--r--
fix pylint warning '(dangerous-default-value) Dangerous default value {} as argument'
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     1
#!/usr/bin/env python
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     3
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
     4
# This file is part of Beremiz, a Integrated Development Environment for
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
     5
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     6
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
     7
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     8
#
1571
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
     9
# See COPYING file for copyrights details.
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    10
#
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    11
# This program is free software; you can redistribute it and/or
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    12
# modify it under the terms of the GNU General Public License
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    13
# as published by the Free Software Foundation; either version 2
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    14
# of the License, or (at your option) any later version.
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    15
#
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    16
# This program is distributed in the hope that it will be useful,
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    19
# GNU General Public License for more details.
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    20
#
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    21
# You should have received a copy of the GNU General Public License
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    22
# along with this program; if not, write to the Free Software
486f94a8032c fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1188
diff changeset
    23
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    24
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    25
import wx
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    26
import wx.lib.agw.customtreectrl as CT
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    27
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    28
from util.BitmapLibrary import GetBitmap
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    29
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    30
# Customize CustomTreeItem for adding icon on item left
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    31
CT.GenericTreeItem._ExtraImage = None
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    32
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    33
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    34
def SetExtraImage(self, image):
1188
63afb5833bd8 Fixed bug two icons displayed for POU category item in Project Tree when adding a second POU
Laurent Bessard
parents: 1177
diff changeset
    35
    self._type = (1 if image is not None else 0)
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    36
    self._ExtraImage = image
1188
63afb5833bd8 Fixed bug two icons displayed for POU category item in Project Tree when adding a second POU
Laurent Bessard
parents: 1177
diff changeset
    37
1749
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    38
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    39
CT.GenericTreeItem.SetExtraImage = SetExtraImage
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    40
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    41
_DefaultGetCurrentCheckedImage = CT.GenericTreeItem.GetCurrentCheckedImage
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    42
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    43
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    44
def GetCurrentCheckedImage(self):
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    45
    if self._ExtraImage is not None:
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    46
        return self._ExtraImage
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    47
    return _DefaultGetCurrentCheckedImage(self)
1749
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    48
d73b64672238 clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1745
diff changeset
    49
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    50
CT.GenericTreeItem.GetCurrentCheckedImage = GetCurrentCheckedImage
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    51
1736
7e61baa047f0 clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1730
diff changeset
    52
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    53
class CustomTree(CT.CustomTreeCtrl):
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    54
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    55
    def __init__(self, *args, **kwargs):
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    56
        CT.CustomTreeCtrl.__init__(self, *args, **kwargs)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    57
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    58
        self.BackgroundBitmap = None
1745
f9d32913bad4 clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1736
diff changeset
    59
        self.BackgroundAlign = wx.ALIGN_LEFT | wx.ALIGN_TOP
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    60
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    61
        self.AddMenu = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    62
        self.Enabled = False
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    63
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    64
        self.Bind(wx.EVT_SCROLLWIN, self.OnScroll)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    65
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    66
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    67
    def SetBackgroundBitmap(self, bitmap, align):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    68
        self.BackgroundBitmap = bitmap
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    69
        self.BackgroundAlign = align
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    70
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    71
    def SetImageListCheck(self, sizex, sizey, imglist=None):
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    72
        CT.CustomTreeCtrl.SetImageListCheck(self, sizex, sizey, imglist=None)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    73
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    74
        self.ExtraImages = {}
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    75
        for image in ["function", "functionBlock", "program"]:
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    76
            self.ExtraImages[image] = self._imageListCheck.Add(GetBitmap(image.upper()))
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    77
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    78
    def SetItemExtraImage(self, item, bitmap):
1188
63afb5833bd8 Fixed bug two icons displayed for POU category item in Project Tree when adding a second POU
Laurent Bessard
parents: 1177
diff changeset
    79
        dc = wx.ClientDC(self)
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    80
        image = self.ExtraImages.get(bitmap)
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    81
        if image is not None:
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
    82
            item.SetExtraImage(image)
1188
63afb5833bd8 Fixed bug two icons displayed for POU category item in Project Tree when adding a second POU
Laurent Bessard
parents: 1177
diff changeset
    83
        else:
63afb5833bd8 Fixed bug two icons displayed for POU category item in Project Tree when adding a second POU
Laurent Bessard
parents: 1177
diff changeset
    84
            item.SetExtraImage(None)
63afb5833bd8 Fixed bug two icons displayed for POU category item in Project Tree when adding a second POU
Laurent Bessard
parents: 1177
diff changeset
    85
        self.CalculateSize(item, dc)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    86
        self.RefreshLine(item)
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    87
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    88
    def SetAddMenu(self, add_menu):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    89
        self.AddMenu = add_menu
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    90
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    91
    def Enable(self, enabled):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    92
        self.Enabled = enabled
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    93
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    94
    def GetBitmapRect(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    95
        client_size = self.GetClientSize()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    96
        bitmap_size = self.BackgroundBitmap.GetSize()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
    97
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    98
        if self.BackgroundAlign & wx.ALIGN_RIGHT:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    99
            x = client_size[0] - bitmap_size[0]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   100
        elif self.BackgroundAlign & wx.ALIGN_CENTER_HORIZONTAL:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   101
            x = (client_size[0] - bitmap_size[0]) / 2
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   102
        else:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   103
            x = 0
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   104
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   105
        if self.BackgroundAlign & wx.ALIGN_BOTTOM:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   106
            y = client_size[1] - bitmap_size[1]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   107
        elif self.BackgroundAlign & wx.ALIGN_CENTER_VERTICAL:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   108
            y = (client_size[1] - bitmap_size[1]) / 2
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   109
        else:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   110
            y = 0
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   111
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   112
        return wx.Rect(x, y, bitmap_size[0], bitmap_size[1])
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   113
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   114
    def OnLeftUp(self, event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   115
        if self.Enabled:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   116
            pos = event.GetPosition()
1847
6198190bc121 explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1766
diff changeset
   117
            _item, flags = self.HitTest(pos)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   118
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   119
            bitmap_rect = self.GetBitmapRect()
1766
c1e5b9f19483 clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
   120
            if ((bitmap_rect.InsideXY(pos.x, pos.y) or
c1e5b9f19483 clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1749
diff changeset
   121
                 flags & wx.TREE_HITTEST_NOWHERE) and self.AddMenu is not None):
1165
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   122
                wx.CallAfter(self.PopupMenuXY, self.AddMenu, pos.x, pos.y)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   123
        event.Skip()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   124
1165
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   125
    def OnEraseBackground(self, event):
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   126
        dc = event.GetDC()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   127
1165
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   128
        if not dc:
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   129
            dc = wx.ClientDC(self)
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   130
            rect = self.GetUpdateRegion().GetBox()
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   131
            dc.SetClippingRect(rect)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   132
1165
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   133
        dc.Clear()
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   134
1165
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   135
        bitmap_rect = self.GetBitmapRect()
99972084890d Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents: 1164
diff changeset
   136
        dc.DrawBitmap(self.BackgroundBitmap, bitmap_rect.x, bitmap_rect.y)
1730
64d8f52bc8c8 clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 1571
diff changeset
   137
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   138
    def OnScroll(self, event):
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
   139
        wx.CallAfter(self.Refresh)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   140
        event.Skip()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   141
1164
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
   142
    def OnSize(self, event):
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
   143
        CT.CustomTreeCtrl.OnSize(self, event)
8fd44bc05aae Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents: 814
diff changeset
   144
        self.Refresh()