J'ai un problème avec ScrollAreaGadget.
Au début tout va bien, je scroll le canvas ave un graphique simple.
Je modifie en copiant du code d'un Panel vers un autre et depuis les Scrollbar ne fonctionnent plus.
Aller sur le TabItem: Schéma
Code : Tout sélectionner
;
; ------------------------------------------------------------
; TRUC EDITEUR
; PureBasic - (c) Fantaisie Software
; ------------------------------------------------------------
Global Cou_JaunePale=$efffff
Global Cou_BleuFoce=$820000
Global Cou_Blanc=$FFFFFF
Global h_lab_titre=30
Global h_lab_simple=25
Global h_txt_simple=25
Global POSY.i=0:InterY.i=50
UseJPEGImageDecoder():UsePNGImageDecoder():UseTGAImageDecoder():UseTIFFImageDecoder()
#Windowpara = #PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget| #PB_Window_Maximize
; #PB_Font_Bold : La police de caractères sera en gras
; #PB_Font_Italic : La police de caractères sera en italique
; #PB_Font_Underline : La police de caractères sera soulignée (Windows seulement)
; #PB_Font_StrikeOut : La police de caractères sera barrée (Windows seulement)
; #PB_Font_HighQuality: La police de caractères sera en qualité supérieure (plus lent)(Windows seulement)
Enumeration ; Containers
#numWIN =200
#MENU
#TB_Gene
#STATUBAR
#SPLITGAUCHE
#SPLITDROIT
#SPLITER
#Tab_DROIT
#Tab_Gauche
#Tab_Parametres ;**************
#Tab_Schema ;*******************
#CO_Schema
#CO_tbSchema
#TB_Schema
#CO_RHSchema
#CO_RVSchema
#sca_Schema
#can_Schema
#Tab_Planche ;******************
#CO_Planche
#CO_tbPlanche
#TB_Planche
#CO_RHPlanche
#CO_RVPlanche
#sca_Planche
#can_Planche
#Tab_Notice ;************************
EndEnumeration
Enumeration Menu
#MENU_Open
#MENU_Close
#MENU_CloseAll
#MENU_Quit
#MENU_TileV
#MENU_TileH
#MENU_Cascade
#MENU_Arrange
#MENU_Previous
#MENU_Next
EndEnumeration
Enumeration LabTxtContainerOptionCheckBox
;label titre frontcolor=blanc backcolor=bleu fontsize=14
#lab_GENERALITES=0
#lab_PLANCHES
;#lab_Platine
#end1
;label simple frontcolor=noir backcolor=blanc fontsize=10
#lab_Nom_Montage=20
#lab_Auteur_Montage
#lab_Date_Montage
#lab_Description_Montage
#lab_SetComposants
#lab_Nombre_Planche
#lab_Nom_Planche
#lab_Description_Planche
#lab_Nombre_Platine
#lab_Orientation
#lab_Horizontale
#lab_Verticale
#lab_cb3
#lab_Modeles
#lab_G
#lab_MG
#lab_SG
#end2
;texte simple frontcolor=noir backcolor=blanc fontsize=10 border=1
#txt_Nom_Montage=60
#txt_Auteur_Montage
#txt_Date_Montage
#txt_Description_Montage
#txt_Nom_Planche
#txt_Description_Planche
#end3
;container
#co_Parametres=90
; #co_Schemas
; #co_Notice
#end4
;option
#op_Horizontale=100
#op_Verticale
#end5
;checkbox
#cb_MontageG=120
#cb_SchemaG
#cb_3
#end6
;spin
#sp_1=140
#sp_Nombre_Platine
#end7
;listbox
#lb_Set_Composant=150
#lb_Modeles
#lb_Planches
#end8
;bouton
#bt_VoirSet=170
#bt_En_Modele
#end9
EndEnumeration
Enumeration PosVerticale 0 Step 30
#PY1=10
#PY2
#PY3
#PY4
#PY5
#PY6
#PY7
#PY8
#PY9
#PY10
#PY11
#PY12
#PY13
#PY14
#PY15
#PY16
#PY17
#PY18
#PY19
#PY20
EndEnumeration
Enumeration PosHorisontale 0 Step 25
#PX1=10
#PX2
#PX3
#PX4
#PX5
#PX6
#PX7
#PX8
#PX9
#PX10
#PX11
#PX12
#PX13
#PX14
#PX15
#PX16
#PX17
#PX18
#PX19
#PX20
#PX21
#PX22
#PX23
#PX24
#PX25
#PX26
#PX27
#PX28
#PX29
#PX30
EndEnumeration
Procedure ReglesSchema() ; REGLES***************************************************************************
;Regle Horizontale
ContainerGadget(#CO_RHSchema, 25,30,300,20, #PB_Container_Flat)
SetGadgetColor(#CO_RHSchema,#PB_Gadget_BackColor, Cou_JaunePale )
CloseGadgetList()
; ;Regle Verticale
ContainerGadget(#CO_RVSchema, 0,55,20,200, #PB_Container_Flat)
SetGadgetColor(#CO_RVSchema,#PB_Gadget_BackColor, Cou_JaunePale )
CloseGadgetList()
; ButtonGadget(#PB_Any, 0, 30, 20, 20, ">")
EndProcedure
Procedure ReglesPlanche() ; REGLES***************************************************************************
;Regle Horizontale
ContainerGadget(#CO_RHPlanche, 25,30,300,20, #PB_Container_Flat)
SetGadgetColor(#CO_RHPlanche,#PB_Gadget_BackColor, Cou_JaunePale )
CloseGadgetList()
; ;Regle Verticale
ContainerGadget(#CO_RVPlanche, 0,55,20,200, #PB_Container_Flat)
SetGadgetColor(#CO_RVPlanche,#PB_Gadget_BackColor, Cou_JaunePale )
CloseGadgetList()
; ButtonGadget(#PB_Any, 0, 30, 20, 20, ">")
EndProcedure
Procedure IniGadgets()
If LoadFont(1,"Arial",10 )
EndIf
If LoadFont(2,"Arial",12, #PB_Font_Italic )
EndIf
If LoadFont(3,"Arial",20, #PB_Font_Bold )
EndIf
If LoadFont(4,"Arial",14, #PB_Font_Bold )
EndIf
For nGadget=0 To #end1-1 ;label titre frontcolor=blanc backcolor=bleu fontsize=14
SetGadgetFont (nGadget, FontID(3))
SetGadgetColor(nGadget, #PB_Gadget_BackColor, Cou_BleuFoce)
SetGadgetColor(nGadget, #PB_Gadget_FrontColor, Cou_Blanc)
Next
For nGadget=20 To #end2-1 ;label simple frontcolor=noir backcolor=blanc fontsize=10
SetGadgetFont (nGadget, FontID(4))
SetGadgetColor(nGadget, #PB_Gadget_BackColor, Cou_JaunePale)
SetGadgetColor(ngadget, #PB_Gadget_FrontColor, RGB(0, 0, 0))
Next
For nGadget=60 To #end3-1 ;texte simple frontcolor=noir backcolor=blanc fontsize=10 border=1
SetGadgetFont (nGadget, FontID(2))
SetGadgetColor(nGadget, #PB_Gadget_BackColor, Cou_Blanc)
SetGadgetColor(ngadget, #PB_Gadget_FrontColor, RGB(0, 0, 0))
Next
For nGadget=90 To #end4-1 ; container backcolor=jaune
SetGadgetColor(nGadget,#PB_Gadget_BackColor, Cou_JaunePale )
Next
For nGadget=100 To #end5-1 ;option frontcolor=noir backcolor=blanc fontsize=10 border=1
SetGadgetFont (nGadget, FontID(4))
Next
For nGadget=120 To #end6-1 ;checkbox frontcolor=noir backcolor=blanc fontsize=10 border=1
SetGadgetFont (nGadget, FontID(4))
Next
For nGadget=140 To #end7-1 ;spin
SetGadgetFont (nGadget, FontID(2))
SetGadgetColor(nGadget, #PB_Gadget_BackColor, Cou_Blanc)
SetGadgetColor(ngadget, #PB_Gadget_FrontColor, RGB(0, 0, 0))
Next
For nGadget=150 To #end8-1 ;listbox
SetGadgetFont (nGadget, FontID(2))
SetGadgetColor(nGadget, #PB_Gadget_BackColor, Cou_BleuFoce)
SetGadgetColor(ngadget, #PB_Gadget_FrontColor, Cou_Blanc)
Next
For nGadget=170 To #end9-1 ;bouton
SetGadgetFont (nGadget, FontID(2))
SetGadgetColor(nGadget, #PB_Gadget_BackColor, Cou_BleuFoce)
SetGadgetColor(ngadget, #PB_Gadget_FrontColor, Cou_Blanc)
Next
EndProcedure
Procedure Resize()
ResizeGadget(#Tab_DROIT, 0, 0, GadgetWidth(#SPLITDROIT),GadgetHeight(#SPLITDROIT) )
ResizeGadget(#CO_Parametres, 0, 0, GadgetWidth(#SPLITDROIT),GadgetHeight(#SPLITDROIT) )
ResizeGadget(#CO_Schema, 0, 0, GadgetWidth(#SPLITDROIT),GadgetHeight(#SPLITDROIT) )
ResizeGadget(#CO_Planche, 0, 0, GadgetWidth(#SPLITDROIT),GadgetHeight(#SPLITDROIT) )
ResizeGadget(#CO_RHSchema, #PB_Ignore, #PB_Ignore, GadgetWidth(#Tab_DROIT)-40,#PB_Ignore )
ResizeGadget(#CO_RVSchema, #PB_Ignore, #PB_Ignore,#PB_Ignore,GadgetHeight(#Tab_DROIT)-85 )
ResizeGadget(#CO_RHPlanche, #PB_Ignore, #PB_Ignore, GadgetWidth(#Tab_DROIT)-40,#PB_Ignore )
ResizeGadget(#CO_RVPlanche, #PB_Ignore, #PB_Ignore,#PB_Ignore,GadgetHeight(#Tab_DROIT)-85 )
ResizeGadget(#CO_tbSchema, 0,0,GadgetWidth(#SPLITDROIT),GadgetHeight(#Tab_DROIT) )
ResizeGadget(#CO_tbPlanche, 0,0,GadgetWidth(#SPLITDROIT),GadgetHeight(#Tab_DROIT) )
ResizeGadget(#sca_Schema, #PB_Ignore, #PB_Ignore, GadgetWidth(#Tab_DROIT)-40,GadgetHeight(#Tab_DROIT)-85 )
ResizeGadget(#sca_Planche, #PB_Ignore, #PB_Ignore, GadgetWidth(#Tab_DROIT)-40,GadgetHeight(#Tab_DROIT)-85 )
EndProcedure
If OpenWindow(#numWIN, 0, 0, 800, 600, "TRUC EDITEUR", #Windowpara )
WinLarg=WindowWidth (#numWIN, #PB_Window_InnerCoordinate)
WinHaut=WindowHeight(#numWIN, #PB_Window_InnerCoordinate)-80
InterY=40
POSY=POSY+InterY
;MENU*************************************************************************************************************************
If CreateMenu(#MENU, WindowID(#numWIN))
MenuTitle("File")
MenuItem(#MENU_Open, "Open")
MenuItem(#MENU_Close, "Close")
MenuItem(#MENU_CloseAll, "Close All")
MenuBar()
MenuItem(#MENU_QUit, "Quit")
MenuTitle("Windows")
MenuItem(#MENU_TileV, "Tile vertically")
MenuItem(#MENU_TileH, "Tile horizontally")
MenuItem(#MENU_Cascade, "Cascade")
MenuItem(#MENU_Previous, "Previous")
MenuItem(#MENU_Next, "Next")
EndIf
;TOOLBAR*********************************************************************************************************************
If CreateToolBar(#TB_Gene, WindowID(#numWIN))
ToolBarStandardButton(#MENU_Open, #PB_ToolBarIcon_Open)
ToolBarStandardButton(#MENU_Close, #PB_ToolBarIcon_Delete)
ToolBarSeparator()
ToolBarStandardButton(#MENU_Previous, #PB_ToolBarIcon_Undo)
ToolBarStandardButton(#MENU_Next, #PB_ToolBarIcon_Redo)
EndIf
;STATUBAR********************************************************************************************************************
If CreateStatusBar(#STATUBAR, WindowID(#numWIN))
AddStatusBarField(100)
AddStatusBarField(50)
AddStatusBarField(100)
StatusBarText(#STATUBAR, 0, "Area 1")
StatusBarText(#STATUBAR, 1, "Area 2", #PB_StatusBar_BorderLess)
StatusBarText(#STATUBAR, 2, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised)
EndIf
;SPLIT GAUCHE*****************************************************************************************************************
ContainerGadget(#SPLITGAUCHE, 0,0,0,0, #PB_Container_Double)
ButtonGadget(#PB_Any, 10, 10, 50, 20, "Bouton 1") ; Inutile de préciser la taille ou les coordonnées
CloseGadgetList()
;SPLIT DROIT*******************************************************************************************************************
ContainerGadget(#SPLITDROIT, 0,0,100,200, #PB_Container_Flat)
PanelGadget (#Tab_DROIT, 0, 0, 400, 503)
;{ ONGLET PARAMETRES*******************************************************************
AddGadgetItem (#Tab_DROIT, -1, "PARAMETRES")
ContainerGadget(#CO_Parametres, 0,0,100,500, #PB_Container_Flat)
;{ GENERALITES////////////////////////////////////////////////////////////////////////////////////////////
TextGadget(#lab_GENERALITES, #PX1, POSY, 750, h_lab_titre, " GENERALITEES")
POSY=POSY+InterY+10
TextGadget(#lab_Nom_Montage, #PX2, POSY, 250, h_lab_simple, "Nom du Montage")
StringGadget(#txt_Nom_Montage, #PX12,POSY, 350, h_txt_simple, "CLIGNOTEUR")
POSY=POSY+InterY
TextGadget(#lab_Auteur_Montage, #PX2, POSY, 250, h_lab_simple, "Auteur")
StringGadget(#txt_Auteur_Montage, #PX12,POSY, 350, h_txt_simple, "JMB")
POSY=POSY+InterY
TextGadget(#lab_Date_Montage, #PX2, POSY, 250, h_lab_simple, "Date")
StringGadget(#txt_Date_Montage, #PX12,POSY, 350, h_txt_simple, "08/06/2016")
POSY=POSY+InterY
TextGadget(#lab_Description_Montage, #PX2, POSY, 250, h_lab_simple, "Description")
StringGadget(#txt_Description_Montage, #PX12,POSY, 350, h_txt_simple, "Fait Clignoter une LED")
POSY=POSY+InterY
TextGadget(#lab_SetComposants, #PX2, POSY, 250, h_lab_simple, "Set Composants")
ComboBoxGadget(#lb_Set_Composant, #px12,POSY+3, 350, h_lab_simple)
AddGadgetItem(#lb_Set_Composant, -1, "Pas de restriction")
AddGadgetItem(#lb_Set_Composant, -1, "Set 1 2016")
AddGadgetItem(#lb_Set_Composant, -1, "Set 2 2016")
ButtonGadget(#bt_VoirSet, #PX27, POSY+5, 100, h_lab_simple, "Voir...")
SetGadgetState(#lb_Set_Composant, 0)
POSY=POSY+InterY
TextGadget(#lab_Modeles, #PX2, POSY, 250, h_lab_simple, "Modèles")
ComboBoxGadget(#lb_Modeles, #px12, POSY+3, 350, h_lab_simple)
AddGadgetItem(#lb_Modeles, -1, "Pas de Modèle")
AddGadgetItem(#lb_Modeles, -1, "Modèle 1")
AddGadgetItem(#lb_Modeles, -1, "Modèle 2")
SetGadgetState(#lb_Modeles, 0)
POSY=POSY+InterY
TextGadget(#lab_Nombre_Planche, #PX2, POSY, 250, h_lab_simple, "Nombre de Planche")
SpinGadget (#sp_1, #PX12,POSY, 100, h_txt_simple, 0, 10)
GadgetToolTip(#sp_1, "Nombre de Planche: Ex: Un Montage avec un Emmeteur et un Récepteur à besoin de deux Planches car il s'agit de deux circuits différents")
POSY=POSY+InterY
TextGadget(#lab_G,#PX2, POSY, 300,h_lab_simple, "Présentation Générale")
POSY=POSY+InterY-10
CheckBoxGadget(#cb_MontageG, #PX2, POSY, 15, h_txt_simple, "")
TextGadget(#lab_MG,#PX3, POSY, 100,h_lab_simple, "Montage")
CheckBoxGadget(#cb_SchemaG, #px9, POSY, 15, h_txt_simple, "")
TextGadget(#lab_SG,#PX10, POSY, 100,h_lab_simple, "Schéma")
CheckBoxGadget(#cb_3, #px16, POSY, 15, h_txt_simple, "")
TextGadget(#lab_cb3,#PX17, POSY, 100,h_lab_simple, "CheckBox 3")
;SetGadgetState(#cb_1, #PB_Checkbox_Unchecked)
;SetGadgetState(#cb_2, #PB_Checkbox_Inbetween)
;}
;{ PLANCHES////////////////////////////////////////////////////////////////////////////////////////////
POSY=POSY+InterY+20
TextGadget(#lab_PLANCHES, #PX1, POSY,750,h_lab_titre+5," PLANCHES")
ComboBoxGadget(#lb_Planches, #px12, POSY+3, 350, h_lab_simple, #PB_ComboBox_Editable)
AddGadgetItem(#lb_Planches, -1, "PLANCHE N° 1")
AddGadgetItem(#lb_Planches, -1, "PLANCHE N° 2")
AddGadgetItem(#lb_Planches, -1, "PLANCHE N° 3")
SetGadgetState(#lb_Planches, 0)
POSY=POSY+InterY+10
TextGadget(#lab_Nom_Planche, #PX2, POSY, 250, h_lab_simple, "Nom de la Planche")
StringGadget(#txt_Nom_Planche, #PX12, POSY, 350, h_txt_simple, "EMETEUR")
POSY=POSY+InterY
TextGadget(#lab_Description_Planche, #PX2, POSY, 250, h_lab_simple, "Description")
StringGadget(#txt_Description_Planche, #PX12, POSY, 350, h_txt_simple, "Fait Clignoter une LED")
POSY=POSY+InterY
TextGadget(#lab_Nombre_Platine, #PX2, POSY, 250, h_lab_simple, "Nombre de Platine")
SpinGadget (#sp_Nombre_Platine, #PX12, POSY, 100, h_txt_simple, 0, 10)
POSY=POSY+InterY
TextGadget(#lab_Orientation, #PX2, POSY, 250, h_lab_simple, "Orientation")
OptionGadget(#op_Horizontale, #PX7, POSY, 15, h_txt_simple, "")
OptionGadget(#op_Verticale, #PX13, POSY, 15, h_txt_simple, "")
TextGadget(#lab_Horizontale, #PX8, POSY, 120, h_lab_simple, "Horizontale")
TextGadget(#lab_Verticale, #PX14, POSY, 120, h_lab_simple, "Verticale")
SetGadgetState(#op_Horizontale, 1) ; sélectionne
POSY=POSY+InterY+250
ButtonGadget(#bt_En_Modele, #PX2, POSY, 270, h_lab_simple+10, "Enregistrer comme Modèle")
CloseGadgetList();#CO_Parametres
;}
;}
larSch=290*10:hauSch=210*10 ;Dimensions du document Graphique final 290/210 mm * 10 pixels (format A4)
;{ ONGLET SCHEMAS*******************************************************************
AddGadgetItem (#Tab_DROIT, -1,"SCHEMA")
ContainerGadget(#CO_Schema, 0,0,1000,500, #PB_Container_BorderLess)
;{ ToolBar Schémas
ContainerGadget(#CO_tbSchema, 0, 0, 472, 30, #PB_Container_BorderLess)
If CreateToolBar(#TB_Schema, GadgetID(#CO_tbSchema))
ToolBarStandardButton(100, 0)
ToolBarStandardButton(101, 1)
ToolBarStandardButton(102, 3)
ToolBarStandardButton(103, 2)
EndIf
CloseGadgetList() ;#CO_tbSchema
;}
ReglesSchema()
ScrollAreaGadget(#sca_Schema, 25, 55, 700,500, larSch, hauSch, 30,#PB_ScrollArea_Flat)
CanvasGadget(#can_Schema, 0, 0, larSch, hauSch, #PB_Canvas_ClipMouse)
If StartDrawing(CanvasOutput(#can_Schema))
Box(0, 0, larSch, hauSch, Cou_JaunePale )
BackColor(Cou_JaunePale)
FrontColor(Cou_BleuFoce)
LineXY(0,0,580,0)
LineXY(580,0,580,580)
LineXY(580,580,0,580)
LineXY(0,580,0,0)
LineXY(0,0,580,580)
StopDrawing()
EndIf
CloseGadgetList();#sca_Schema
CloseGadgetList();#CO_Schema
;}
;{ ONGLET PLANCHES*******************************************************************
AddGadgetItem (#Tab_DROIT, -1,"PLANCHES")
ContainerGadget(#CO_Planche, 0,0,1000,500, #PB_Container_BorderLess)
;{ ToolBar Planches
ContainerGadget(#CO_tbPlanche, 0, 0, 472, 30, #PB_Container_BorderLess)
If CreateToolBar(#TB_Planche, GadgetID(#CO_tbPlanche))
ToolBarStandardButton(100, 0)
ToolBarStandardButton(101, 1)
ToolBarStandardButton(102, 3)
ToolBarStandardButton(103, 2)
EndIf
CloseGadgetList();#CO_tbPlanche
;}
ReglesPlanche()
ScrollAreaGadget(#sca_Planche, 25, 55, 700,500, larSch, hauSch, 30,#PB_ScrollArea_Flat)
CanvasGadget(#can_Planche, 0, 0, larSch, hauSch, #PB_Canvas_ClipMouse)
; If StartDrawing(CanvasOutput(#can_Planche))
; Box(0, 0, larSch, hauSch, Cou_JaunePale )
; BackColor(Cou_JaunePale)
; FrontColor(Cou_BleuFoce)
; LineXY(0,0,580,0)
; LineXY(580,0,580,580)
; LineXY(580,580,0,580)
; LineXY(0,580,0,0)
; LineXY(0,0,580,580)
; StopDrawing()
; EndIf
CloseGadgetList();#sca_Planche
CloseGadgetList();#CO_Planche
; ONGLET NOTICES*******************************************************************
AddGadgetItem (#Tab_DROIT, -1,"NOTICES")
ButtonGadget(#PB_Any, 95, 15, 80, 24,"Bouton 2")
; CloseGadgetList()
CloseGadgetList();#Tab_DROIT
CloseGadgetList() ;#SPLITDROIT
SplitterGadget(#SPLITER, 5,30,WinLarg,WinHaut, #SPLITGAUCHE,#SPLITDROIT, #PB_Splitter_Vertical| #PB_Splitter_Separator)
SetGadgetState(#SPLITER,300)
IniGadgets()
Resize()
Quit = 0
Repeat
Event = WaitWindowEvent()
If Event= #PB_Event_Gadget
Select EventGadget()
Case #SPLITER ; Le Spliter est déplacé
Resize()
; Case 2
EndSelect
EndIf
If Event = #PB_Event_CloseWindow
Window = EventWindow()
If Window = #numWIN ; Out main window is closed, just quit
Quit = 1
EndIf
ElseIf Event = #PB_Event_Menu
Select EventMenu()
Case #MENU_Open
Case #MENU_Close
Case #MENU_Quit
Quit = 1
EndSelect
ElseIf Event = #PB_Event_SizeWindow
Window = EventWindow()
EndIf
Until Quit = 1
EndIf
N'hésiter pas à critiquer le reste si votre temps et envie le permet.
Merci par avance,
JM