summaryrefslogtreecommitdiff
path: root/cad/src/PM/GroupButtonMixin.py
blob: 72a8ef34d1cdda2b08e6bc6eb75e1252f09f30b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright 2006-2007 Nanorex, Inc.  See LICENSE file for details.
"""
GroupButtonMixin.py

$Id$

History and status:

Written by Will in GeneratorBaseClass.py, but no longer used there
or by anything that uses it.

bruce 070619 moved this from GeneratorBaseClass.py to its own file. It is deprecated;
its uses should be replaced by rewriting its callers to use the PM package.

Module classification:

As of 071214, it is used only by MinimizeEnergyProp and PovraySceneProp,
which should be rewritten to use PM_Dialog and get things like this file
provides from PM package, so I am classifying it as if it was part
of the PM package. [bruce 071214]

"""

__author__ = "Will"

from PyQt4.Qt import QPixmap, QIcon

_up_arrow_data = \
    "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" \
    "\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\x00\x00\x00\x90\x91\x68" \
    "\x36\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0" \
    "\xbd\xa7\x93\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00" \
    "\x00\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45" \
    "\x07\xd6\x06\x03\x03\x21\x26\xc9\x92\x21\x9b\x00\x00\x00\x10\x74" \
    "\x45\x58\x74\x43\x6f\x6d\x6d\x65\x6e\x74\x00\x4e\x61\x6e\x6f\x74" \
    "\x75\x62\x65\xa3\x8c\x3b\xec\x00\x00\x00\xda\x49\x44\x41\x54\x28" \
    "\xcf\xb5\x92\x41\x0e\x82\x30\x10\x45\x5b\xe3\x01\x24\x14\x69\x39" \
    "\x01\x3d\x83\x6c\x24\xdc\xc0\xb0\x31\x5c\x8f\x78\x8b\x76\x16\x70" \
    "\x95\xb2\x01\x71\xcd\xa2\x75\x51\x6d\x1a\x40\x23\x0b\xff\x6e\x32" \
    "\xef\xb7\x99\x3f\x83\x55\xa7\xd0\x16\xed\xd0\x46\xed\xfd\xa2\x69" \
    "\x9b\x25\x91\x9d\xb2\x75\x43\xd3\x36\xe5\xa5\x5c\x1a\xea\x5b\x9d" \
    "\x9f\x73\x57\x62\x3b\x83\xa5\x87\xfb\xe0\x1a\x24\x24\xfd\xd0\x23" \
    "\x84\xa6\x69\x12\x52\xf0\x94\x33\xc6\xe6\x33\x98\xb7\x48\x48\x00" \
    "\x80\x84\xc4\x18\x63\x5b\xe3\x63\x5c\x19\x5a\x6b\xad\xb5\x8e\x48" \
    "\x04\x00\x08\x21\x00\x88\x48\xf4\x2d\x25\x63\x4c\x7c\x8c\x2d\x6d" \
    "\x05\x00\x09\x4b\x3e\x1a\x68\x4c\x7d\xda\x79\xaa\x6b\xb5\x62\xc0" \
    "\x18\x2f\x69\xe7\x29\xf2\xe2\x55\xa8\x4e\xfd\xbe\x6c\xd5\x29\xec" \
    "\x68\x21\x85\x9f\xb7\x93\x90\x82\x52\x1a\x1c\x02\x1b\x2b\xf6\x9f" \
    "\x17\x52\x2c\x0d\x3e\x3d\x3f\x0d\x9e\x72\x97\xb7\x93\x4f\xcf\x7f" \
    "\xf8\xcb\xb5\x3e\x01\x8d\xb5\x6a\x19\xa6\x37\x6f\xd9\x00\x00\x00" \
    "\x00\x49\x45\x4e\x44\xae\x42\x60\x82"

_down_arrow_data = \
    "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52" \
    "\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\x00\x00\x00\x90\x91\x68" \
    "\x36\x00\x00\x00\x06\x62\x4b\x47\x44\x00\xff\x00\xff\x00\xff\xa0" \
    "\xbd\xa7\x93\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00" \
    "\x00\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x00\x07\x74\x49\x4d\x45" \
    "\x07\xd6\x06\x03\x03\x29\x2f\x78\x97\x13\x37\x00\x00\x00\x10\x74" \
    "\x45\x58\x74\x43\x6f\x6d\x6d\x65\x6e\x74\x00\x4e\x61\x6e\x6f\x74" \
    "\x75\x62\x65\xa3\x8c\x3b\xec\x00\x00\x00\xba\x49\x44\x41\x54\x28" \
    "\xcf\xb5\x92\x3f\x0e\x82\x30\x14\x87\x8b\x31\xcc\x32\xd9\x72\x02" \
    "\x39\x83\x0c\x3f\xb8\x82\xc2\x09\x41\x2f\x41\x0a\x43\x7b\x95\x52" \
    "\x26\xbc\x41\x1d\x48\xb0\xb6\x40\x64\xf0\x6d\x2f\xfd\xbe\xf4\xfd" \
    "\x0b\x54\xaf\xc8\x9e\x38\x90\x9d\x71\xb4\x13\x21\x85\x4f\xa4\xd7" \
    "\x74\x59\x10\x52\x14\xb7\xc2\x17\xea\x67\x9d\x67\xb9\x2b\xc4\x2c" \
    "\xfe\xa5\x1e\xd5\xab\x60\x6a\x5a\x48\x51\xde\xcb\xae\xeb\xd6\x50" \
    "\x00\x13\xf9\x69\xda\x18\x03\x60\x8d\x6e\x78\xb3\x30\x25\x3d\x68" \
    "\xdf\x01\x50\x3d\xaa\xd5\xb1\x3a\x0e\x00\x63\x4c\x18\x86\x5b\x7b" \
    "\x98\x1d\x00\x7a\xd0\x5b\x7b\xb0\x1d\x7a\xa6\x3e\x4d\x08\x09\xe6" \
    "\xd3\xe0\x2d\xb7\xe7\x3d\x07\x6f\x39\xa5\x34\x3a\x45\x8c\xb1\x2f" \
    "\x61\x7a\xf3\x05\x9b\x76\x4b\x4a\x2e\xc9\xf8\x1a\x1d\xc1\xa6\xdd" \
    "\x1f\xfe\x72\xad\x6f\xd8\xd4\x50\x37\x09\xb5\x93\x63\x00\x00\x00" \
    "\x00\x49\x45\x4e\x44\xae\x42\x60\x82"

class GroupButtonMixin:
    """
    Mixin class for providing the method toggle_groupbox_in_dialogs,
    suitable as part of a slot method for toggling the state of a dialog GroupBox.
    (Current implementation uses open/close icons which look good on Linux and
     Windows but don't look good on the Mac.)

    [DEPRECATED. New code should avoid using this, and should instead
    use the groupboxes provided by PropMgrBaseClass if possible.]
    """
    # Note: this is only used by a couple of non-generator dialogs,
    # so it (and the strings _up_arrow_data and _down_arrow_data which nothing else uses)
    # should be moved into some other file. [bruce 070615 comment]
    def initialize():
        _up_arrow = QPixmap()
        _up_arrow.loadFromData(_up_arrow_data)
        _down_arrow = QPixmap()
        _down_arrow.loadFromData(_down_arrow_data)
    initialize = staticmethod(initialize)

    def toggle_groupbox_in_dialogs(self, button, *things):
        """
        This is intended to be part of the slot method for clicking on an open/close icon
        of a dialog GroupBox. The arguments should be the button (whose icon will be altered here)
        and the child widgets in the groupbox whose visibility should be toggled.
        """
        if things[0].isVisible():
            button.setIcon(QIcon(self._down_arrow))
            for thing in things:
                thing.hide()
        else:
            button.setIcon(QIcon(self._up_arrow))
            for thing in things:
                thing.show()
        return
    pass # end of class GroupButtonMixin

# end