Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/Windows Font Dialog
Function:
Required plugins for this example: MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Windows Font Dialog
This example is the version from Mon, 9th Jul 2017.
Project "Windows Font Dialog.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control FontName Inherits TextField
ControlInstance FontName Inherits TextField
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control CheckBold Inherits CheckBox
ControlInstance CheckBold Inherits CheckBox
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control CheckUnderline Inherits CheckBox
ControlInstance CheckUnderline Inherits CheckBox
End Control
Control CheckItalic Inherits CheckBox
ControlInstance CheckItalic Inherits CheckBox
End Control
Control CheckStrikethrough Inherits CheckBox
ControlInstance CheckStrikethrough Inherits CheckBox
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() f = new FontDialog f.Effects = CheckEffects.Value f.ShowApply = CheckApply.Value f.parent = self ControlsToProperties if f.ChooseFont then PropertiesToControls else if f.LastError = 0 then MsgBox "Cancel" else MsgBox "Error: "+str(f.LastError) end if end if f = nil End EventHandler
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control CheckApply Inherits CheckBox
ControlInstance CheckApply Inherits CheckBox
End Control
Control Label5 Inherits Label
ControlInstance Label5 Inherits Label
End Control
Control TextSize Inherits TextField
ControlInstance TextSize Inherits TextField
End Control
Control CheckEffects Inherits CheckBox
ControlInstance CheckEffects Inherits CheckBox
End Control
Control TextColor Inherits ColorPicker
ControlInstance TextColor Inherits ColorPicker
End Control
Sub ControlsToProperties() f.Bold = checkbold.value f.Italic = CheckItalic.Value f.Underline = CheckUnderline.Value f.Strikethrough = CheckStrikethrough.Value f.size = val(TextSize.text) f.FontName = FontName.Text f.TextColor = TextColor.ThisColor End Sub
Sub PropertiesToControls() Checkbold.Value = f.bold CheckItalic.Value = f.Italic CheckUnderline.Value = f.underline CheckStrikethrough.Value = f.StrikeThrough TextSize.Text = str(f.size) FontName.Text = f.fontName TextColor.ThisColor = f.TextColor End Sub
Property NoEvents As Boolean
Property f As FontDialog
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class FontDialog Inherits WindowsFontDialogMBS
EventHandler Sub Apply() System.DebugLog CurrentMethodName MainWindow.PropertiesToControls End EventHandler
EventHandler Sub BoundsChanged() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub BoundsChanging() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub GotFocus() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Hide() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Init() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub LostFocus() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Show() System.DebugLog CurrentMethodName End EventHandler
End Class
Class ColorPicker Inherits Canvas
ComputedProperty HasColor As Boolean
Sub Set() mHascolor = value me.Invalidate(me.EraseBackground) RaiseEvent ColorChanged() End Set
Sub Get() return mHascolor End Get
End ComputedProperty
ComputedProperty ThisColor As Color
Sub Set() mThiscolor = value me.HasColor = True me.Invalidate(me.EraseBackground) RaiseEvent ColorChanged() End Set
Sub Get() return mThiscolor End Get
End ComputedProperty
Event ColorChanged() End Event
EventHandler Function MouseDown(X As Integer, Y As Integer) As Boolean Return True End EventHandler
EventHandler Sub MouseUp(X As Integer, Y As Integer) If X > me.Width or Y > me.Height or X < 0 or Y < 0 Then Return end if if AllowPicking Then PickColor end if End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) If (me.HasColor) or (me.AlwaysColored) Then g.ForeColor = DarkBevelColor g.FillRect 0,0,g.Width,g.Height g.ForeColor = mThiscolor g.FillRect 1,1,g.Width-2,g.Height-2 Else g.ForeColor = DarkBevelColor g.FillRect 0,0,g.Width,g.Height g.PenWidth = 1 g.ForeColor = &cFF0000 g.DrawLine(3,3,g.width-4,g.height-4) End If End EventHandler
Sub PickColor() Dim cTempColor As Color cTempColor = mThisColor If SelectColor(cTempColor,"Choose the " + me.ColorName + " color") Then //user selected a color me.ThisColor = cTempColor me.Invalidate(me.EraseBackground) End If End Sub
Property AllowPicking As Boolean
Property AlwaysColored As Boolean
Property ColorName As String
Property Private mHascolor As Boolean
Property Private mThiscolor As Color
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Win Plugin.




Links
MBS FileMaker Plugins