Editeur de texte
Editeur de texte
Je cherche un éditeur de texte le plus complet possible et écrit en purebasic bien sûr.
Quelqu'un a-t-il gardé le fichier qui est ici ?
http://forums.purebasic.com/french/view ... baed9bc841
Ce qui m’intéresse le plus c'est l'ouverture et l'enregistrement de texte au format html et pdf.
Des idées ?
Mesa.
Quelqu'un a-t-il gardé le fichier qui est ici ?
http://forums.purebasic.com/french/view ... baed9bc841
Ce qui m’intéresse le plus c'est l'ouverture et l'enregistrement de texte au format html et pdf.
Des idées ?
Mesa.
- Kwai chang caine
- Messages : 6989
- Inscription : sam. 23/sept./2006 18:32
- Localisation : Isere
Re: Editeur de texte
Moi j'ai ça de STEFOU comme editeur de texte, je ne sais pas si ça correspond 
1er code

1er code
Code : Tout sélectionner
Global nom_fichier_note_pad$,MaxD,code_fin_sauvegarde_texte$,code_fin_sauvegarde_format$
nom_fichier_note_pad$="text_note_pad.txt"
code_fin_sauvegarde_texte$="#FIN_TXT#"
code_fin_sauvegarde_format$="#FIN_FORMAT#"
Procedure.b ReadBin(Valeur.l, Position);permet de lire un byte à la position
If Valeur & (%1 << Position)
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure
Global Dim Couleur_Base(10)
Global Dim Couleur_perso(2,10)
Global Dim Nom_Font.s(1)
Nom_Font(0)="0"
Procedure Initialise_couleur(); couleur de la palette de base
i=0
Couleur_Base(i)= 0 : i=i+1
Couleur_Base(i)= 1 : i=i+1
Couleur_Base(i)= $0000FF : i=i+1
Couleur_Base(i)= $00FFFF : i=i+1
Couleur_Base(i)= $FF00FF : i=i+1
Couleur_Base(i)= $00FF00 : i=i+1
Couleur_Base(i)= $FFFF00 : i=i+1
Couleur_Base(i)= $FF0000 : i=i+1
Couleur_Base(i)= $008000 : i=i+1
Couleur_Base(i)= $FFFFFF : i=i+1
For i=0 To 2
For j=0 To 9
Couleur_perso(i,j)=$E26152
Next
Next
EndProcedure
Procedure Test_Font_Doublon(nom_font$);Test si le nom de la police est déjà dans la liste
For i=1 To Val(Nom_Font(0))
If Nom_Font(i)=nom_font$
ProcedureReturn 0
EndIf
Next
ProcedureReturn 1
EndProcedure
Procedure Ajout_Nom_Font(nom_font$);Ajoute le nom de la police à la liste des polices
If Test_Font_Doublon(nom_font$)
nb_ele=Val(Nom_Font(0))+1
ReDim Nom_Font.s(nb_ele)
Nom_Font(nb_ele)=nom_font$
Nom_Font(0)=Str(nb_ele)
EndIf
EndProcedure
Procedure EnumFontFamProc(lpelf.l, lpntm.l, FontType.l, lParam.l)
Static FontCounter.l
*lpelf.ENUMLOGFONT = lpelf
sFontType.s = ""
TrueType = #False
If FontType & #DEVICE_FONTTYPE
sFontType.s + "Device "
EndIf
If FontType & #RASTER_FONTTYPE
sFontType.s + "Raster "
EndIf
If FontType & #TRUETYPE_FONTTYPE
sFontType.s + "TrueType "
TrueType = #True
EndIf
FontHeight = *lpelf\elfLogFont\lfHeight
FontWidth = *lpelf\elfLogFont\lfWidth
FontEscapement = *lpelf\elfLogFont\lfEscapement
FontOrientation = *lpelf\elfLogFont\lfOrientation
FontWeight = *lpelf\elfLogFont\lfWeight
FontItalic = *lpelf\elfLogFont\lfItalic
FontUnderline = *lpelf\elfLogFont\lfUnderline
FontStrikeOut = *lpelf\elfLogFont\lfStrikeOut
FontCharSet = *lpelf\elfLogFont\lfCharSet
FontOutPrecision = *lpelf\elfLogFont\lfOutPrecision
FontClipPrecision = *lpelf\elfLogFont\lfClipPrecision
FontQuality = *lpelf\elfLogFont\lfQuality
FontPitchAndFamily = *lpelf\elfLogFont\lfPitchAndFamily
FontName.s = ""
i = 0
While *lpelf\elfFullName[i] <>0
FontName + Chr(*lpelf\elfFullName[i])
i + 1
Wend
FontStyle.s = ""
i = 0
While *lpelf\elfStyle[i] <>0
FontStyle + Chr(*lpelf\elfStyle[i])
i + 1
Wend
If TrueType
*lpntm1.NEWTEXTMETRIC = lpntm
MetricHeight = *lpntm1\tmHeight
MetricAscent = *lpntm1\tmAscent
MetricDescent = *lpntm1\tmDescent
MetricInternalLeading = *lpntm1\tmInternalLeading
MetricExternalLeading = *lpntm1\tmExternalLeading
MetricAveCharWidth = *lpntm1\tmAveCharWidth
MetricMaxCharWidth = *lpntm1\tmMaxCharWidth
MetricWeight = *lpntm1\tmWeight
MetricOverhang = *lpntm1\tmOverhang
MetricDigitizedAspectX = *lpntm1\tmDigitizedAspectX
MetricDigitizedAspectY = *lpntm1\tmDigitizedAspectY
MetricFirstChar = *lpntm1\tmFirstChar
MetricLastChar = *lpntm1\tmLastChar
MetricDefaultChar = *lpntm1\tmDefaultChar
MetricBreakChar = *lpntm1\tmBreakChar
MetricItalic = *lpntm1\tmItalic
MetricUnderlined = *lpntm1\tmUnderlined
MetricStruckOut = *lpntm1\tmStruckOut
MetricPitchAndFamily = *lpntm1\tmPitchAndFamily
MetricCharSet = *lpntm1\tmCharSet
MetricFlags = *lpntm1\ntmFlags
MetricSizeEM = *lpntm1\ntmSizeEM
MetricCellHeight = *lpntm1\ntmCellHeight
MetricAveWidth = *lpntm1\ntmAveWidth
Else
*lpntm2.TEXTMETRIC = lpntm
MetricHeight = *lpntm2\tmHeight
MetricAscent = *lpntm2\tmAscent
MetricDescent = *lpntm2\tmDescent
MetricInternalLeading = *lpntm2\tmInternalLeading
MetricExternalLeading = *lpntm2\tmExternalLeading
MetricAveCharWidth = *lpntm2\tmAveCharWidth
MetricMaxCharWidth = *lpntm2\tmMaxCharWidth
MetricWeight = *lpntm2\tmWeight
MetricOverhang = *lpntm2\tmOverhang
MetricDigitizedAspectX = *lpntm2\tmDigitizedAspectX
MetricDigitizedAspectY = *lpntm2\tmDigitizedAspectY
MetricFirstChar = *lpntm2\tmFirstChar
MetricLastChar = *lpntm2\tmLastChar
MetricDefaultChar = *lpntm2\tmDefaultChar
MetricBreakChar = *lpntm2\tmBreakChar
MetricItalic = *lpntm2\tmItalic
MetricUnderlined = *lpntm2\tmUnderlined
MetricStruckOut = *lpntm2\tmStruckOut
MetricPitchAndFamily = *lpntm2\tmPitchAndFamily
MetricCharSet = *lpntm2\tmCharSet
EndIf
sFontAttributes.s = ""
If FontItalic
sFontAttributes + "I"
EndIf
If FontUnderline
sFontAttributes + "U"
EndIf
If FontStrikeOut
sFontAttributes + "S"
EndIf
If sFontAttributes <> ""
sFontAttributes = "(" + sFontAttributes + ")"
EndIf
If lParam
If FindString(LCase(FontName), LCase(PeekS(lParam)), 1)
nom_font$=FontName
Debug "***** "+nom_font$
Ajout_Nom_Font(nom_font$)
EndIf
Else
nom_font$=FontName
Debug "****- "+nom_font$
Ajout_Nom_Font(nom_font$)
EndIf
While WindowEvent()
Wend
FontCounter + 1
ProcedureReturn 1
EndProcedure
Procedure list_font(id_window,id_gadget)
ClearGadgetItemList(id_gadget)
Ajout_Nom_Font("//Base//")
EnumFontFamilies_(GetDC_(WindowID(id_window)), #Null, @EnumFontFamProc(), 0)
nb_ele=Val(Nom_Font(0))
Nom_Font(0)=""
SortArray(Nom_Font(),2)
For i=1 To nb_ele
AddGadgetItem(id_gadget,-1,Nom_Font(i))
Next
SetGadgetState(id_gadget,0)
EndProcedure
Enumeration #PB_Compiler_EnumerationValue
#note_pad_ID
#notepade_load
#notepade_save
#notepade_zoom
#notepade_alig_gauche
#notepade_alig_centre
#notepade_alig_droite
#notepade_text_plus
#notepade_text_moins
#notepade_gras
#notepade_italique
#notepade_surligner
#notepade_barrer
;ne pas changer l'ordre d'ici
#im_coul_texte
#im_coul_fond
#im_coul_page
;ne pas changer l'ordre a ici
#notepade_liste_font
EndEnumeration
Procedure Create_palette(id_im,l,h)
Select id_im
Case #im_coul_texte
num_pal=0
Case #im_coul_fond
num_pal=1
Case #im_coul_page
num_pal=2
EndSelect
CreateImage(id_im,l,h)
StartDrawing(ImageOutput(id_im))
Box(0,0,l,h,$C0C0C0)
For i=0 To 10
Box(i*l/10,0,l/10-1,h/2-1,$9A9A9A)
Next
Box(1,0+1,l/10-3,h/2-3,$FFFFFF)
LineXY(1,0+1,l/10-3,h/2-3,$0000FF)
For i=1 To 10
Box(i*l/10+1,0+1,l/10-3,h/2-3,Couleur_Base(i))
Next
For i=0 To 10
Box(i*l/10+1,h/2+1,l/10-3,h/2-3,Couleur_perso(num_pal,i))
Next
StopDrawing()
SetGadgetState(id_im,ImageID( id_im))
EndProcedure
Procedure Dessine_palette()
;HideGadget(#note_pad_ID,1)
x=GadgetX(#note_pad_ID)
y=GadgetY(#note_pad_ID)+20;+GadgetHeight(#note_pad_ID)+40
l=GadgetWidth(#note_pad_ID)
h=GadgetHeight(#note_pad_ID)
espace=15
l_pal=l/3-espace
h_pal=40
TextGadget(#PB_Any,x,y+h,l_pal,h_pal,"Couleur du texte" )
TextGadget(#PB_Any,x+l_pal+espace,y+h,l_pal,h_pal,"Couleur du fond du texte" )
TextGadget(#PB_Any,x+2*l_pal+2*espace,y+h,l_pal,h_pal,"Couleur de la page" )
ImageGadget(#im_coul_texte,x,y+h+20,l_pal,h_pal,0)
Create_palette(#im_coul_texte,l_pal,h_pal)
ImageGadget(#im_coul_fond,x+l_pal+espace,y+h+20,l_pal,h_pal,0)
Create_palette(#im_coul_fond,l_pal,h_pal)
ImageGadget(#im_coul_page,x+2*l_pal+2*espace,y+h+20,l_pal,h_pal,0)
Create_palette(#im_coul_page,l_pal,h_pal)
TextGadget(#PB_Any,x+l_pal+espace,y+h+20+h_pal,l_pal,20,"Clic droit pour choisir une couleur" )
TextGadget(#PB_Any,x+l_pal+espace,y+h+40+h_pal,l_pal,20,"F6 pour inserer un tableau" )
EndProcedure
Procedure CreateNotepad(x,y,l,h)
pos=x
EditorGadget(#note_pad_ID,x,y+20,l,h-60)
SendMessage_(GadgetID(#note_pad_ID), #EM_SETTARGETDEVICE, #Null, 0) ;retour à la ligne automatique
pos=x
h_g=20
l_g=40
ButtonGadget(#notepade_load,pos,y,l_g,h_g,"Ouvrir")
pos=pos+l_g+2
l_g=50
ButtonGadget(#notepade_save,pos,y,l_g,h_g,"Enregistrer")
pos=pos+l_g+2+5
l_g=25
ButtonGadget(#notepade_alig_gauche,pos,y,l_g,h_g,"G",#PB_Button_Toggle )
pos=pos+l_g+2
;l_g=40
ButtonGadget(#notepade_alig_centre,pos,y,l_g,h_g,"C",#PB_Button_Toggle )
pos=pos+l_g+2
;l_g=40
ButtonGadget(#notepade_alig_droite,pos,y,l_g,h_g,"D",#PB_Button_Toggle )
l_g=45
pos=pos+l_g+2
ButtonGadget(#notepade_text_moins,pos,y,l_g,h_g,"Texte -")
pos=pos+l_g+2
ButtonGadget(#notepade_text_plus,pos,y,l_g,h_g,"Texte +")
pos=pos+l_g+2
l_g=20
ButtonGadget(#notepade_gras,pos,y,l_g,h_g,"G",#PB_Button_Toggle )
pos=pos+l_g+2
ButtonGadget(#notepade_italique,pos,y,l_g,h_g,"I",#PB_Button_Toggle )
pos=pos+l_g+2
ButtonGadget(#notepade_surligner,pos,y,l_g,h_g,"S",#PB_Button_Toggle )
pos=pos+l_g+2
ButtonGadget(#notepade_barrer,pos,y,l_g,h_g,"B",#PB_Button_Toggle )
pos=pos+l_g+2
ComboBoxGadget(#notepade_liste_font,pos,y,160,300 )
pos=pos+l_g+2
Maxrange=100
MaxD=Maxrange/10 +1
TrackBarGadget(#notepade_zoom, x+l-60, y,60,20, 1, Maxrange )
Dessine_palette()
EndProcedure
Procedure Selection_SelectAll(editorgadget)
range.CHARRANGE\cpMin = 0
range\cpMax = -1
ProcedureReturn SendMessage_(GadgetID(editorgadget),#EM_EXSETSEL,0,@range)
EndProcedure
Procedure Selection_Select(Gadget, LineStart.l, CharStart.l, LineEnd.l, CharEnd.l)
sel.CHARRANGE
sel\cpMin = SendMessage_(GadgetID(Gadget), #EM_LINEINDEX, LineStart, 0) + CharStart - 1
If LineEnd = -1
LineEnd = SendMessage_(GadgetID(Gadget), #EM_GETLINECOUNT, 0, 0)-1
EndIf
sel\cpMax = SendMessage_(GadgetID(Gadget), #EM_LINEINDEX, LineEnd, 0)
If CharEnd = -1
sel\cpMax + SendMessage_(GadgetID(Gadget), #EM_LINELENGTH, sel\cpMax, 0)
Else
sel\cpMax + CharEnd - 1
EndIf
SendMessage_(GadgetID(Gadget), #EM_EXSETSEL, 0, @sel)
EndProcedure
;- Format par charactere
Procedure Get_Selection_Color(Gadget)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_COLOR
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
ProcedureReturn format\crTextColor
EndProcedure
Procedure Get_Selection_BackColor(Gadget)
format.CHARFORMAT2
format\cbSize = SizeOf(CHARFORMAT2)
format\dwMask = $4000000;#CFM_COLOR
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
ProcedureReturn format\crBackColor
EndProcedure
Procedure Get_Selection_Taille(Gadget)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_SIZE
format\yHeight= Taille
format\crTextColor = Color
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
ProcedureReturn format\yHeight
EndProcedure
Procedure Get_Selection_Effect(Gadget)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_BOLD
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
ProcedureReturn format\dwEffects
EndProcedure
Procedure.s Get_Selection_Font(Gadget)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_FACE
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
FontName.s=PeekS(@format\szFaceName )
ProcedureReturn FontName
EndProcedure
Procedure Set_Selection_Font(Gadget,FontName.s)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_FACE
PokeS(@format\szFaceName, FontName)
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Set_Selection_Effect(Gadget, effect,type)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = effect
format\dwEffects = type
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Set_Selection_Taille(Gadget, Taille.l)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\yHeight= Taille
format\dwMask = #CFM_SIZE
format\crTextColor = Color
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Set_Selection_Color(Gadget, Color.l)
Debug Color
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_COLOR
format\crTextColor = Color
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Set_Selection_BackColor(Gadget, Color.l)
Debug "setcolor"
Debug Color
format.CHARFORMAT2;_
format\cbSize = SizeOf(CHARFORMAT2);_)
format\dwMask = $4000000 ; = #CFM_BACKCOLOR
format\crBackColor = Color
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
;- Format par paragraphe
Procedure Get_Selection_paragraphe(Gadget)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_ALIGNMENT
SendMessage_(GadgetID(Gadget), #EM_GETPARAFORMAT, 0, @format)
ProcedureReturn format\wAlignment
EndProcedure
Procedure Get_Selection_decallage_gauche(Gadget)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_OFFSETINDENT
SendMessage_(GadgetID(Gadget), #EM_GETPARAFORMAT, 0, @format)
ProcedureReturn format\dxStartIndent
EndProcedure
Procedure Get_Selection_decallage_droite(Gadget)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_RIGHTINDENT
SendMessage_(GadgetID(Gadget), #EM_GETPARAFORMAT, 0, @format)
ProcedureReturn format\dxRightIndent
EndProcedure
Procedure Get_Selection_decallage_gauche_ss_premiere_ligne(Gadget)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_OFFSET
SendMessage_(GadgetID(Gadget), #EM_GETPARAFORMAT, 0, @format)
ProcedureReturn format\dxOffset
EndProcedure
Procedure Set_Selection_decallage_gauche_ss_premiere_ligne(Gadget,decallage)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_OFFSET
format\dxOffset = decallage
SendMessage_(GadgetID(Gadget), #EM_SETPARAFORMAT, 0, @format)
EndProcedure
Procedure Set_Selection_decallage_droite(Gadget,decallage)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_RIGHTINDENT
format\dxRightIndent = decallage
SendMessage_(GadgetID(Gadget), #EM_SETPARAFORMAT, 0, @format)
EndProcedure
Procedure Set_Selection_decallage_gauche(Gadget,decallage)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_OFFSETINDENT
format\dxStartIndent = decallage
SendMessage_(GadgetID(Gadget), #EM_SETPARAFORMAT, 0, @format)
EndProcedure
Procedure Set_Selection_paragraphe(Gadget,paragraphe)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_ALIGNMENT
format\wAlignment = paragraphe
SendMessage_(GadgetID(Gadget), #EM_SETPARAFORMAT, 0, @format)
EndProcedure
Procedure.s TableauRTF(nbcol,nbligne,largeur)
result.s = "{\rtf1\trowd"
For i=1 To nbcol
result + "\cellx"+Str(i*largeur)
Next
For j=1 To nbligne
result + "\intbl"
For i=1 To nbcol
result + "\cell"
Next
result + "\row"
Next
result + "}"
ProcedureReturn result
EndProcedure
Procedure EditorGadgetCursorX(Gadget)
; returns X-Pos of Cursor
REG = GadgetID(Gadget)
SendMessage_(REG,#EM_EXGETSEL,0,range.CHARRANGE)
ProcedureReturn (range\cpMax-(SendMessage_(REG,#EM_LINEINDEX,SendMessage_(REG,#EM_EXLINEFROMCHAR,0,range\cpMin),0))+1)
EndProcedure
Procedure EditorGadgetCursorY(Gadget)
; returns Y-Pos of Cursor
REG = GadgetID(Gadget)
SendMessage_(REG,#EM_EXGETSEL,0,range.CHARRANGE)
ProcedureReturn SendMessage_(REG,#EM_EXLINEFROMCHAR,0,range\cpMin)+1
EndProcedure
Procedure EditorGadgetCursorPos(Gadget)
; returns relative Position of Cursor
SendMessage_(GadgetID(Gadget),#EM_EXGETSEL,0,range.CHARRANGE)
ProcedureReturn range\cpMax
EndProcedure
Procedure EditorGadgetLocate(Gadget,x,y)
; Set cursor position
REG = GadgetID(Gadget)
CharIdx = SendMessage_(REG,#EM_LINEINDEX,y-1,0)
LLength = SendMessage_(REG,#EM_LINELENGTH,CharIdx,0)
If LLength >= x-1
CharIdx + x-1
EndIf
range.CHARRANGE
range\cpMin = CharIdx
range\cpMax = CharIdx
SendMessage_(REG,#EM_EXSETSEL,0,range)
EndProcedure
Procedure Write_Format(ligne_debut,ligne_fin,debut,fin,couleur,couleur_fond,Taille,effect,paragraphe,FontName$)
Debug Str(ligne_debut)+" : "+Str(ligne_fin)+" : "+Str(debut)+" : "+Str(fin)+" : "+Str(couleur)+" : "+Str(couleur_fond)+" : "+Str(Taille)+" : "
WriteLong(0, ligne_debut)
WriteLong(0, ligne_fin)
WriteLong(0, debut)
WriteLong(0, fin)
WriteLong(0, couleur)
If couleur_fond=0
couleur_fond=-1
EndIf
WriteLong(0, couleur_fond)
WriteLong(0, Taille)
WriteLong(0, effect)
WriteLong(0, paragraphe)
WriteStringN(0,FontName$)
EndProcedure
Procedure sauve_editor1(id_gadget,nom_fichier$) ; procedure plus utilisé, mais je la garde sous le coude !
Debug "SAUVE"
;AddGadgetItem(id_gadget, 0,"")
If CreateFile(0,nom_fichier$)
;{Enregistrement du texte
WriteStringN(0,GetGadgetText(id_gadget))
WriteStringN(0,code_fin_sauvegarde_texte$)
;}
;{Enregistrement des parametres bases et de départ
zoom=GetGadgetState(#notepade_zoom)
WriteLong(0, zoom)
WriteLong(0, GetGadgetColor(id_gadget,#PB_Gadget_BackColor))
;}
format.CHARFORMAT2
format\cbSize = SizeOf(CHARFORMAT2)
format\dwMask = #CFM_COLOR | #CFM_SIZE |#CFM_BOLD|#CFM_FACE
Selection_Select(id_gadget, 0, 1, 0, 1)
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
couleur= format\crTextColor
couleur_fond= format\crBackColor
Taille= format\yHeight
effect=format\dwEffects
FontName$=PeekS(@format\szFaceName )
;WriteLong(0, der_couleur )
;;WriteLong(0,der_couleur_fond)
;WriteLong(0,der_taille)
der_paragraphe=Get_Selection_paragraphe(Gadget)
paragraphe=der_paragraphe
der_effect=effect
der_couleur_fond=couleur_fond
der_couleur=couleur
der_taille=Taille
der_FontName$=FontName$
pos_coul=1
ligne_coul=0
For i=0 To CountGadgetItems(id_gadget)
nb_chr=Len( GetGadgetItemText(id_gadget,i,0))
For j=1 To nb_chr
Selection_Select(id_gadget, i, j+1, i, j+1)
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
FontName$=PeekS(@format\szFaceName )
couleur= format\crTextColor
couleur_fond= format\crBackColor
Taille= format\yHeight
effect=format\dwEffects
paragraphe=Get_Selection_paragraphe(Gadget)
If der_couleur<>couleur Or der_FontName$<>FontName$ Or der_taille<>Taille Or der_couleur_fond<>couleur_fond Or effect<>der_effect Or paragraphe<>der_paragraphe
Write_Format(ligne_coul,i,pos_coul,j,der_couleur,der_couleur_fond,der_taille,der_effect,der_paragraphe,der_FontName$)
der_paragraphe=paragraphe
der_effect=effect
der_couleur_fond=couleur_fond
der_couleur=couleur
der_taille=Taille
der_FontName$=FontName$
ligne_coul=i
pos_coul=j
EndIf
Next
Next
Write_Format(ligne_coul,i,pos_coul,j,der_couleur,der_couleur_fond,der_taille,der_effect,der_paragraphe,FontName$)
WriteStringN(0, code_fin_sauvegarde_format$)
For i=0 To 9
WriteLong(0,Couleur_Base(i))
Next
For i=0 To 2
For j=0 To 9
WriteLong(0,Couleur_perso(i,j))
Next
Next
CloseFile(0)
EndIf
EndProcedure
Procedure load_editor1(id_gadget,nom_fichier$) ; procedure plus utilisé, mais je la garde sous le coude !
Debug "LOAD"
;SetGadgetText(id_gadget,"")
ClearGadgetItemList(id_gadget)
If ReadFile(0,nom_fichier$)
Repeat
ligne$=ReadString(0)
If ligne$<>code_fin_sauvegarde_texte$
AddGadgetItem(id_gadget,-1,ligne$)
EndIf
Until Loc(0)=Lof(0) Or ligne$=code_fin_sauvegarde_texte$
; FileSeek(0,Loc(0)-2)
; Debug ReadByte(0)
; Debug ReadByte(0)
zoom=ReadLong(0)
lRet=SendMessage_(GadgetID(#note_pad_ID),#EM_SETZOOM,zoom+10,MaxD)
SetGadgetState(#notepade_zoom,zoom)
couleur_page=ReadLong(0)
SetGadgetColor(id_gadget,#PB_Gadget_BackColor,couleur_page)
Selection_Select(id_gadget, 0, 1, 0, 1)
;Set_Selection_Color(id_gadget,ReadLong(0))
;Set_Selection_BackColor(id_gadget,ReadLong(0))
;Set_Selection_Taille(id_gadget,ReadLong(0))
If Loc(0)<>Lof(0)
Repeat
ligne_debut=ReadLong(0)
ligne_fin=ReadLong(0)
debut=ReadLong(0)
fin=ReadLong(0)
couleur=ReadLong(0)
couleur_fond=ReadLong(0)
Taille=ReadLong(0)
effect=ReadLong(0)
paragraphe=ReadLong(0)
FontName$=ReadString(0)
Debug Str(ligne_debut)+" : "+Str(ligne_fin)+" : "+Str(debut)+" : "+Str(fin)+" : "+Str(couleur)+" : "+Str(couleur_fond)+" : "+Str(Taille)+" : "
Selection_Select(id_gadget, ligne_debut, debut, ligne_fin, fin)
If couleur<>-1
Set_Selection_Color(id_gadget,couleur)
EndIf
If couleur_fond<>-1
Set_Selection_BackColor(id_gadget,couleur_fond)
EndIf
If Taille<>-1
Set_Selection_Taille(id_gadget,Taille)
EndIf
Set_Selection_Effect(id_gadget, effect,effect)
Set_Selection_paragraphe(id_gadget,paragraphe)
Debug "setfont"
Debug FontName$
Set_Selection_Font(id_gadget,FontName$)
pos=Loc(0)
ligne$=ReadString(0)
FileSeek(0,pos)
Until Loc(0)=Lof(0) Or ligne$= code_fin_sauvegarde_format$
If Loc(0)<>Lof(0)
ligne$=ReadString(0)
For i=0 To 9
Couleur_Base(i)=ReadLong(0)
Next
For i=0 To 2
For j=0 To 9
Couleur_perso(i,j)=ReadLong(0)
Next
Next
EndIf
CloseFile(0)
;RemoveGadgetItem(id_gadget, 0)
Selection_Select(id_gadget,0, 0,0, 0)
Dessine_palette()
EndIf
EndIf
EndProcedure
Procedure EditCallBack_Ecriture(dwCookie.l, *pbBuff.l, cb.l, *pcb.l)
If WriteData(0,*pbBuff, cb)
ProcedureReturn 0
Else
ProcedureReturn 1
EndIf
EndProcedure
Procedure EditCallBack_Lecture(dwCookie.l, *pbBuff.l, cb.l, *pcb.l)
If ReadFile_(dwCookie, *pbBuff, cb, *pcb, 0)
ProcedureReturn 0
Else
ProcedureReturn 1
EndIf
EndProcedure
Procedure sauve_editor(id_gadget,nom_fichier$)
If nom_fichier$<>""
If CreateFile(0, nom_fichier$)
Edit.EDITSTREAM
Edit\dwCookie=0
Edit\pfnCallback=@EditCallBack_Ecriture()
SendMessage_(GadgetID(id_gadget),#EM_STREAMOUT,#SF_RTF,Edit)
If Edit\dwError=0
Debug "L'écriture s'est bien déroulée"
Else
Debug "L'écriture du fichier a provoqué une erreur"
EndIf
CloseFile(0)
EndIf
EndIf
EndProcedure
Procedure load_editor(id_gadget,nom_fichier$)
If nom_fichier$<>""
hFile=OpenFile(1, nom_fichier$)
Edit.EDITSTREAM
Edit\dwCookie=hFile
Edit\pfnCallback=@EditCallBack_Lecture()
SendMessage_(GadgetID(id_gadget),#EM_STREAMIN,#SF_RTF,Edit)
If Edit\dwError=0
Debug "La lecture s'est bien déroulée"
Else
Debug "La lecture du fichier a provoqué une erreur"
EndIf
CloseFile(1)
EndIf
EndProcedure
Procedure Select_Font(Nom_font.s)
For i=0 To CountGadgetItems(#notepade_liste_font)
If Nom_font=GetGadgetItemText(#notepade_liste_font,i,i)
SetGadgetState(#notepade_liste_font,i)
ProcedureReturn 1
EndIf
Next
SetGadgetState(#notepade_liste_font,0)
ProcedureReturn -1
EndProcedure
Procedure evenement_notepad(id_window,event )
Select event
Case #PB_Event_Gadget; *****************Choix d'un bouton
Select EventGadget()
Case #note_pad_ID
Select_Font( Get_Selection_Font(Gadget))
Debug "P:"+Str(Get_Selection_paragraphe(Gadget))+"E:"+Str(Get_Selection_Effect(Gadget))+"C:"+Str(Get_Selection_Color(Gadget))+" BC:"+Str(Get_Selection_BackColor(Gadget) )+" T:"+Str(Get_Selection_Taille(Gadget) )
Select Get_Selection_paragraphe(Gadget)
Case 0,1
SetGadgetState(#notepade_alig_gauche,1)
SetGadgetState(#notepade_alig_droite,0)
SetGadgetState(#notepade_alig_centre,0)
Case 2
SetGadgetState(#notepade_alig_gauche,0)
SetGadgetState(#notepade_alig_droite,1)
SetGadgetState(#notepade_alig_centre,0)
Case 3
SetGadgetState(#notepade_alig_gauche,0)
SetGadgetState(#notepade_alig_droite,0)
SetGadgetState(#notepade_alig_centre,1)
EndSelect
effect=Get_Selection_Effect(Gadget)
If ReadBin(effect, 0)
SetGadgetState(#notepade_gras,1)
Else
SetGadgetState(#notepade_gras,0)
EndIf
If ReadBin(effect, 1)
SetGadgetState(#notepade_italique,1)
Else
SetGadgetState(#notepade_italique,0)
EndIf
If ReadBin(effect, 2)
SetGadgetState(#notepade_surligner,1)
Else
SetGadgetState(#notepade_surligner,0)
EndIf
If ReadBin(effect, 3)
SetGadgetState(#notepade_barrer,1)
Else
SetGadgetState(#notepade_barrer,0)
EndIf
Case #notepade_load
load_editor(#note_pad_ID,nom_fichier_note_pad$)
Case #notepade_save
sauve_editor(#note_pad_ID,nom_fichier_note_pad$)
Case #notepade_zoom
Value=GetGadgetState(#notepade_zoom)
lRet=SendMessage_(GadgetID(#note_pad_ID),#EM_SETZOOM,Value+10,MaxD)
Case #notepade_alig_gauche
Set_Selection_paragraphe(#note_pad_ID,1)
Case #notepade_alig_centre
Set_Selection_paragraphe(#note_pad_ID,3)
Case #notepade_alig_droite
Set_Selection_paragraphe(#note_pad_ID,2)
Case #notepade_text_moins
Taille= Get_Selection_Taille(#note_pad_ID)
Set_Selection_Taille(#note_pad_ID, 0.8*Taille)
Case #notepade_text_plus
Taille= Get_Selection_Taille(#note_pad_ID)
Set_Selection_Taille(#note_pad_ID, 1.2*Taille)
Case #notepade_gras
Debug Get_Selection_Effect(#note_pad_ID)
If ReadBin(Get_Selection_Effect(#note_pad_ID), 0)=0
Set_Selection_Effect(#note_pad_ID, 1,1)
Else
Set_Selection_Effect(#note_pad_ID, 1,0)
EndIf
Case #notepade_italique
If ReadBin(Get_Selection_Effect(#note_pad_ID), 1)=0
Set_Selection_Effect(#note_pad_ID, 2,2)
Else
Set_Selection_Effect(#note_pad_ID, 2,0)
EndIf
Case #notepade_surligner
If ReadBin(Get_Selection_Effect(#note_pad_ID), 2)=0
Set_Selection_Effect(#note_pad_ID, 4,4)
Else
Set_Selection_Effect(#note_pad_ID, 4,0)
EndIf
Case #notepade_barrer
If ReadBin(Get_Selection_Effect(#note_pad_ID), 3)=0
Set_Selection_Effect(#note_pad_ID, 8,8)
Else
Set_Selection_Effect(#note_pad_ID, 8,0)
EndIf
Case #im_coul_texte,#im_coul_fond,#im_coul_page
id_palette=EventGadget()
num_palette=id_palette-#im_coul_texte
num_coul=(WindowMouseX(id_window)-GadgetX(id_palette))/(GadgetWidth(id_palette)/10)
Select EventType()
Case 0
If WindowMouseY(id_window)-GadgetY(id_palette)<GadgetHeight(id_palette)/2
couleur=Couleur_Base(num_coul)
Else
couleur=Couleur_perso(num_palette,num_coul)
EndIf
Select id_palette
Case #im_coul_texte
Set_Selection_Color(#note_pad_ID,couleur)
Case #im_coul_fond
Set_Selection_BackColor(#note_pad_ID,couleur)
Case #im_coul_page
SetGadgetColor(#note_pad_ID,#PB_Gadget_BackColor,couleur)
EndSelect
Case 1
If WindowMouseY(id_window)-GadgetY(id_palette)<GadgetHeight(id_palette)/2
Couleur_Base(num_coul)=ColorRequester()
Else
Couleur_perso(num_palette,num_coul)=ColorRequester()
EndIf
Dessine_palette()
EndSelect
Case #notepade_liste_font
Debug EventType()
Select EventType()
Case 1
Debug GetGadgetText(#notepade_liste_font)
Set_Selection_Font(#note_pad_ID,GetGadgetText(#notepade_liste_font))
EndSelect
EndSelect
EndSelect
EndProcedure
OpenWindow(0,0,0,800,600,"Editeur de texte",#PB_Window_SystemMenu )
CreateGadgetList(WindowID(0))
CreateNotepad(30,10,600,500)
list_font(0,#notepade_liste_font)
Initialise_couleur()
Dessine_palette()
;load_editor(#note_pad_ID,nom_fichier_note_pad$)
Repeat
event=WaitWindowEvent()
evenement_notepad(0,event )
Select event
Case #WM_KEYDOWN ;{touche clavier
Debug "Appuye touche "+Str(EventwParam())
id_touche=EventwParam()
Select id_touche
Case 116 ;F5
Case 117 ;F6 creation d'un tableau en RTF
AddGadgetItem(#note_pad_ID,-1,TableauRTF(5,3,600))
Case 118
EndSelect
EndSelect
Until event=#WM_CLOSE
- Kwai chang caine
- Messages : 6989
- Inscription : sam. 23/sept./2006 18:32
- Localisation : Isere
Re: Editeur de texte
2eme code[
Code : Tout sélectionner
Global nom_fichier_note_pad$,MaxD,code_fin_sauvegarde_texte$,code_fin_sauvegarde_format$
nom_fichier_note_pad$="text_note_pad.txt"
code_fin_sauvegarde_texte$="#FIN_TXT#"
code_fin_sauvegarde_format$="#FIN_FORMAT#"
Procedure.b ReadBin(Valeur.l, Position);permet de lire un byte à la position
If Valeur & (%1 << Position)
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure
Global Dim Couleur_Base(10)
Global Dim Couleur_perso(2,10)
Global Dim Nom_Font.s(1)
Nom_Font(0)="0"
Procedure Initialise_couleur(); couleur de la palette de base
i=0
Couleur_Base(i)= 0 : i=i+1
Couleur_Base(i)= 1 : i=i+1
Couleur_Base(i)= $0000FF : i=i+1
Couleur_Base(i)= $00FFFF : i=i+1
Couleur_Base(i)= $FF00FF : i=i+1
Couleur_Base(i)= $00FF00 : i=i+1
Couleur_Base(i)= $FFFF00 : i=i+1
Couleur_Base(i)= $FF0000 : i=i+1
Couleur_Base(i)= $008000 : i=i+1
Couleur_Base(i)= $FFFFFF : i=i+1
For i=0 To 2
For j=0 To 9
Couleur_perso(i,j)=$E26152
Next
Next
EndProcedure
Procedure Test_Font_Doublon(nom_font$);Test si le nom de la police est déjà dans la liste
For i=1 To Val(Nom_Font(0))
If Nom_Font(i)=nom_font$
ProcedureReturn 0
EndIf
Next
ProcedureReturn 1
EndProcedure
Procedure Ajout_Nom_Font(nom_font$);Ajoute le nom de la police à la liste des polices
If Test_Font_Doublon(nom_font$)
nb_ele=Val(Nom_Font(0))+1
ReDim Nom_Font.s(nb_ele)
Nom_Font(nb_ele)=nom_font$
Nom_Font(0)=Str(nb_ele)
EndIf
EndProcedure
Procedure EnumFontFamProc(lpelf.l, lpntm.l, FontType.l, lParam.l)
Static FontCounter.l
*lpelf.ENUMLOGFONT = lpelf
sFontType.s = ""
TrueType = #False
If FontType & #DEVICE_FONTTYPE
sFontType.s + "Device "
EndIf
If FontType & #RASTER_FONTTYPE
sFontType.s + "Raster "
EndIf
If FontType & #TRUETYPE_FONTTYPE
sFontType.s + "TrueType "
TrueType = #True
EndIf
FontHeight = *lpelf\elfLogFont\lfHeight
FontWidth = *lpelf\elfLogFont\lfWidth
FontEscapement = *lpelf\elfLogFont\lfEscapement
FontOrientation = *lpelf\elfLogFont\lfOrientation
FontWeight = *lpelf\elfLogFont\lfWeight
FontItalic = *lpelf\elfLogFont\lfItalic
FontUnderline = *lpelf\elfLogFont\lfUnderline
FontStrikeOut = *lpelf\elfLogFont\lfStrikeOut
FontCharSet = *lpelf\elfLogFont\lfCharSet
FontOutPrecision = *lpelf\elfLogFont\lfOutPrecision
FontClipPrecision = *lpelf\elfLogFont\lfClipPrecision
FontQuality = *lpelf\elfLogFont\lfQuality
FontPitchAndFamily = *lpelf\elfLogFont\lfPitchAndFamily
FontName.s = ""
i = 0
While *lpelf\elfFullName[i] <>0
FontName + Chr(*lpelf\elfFullName[i])
i + 1
Wend
FontStyle.s = ""
i = 0
While *lpelf\elfStyle[i] <>0
FontStyle + Chr(*lpelf\elfStyle[i])
i + 1
Wend
If TrueType
*lpntm1.NEWTEXTMETRIC = lpntm
MetricHeight = *lpntm1\tmHeight
MetricAscent = *lpntm1\tmAscent
MetricDescent = *lpntm1\tmDescent
MetricInternalLeading = *lpntm1\tmInternalLeading
MetricExternalLeading = *lpntm1\tmExternalLeading
MetricAveCharWidth = *lpntm1\tmAveCharWidth
MetricMaxCharWidth = *lpntm1\tmMaxCharWidth
MetricWeight = *lpntm1\tmWeight
MetricOverhang = *lpntm1\tmOverhang
MetricDigitizedAspectX = *lpntm1\tmDigitizedAspectX
MetricDigitizedAspectY = *lpntm1\tmDigitizedAspectY
MetricFirstChar = *lpntm1\tmFirstChar
MetricLastChar = *lpntm1\tmLastChar
MetricDefaultChar = *lpntm1\tmDefaultChar
MetricBreakChar = *lpntm1\tmBreakChar
MetricItalic = *lpntm1\tmItalic
MetricUnderlined = *lpntm1\tmUnderlined
MetricStruckOut = *lpntm1\tmStruckOut
MetricPitchAndFamily = *lpntm1\tmPitchAndFamily
MetricCharSet = *lpntm1\tmCharSet
MetricFlags = *lpntm1\ntmFlags
MetricSizeEM = *lpntm1\ntmSizeEM
MetricCellHeight = *lpntm1\ntmCellHeight
MetricAveWidth = *lpntm1\ntmAveWidth
Else
*lpntm2.TEXTMETRIC = lpntm
MetricHeight = *lpntm2\tmHeight
MetricAscent = *lpntm2\tmAscent
MetricDescent = *lpntm2\tmDescent
MetricInternalLeading = *lpntm2\tmInternalLeading
MetricExternalLeading = *lpntm2\tmExternalLeading
MetricAveCharWidth = *lpntm2\tmAveCharWidth
MetricMaxCharWidth = *lpntm2\tmMaxCharWidth
MetricWeight = *lpntm2\tmWeight
MetricOverhang = *lpntm2\tmOverhang
MetricDigitizedAspectX = *lpntm2\tmDigitizedAspectX
MetricDigitizedAspectY = *lpntm2\tmDigitizedAspectY
MetricFirstChar = *lpntm2\tmFirstChar
MetricLastChar = *lpntm2\tmLastChar
MetricDefaultChar = *lpntm2\tmDefaultChar
MetricBreakChar = *lpntm2\tmBreakChar
MetricItalic = *lpntm2\tmItalic
MetricUnderlined = *lpntm2\tmUnderlined
MetricStruckOut = *lpntm2\tmStruckOut
MetricPitchAndFamily = *lpntm2\tmPitchAndFamily
MetricCharSet = *lpntm2\tmCharSet
EndIf
sFontAttributes.s = ""
If FontItalic
sFontAttributes + "I"
EndIf
If FontUnderline
sFontAttributes + "U"
EndIf
If FontStrikeOut
sFontAttributes + "S"
EndIf
If sFontAttributes <> ""
sFontAttributes = "(" + sFontAttributes + ")"
EndIf
If lParam
If FindString(LCase(FontName), LCase(PeekS(lParam)), 1)
nom_font$=FontName
Debug "***** "+nom_font$
Ajout_Nom_Font(nom_font$)
EndIf
Else
nom_font$=FontName
Debug "****- "+nom_font$
Ajout_Nom_Font(nom_font$)
EndIf
While WindowEvent()
Wend
FontCounter + 1
ProcedureReturn 1
EndProcedure
Procedure list_font(id_window,id_gadget)
ClearGadgetItemList(id_gadget)
Ajout_Nom_Font("//Base//")
EnumFontFamilies_(GetDC_(WindowID(id_window)), #Null, @EnumFontFamProc(), 0)
nb_ele=Val(Nom_Font(0))
Nom_Font(0)=""
SortArray(Nom_Font(),2)
For i=1 To nb_ele
AddGadgetItem(id_gadget,-1,Nom_Font(i))
Next
SetGadgetState(id_gadget,0)
EndProcedure
Enumeration #PB_Compiler_EnumerationValue
#note_pad_ID
#notepade_load
#notepade_save
#notepade_zoom
#notepade_alig_gauche
#notepade_alig_centre
#notepade_alig_droite
#notepade_text_plus
#notepade_text_moins
#notepade_gras
#notepade_italique
#notepade_surligner
#notepade_barrer
;ne pas changer l'ordre d'ici
#im_coul_texte
#im_coul_fond
#im_coul_page
;ne pas changer l'ordre a ici
#notepade_liste_font
EndEnumeration
Procedure Create_palette(id_im,l,h)
Select id_im
Case #im_coul_texte
num_pal=0
Case #im_coul_fond
num_pal=1
Case #im_coul_page
num_pal=2
EndSelect
CreateImage(id_im,l,h)
StartDrawing(ImageOutput(id_im))
Box(0,0,l,h,$C0C0C0)
For i=0 To 10
Box(i*l/10,0,l/10-1,h/2-1,$9A9A9A)
Next
Box(1,0+1,l/10-3,h/2-3,$FFFFFF)
LineXY(1,0+1,l/10-3,h/2-3,$0000FF)
For i=1 To 10
Box(i*l/10+1,0+1,l/10-3,h/2-3,Couleur_Base(i))
Next
For i=0 To 10
Box(i*l/10+1,h/2+1,l/10-3,h/2-3,Couleur_perso(num_pal,i))
Next
StopDrawing()
SetGadgetState(id_im,ImageID( id_im))
EndProcedure
Procedure Dessine_palette()
;HideGadget(#note_pad_ID,1)
x=GadgetX(#note_pad_ID)
y=GadgetY(#note_pad_ID)+20;+GadgetHeight(#note_pad_ID)+40
l=GadgetWidth(#note_pad_ID)
h=GadgetHeight(#note_pad_ID)
espace=15
l_pal=l/3-espace
h_pal=40
TextGadget(#PB_Any,x,y+h,l_pal,h_pal,"Couleur du texte" )
TextGadget(#PB_Any,x+l_pal+espace,y+h,l_pal,h_pal,"Couleur du fond du texte" )
TextGadget(#PB_Any,x+2*l_pal+2*espace,y+h,l_pal,h_pal,"Couleur de la page" )
ImageGadget(#im_coul_texte,x,y+h+20,l_pal,h_pal,0)
Create_palette(#im_coul_texte,l_pal,h_pal)
ImageGadget(#im_coul_fond,x+l_pal+espace,y+h+20,l_pal,h_pal,0)
Create_palette(#im_coul_fond,l_pal,h_pal)
ImageGadget(#im_coul_page,x+2*l_pal+2*espace,y+h+20,l_pal,h_pal,0)
Create_palette(#im_coul_page,l_pal,h_pal)
TextGadget(#PB_Any,x+l_pal+espace,y+h+20+h_pal,l_pal,20,"Clic droit pour choisir une couleur" )
TextGadget(#PB_Any,x+l_pal+espace,y+h+40+h_pal,l_pal,20,"F6 pour inserer un tableau" )
EndProcedure
Procedure CreateNotepad(x,y,l,h)
pos=x
EditorGadget(#note_pad_ID,x,y+20,l,h-60)
SendMessage_(GadgetID(#note_pad_ID), #EM_SETTARGETDEVICE, #Null, 0) ;retour à la ligne automatique
pos=x
h_g=20
l_g=40
ButtonGadget(#notepade_load,pos,y,l_g,h_g,"Ouvrir")
pos=pos+l_g+2
l_g=50
ButtonGadget(#notepade_save,pos,y,l_g,h_g,"Enregistrer")
pos=pos+l_g+2+5
l_g=25
ButtonGadget(#notepade_alig_gauche,pos,y,l_g,h_g,"G",#PB_Button_Toggle )
pos=pos+l_g+2
;l_g=40
ButtonGadget(#notepade_alig_centre,pos,y,l_g,h_g,"C",#PB_Button_Toggle )
pos=pos+l_g+2
;l_g=40
ButtonGadget(#notepade_alig_droite,pos,y,l_g,h_g,"D",#PB_Button_Toggle )
l_g=45
pos=pos+l_g+2
ButtonGadget(#notepade_text_moins,pos,y,l_g,h_g,"Texte -")
pos=pos+l_g+2
ButtonGadget(#notepade_text_plus,pos,y,l_g,h_g,"Texte +")
pos=pos+l_g+2
l_g=20
ButtonGadget(#notepade_gras,pos,y,l_g,h_g,"G",#PB_Button_Toggle )
pos=pos+l_g+2
ButtonGadget(#notepade_italique,pos,y,l_g,h_g,"I",#PB_Button_Toggle )
pos=pos+l_g+2
ButtonGadget(#notepade_surligner,pos,y,l_g,h_g,"S",#PB_Button_Toggle )
pos=pos+l_g+2
ButtonGadget(#notepade_barrer,pos,y,l_g,h_g,"B",#PB_Button_Toggle )
pos=pos+l_g+2
ComboBoxGadget(#notepade_liste_font,pos,y,160,300 )
pos=pos+l_g+2
Maxrange=100
MaxD=Maxrange/10 +1
TrackBarGadget(#notepade_zoom, x+l-60, y,60,20, 1, Maxrange )
Dessine_palette()
EndProcedure
Procedure Selection_SelectAll(editorgadget)
range.CHARRANGE\cpMin = 0
range\cpMax = -1
ProcedureReturn SendMessage_(GadgetID(editorgadget),#EM_EXSETSEL,0,@range)
EndProcedure
Procedure Selection_Select(Gadget, LineStart.l, CharStart.l, LineEnd.l, CharEnd.l)
sel.CHARRANGE
sel\cpMin = SendMessage_(GadgetID(Gadget), #EM_LINEINDEX, LineStart, 0) + CharStart - 1
If LineEnd = -1
LineEnd = SendMessage_(GadgetID(Gadget), #EM_GETLINECOUNT, 0, 0)-1
EndIf
sel\cpMax = SendMessage_(GadgetID(Gadget), #EM_LINEINDEX, LineEnd, 0)
If CharEnd = -1
sel\cpMax + SendMessage_(GadgetID(Gadget), #EM_LINELENGTH, sel\cpMax, 0)
Else
sel\cpMax + CharEnd - 1
EndIf
SendMessage_(GadgetID(Gadget), #EM_EXSETSEL, 0, @sel)
EndProcedure
;- Format par charactere
Procedure Get_Selection_Color(Gadget)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_COLOR
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
ProcedureReturn format\crTextColor
EndProcedure
Procedure Get_Selection_BackColor(Gadget)
format.CHARFORMAT2
format\cbSize = SizeOf(CHARFORMAT2)
format\dwMask = $4000000;#CFM_COLOR
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
ProcedureReturn format\crBackColor
EndProcedure
Procedure Get_Selection_Taille(Gadget)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_SIZE
format\yHeight= Taille
format\crTextColor = Color
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
ProcedureReturn format\yHeight
EndProcedure
Procedure Get_Selection_Effect(Gadget)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_BOLD
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
ProcedureReturn format\dwEffects
EndProcedure
Procedure.s Get_Selection_Font(Gadget)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_FACE
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
FontName.s=PeekS(@format\szFaceName )
ProcedureReturn FontName
EndProcedure
Procedure Set_Selection_Font(Gadget,FontName.s)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_FACE
PokeS(@format\szFaceName, FontName)
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Set_Selection_Effect(Gadget, effect,type)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = effect
format\dwEffects = type
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Set_Selection_Taille(Gadget, Taille.l)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\yHeight= Taille
format\dwMask = #CFM_SIZE
format\crTextColor = Color
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Set_Selection_Color(Gadget, Color.l)
Debug Color
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_COLOR
format\crTextColor = Color
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Set_Selection_BackColor(Gadget, Color.l)
Debug "setcolor"
Debug Color
format.CHARFORMAT2;_
format\cbSize = SizeOf(CHARFORMAT2);_)
format\dwMask = $4000000 ; = #CFM_BACKCOLOR
format\crBackColor = Color
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
;- Format par paragraphe
Procedure Get_Selection_paragraphe(Gadget)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_ALIGNMENT
SendMessage_(GadgetID(Gadget), #EM_GETPARAFORMAT, 0, @format)
ProcedureReturn format\wAlignment
EndProcedure
Procedure Get_Selection_decallage_gauche(Gadget)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_OFFSETINDENT
SendMessage_(GadgetID(Gadget), #EM_GETPARAFORMAT, 0, @format)
ProcedureReturn format\dxStartIndent
EndProcedure
Procedure Get_Selection_decallage_droite(Gadget)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_RIGHTINDENT
SendMessage_(GadgetID(Gadget), #EM_GETPARAFORMAT, 0, @format)
ProcedureReturn format\dxRightIndent
EndProcedure
Procedure Get_Selection_decallage_gauche_ss_premiere_ligne(Gadget)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_OFFSET
SendMessage_(GadgetID(Gadget), #EM_GETPARAFORMAT, 0, @format)
ProcedureReturn format\dxOffset
EndProcedure
Procedure Set_Selection_decallage_gauche_ss_premiere_ligne(Gadget,decallage)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_OFFSET
format\dxOffset = decallage
SendMessage_(GadgetID(Gadget), #EM_SETPARAFORMAT, 0, @format)
EndProcedure
Procedure Set_Selection_decallage_droite(Gadget,decallage)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_RIGHTINDENT
format\dxRightIndent = decallage
SendMessage_(GadgetID(Gadget), #EM_SETPARAFORMAT, 0, @format)
EndProcedure
Procedure Set_Selection_decallage_gauche(Gadget,decallage)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_OFFSETINDENT
format\dxStartIndent = decallage
SendMessage_(GadgetID(Gadget), #EM_SETPARAFORMAT, 0, @format)
EndProcedure
Procedure Set_Selection_paragraphe(Gadget,paragraphe)
format.PARAFORMAT
format\cbSize = SizeOf(PARAFORMAT)
format\dwMask = #PFM_ALIGNMENT
format\wAlignment = paragraphe
SendMessage_(GadgetID(Gadget), #EM_SETPARAFORMAT, 0, @format)
EndProcedure
Procedure.s TableauRTF(nbcol,nbligne,largeur)
result.s = "{\rtf1\trowd"
For i=1 To nbcol
result + "\cellx"+Str(i*largeur)
Next
For j=1 To nbligne
result + "\intbl"
For i=1 To nbcol
result + "\cell"
Next
result + "\row"
Next
result + "}"
ProcedureReturn result
EndProcedure
Procedure EditorGadgetCursorX(Gadget)
; returns X-Pos of Cursor
REG = GadgetID(Gadget)
SendMessage_(REG,#EM_EXGETSEL,0,range.CHARRANGE)
ProcedureReturn (range\cpMax-(SendMessage_(REG,#EM_LINEINDEX,SendMessage_(REG,#EM_EXLINEFROMCHAR,0,range\cpMin),0))+1)
EndProcedure
Procedure EditorGadgetCursorY(Gadget)
; returns Y-Pos of Cursor
REG = GadgetID(Gadget)
SendMessage_(REG,#EM_EXGETSEL,0,range.CHARRANGE)
ProcedureReturn SendMessage_(REG,#EM_EXLINEFROMCHAR,0,range\cpMin)+1
EndProcedure
Procedure EditorGadgetCursorPos(Gadget)
; returns relative Position of Cursor
SendMessage_(GadgetID(Gadget),#EM_EXGETSEL,0,range.CHARRANGE)
ProcedureReturn range\cpMax
EndProcedure
Procedure EditorGadgetLocate(Gadget,x,y)
; Set cursor position
REG = GadgetID(Gadget)
CharIdx = SendMessage_(REG,#EM_LINEINDEX,y-1,0)
LLength = SendMessage_(REG,#EM_LINELENGTH,CharIdx,0)
If LLength >= x-1
CharIdx + x-1
EndIf
range.CHARRANGE
range\cpMin = CharIdx
range\cpMax = CharIdx
SendMessage_(REG,#EM_EXSETSEL,0,range)
EndProcedure
Procedure Write_Format(ligne_debut,ligne_fin,debut,fin,couleur,couleur_fond,Taille,effect,paragraphe,FontName$)
Debug Str(ligne_debut)+" : "+Str(ligne_fin)+" : "+Str(debut)+" : "+Str(fin)+" : "+Str(couleur)+" : "+Str(couleur_fond)+" : "+Str(Taille)+" : "
WriteLong(0, ligne_debut)
WriteLong(0, ligne_fin)
WriteLong(0, debut)
WriteLong(0, fin)
WriteLong(0, couleur)
If couleur_fond=0
couleur_fond=-1
EndIf
WriteLong(0, couleur_fond)
WriteLong(0, Taille)
WriteLong(0, effect)
WriteLong(0, paragraphe)
WriteStringN(0,FontName$)
EndProcedure
Procedure sauve_editor1(id_gadget,nom_fichier$) ; procedure plus utilisé, mais je la garde sous le coude !
Debug "SAUVE"
;AddGadgetItem(id_gadget, 0,"")
If CreateFile(0,nom_fichier$)
;{Enregistrement du texte
WriteStringN(0,GetGadgetText(id_gadget))
WriteStringN(0,code_fin_sauvegarde_texte$)
;}
;{Enregistrement des parametres bases et de départ
zoom=GetGadgetState(#notepade_zoom)
WriteLong(0, zoom)
WriteLong(0, GetGadgetColor(id_gadget,#PB_Gadget_BackColor))
;}
format.CHARFORMAT2
format\cbSize = SizeOf(CHARFORMAT2)
format\dwMask = #CFM_COLOR | #CFM_SIZE |#CFM_BOLD|#CFM_FACE
Selection_Select(id_gadget, 0, 1, 0, 1)
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
couleur= format\crTextColor
couleur_fond= format\crBackColor
Taille= format\yHeight
effect=format\dwEffects
FontName$=PeekS(@format\szFaceName )
;WriteLong(0, der_couleur )
;;WriteLong(0,der_couleur_fond)
;WriteLong(0,der_taille)
der_paragraphe=Get_Selection_paragraphe(Gadget)
paragraphe=der_paragraphe
der_effect=effect
der_couleur_fond=couleur_fond
der_couleur=couleur
der_taille=Taille
der_FontName$=FontName$
pos_coul=1
ligne_coul=0
For i=0 To CountGadgetItems(id_gadget)
nb_chr=Len( GetGadgetItemText(id_gadget,i,0))
For j=1 To nb_chr
Selection_Select(id_gadget, i, j+1, i, j+1)
SendMessage_(GadgetID(Gadget), #EM_GETCHARFORMAT, #SCF_SELECTION, @format)
FontName$=PeekS(@format\szFaceName )
couleur= format\crTextColor
couleur_fond= format\crBackColor
Taille= format\yHeight
effect=format\dwEffects
paragraphe=Get_Selection_paragraphe(Gadget)
If der_couleur<>couleur Or der_FontName$<>FontName$ Or der_taille<>Taille Or der_couleur_fond<>couleur_fond Or effect<>der_effect Or paragraphe<>der_paragraphe
Write_Format(ligne_coul,i,pos_coul,j,der_couleur,der_couleur_fond,der_taille,der_effect,der_paragraphe,der_FontName$)
der_paragraphe=paragraphe
der_effect=effect
der_couleur_fond=couleur_fond
der_couleur=couleur
der_taille=Taille
der_FontName$=FontName$
ligne_coul=i
pos_coul=j
EndIf
Next
Next
Write_Format(ligne_coul,i,pos_coul,j,der_couleur,der_couleur_fond,der_taille,der_effect,der_paragraphe,FontName$)
WriteStringN(0, code_fin_sauvegarde_format$)
For i=0 To 9
WriteLong(0,Couleur_Base(i))
Next
For i=0 To 2
For j=0 To 9
WriteLong(0,Couleur_perso(i,j))
Next
Next
CloseFile(0)
EndIf
EndProcedure
Procedure load_editor1(id_gadget,nom_fichier$) ; procedure plus utilisé, mais je la garde sous le coude !
Debug "LOAD"
;SetGadgetText(id_gadget,"")
ClearGadgetItemList(id_gadget)
If ReadFile(0,nom_fichier$)
Repeat
ligne$=ReadString(0)
If ligne$<>code_fin_sauvegarde_texte$
AddGadgetItem(id_gadget,-1,ligne$)
EndIf
Until Loc(0)=Lof(0) Or ligne$=code_fin_sauvegarde_texte$
; FileSeek(0,Loc(0)-2)
; Debug ReadByte(0)
; Debug ReadByte(0)
zoom=ReadLong(0)
lRet=SendMessage_(GadgetID(#note_pad_ID),#EM_SETZOOM,zoom+10,MaxD)
SetGadgetState(#notepade_zoom,zoom)
couleur_page=ReadLong(0)
SetGadgetColor(id_gadget,#PB_Gadget_BackColor,couleur_page)
Selection_Select(id_gadget, 0, 1, 0, 1)
;Set_Selection_Color(id_gadget,ReadLong(0))
;Set_Selection_BackColor(id_gadget,ReadLong(0))
;Set_Selection_Taille(id_gadget,ReadLong(0))
If Loc(0)<>Lof(0)
Repeat
ligne_debut=ReadLong(0)
ligne_fin=ReadLong(0)
debut=ReadLong(0)
fin=ReadLong(0)
couleur=ReadLong(0)
couleur_fond=ReadLong(0)
Taille=ReadLong(0)
effect=ReadLong(0)
paragraphe=ReadLong(0)
FontName$=ReadString(0)
Debug Str(ligne_debut)+" : "+Str(ligne_fin)+" : "+Str(debut)+" : "+Str(fin)+" : "+Str(couleur)+" : "+Str(couleur_fond)+" : "+Str(Taille)+" : "
Selection_Select(id_gadget, ligne_debut, debut, ligne_fin, fin)
If couleur<>-1
Set_Selection_Color(id_gadget,couleur)
EndIf
If couleur_fond<>-1
Set_Selection_BackColor(id_gadget,couleur_fond)
EndIf
If Taille<>-1
Set_Selection_Taille(id_gadget,Taille)
EndIf
Set_Selection_Effect(id_gadget, effect,effect)
Set_Selection_paragraphe(id_gadget,paragraphe)
Debug "setfont"
Debug FontName$
Set_Selection_Font(id_gadget,FontName$)
pos=Loc(0)
ligne$=ReadString(0)
FileSeek(0,pos)
Until Loc(0)=Lof(0) Or ligne$= code_fin_sauvegarde_format$
If Loc(0)<>Lof(0)
ligne$=ReadString(0)
For i=0 To 9
Couleur_Base(i)=ReadLong(0)
Next
For i=0 To 2
For j=0 To 9
Couleur_perso(i,j)=ReadLong(0)
Next
Next
EndIf
CloseFile(0)
;RemoveGadgetItem(id_gadget, 0)
Selection_Select(id_gadget,0, 0,0, 0)
Dessine_palette()
EndIf
EndIf
EndProcedure
Procedure EditCallBack_Ecriture(dwCookie.l, *pbBuff.l, cb.l, *pcb.l)
If WriteData(0,*pbBuff, cb)
ProcedureReturn 0
Else
ProcedureReturn 1
EndIf
EndProcedure
Procedure EditCallBack_Lecture(dwCookie.l, *pbBuff.l, cb.l, *pcb.l)
If ReadFile_(dwCookie, *pbBuff, cb, *pcb, 0)
ProcedureReturn 0
Else
ProcedureReturn 1
EndIf
EndProcedure
Procedure sauve_editor(id_gadget,nom_fichier$)
If nom_fichier$<>""
If CreateFile(0, nom_fichier$)
Edit.EDITSTREAM
Edit\dwCookie=0
Edit\pfnCallback=@EditCallBack_Ecriture()
SendMessage_(GadgetID(id_gadget),#EM_STREAMOUT,#SF_RTF,Edit)
If Edit\dwError=0
Debug "L'écriture s'est bien déroulée"
Else
Debug "L'écriture du fichier a provoqué une erreur"
EndIf
CloseFile(0)
EndIf
EndIf
EndProcedure
Procedure load_editor(id_gadget,nom_fichier$)
If nom_fichier$<>""
hFile=OpenFile(1, nom_fichier$)
Edit.EDITSTREAM
Edit\dwCookie=hFile
Edit\pfnCallback=@EditCallBack_Lecture()
SendMessage_(GadgetID(id_gadget),#EM_STREAMIN,#SF_RTF,Edit)
If Edit\dwError=0
Debug "La lecture s'est bien déroulée"
Else
Debug "La lecture du fichier a provoqué une erreur"
EndIf
CloseFile(1)
EndIf
EndProcedure
Procedure Select_Font(Nom_font.s)
For i=0 To CountGadgetItems(#notepade_liste_font)
If Nom_font=GetGadgetItemText(#notepade_liste_font,i,i)
SetGadgetState(#notepade_liste_font,i)
ProcedureReturn 1
EndIf
Next
SetGadgetState(#notepade_liste_font,0)
ProcedureReturn -1
EndProcedure
Procedure evenement_notepad(id_window,event )
Select event
Case #PB_Event_Gadget; *****************Choix d'un bouton
Select EventGadget()
Case #note_pad_ID
Select_Font( Get_Selection_Font(Gadget))
Debug "P:"+Str(Get_Selection_paragraphe(Gadget))+"E:"+Str(Get_Selection_Effect(Gadget))+"C:"+Str(Get_Selection_Color(Gadget))+" BC:"+Str(Get_Selection_BackColor(Gadget) )+" T:"+Str(Get_Selection_Taille(Gadget) )
Select Get_Selection_paragraphe(Gadget)
Case 0,1
SetGadgetState(#notepade_alig_gauche,1)
SetGadgetState(#notepade_alig_droite,0)
SetGadgetState(#notepade_alig_centre,0)
Case 2
SetGadgetState(#notepade_alig_gauche,0)
SetGadgetState(#notepade_alig_droite,1)
SetGadgetState(#notepade_alig_centre,0)
Case 3
SetGadgetState(#notepade_alig_gauche,0)
SetGadgetState(#notepade_alig_droite,0)
SetGadgetState(#notepade_alig_centre,1)
EndSelect
effect=Get_Selection_Effect(Gadget)
If ReadBin(effect, 0)
SetGadgetState(#notepade_gras,1)
Else
SetGadgetState(#notepade_gras,0)
EndIf
If ReadBin(effect, 1)
SetGadgetState(#notepade_italique,1)
Else
SetGadgetState(#notepade_italique,0)
EndIf
If ReadBin(effect, 2)
SetGadgetState(#notepade_surligner,1)
Else
SetGadgetState(#notepade_surligner,0)
EndIf
If ReadBin(effect, 3)
SetGadgetState(#notepade_barrer,1)
Else
SetGadgetState(#notepade_barrer,0)
EndIf
Case #notepade_load
load_editor(#note_pad_ID,nom_fichier_note_pad$)
Case #notepade_save
sauve_editor(#note_pad_ID,nom_fichier_note_pad$)
Case #notepade_zoom
Value=GetGadgetState(#notepade_zoom)
lRet=SendMessage_(GadgetID(#note_pad_ID),#EM_SETZOOM,Value+10,MaxD)
Case #notepade_alig_gauche
Set_Selection_paragraphe(#note_pad_ID,1)
Case #notepade_alig_centre
Set_Selection_paragraphe(#note_pad_ID,3)
Case #notepade_alig_droite
Set_Selection_paragraphe(#note_pad_ID,2)
Case #notepade_text_moins
Taille= Get_Selection_Taille(#note_pad_ID)
Set_Selection_Taille(#note_pad_ID, 0.8*Taille)
Case #notepade_text_plus
Taille= Get_Selection_Taille(#note_pad_ID)
Set_Selection_Taille(#note_pad_ID, 1.2*Taille)
Case #notepade_gras
Debug Get_Selection_Effect(#note_pad_ID)
If ReadBin(Get_Selection_Effect(#note_pad_ID), 0)=0
Set_Selection_Effect(#note_pad_ID, 1,1)
Else
Set_Selection_Effect(#note_pad_ID, 1,0)
EndIf
Case #notepade_italique
If ReadBin(Get_Selection_Effect(#note_pad_ID), 1)=0
Set_Selection_Effect(#note_pad_ID, 2,2)
Else
Set_Selection_Effect(#note_pad_ID, 2,0)
EndIf
Case #notepade_surligner
If ReadBin(Get_Selection_Effect(#note_pad_ID), 2)=0
Set_Selection_Effect(#note_pad_ID, 4,4)
Else
Set_Selection_Effect(#note_pad_ID, 4,0)
EndIf
Case #notepade_barrer
If ReadBin(Get_Selection_Effect(#note_pad_ID), 3)=0
Set_Selection_Effect(#note_pad_ID, 8,8)
Else
Set_Selection_Effect(#note_pad_ID, 8,0)
EndIf
Case #im_coul_texte,#im_coul_fond,#im_coul_page
id_palette=EventGadget()
num_palette=id_palette-#im_coul_texte
num_coul=(WindowMouseX(id_window)-GadgetX(id_palette))/(GadgetWidth(id_palette)/10)
Select EventType()
Case 0
If WindowMouseY(id_window)-GadgetY(id_palette)<GadgetHeight(id_palette)/2
couleur=Couleur_Base(num_coul)
Else
couleur=Couleur_perso(num_palette,num_coul)
EndIf
Select id_palette
Case #im_coul_texte
Set_Selection_Color(#note_pad_ID,couleur)
Case #im_coul_fond
Set_Selection_BackColor(#note_pad_ID,couleur)
Case #im_coul_page
SetGadgetColor(#note_pad_ID,#PB_Gadget_BackColor,couleur)
EndSelect
Case 1
If WindowMouseY(id_window)-GadgetY(id_palette)<GadgetHeight(id_palette)/2
Couleur_Base(num_coul)=ColorRequester()
Else
Couleur_perso(num_palette,num_coul)=ColorRequester()
EndIf
Dessine_palette()
EndSelect
Case #notepade_liste_font
Debug EventType()
Select EventType()
Case 1
Debug GetGadgetText(#notepade_liste_font)
Set_Selection_Font(#note_pad_ID,GetGadgetText(#notepade_liste_font))
EndSelect
EndSelect
EndSelect
EndProcedure
OpenWindow(0,0,0,800,600,"Editeur de texte",#PB_Window_SystemMenu )
CreateGadgetList(WindowID(0))
CreateNotepad(30,10,600,500)
list_font(0,#notepade_liste_font)
Initialise_couleur()
Dessine_palette()
;load_editor(#note_pad_ID,nom_fichier_note_pad$)
Repeat
event=WaitWindowEvent()
evenement_notepad(0,event )
Select event
Case #WM_KEYDOWN ;{touche clavier
Debug "Appuye touche "+Str(EventwParam())
id_touche=EventwParam()
Select id_touche
Case 116 ;F5
Case 117 ;F6 creation d'un tableau en RTF
AddGadgetItem(#note_pad_ID,-1,TableauRTF(5,3,600))
Case 118
EndSelect
EndSelect
Until event=#WM_CLOSE
-
- Messages : 510
- Inscription : dim. 25/mars/2007 13:44
- Localisation : Toulouse, France
- Contact :
Re: Editeur de texte
KCC parfois j'ai l'impression que tu es la "banque de codes source" ^^
- Kwai chang caine
- Messages : 6989
- Inscription : sam. 23/sept./2006 18:32
- Localisation : Isere
Re: Editeur de texte


En fait, c'est un de mes nombreux "defauts"...
Dans n'importe quel domaine ou j'aurais trainé mes guettres, et y'en a quelques uns, j'aurais stocké tout ce qui peut etre stockable

Je suis ce qu'on appelle un hypermaterialiste, chaque objet, fichier, ou autre revete une importance pour moi

C'est ainsi que je me retrouve le sauveur de tonnes d'objets que les gens ne veulent plus, apres qu'ils en ai usé et voir meme abusé, ils n'ont comme remerciement que la benne à leur offrir

Alors KCC c'est le sauveur de l'objet..le super héros défenseur de ces petites merveilles, parfois de technologie, ou bien même de beauté, finesse..
Il va peut etre monter sa SPO (Société Protectrice de l'Objet) pour sauver toutes ces choses, petites ou grosses qui ont tant couté pour etre construite, et qui coute encore pour etre détruite.

Alors tu imagines que dans cet etat d'esprit, il ne pouvait en etre autrement, que je stocke tous les codes que je trouve quotidiennement depuis 6 ans, ce qui me mene à la tete d'une hotte de plus de 30 000 codes

Ceci dans le soucis de ne pas etre en panne quand j'ai pas internet, et donc pas de forum, et aussi..je doit le reconnaitre car la langue de bois et moi ça fait deux...dans mon esprit de collectionneur.
Mais aussi, je l'ai assez répété par amour pour ce langage et ce qu'il peut faire, et admiration pour ces millions de lignes que je ne suis pas capable de creer

Généreusement offertes par ces gens pleins de talents, dont vous faites partie, que je suis si fier de connaitre, et même de converser avec eux

Pour certains, etre collectionneur c'est grave, car ça pourri leur vie (manque de place, perte de temps, perte de leur famille, leur femme, etc..) mais moi je suis ce que l'on appelle un collectionneur de collections...je te laisse donc imaginer ma vie

En tout cas merci beaucoup de cette phrase qui tinte au conduit de mes organes auditifs, comme un compliment

Re: Editeur de texte
Merci.
Je me demande si ça ne vaudrait pas le coup qu'on fasse une petite appli qui recenserait tous les codes de KCC. Pour plus de simplicité, les codes pourraient être classés dans les même rubriques que l'aide de purebasic par exemple.
Ou alors une mega droopylib...
Mesa.
Je me demande si ça ne vaudrait pas le coup qu'on fasse une petite appli qui recenserait tous les codes de KCC. Pour plus de simplicité, les codes pourraient être classés dans les même rubriques que l'aide de purebasic par exemple.
Ou alors une mega droopylib...
Mesa.
- Kwai chang caine
- Messages : 6989
- Inscription : sam. 23/sept./2006 18:32
- Localisation : Isere
Re: Editeur de texte


Bon commençons par le début du commencement

Premierement ce ne sont pas MES CODES ce sont ceux de ceux qui ont bien voulu me les donner et que je remercie tous les matins

Encore une fois 80% d'entres eux a part faire du copier/coller c'est tout ce que saurais faire pour les modifier

Mais je progresse...j'en etait a 99.99 % il y a 6 ans, l'espoir fait vivre

Ensuite, j'ai déja essayé de creer un petit gestionnaire de ces codes..mais y'a un gros bleme, cela prend la modique taille de 1,25 GO rien que les codes alors a distribuer...
Et puis aussi d'autres problemes, moi j'ai nommé les codes comme je les comprenais, quand je les comprenais...car parfois et même trop souvent tout le monde s'esclaffe en remerçiant le createur et moi, j'suis même pas arrivé à le lancer

Encore un probleme, exemple j'ai nommé, "GadgetListIcon mettre des lignes dedans en faisant un double clic avec la boite ronde qui a un fil v4.51 [Kernadec]"

Alors imagine le moteur de recherche....renommer et nettoyer 30 000 codes.....j't'explique pas le boulot

Puis ensuite certains ne marchent plus, du aux versions, aux bugs etc....
De plus certains ont dèjà eu l'idée aussi, alors je leurs laisse volontier la place, dans les premiers c'est DOBRO, mais y'en a d'autres avec des logiciels trop classes, je peux pas rivaliser

Donc voila, j'me suis dit que comme j'suis trop souvent pas assez bon pour aider, je peux au moins chercher un code qui ressemble a ce que demande un copain dans le besoin, sans etre vraiment sur que ça lui aille, mais un debut c'est mieux que rien

Et je pense que c'est la méthode la plus raisonable pour l'instant, pour rendre ce que l'on m'a donné et faire profiter de mon travail d'ArchivCollectionneur.

Car on dirait pas, mais rien que les chercher, les copier, les essayer, les comprendre tous les jours, ça m'occupe pas mal, chaque matin que les dieux font

-
- Messages : 1501
- Inscription : dim. 18/avr./2004 15:04
- Localisation : sud de la france
- Kwai chang caine
- Messages : 6989
- Inscription : sam. 23/sept./2006 18:32
- Localisation : Isere