controls/DebugVariablePanel/GraphButton.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Mon, 24 Oct 2016 18:02:53 +0300
changeset 1549 f526fd97a7b0
parent 1267 fae0809eae98
child 1571 486f94a8032c
permissions -rw-r--r--
add $(Beremiz installation)/mingw/bin in PATH on Windows platform

This fixes issue if multiple gcc installation are found in user's
PATH. Now gcc from Beremiz is used by default.
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
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     4
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     5
#based on the plcopen standard. 
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     6
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     7
#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     8
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
     9
#See COPYING file for copyrights details.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    10
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    11
#This library is free software; you can redistribute it and/or
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    12
#modify it under the terms of the GNU General Public
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    13
#License as published by the Free Software Foundation; either
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    14
#version 2.1 of the License, or (at your option) any later version.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    15
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    16
#This library is distributed in the hope that it will be useful,
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    17
#but WITHOUT ANY WARRANTY; without even the implied warranty of
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    18
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    19
#General Public License for more details.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    20
#
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    21
#You should have received a copy of the GNU General Public
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    22
#License along with this library; if not, write to the Free Software
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    23
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    24
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    25
import wx
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    26
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    27
from util.BitmapLibrary import GetBitmap
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    28
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    29
#-------------------------------------------------------------------------------
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    30
#                        Custom button for Graphic Viewer Class
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    31
#-------------------------------------------------------------------------------
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    32
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    33
"""
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    34
Class that implements a custom button for graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    35
"""
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    36
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    37
class GraphButton():
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    38
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    39
    def __init__(self, x, y, bitmap, callback):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    40
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    41
        Constructor
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    42
        @param x: X coordinate of Button in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    43
        @param y: Y coordinate of Button in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    44
        @param bitmap: Name of bitmap to use for button
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    45
        @param callback: Reference to function to call when button is pressed
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    46
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    47
        # Save button position
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    48
        self.SetPosition(x, y)
1267
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    49
        # Set button bitmap
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    50
        self.SetBitmap(bitmap)
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    51
        
1209
953a8f14040a Rewrite DebugVariablePanel and fixed bugs
Laurent Bessard
parents: 1200
diff changeset
    52
        # By default button is hide and enabled
953a8f14040a Rewrite DebugVariablePanel and fixed bugs
Laurent Bessard
parents: 1200
diff changeset
    53
        self.Shown = False
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    54
        self.Enabled = True
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    55
        
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    56
        # Save reference to callback function
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    57
        self.Callback = callback
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    58
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    59
    def __del__(self):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    60
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    61
        Destructor
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    62
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    63
        # Remove reference to callback function
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    64
        self.callback = None
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    65
    
1267
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    66
    def SetBitmap(self, bitmap):
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    67
        """
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    68
        Set bitmap to use for button
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    69
        @param bitmap: Name of bitmap to use for button
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    70
        """
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    71
        # Get wx.Bitmap object corresponding to bitmap
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    72
        self.Bitmap = GetBitmap(bitmap)
fae0809eae98 Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents: 1209
diff changeset
    73
    
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    74
    def GetSize(self):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    75
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    76
        Return size of button
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    77
        @return: wx.Size object containing button size
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    78
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    79
        # Button size is size of bitmap
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    80
        return self.Bitmap.GetSize()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    81
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    82
    def SetPosition(self, x, y):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    83
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    84
        Set button position
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    85
        @param x: X coordinate of Button in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    86
        @param y: Y coordinate of Button in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    87
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    88
        self.Position = wx.Point(x, y)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    89
    
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    90
    def Show(self, show=True):
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    91
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    92
        Mark if button to be displayed in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    93
        @param show: True if button to be displayed in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    94
        (default True)
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    95
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    96
        self.Shown = show
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    97
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    98
    def Hide(self):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    99
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   100
        Hide button from Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   101
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   102
        self.Show(False)
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   103
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   104
    def IsShown(self):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   105
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   106
        Return if button is displayed in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   107
        @return: True if button is displayed in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   108
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   109
        return self.Shown
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   110
    
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   111
    def Enable(self, enable=True):
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   112
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   113
        Mark if button is active in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   114
        @param enable: True if button is active in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   115
        (default True)
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   116
        """
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   117
        self.Enabled = enable
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   118
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   119
    def Disable(self):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   120
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   121
        Deactivate button in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   122
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   123
        self.Enabled = False
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   124
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   125
    def IsEnabled(self):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   126
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   127
        Return if button is active in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   128
        @return: True if button is active in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   129
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   130
        return self.Enabled
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   131
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   132
    def HitTest(self, x, y):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   133
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   134
        Test if point is inside button
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   135
        @param x: X coordinate of point
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   136
        @param y: Y coordinate of point
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   137
        @return: True if button is active and displayed and point is inside
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   138
        button 
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   139
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   140
        # Return immediately if button is hidden or inactive
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   141
        if not (self.IsShown() and self.IsEnabled()):
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   142
            return False
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   143
        
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   144
        # Test if point is inside button
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   145
        w, h = self.Bitmap.GetSize()
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   146
        rect = wx.Rect(self.Position.x, self.Position.y, w, h)
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   147
        return rect.InsideXY(x, y)
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   148
    
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   149
    def ProcessCallback(self):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   150
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   151
        Call callback function if defined
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   152
        """
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   153
        if self.Callback is not None:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   154
            self.Callback()
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   155
    
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   156
    def Draw(self, dc):
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   157
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   158
        Draw button in Graphic Viewer
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   159
        @param dc: wx.DC object corresponding to Graphic Viewer device context
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   160
        """
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
   161
        # Only draw button if button is active and displayed
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   162
        if self.Shown and self.Enabled:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   163
            dc.DrawBitmap(self.Bitmap, self.Position.x, self.Position.y, True)