| | 89 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| | 90 | |
|---|
| | 91 | def SetupScreenLockingSides(Class): |
|---|
| | 92 | l,t,w,h = wx.wxGetClientDisplayRect().asTuple() |
|---|
| | 93 | Class._LockingSides[Class._LeftInnerSide][0][None] = [(l-Class._DeltaResist, t, l+Class._DeltaAttract, t+h, l)] |
|---|
| | 94 | Class._LockingSides[Class._RightInnerSide][0][None] = [(l+w-Class._DeltaAttract, t, l+w+Class._DeltaResist, t+h, l+w)] |
|---|
| | 95 | Class._LockingSides[Class._BottomInnerSide][0][None] = [(l, t+h-Class._DeltaAttract, l+w, t+h+Class._DeltaResist, t+h)] |
|---|
| | 96 | Class._LockingSides[Class._TopInnerSide][0][None] = [(l, t-Class._DeltaResist, l+w, t+Class._DeltaAttract, t)] |
|---|
| | 97 | SetupScreenLockingSides = classmethod(SetupScreenLockingSides) |
|---|
| | 98 | |
|---|
| | 99 | def Show(self, bShow=True): |
|---|
| | 100 | result = wx.wxFrame.Show(self, bShow) |
|---|
| | 101 | if bShow: self._SaveSidePositions() |
|---|
| | 102 | else: self._RemoveSidePositions() |
|---|
| | 103 | return result |
|---|
| | 104 | |
|---|
| | 105 | def Move(self, pos): |
|---|
| | 106 | self.__bLocking = 1 |
|---|
| | 107 | if isinstance(pos, tuple): newpos = pos |
|---|
| | 108 | else: newpos = pos.x, pos.y |
|---|
| | 109 | |
|---|
| | 110 | newpos, newsize = self._OnLockingMove(newpos, self.GetSize().asTuple()) or newpos |
|---|
| | 111 | result = wx.wxFrame.Move(self, newpos) |
|---|
| | 112 | |
|---|
| | 113 | self.__bLocking = 0 |
|---|
| | 114 | return result |
|---|
| | 115 | |
|---|
| | 116 | def OnLocktoFrame(self, weakframe, pos): |
|---|
| | 117 | pass #print "Now locked to weakframe %r" % weakframe |
|---|
| | 118 | |
|---|
| | 119 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| | 120 | #~ Protected Methods |
|---|
| 112 | | def Show(self, bShow=True): |
|---|
| 113 | | result = wx.wxFrame.Show(self, bShow) |
|---|
| 114 | | if bShow: self._SaveSidePositions() |
|---|
| 115 | | else: self._RemoveSidePositions() |
|---|
| 116 | | return result |
|---|
| 117 | | |
|---|
| 118 | | def Move(self, pos): |
|---|
| 119 | | self.__bLocking = 1 |
|---|
| 120 | | if isinstance(pos, tuple): newpos = pos |
|---|
| 121 | | else: newpos = pos.x, pos.y |
|---|
| 122 | | |
|---|
| 123 | | newpos, newsize = self._OnLockingMove(newpos, self.GetSize().asTuple()) or newpos |
|---|
| 124 | | result = wx.wxFrame.Move(self, newpos) |
|---|
| 125 | | |
|---|
| 126 | | self.__bLocking = 0 |
|---|
| 127 | | return result |
|---|
| 128 | | |
|---|
| 129 | | def OnLocktoFrame(self, weakframe, pos): |
|---|
| 130 | | pass #print "Now locked to weakframe %r" % weakframe |
|---|
| 131 | | |
|---|
| 132 | | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 133 | | #~ Protected Methods |
|---|
| 134 | | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 135 | | |
|---|
| 145 | | self._LockingSides[self._LeftSide][0][self._weakself] = [(l-self.delta, t, l+self.delta, t+h, l)] |
|---|
| 146 | | self._LockingSides[self._RightSide][0][self._weakself] = [(l+w-self.delta, t, l+w+self.delta, t+h, l+w)] |
|---|
| 147 | | self._LockingSides[self._BottomSide][0][self._weakself] = [(l, t+h-self.delta, l+w, t+h+self.delta, t+h)] |
|---|
| 148 | | self._LockingSides[self._TopSide][0][self._weakself] = [(l, t-self.delta, l+w, t+self.delta, t)] |
|---|
| 149 | | |
|---|
| 150 | | self._LockingSides[self._LeftInnerSide][0][self._weakself] = [(l-self.delta, t-self.delta, l+self.delta, t, l), (l-self.delta, t+h, l+self.delta, t+h+self.delta, l)] |
|---|
| 151 | | self._LockingSides[self._RightInnerSide][0][self._weakself] = [(l+w-self.delta, t-self.delta, l+w+self.delta, t, l+w), (l+w-self.delta, t+h, l+w+self.delta, t+h+self.delta, l+w)] |
|---|
| 152 | | self._LockingSides[self._BottomInnerSide][0][self._weakself] = [(l-self.delta, t+h-self.delta, l, t+h+self.delta, t+h), (l+w, t+h-self.delta, l+w+self.delta, t+h+self.delta, t+h)] |
|---|
| 153 | | self._LockingSides[self._TopInnerSide][0][self._weakself] = [(l-self.delta, t-self.delta, l, t+self.delta, t), (l+w, t-self.delta, l+w+self.delta, t+self.delta, t)] |
|---|
| | 152 | |
|---|
| | 153 | self._LockingSides[self._LeftSide][0][self._weakself] = [(l-self._DeltaAttract, t, l+self._DeltaResist, t+h, l)] |
|---|
| | 154 | self._LockingSides[self._RightSide][0][self._weakself] = [(l+w-self._DeltaResist, t, l+w+self._DeltaAttract, t+h, l+w)] |
|---|
| | 155 | self._LockingSides[self._BottomSide][0][self._weakself] = [(l, t+h-self._DeltaResist, l+w, t+h+self._DeltaAttract, t+h)] |
|---|
| | 156 | self._LockingSides[self._TopSide][0][self._weakself] = [(l, t-self._DeltaAttract, l+w, t+self._DeltaResist, t)] |
|---|
| | 157 | |
|---|
| | 158 | self._LockingSides[self._LeftInnerSide][0][self._weakself] = [(l-self._DeltaResist, t-self._DeltaWing, l+self._DeltaAttract, t, l), (l-self._DeltaResist, t+h, l+self._DeltaAttract, t+h+self._DeltaWing, l)] |
|---|
| | 159 | self._LockingSides[self._RightInnerSide][0][self._weakself] = [(l+w-self._DeltaAttract, t-self._DeltaWing, l+w+self._DeltaResist, t, l+w), (l+w-self._DeltaAttract, t+h, l+w+self._DeltaResist, t+h+self._DeltaWing, l+w)] |
|---|
| | 160 | self._LockingSides[self._BottomInnerSide][0][self._weakself] = [(l-self._DeltaWing, t+h-self._DeltaAttract, l, t+h+self._DeltaResist, t+h), (l+w, t+h-self._DeltaAttract, l+w+self._DeltaWing, t+h+self._DeltaResist, t+h)] |
|---|
| | 161 | self._LockingSides[self._TopInnerSide][0][self._weakself] = [(l-self._DeltaWing, t-self._DeltaResist, l, t+self._DeltaAttract, t), (l+w, t-self._DeltaResist, l+w+self._DeltaWing, t+self._DeltaAttract, t)] |
|---|
| 207 | | def _SetupScreenLockingSides(): |
|---|
| 208 | | l,t,w,h = wx.wxGetClientDisplayRect().asTuple() |
|---|
| 209 | | wxLockingFrame._LockingSides[wxLockingFrame._LeftInnerSide][0][None] = [(l-wxLockingFrame.delta, t, l+wxLockingFrame.delta, t+h, l)] |
|---|
| 210 | | wxLockingFrame._LockingSides[wxLockingFrame._RightInnerSide][0][None] = [(l+w-wxLockingFrame.delta, t, l+w+wxLockingFrame.delta, t+h, l+w)] |
|---|
| 211 | | wxLockingFrame._LockingSides[wxLockingFrame._BottomInnerSide][0][None] = [(l, t+h-wxLockingFrame.delta, l+w, t+h+wxLockingFrame.delta, t+h)] |
|---|
| 212 | | wxLockingFrame._LockingSides[wxLockingFrame._TopInnerSide][0][None] = [(l, t-wxLockingFrame.delta, l+w, t+wxLockingFrame.delta, t)] |
|---|
| 213 | | |
|---|
| 214 | | _SetupScreenLockingSides() |
|---|
| | 215 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| | 216 | |
|---|
| | 217 | class wxAttractiveLockingFrame(wxLockingFrameBase): |
|---|
| | 218 | _LockingSides = wxLockingFrameBase._LockingSides[:] |
|---|
| | 219 | _DeltaAttract = 20 |
|---|
| | 220 | _DeltaResist = 0 |
|---|
| | 221 | _DeltaWing = 10 |
|---|
| | 222 | |
|---|
| | 223 | wxAttractiveLockingFrame.SetupScreenLockingSides() |
|---|
| | 224 | |
|---|
| | 225 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| | 226 | |
|---|
| | 227 | class wxResistiveLockingFrame(wxLockingFrameBase): |
|---|
| | 228 | _LockingSides = wxLockingFrameBase._LockingSides[:] |
|---|
| | 229 | _DeltaAttract = 0 |
|---|
| | 230 | _DeltaResist = 20 |
|---|
| | 231 | _DeltaWing = 10 |
|---|
| | 232 | |
|---|
| | 233 | wxResistiveLockingFrame.SetupScreenLockingSides() |
|---|
| | 234 | |
|---|
| | 235 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| | 236 | |
|---|
| | 237 | class wxLockingFrame(wxLockingFrameBase): |
|---|
| | 238 | _LockingSides = wxLockingFrameBase._LockingSides[:] |
|---|
| | 239 | _DeltaAttract = 10 |
|---|
| | 240 | _DeltaResist = 10 |
|---|
| | 241 | _DeltaWing = 10 |
|---|
| | 242 | |
|---|
| | 243 | wxLockingFrame.SetupScreenLockingSides() |
|---|
| | 244 | |
|---|
| | 245 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|