EagleEye
unread,Aug 12, 2008, 3:49:51 AM8/12/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to EEGUI
In the development of one of my games (Pro Bridge Player), I have been
making some changes to EEGUI to accommodate what my needs are. One of
the changes you may have seen in the previous message was my changing
of the guiListBox inheritance to make it inherit from
guiScrollingWindow, instead of guiWindowEnhanced.
To be honest, guiWindowEnhanced should have NEVER been included as a
built-in control with EEGUI. It's far too complex and specialized to
be a legitimate control.
What I should have done instead is include a few separate controls...
one of which should have been a better window handle that isn't an
"attachable control" like scrollbars are, but rather a label that is a
window handle that rests on top of a window as a child, rather than
along-side it.
So here's my window handle class that I just developed. Feel free to
use it, and by all means, learn from it.
-----------------------
Public Class WindowHandle
Inherits StdLabel
Public WithEvents ControlBox As New ControlBox
Public Sub New()
DragBehavior = DragBehaviors.DragWithinParent
CanBeDragged(0) = True
DelayBeforeDrag = 0
MoveDistanceBeforeDrag = 0
End Sub
Public Overrides Sub Initialize(ByVal LabelText As String)
MyBase.Initialize(LabelText)
TextAlignHoriz = HorizAlign.Left
AddChild(ControlBox)
ControlBox.Initialize()
End Sub
Private Sub Dragged(ByVal Distance As Point) Handles
MyBase.Dragging
Position -= Distance
If Not Parent Is Nothing Then Parent.Position += Distance
End Sub
Private Sub Iwasresized() Handles MyBase.Resized
ControlBox.PositionRelativeTo(Me, RelativeDirections.Left, ,
True)
ControlBox.PositionOnParent(EEGUI.Orientation.Vertical)
End Sub
Public Event MinimizeClicked(ByVal Button As Integer)
Public Event MaximizeClicked(ByVal Button As Integer)
Public Event CloseClicked(ByVal Button As Integer)
Private Sub MinClicked(ByVal B As Integer) Handles
ControlBox.MinimizeClicked
RaiseEvent MinimizeClicked(B)
End Sub
Private Sub MaxClicked(ByVal B As Integer) Handles
ControlBox.MaximizeClicked
RaiseEvent MaximizeClicked(B)
End Sub
Private Sub CloClicked(ByVal B As Integer) Handles
ControlBox.CloseClicked
RaiseEvent CloseClicked(B)
End Sub
End Class
-----------------------
Now, you may notice I have a "controlbox" control in there. This is
the same as the windows.forms one, with the minimize/maximize/close
buttons. I just knocked it out real quick tonight... here it is:
-----------------------
Public Class ControlBox
Inherits StdWindow
Public WithEvents btnMinimize As New ControlBoxButton
Public WithEvents btnMaximize As New ControlBoxButton
Public WithEvents btnClose As New ControlBoxButton
Private bMaximized As Boolean
Public OldSize As Size
Public OldLocation As Point
Public Property Maximized() As Boolean
Get
Return bMaximized
End Get
Set(ByVal value As Boolean)
bMaximized = value
If bMaximized Then
btnMaximize.Background.Base.Texture.Tex =
"ButtonMaximizedBase"
btnMaximize.Background.MouseDown.Texture.Tex =
"ButtonMaximizedMouseDown"
btnMaximize.Background.MouseOver.Texture.Tex =
"ButtonMaximizedMouseOver"
btnMaximize.Background.Selected.Texture.Tex =
"ButtonMaximizedSelected"
btnMaximize.Background.Disabled.Texture.Tex =
"ButtonMaximizedDisabled"
Else
btnMaximize.Background.Base.Texture.Tex =
"ButtonMaximizeBase"
btnMaximize.Background.MouseDown.Texture.Tex =
"ButtonMaximizeMouseDown"
btnMaximize.Background.MouseOver.Texture.Tex =
"ButtonMaximizeMouseOver"
btnMaximize.Background.Selected.Texture.Tex =
"ButtonMaximizeSelected"
btnMaximize.Background.Disabled.Texture.Tex =
"ButtonMaximizeDisabled"
End If
End Set
End Property
Public Overrides Sub Initialize()
MyBase.Initialize()
AddChildren(btnMinimize, btnMaximize, btnClose)
btnMinimize.Initialize("ButtonMinimize")
btnMaximize.Initialize("ButtonMaximize")
btnClose.Initialize("ButtonClose")
btnMinimize.Position = New Point
btnMaximize.Left = btnMinimize.Right + 2
btnClose.Left = btnMaximize.Right + 2
Height = btnMinimize.Height
Width = btnClose.Right
End Sub
Public Event MinimizeClicked(ByVal Button As Integer)
Public Event MaximizeClicked(ByVal Button As Integer)
Public Event CloseClicked(ByVal Button As Integer)
Private Sub MinClicked(ByVal B As Integer) Handles
btnMinimize.Triggered
RaiseEvent MinimizeClicked(B)
End Sub
Private Sub MaxClicked(ByVal B As Integer) Handles
btnMaximize.Triggered
RaiseEvent MaximizeClicked(B)
End Sub
Private Sub CloClicked(ByVal B As Integer) Handles
btnClose.Triggered
RaiseEvent CloseClicked(B)
End Sub
End Class
Public Class ControlBoxButton
Inherits StdButton
Public Overrides Sub Initialize(Optional ByVal LabelText As String
= "")
MyBase.Initialize("")
Size = New Size(12, 12)
With Background
.EnableAllTextures()
.DisableAllColors()
With .Base.Texture
.Tex = LabelText & "Base"
End With
With .MouseOver.Texture
.Tex = LabelText & "MouseOver"
End With
With .MouseDown.Texture
.Tex = LabelText & "MouseDown"
End With
With .Disabled.Texture
.Tex = LabelText & "Disabled"
End With
With .Selected.Texture
.Tex = LabelText & "Selected"
End With
End With
Border.DisableAllColors()
End Sub
End Class
------------------------
Now, these classes inherit from StdWindow, StdButton, and StdLabel --
All of which, I believe, are included in the Demo app, but are called
"MyWindow", "MyButton" and "MyLabel", or somesuch...
Without looking, I think those demo classes are a little outdated...
so here's what I have for my own:
------------------------
Imports System.IO
Public Class StdWindow
Inherits guiControlBase
Public Event Err(ByVal E As String, ByVal EL As bDebugLevel, ByVal
InWindow As Boolean)
Public Overridable Sub Initialize()
Me.CenterOnParent()
Me.EscapeAction = EscapeActions.RaiseAnEvent
End Sub
Public Sub AddChildren(ByRef a As guiControlBase, ByRef b As
guiControlBase)
AddChild(a)
AddChild(b)
End Sub
Public Sub AddChildren(ByRef a As guiControlBase, ByRef b As
guiControlBase, ByRef c As guiControlBase)
AddChildren(a, b)
AddChild(c)
End Sub
Public Sub AddChildren(ByRef a As guiControlBase, ByRef b As
guiControlBase, ByRef c As guiControlBase, ByRef d As guiControlBase)
AddChildren(a, b)
AddChildren(c, d)
End Sub
Public Sub AddChildren(ByRef a As guiControlBase, ByRef b As
guiControlBase, ByRef c As guiControlBase, ByRef d As guiControlBase,
ByRef e As guiControlBase)
AddChildren(a, b)
AddChildren(c, d)
AddChild(e)
End Sub
Public Sub AddChildren(ByRef a As guiControlBase, ByRef b As
guiControlBase, ByRef c As guiControlBase, ByRef d As guiControlBase,
ByRef e As guiControlBase, ByRef f As guiControlBase)
AddChildren(a, b)
AddChildren(c, d)
AddChildren(e, f)
End Sub
Public Sub AddChildren(ByRef a As guiControlBase, ByRef b As
guiControlBase, ByRef c As guiControlBase, ByRef d As guiControlBase,
ByRef e As guiControlBase, ByRef f As guiControlBase, ByRef g As
guiControlBase)
AddChildren(a, b)
AddChildren(c, d)
AddChildren(e, f)
AddChild(g)
End Sub
End Class
------------------------
Public Class StdButton
Inherits guiButton
Public Overridable Sub Initialize(Optional ByVal LabelText As
String = "")
SetTextPadding(4, 2)
Text = LabelText
Me.AutoSize = AutoSizingMode.GrowOnly
Me.AutoSizeDirection = AutoSizingDirections.Both
Me.TextAlignHoriz = HorizAlign.Center
Me.TextAlignVert = VertAlign.Center
Me.AlwaysOnTop = True
FontIndex = SText.TextureFont_GetFontByName("Main")
With Background
With .Base.Texture
.Enabled = True
.Tex = "std_buttonBack"
End With
With .MouseOver.Texture
.Enabled = True
.Tex = "std_buttonOver"
End With
With .Selected.Texture
.Enabled = True
.Tex = "std_buttonFocus"
End With
With .MouseDown.Texture
.Enabled = True
.Tex = "std_buttonDown"
End With
End With
With Foreground
With .Base.Color
.Enabled = True
.RGBAInt = CONST_TV_COLORKEY.TV_COLORKEY_WHITE
End With
End With
With ForeShadow.Base.Color
.Enabled = True
.RGBAInt = CONST_TV_COLORKEY.TV_COLORKEY_BLACK
End With
With Border
With .Base.Color
.Enabled = True
.TVColor = New TV_COLOR(0.5, 0.5, 0.5, 1)
End With
With .MouseOver.Color
.Enabled = True
.RGBAInt = CONST_TV_COLORKEY.TV_COLORKEY_WHITE
End With
With .Selected.Color
.Enabled = True
.TVColor = New TV_COLOR(0.75, 0.75, 0.75, 1)
End With
End With
Alpha = 1
Foreground.SetAlpha(1)
End Sub
End Class
------------------------
Public Class StdLabel
Inherits guiLabel
Public Overridable Sub Initialize(ByVal LabelText As String)
Me.Text = LabelText
TextAlignHoriz = HorizAlign.Center
TextAlignVert = VertAlign.Center
Me.AutoSize = AutoSizingMode.GrowOnly
Me.AutoSizeDirection = AutoSizingDirections.Both
EscapeAction = EscapeActions.DoNothing
FontIndex = SText.TextureFont_GetFontByName("Title")
SetTextPadding(6, 2)
Me.ForeShadowOffset = 3
With Background
With .Base.Color
.Enabled = False
End With
With .MouseOver.Color
.Enabled = False
End With
With .Selected.Color
.Enabled = False
End With
End With
With Foreground.Base.Color
.Enabled = True
.RGBAInt = CONST_TV_COLORKEY.TV_COLORKEY_WHITE
End With
With ForeShadow.Base.Color
.Enabled = True
.RGBAInt = CONST_TV_COLORKEY.TV_COLORKEY_BLACK
End With
With Border
With .Base.Color
.Enabled = True
.TVColor = New TV_COLOR(0.5, 0.5, 0.5, 1)
End With
With .MouseOver.Color
.Enabled = False
.RGBAInt = CONST_TV_COLORKEY.TV_COLORKEY_WHITE
End With
With .Selected.Color
.Enabled = False
.TVColor = New TV_COLOR(0.75, 0.75, 0.75, 1)
End With
End With
Visible = True
Alpha = 0.75
Foreground.SetAlpha(1)
End Sub
End Class
------------------------
Again, feel free to use these... at the very least, learn from them on
how I have built my GUI in my own game.
I'll be posting some screen shots of it on the group soon.