SplitterGadget Trennbalkens

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
marcelx
Beiträge: 381
Registriert: 19.02.2010 20:19
Wohnort: Darmstadt

SplitterGadget Trennbalkens

Beitrag von marcelx »

SplitterGadget Trennbalkens

Hallo,

wie kann ich nach Veränderung der Größe mit der Trennbalkens, die Breite der TextGadget/ListViewGadget anpassen?

Code: Alles auswählen

Enumeration
  #Window_data
  
  #containerG
  #titleG
  #listG
  
  #containerSG
  #titleSG
  #listSG
  
  #Splitter  
EndEnumeration

#rand = 20

If OpenWindow(#Window_data, 0, 0, 250+#rand, 200, "Test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  ContainerGadget(#containerG, 0, 0, 0, 0, #PB_Container_Double)
    TextGadget(#titleG, 10,10, 100,#rand,"Gruppe", #PB_Text_Center|#PB_Text_Border)
    ListViewGadget(#listG, 10, 50, 100, 120)
  CloseGadgetList()
    
  ContainerGadget(#containerSG, 0, 0, 0, 0, #PB_Container_Double)
    TextGadget(#titleSG, 10,10, 100,#rand,"Untergruppe", #PB_Text_Center|#PB_Text_Border)
    ListViewGadget(#listSG, 10, 50, 100, 120)
  CloseGadgetList()
  
  SplitterGadget(#Splitter, 5, 10, 250, 200-#rand, #containerG, #containerSG, #PB_Splitter_Vertical)
  
  For a = 1 To 12
    AddGadgetItem (#listG, -1, "G Item " + Str(a))   ; definieren des Listview-Inhalts
  Next
  SetGadgetState(#listG, 2)
  
  For a = 1 To 8
    AddGadgetItem (#listSG, -1, "SG Item " + Str(a))   ; definieren des Listview-Inhalts
  Next
  SetGadgetState(#listSG, 3)  
  
  Repeat
    Select WaitWindowEvent() 
      Case  #PB_Event_CloseWindow 
          Event = #PB_Event_CloseWindow
     
      Case #PB_Event_SizeWindow
        If IsGadget(#Splitter) ; vorhanden
          ExamineDesktops()
          ResizeGadget(#Splitter, #PB_Ignore, #PB_Ignore, WindowWidth(#Window_data) - #rand, WindowHeight(#Window_data)-#rand)
          
          ResizeGadget(#titleG, #PB_Ignore, #PB_Ignore, WindowWidth(#Window_data)/2 - 2*#rand, #PB_Ignore)
          ResizeGadget(#listG, #PB_Ignore, #PB_Ignore, WindowWidth(#Window_data)/2 - 2*#rand, WindowHeight(#Window_data)-4*#rand)
          
          ResizeGadget(#titleSG, #PB_Ignore, #PB_Ignore, WindowWidth(#Window_data)/2 - 2*#rand, #PB_Ignore)
          ResizeGadget(#listSG, #PB_Ignore, #PB_Ignore, WindowWidth(#Window_data)/2 - 2*#rand, WindowHeight(#Window_data)-4*#rand)
          
        EndIf
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Splitter
            Debug "EV SPL"
             
        EndSelect          
    EndSelect
  Until Event = #PB_Event_CloseWindow   
EndIf
Gruß
MarcelX
Win-10, PB 5.31 (Windows - x86)
mestnyi
Beiträge: 14
Registriert: 25.02.2014 22:00

Re: SplitterGadget Trennbalkens

Beitrag von mestnyi »

Code: Alles auswählen

Enumeration
  #Window_data
  
  #containerG
  #titleG
  #listG
  
  #containerSG
  #titleSG
  #listSG
  
  #Splitter  
EndEnumeration

#rand = 20

If OpenWindow(#Window_data, 0, 0, 250+#rand, 200, "Test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  ContainerGadget(#containerG, 0, 0, 0, 0, #PB_Container_Double)
    TextGadget(#titleG, 10,10, 100,#rand,"Gruppe", #PB_Text_Center|#PB_Text_Border)
    ListViewGadget(#listG, 10, 40, 100, 120)
  CloseGadgetList()
    
  ContainerGadget(#containerSG, 0, 0, 0, 0, #PB_Container_Double)
    TextGadget(#titleSG, 10,10, 100,#rand,"Untergruppe", #PB_Text_Center|#PB_Text_Border)
    ListViewGadget(#listSG, 10, 40, 100, 120)
  CloseGadgetList()
  
  SplitterGadget(#Splitter, 5, 10, 250, 200-#rand, #containerG, #containerSG, #PB_Splitter_Vertical)
  
  For a = 1 To 12
    AddGadgetItem (#listG, -1, "G Item " + Str(a))   ; definieren des Listview-Inhalts
  Next
  SetGadgetState(#listG, 2)
  
  For a = 1 To 8
    AddGadgetItem (#listSG, -1, "SG Item " + Str(a))   ; definieren des Listview-Inhalts
  Next
  SetGadgetState(#listSG, 3)  
  
  Repeat
    Select WaitWindowEvent() 
      Case  #PB_Event_CloseWindow 
          Event = #PB_Event_CloseWindow
     
      Case #PB_Event_SizeWindow
        If IsGadget(#Splitter) ; vorhanden
          ExamineDesktops()
          ResizeGadget(#Splitter, #PB_Ignore, #PB_Ignore, WindowWidth(#Window_data) - #rand, WindowHeight(#Window_data)-#rand)
        EndIf
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #containerG
            Select EventType()
              Case #PB_EventType_Resize
                ResizeGadget(#titleG, #PB_Ignore, #PB_Ignore, GadgetWidth(#containerG) - #rand, #PB_Ignore)
                ResizeGadget(#listG, #PB_Ignore, #PB_Ignore, GadgetWidth(#containerG) - #rand, GadgetHeight(#containerG)-30-#rand)
            EndSelect
            
          Case #containerSG
            Select EventType()
              Case #PB_EventType_Resize
                ResizeGadget(#titleSG, #PB_Ignore, #PB_Ignore, GadgetWidth(#containerSG) - #rand, #PB_Ignore)
                ResizeGadget(#listSG, #PB_Ignore, #PB_Ignore, GadgetWidth(#containerSG) - #rand, GadgetHeight(#containerSG)-30-#rand)
            EndSelect
            
          Case #Splitter
            Debug "EV SPL"
             
        EndSelect          
    EndSelect
  Until Event = #PB_Event_CloseWindow   
EndIf
Benutzeravatar
marcelx
Beiträge: 381
Registriert: 19.02.2010 20:19
Wohnort: Darmstadt

Re: SplitterGadget Trennbalkens

Beitrag von marcelx »

Danke mestnyi nur #PB_EventType_Resize gibt es leider nicht bei PB 5.31

EDIT:
so funktioniert:

Code: Alles auswählen

          Case #containerG
           ; Select EventType()
           ;   Case #PB_EventType_Resize ResizeGadget
                ResizeGadget(#titleG, #PB_Ignore, #PB_Ignore, GadgetWidth(#containerG) - #rand, #PB_Ignore)
                ResizeGadget(#listG, #PB_Ignore, #PB_Ignore, GadgetWidth(#containerG) - #rand, GadgetHeight(#containerG)-30-#rand)
           ; EndSelect
Win-10, PB 5.31 (Windows - x86)
Antworten