Skip to content

Commit

Permalink
Merge pull request #179 from Kroc/master
Browse files Browse the repository at this point in the history
Add `iControlThemeable` interface
  • Loading branch information
tannerhelland committed Jan 14, 2016
2 parents 9e29fb8 + 9e6bb26 commit 1954ac2
Show file tree
Hide file tree
Showing 28 changed files with 267 additions and 9 deletions.
16 changes: 16 additions & 0 deletions Classes/iControlThemable.cls
@@ -0,0 +1,16 @@
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "iControlThemable"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public Sub UpdateAgainstCurrentTheme(): End Sub
10 changes: 10 additions & 0 deletions Controls/brushSelector.ctl
Expand Up @@ -51,6 +51,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'This control doesn't really do anything interesting, besides allow a brush to be selected.
Public Event BrushChanged()

Expand Down Expand Up @@ -133,6 +139,10 @@ Public Sub DisplayBrushSelection()
RaiseBrushDialog
End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub ucSupport_ClickCustom(ByVal Button As PDMouseButtonConstants, ByVal Shift As ShiftConstants, ByVal x As Long, ByVal y As Long)
UpdateMousePosition x, y
If m_MouseInsideBrushRect Then RaiseBrushDialog
Expand Down
9 changes: 9 additions & 0 deletions Controls/buttonStrip.ctl
Expand Up @@ -55,6 +55,11 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable

'This control really only needs one event raised - Click
Public Event Click(ByVal buttonIndex As Long)

Expand Down Expand Up @@ -166,6 +171,10 @@ Public Property Let FontSize(ByVal newSize As Single)
End If
End Property

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

'When the control receives focus, if the focus isn't received via mouse click, display a focus rect around the active button
Private Sub ucSupport_GotFocusAPI()

Expand Down
10 changes: 10 additions & 0 deletions Controls/buttonStripVertical.ctl
Expand Up @@ -55,6 +55,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'This control really only needs one event raised - Click
Public Event Click(ByVal buttonIndex As Long)

Expand Down Expand Up @@ -151,6 +157,10 @@ Public Property Let FontSize(ByVal newSize As Single)
End If
End Property

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

'When the control receives focus, if the focus isn't received via mouse click, display a focus rect around the active button
Private Sub ucSupport_GotFocusAPI()

Expand Down
10 changes: 10 additions & 0 deletions Controls/colorSelector.ctl
Expand Up @@ -52,6 +52,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'This control doesn't really do anything interesting, besides allow a color to be selected.
Public Event ColorChanged()

Expand Down Expand Up @@ -168,6 +174,10 @@ Public Sub DisplayColorSelection()

End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub ucSupport_MouseDownCustom(ByVal Button As PDMouseButtonConstants, ByVal Shift As ShiftConstants, ByVal x As Long, ByVal y As Long)

'Primary color area raises a dialog; secondary color area copies the color from the main screen
Expand Down
10 changes: 10 additions & 0 deletions Controls/gradientSelector.ctl
Expand Up @@ -49,6 +49,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'This control doesn't really do anything interesting, besides allow a gradient to be selected.
Public Event GradientChanged()

Expand Down Expand Up @@ -131,6 +137,10 @@ Public Sub DisplayGradientSelection()
RaiseGradientDialog
End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub ucSupport_ClickCustom(ByVal Button As PDMouseButtonConstants, ByVal Shift As ShiftConstants, ByVal x As Long, ByVal y As Long)
UpdateMousePosition x, y
If m_MouseInsideGradientRect Then RaiseGradientDialog
Expand Down
10 changes: 10 additions & 0 deletions Controls/pdButton.ctl
Expand Up @@ -55,6 +55,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'This control really only needs one event raised - Click
Public Event Click()

Expand Down Expand Up @@ -368,6 +374,10 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub UserControl_AccessKeyPress(KeyAscii As Integer)
RaiseEvent Click
End Sub
Expand Down
10 changes: 10 additions & 0 deletions Controls/pdButtonToolbox.ctl
Expand Up @@ -61,6 +61,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'This control really only needs one event raised - Click
Public Event Click()

Expand Down Expand Up @@ -288,6 +294,10 @@ Public Sub AssignImage_Pressed(Optional ByVal resName As String = "", Optional B

End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

'A few key events are also handled
Private Sub ucSupport_KeyDownCustom(ByVal Shift As ShiftConstants, ByVal vkCode As Long, markEventHandled As Boolean)

Expand Down
10 changes: 10 additions & 0 deletions Controls/pdCanvas.ctl
Expand Up @@ -272,6 +272,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


Private Enum PD_MOUSEEVENT
pMouseDown = 0
pMouseMove = 1
Expand Down Expand Up @@ -1922,6 +1928,10 @@ Public Sub cMouseEvents_MouseWheelZoom(ByVal Button As PDMouseButtonConstants, B

End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

'(This code is copied from FormMain's OLEDragDrop event - please mirror any changes there)
Private Sub picCanvas_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)

Expand Down
10 changes: 10 additions & 0 deletions Controls/pdColorVariants.ctl
Expand Up @@ -49,6 +49,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'Just like PD's old color selector, this control will raise a ColorChanged event after user interactions.
Public Event ColorChanged(ByVal newColor As Long, ByVal srcIsInternal As Boolean)

Expand Down Expand Up @@ -261,6 +267,10 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub UserControl_Initialize()

If g_IsProgramRunning Then
Expand Down
10 changes: 10 additions & 0 deletions Controls/pdColorWheel.ctl
Expand Up @@ -46,6 +46,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'Just like PD's old color selector, this control will raise a ColorChanged event after user interactions.
Public Event ColorChanged(ByVal newColor As Long, ByVal srcIsInternal As Boolean)

Expand Down Expand Up @@ -367,6 +373,10 @@ Private Sub cPainter_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long, By

End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub UserControl_Initialize()

If g_IsProgramRunning Then
Expand Down
10 changes: 10 additions & 0 deletions Controls/pdComboBox.ctl
Expand Up @@ -70,6 +70,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'By design, this combo box raises fewer events than a standard combo box. I would prefer the Click() event to actually be Change(),
' but I have used Click() throughout VB due to the behavior of the old combo box - and rather than rewrite all that code, I've simply
' used the same semantics here. Note, however, that "Click" will also return changes to the combo box that originate from the keyboard.
Expand Down Expand Up @@ -835,6 +841,10 @@ Private Sub cResize_WindowResize(ByVal newWidth As Long, ByVal newHeight As Long
If Not m_InternalResizeState Then syncUserControlSizeToComboSize
End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub tmrHookRelease_Timer()

'If a hook is active, this timer will repeatedly try to kill it. Do not enable it until you are certain the hook needs to be released.
Expand Down
10 changes: 10 additions & 0 deletions Controls/pdComboBox_Font.ctl
Expand Up @@ -71,6 +71,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'By design, this combo box raises fewer events than a standard combo box. I would prefer the Click() event to actually be Change(),
' but I have used Click() throughout VB due to the behavior of the old combo box - and rather than rewrite all that code, I've simply
' used the same semantics here. Note, however, that "Click" will also return changes to the combo box that originate from the keyboard.
Expand Down Expand Up @@ -808,6 +814,10 @@ Private Sub cPainterBox_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long,
drawComboBox True
End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub tmrHookRelease_Timer()

'If a hook is active, this timer will repeatedly try to kill it. Do not enable it until you are certain the hook needs to be released.
Expand Down
10 changes: 10 additions & 0 deletions Controls/pdComboBox_Hatch.ctl
Expand Up @@ -70,6 +70,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'By design, this combo box raises fewer events than a standard combo box. I would prefer the Click() event to actually be Change(),
' but I have used Click() throughout VB due to the behavior of the old combo box - and rather than rewrite all that code, I've simply
' used the same semantics here. Note, however, that "Click" will also return changes to the combo box that originate from the keyboard.
Expand Down Expand Up @@ -728,6 +734,10 @@ Private Sub cPainterBox_PaintWindow(ByVal winLeft As Long, ByVal winTop As Long,
drawComboBox True
End Sub

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub tmrHookRelease_Timer()

'If a hook is active, this timer will repeatedly try to kill it. Do not enable it until you are certain the hook needs to be released.
Expand Down
10 changes: 10 additions & 0 deletions Controls/pdHyperlink.ctl
Expand Up @@ -61,6 +61,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'In its default configuration, this control raises no events. However, if default "shell URL behavior" is not desired,
' properties can be modified so that a Click() event is raised instead.
Public Event Click()
Expand Down Expand Up @@ -455,6 +461,10 @@ Public Property Get ContainerHwnd() As Long
ContainerHwnd = UserControl.ContainerHwnd
End Property

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

'INITIALIZE control
Private Sub UserControl_Initialize()

Expand Down
10 changes: 10 additions & 0 deletions Controls/pdLabel.ctl
Expand Up @@ -60,6 +60,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'This control raises no events, by design.

'Rather than handle autosize and wordwrap separately, this control combines them into a single "Layout" property.
Expand Down Expand Up @@ -248,6 +254,10 @@ Public Property Let UseCustomForeColor(ByVal newSetting As Boolean)
End If
End Property

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub ucSupport_RepaintRequired(ByVal updateLayoutToo As Boolean)
If updateLayoutToo Then updateControlLayout
RedrawBackBuffer
Expand Down
10 changes: 10 additions & 0 deletions Controls/pdListBox.ctl
Expand Up @@ -42,6 +42,12 @@ Attribute VB_Exposed = False

Option Explicit

'This implementation binding will allow us to refer to all themeable controls _
under a single type, making form control iteration much simpler _
(we won't need to maintain long lists of UserControl names)
Implements iControlThemable


'This control raises much fewer events than a standard ListBox, by design
Public Event Click()

Expand Down Expand Up @@ -100,6 +106,10 @@ Public Property Get hWnd() As Long
hWnd = UserControl.hWnd
End Property

Private Sub iControlThemable_UpdateAgainstCurrentTheme()
Call Me.UpdateAgainstCurrentTheme
End Sub

Private Sub ucSupport_ClickCustom(ByVal Button As PDMouseButtonConstants, ByVal Shift As ShiftConstants, ByVal x As Long, ByVal y As Long)
UpdateMousePosition x, y
'TODO: raise click events
Expand Down

0 comments on commit 1954ac2

Please sign in to comment.