Table Unicode
Publié : ven. 23/avr./2010 20:54
Un petit programme pour afficher la table des caractère Unicode
(Mettre Unicode dans les options de compilation, sinon, vous aurez la table ASCII)
(Mettre Unicode dans les options de compilation, sinon, vous aurez la table ASCII)
Code : Tout sélectionner
; Auteur : Le Soldat Inconnu
; Version de PB : 4
;
; Explication du programme :
; Création de la table ASCII ou UNICODE (en fonction du mode de compilation)
Structure Structure_Table
Chr.s
Gadget.i
Image.i
EndStructure
NewList Table.Structure_Table()
; Création de la fenêtre et de la GadgetList
CompilerIf #PB_Compiler_Unicode
Titre.s = "Table Unicode"
Maximum = 32767
CompilerElse
Titre.s = "Table ASCII"
Maximum = 255
CompilerEndIf
If OpenWindow(0, 0, 0, 600, 400, Titre, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget) = 0
End
EndIf
; Temps1 = ElapsedMilliseconds()
Define WindowDefaultFontName.s
Define ncm.NONCLIENTMETRICS
ncm\cbSize = SizeOf(NONCLIENTMETRICS)
SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
WindowDefaultFontName = PeekS(@ncm\lfMessageFont\lfFaceName, 32)
LoadFont(0, WindowDefaultFontName, 8, #PB_Font_HighQuality)
LoadFont(1, WindowDefaultFontName, 12, #PB_Font_HighQuality)
ProgressBarGadget(0, 0, 0, 600, 30, 32, Maximum)
#Taille = 16
CreateImage(0, #Taille, #Taille, 24)
Dim Image.l(#Taille - 1, #Taille - 1)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(0))
FrontColor($FFFFFF)
DrawText(0, 0, Chr(20))
For x = 0 To #Taille - 1
For y = 0 To #Taille - 1
Image(x, y) = Point(x, y)
Next
Next
AddElement(Table())
Table()\Chr = " "
For n = 33 To Maximum
Box(0, 0, #Taille, #Taille, 0)
DrawText(0, 0, Chr(n))
For x = 0 To #Taille - 1
For y = 0 To #Taille - 1
Couleur = Point(x, y)
If Image(x, y) <> Couleur And Couleur <> 0
AddElement(Table())
Table()\Chr = Chr(n)
Break 2
EndIf
Next
Next
If n > nn
nn = n + Maximum / 50
SetGadgetState(0, n)
While WindowEvent() : Wend
EndIf
Next
DrawingFont(FontID(1))
Caractere_Dimension = TextHeight("a")
StopDrawing()
FreeGadget(0)
FreeImage(0)
; Temps2 = ElapsedMilliseconds()
; MessageRequester("Temps", Str(Temps2 - Temps1))
Caractere_Dimension + 4
Largeur = Int(570 / Caractere_Dimension)
Hauteur = Round(ListSize(Table()) / Largeur, #PB_Round_Up) * Caractere_Dimension
Largeur * Caractere_Dimension
SetWindowColor(0, $FFFFFF)
If Hauteur <= 32767
ScrollAreaGadget(0, 0, 0, 600, 370, Largeur, Hauteur, #PB_ScrollArea_BorderLess)
HideGadget(0, 1)
SetGadgetColor(0, #PB_Gadget_BackColor, $FFFFFF)
Ligne = 0
Colonne = 0
ForEach Table()
Table()\Image = CreateImage(#PB_Any, Caractere_Dimension, Caractere_Dimension, 24)
If StartDrawing(ImageOutput(Table()\Image))
Box(0, 0, Caractere_Dimension, Caractere_Dimension, $FFFFFF)
DrawingMode(#PB_2DDrawing_Transparent | #PB_2DDrawing_Outlined)
DrawingFont(FontID(1))
Box(0, 0, Caractere_Dimension, Caractere_Dimension, $C0C0C0)
DrawText((Caractere_Dimension - TextWidth(Table()\Chr)) / 2, (Caractere_Dimension - TextHeight(Table()\Chr)) / 2, Table()\Chr, 0)
StopDrawing()
Table()\Gadget = ImageGadget(#PB_Any, Caractere_Dimension * Colonne, Caractere_Dimension * Ligne, Caractere_Dimension, Caractere_Dimension, ImageID(Table()\Image))
EndIf
Colonne + 1
If Caractere_Dimension * Colonne >= Largeur
Colonne = 0
Ligne + 1
EndIf
Next
CloseGadgetList()
HideGadget(0, 0)
EndIf
StringGadget(1, 0, 370, 100, 30, "")
SetGadgetFont(1, FontID(1))
StringGadget(2, 100, 370, 200, 30, "")
SetGadgetFont(2, FontID(1))
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Gadget.i = EventGadget()
ForEach Table()
If Gadget = Table()\Gadget
If EventType() = #PB_EventType_LeftClick
SetGadgetText(1, "Chr(" + Str(Asc(Table()\Chr)) + ")")
SetGadgetText(2, Right(GetGadgetText(2), 10) + Table()\Chr)
EndIf
Break
EndIf
Next
EndSelect
Until Event = #PB_Event_CloseWindow