LayoutManager, automatische Anordnung von Gadgets, Layout

Hier könnt Ihr gute, von Euch geschriebene Codes posten. Sie müssen auf jeden Fall funktionieren und sollten möglichst effizient, elegant und beispielhaft oder einfach nur cool sein.
Mesa
Beiträge: 16
Registriert: 03.05.2012 18:23

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Mesa »

I changed the line 471, it's better when you change the font size
Ich habe die Linie 471, ist es besser, wenn Sie die Schriftgröße ändern

change this:

Code: Alles auswählen

InnerBorderTop = ____AWPB_GetGadgetTextHeight(GadgetID)
by that:

Code: Alles auswählen

InnerBorderTop = ____AWPB_GetGadgetTextHeight(GadgetID)*2
Mesa.
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

okay, changed. but it's better to change within ____AWPB_GetGadgetTextHeight because for linux it is calculated different.
okay, habe ich geändert. aber es ist besser das in der prozedur ____AWPB_GetGadgetTextHeight direkt zu ändern, da die berechnung für linux anders funktioniert.

please redownload, as i've fixed another bug too.
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Nino
Beiträge: 1300
Registriert: 13.05.2010 09:26
Wohnort: Berlin

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Nino »

@cptdark:
Danke, dass Du Deine Antworten jetzt auch auf Deutsch schreibst.

Grüße, Nino
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

Nino hat geschrieben:@cptdark:
Danke, dass Du Deine Antworten jetzt auch auf Deutsch schreibst.
Grüße, Nino
kein Problem :)

Topic: Neu in Version 0.1.6 ist eine SizerListe. Dort können Sizer voneinander abhängig sein.
Z.B. bei PanelGadgets oder SplitterGadgets muss erst der Sizer resized/berechnet werden, in dem das entsprechende Gadget liegt, und dann erst die davon abhängigen. Es erspart auch mehrere Aufrufe beim Resize (v.a. die Überlegung der richtigen Reihenfolge.) 2 etwas umfangreichere Beispiele dazu sind im Paket enthalten.
Zuletzt geändert von cptdark am 27.11.2012 22:45, insgesamt 1-mal geändert.
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Mesa
Beiträge: 16
Registriert: 03.05.2012 18:23

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Mesa »

Hello,

In the example 6 and 7, the TreeGadget, the ListViewGadget and the EditorGadget are flickering when i use the SplitterGadget.
Im Beispiel 6 und 7 werden die TreeGadget, die ListViewGadget und die flackernden EditorGadget, wenn ich die SplitterGadget verwenden.

I would suggest you to add a function : Procedure ____AWPB_GetGadgetTextWidth(GadgetID.i) because it should be very useful when we use a sizer withthe flag #AWPB_GUILO_SIZER_FIX.
Ich würde Ihnen vorschlagen, um eine Funktion hinzuzufügen: Verfahren ____ AWPB_GetGadgetTextWidth (GadgetID.i), weil es sein sollte sehr nützlich, wenn wir ein sizer EMPFOHLENEN flag # AWPB_GUILO_SIZER_FIX verwenden

You can have a look at this very useful and multipalform function:
Sie können einen Blick auf diese sehr nützlich und multipalform Funktion haben:
http://purebasic.developpez.com/sources ... sizeGadget

I use it to create my own FitGadget.pbi (but not multiplatform)
Ich benutze es, um meine eigene FitGadget.pbi erstellen (aber nicht Multiplattform)

Code: Alles auswählen

;
;FitGadget.pbi 

;Code SROD


;EnableExplicit



Procedure.l GetTextWidthPix(NumGadget, espace=1)
  Protected result, hdc, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char,lpSize.SIZE 
  ;espace : null-terminated + pour la checkbox par exemple, il faut ajouter la largeur d'un espace au texte 
  hDC = GetDC_(GadgetID(NumGadget))
  hFont = SendMessage_(GadgetID(NumGadget),#WM_GETFONT,0,0)
  If hFont And hDC
    SelectObject_(hDC,hFont)
  EndIf
  GetTextExtentPoint32_(hDC, GetGadgetText(NumGadget), Len(GetGadgetText(NumGadget)) + espace, lpSize)
  ;Ajustement qui depend du type de font; raster ou true/open type.
  GetTextMetrics_(hdc, tm)
  ;*sz\cy=tm\tmHeight-tm\tmInternalLeading ;on peut enlever le internal leading height
  If tm\tmOverhang ;Raster font.
    lpSize\cx + tm\tmOverhang
  Else
    char = Asc(Right(GetGadgetText(NumGadget),1))
    GetCharABCWidths_(hdc, char, char, abc) 
    overhang = abc\abcC
    If overHang < 0
      lpSize\cx - overHang
    EndIf
  EndIf
  
  SelectObject_(hdc, hFont)
  ReleaseDC_(GadgetID(NumGadget), hdc)
  result=lpSize\cx
  
  ProcedureReturn result
EndProcedure

Procedure.l GetTextHeightPix(NumGadget, espace=8)
  Protected result, hdc, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, lpSize.SIZE
  ; pourquoi 8 ????? 
  hDC = GetDC_(GadgetID(NumGadget))
  hFont = SendMessage_(GadgetID(NumGadget),#WM_GETFONT,0,0)
  If hFont And hDC
    SelectObject_(hDC,hFont)
  EndIf
  GetTextExtentPoint32_(hDC, GetGadgetText(NumGadget), Len(GetGadgetText(NumGadget)), lpSize)
  ;Ajustement qui depend du type de font; raster ou true/open type.
  GetTextMetrics_(hdc, tm)
  ;*sz\cy=tm\tmHeight-tm\tmInternalLeading ;on peut enlever le internal leading height
  If tm\tmOverhang ;Raster font.
    lpSize\cx + tm\tmOverhang
  Else
    char = Asc(Right(GetGadgetText(NumGadget),1))
    GetCharABCWidths_(hdc, char, char, abc) 
    overhang = abc\abcC
    If overHang < 0
      lpSize\cx - overHang
    EndIf
  EndIf
  
  SelectObject_(hdc, hFont)
  ReleaseDC_(GadgetID(NumGadget), hdc)
  result=lpSize\cy + espace
  
  ProcedureReturn result
EndProcedure


;Code Mesa 2012
Procedure.l GetHigherTextInListWidthPix(NumGadget)
  Protected result, hdc, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, Max, n, i, lg, lpSize.SIZE
  ;espace : null-terminated + pour la checkbox par exemple, il faut ajouter la largeur d'un espace au texte 
  hDC = GetDC_(GadgetID(NumGadget))
  hFont = SendMessage_(GadgetID(NumGadget),#WM_GETFONT,0,0)
  If hFont And hDC
    SelectObject_(hDC,hFont)
  EndIf
  n=0 
  Max=0
  For i=0 To CountGadgetItems(NumGadget)-1
    GetTextExtentPoint32_(hDC, GetGadgetItemText(NumGadget,i), Len(GetGadgetItemText(NumGadget,i)) , lpSize)
    
    If lpSize\cy>Max
      Max=lpSize\cy
      n=i
    EndIf
    
  Next i
  lpSize\cy=Max
  
  SelectObject_(hdc, hFont)
  ReleaseDC_(GadgetID(NumGadget), hdc)
  result=lpSize\cy
  
  ProcedureReturn result
EndProcedure  

Procedure.l GetLongerTextInListWidthPix(NumGadget)
  Protected result, hdc, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, Max, n, i, lg, lpSize.SIZE
  ;espace : null-terminated + pour la checkbox par exemple, il faut ajouter la largeur d'un espace au texte 
  hDC = GetDC_(GadgetID(NumGadget))
  hFont = SendMessage_(GadgetID(NumGadget),#WM_GETFONT,0,0)
  If hFont And hDC
    SelectObject_(hDC,hFont)
  EndIf
  n=0 
  Max=0
  For i=0 To CountGadgetItems(NumGadget)-1
    GetTextExtentPoint32_(hDC, GetGadgetItemText(NumGadget,i), Len(GetGadgetItemText(NumGadget,i)) , lpSize)
    
    If lpSize\cx>Max
      Max=lpSize\cx
      n=i
    EndIf
    
  Next i
  lpSize\cx=Max
  ;Ajustement qui depend du type de font; raster ou true/open type.
  GetTextMetrics_(hdc, tm)
  ;*sz\cy=tm\tmHeight-tm\tmInternalLeading ;on peut enlever le internal leading height
  If tm\tmOverhang ;Raster font.
    lpSize\cx + tm\tmOverhang
  Else
    char = Asc(Right(GetGadgetItemText(NumGadget,n),1))
    GetCharABCWidths_(hdc, char, char, abc) 
    overhang = abc\abcC
    If overHang < 0
      lpSize\cx - overHang
    EndIf
  EndIf
  
  SelectObject_(hdc, hFont)
  ReleaseDC_(GadgetID(NumGadget), hdc)
  result=lpSize\cx
  
  ProcedureReturn result
EndProcedure  

Procedure.l FitGadget(NumGadget, En_Longueur.b=#True, En_Hauteur.b=#True, Option.l=-1)
  Protected  DC, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, ncm.NONCLIENTMETRICS
  Protected Hauteur_case_a_cocher, rc.RECT,sz.SIZE, os, bordure, marge, handleimagelist, okBOOL
  Protected old$, min, max
  Protected BCM_FIRST, BCM_GETIDEALSIZE, BCM_GETTEXTMARGIN, MCM_FIRST, MCM_GETCALENDARBORDER,CBEM_GETIMAGELIST
  Protected pImageInfo.IMAGEINFO
  
  Select GadgetType(NumGadget)
    Case #PB_GadgetType_Button ;================ 
      BCM_FIRST            = $1600
      BCM_GETIDEALSIZE     = (BCM_FIRST + $0001) 
      If SendMessage_(GadgetID(NumGadget),BCM_GETIDEALSIZE,0,sz) = #True
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , sz\cx,sz\cy)
      EndIf
      
    Case #PB_GadgetType_Option ;================
      ncm\cbSize = SizeOf(NONCLIENTMETRICS)
      SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
      DC = GetDC_(0)
      Hauteur_case_a_cocher=Abs(ncm\lfMessageFont\lfheight); c'est aussi sa longueur
      ; GetDeviceCaps_(DC, #LOGPIXELSY)
      ReleaseDC_(0, DC)
      BCM_FIRST            = $1600
      BCM_GETTEXTMARGIN    = BCM_FIRST + $0005
      SendMessage_(GadgetID(NumGadget),BCM_GETTEXTMARGIN,0,rc)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\left+rc\right+Hauteur_case_a_cocher+GetTextWidthPix(NumGadget, 1),GetTextHeightPix(NumGadget,0))
      
    Case #PB_GadgetType_CheckBox ;================
      ncm\cbSize = SizeOf(NONCLIENTMETRICS)
      SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
      DC = GetDC_(0)
      Hauteur_case_a_cocher=Abs(ncm\lfMessageFont\lfheight); c'est aussi sa longueur
      ; GetDeviceCaps_(DC, #LOGPIXELSY)
      ReleaseDC_(0, DC)
      BCM_FIRST            = $1600
      BCM_GETTEXTMARGIN    = BCM_FIRST + $0005
      SendMessage_(GadgetID(NumGadget),BCM_GETTEXTMARGIN,0,rc)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\left+rc\right+Hauteur_case_a_cocher+GetTextWidthPix(NumGadget, 1),GetTextHeightPix(NumGadget,0))
      
    Case #PB_GadgetType_Calendar ;================
      SendMessage_(GadgetID(NumGadget),#MCM_GETMINREQRECT,0,rc)
      
      ;        If option= #PB_Calendar_Borderless 
      ;         ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\Right,rc\bottom)
      ;         
      ;       Else
      os=OSVersion()
      If  os=#PB_OS_Windows_Vista Or os=#PB_OS_Windows_Server_2008 Or os= #PB_OS_Windows_7 Or os=#PB_OS_Windows_Future
        MCM_FIRST               = $1000
        MCM_GETCALENDARBORDER   = MCM_FIRST + 31
        bordure= SendMessage_(GadgetID(NumGadget),MCM_GETCALENDARBORDER,0,0)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\Right+bordure,rc\bottom+bordure)
      Else
        
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\Right+4,rc\bottom+4)
      EndIf
      ;EndIf
      ;========================================================================  
    Case #PB_GadgetType_ComboBox ;================
      CBEM_GETIMAGELIST=1027
      marge=4
      ;Image presente ?
      handleimagelist= SendMessage_(GadgetID(NumGadget),CBEM_GETIMAGELIST ,0,0)
      If handleimagelist
        ;Retrieves information about an image. 
        okBOOL= ImageList_GetImageInfo_(handleimagelist,1,pImageInfo)
        marge+pImageInfo\rcImage\right+4
        If GetTextHeightPix(NumGadget)>pImageInfo\rcImage\bottom
          ;longueur dropdown =26
          ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 26+marge+GetLongerTextInListWidthPix(NumGadget),GetTextHeightPix(NumGadget))
        Else
          ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 26+marge+GetLongerTextInListWidthPix(NumGadget),0) 
        EndIf
      Else
        
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 26+marge+GetLongerTextInListWidthPix(NumGadget),0);GetTextHeightPix(NumGadget)
      EndIf
      
    Case #PB_GadgetType_Date ;================
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 26+GetTextWidthPix(NumGadget),GetTextHeightPix(NumGadget))
      
    Case #PB_GadgetType_Editor ;================
      marge=4
      
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),(CountGadgetItems(NumGadget)-1)*GetHigherTextInListWidthPix(NumGadget)) 
      
    Case #PB_GadgetType_String ;================
      marge=SendMessage_(GadgetID(NumGadget),#EM_GETMARGINS,0,0)
      ;Returns the width of the left margin in the LOWORD, And the width of the right margin in the HIWORD.
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , 4+(marge & $FFFF)+((marge >> 16) & $FFFF)+GetTextWidthPix(NumGadget),GetTextHeightPix(NumGadget)) 
      
    Case #PB_GadgetType_Text ;================
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget,0),GetTextHeightPix(NumGadget,0)) 
      
    Case #PB_GadgetType_HyperLink ;================
      If option=#PB_HyperLink_Underline
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget,0),GetTextHeightPix(NumGadget)) 
      Else
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget,0),GetTextHeightPix(NumGadget,0))  
      EndIf
      
    Case #PB_GadgetType_Spin ;================
      old$=GetGadgetText(NumGadget)
      min=GetGadgetAttribute(NumGadget, #PB_Spin_Minimum);#PB_Spin_Maximum
      SetGadgetText(NumGadget, Str(min))
      min=GetTextWidthPix(NumGadget,0)
      
      max=GetGadgetAttribute(NumGadget, #PB_Spin_Maximum)
      SetGadgetText(NumGadget, Str(max))
      max=GetTextWidthPix(NumGadget,0)
      
      SetGadgetText(NumGadget, old$)
      marge=20
      If max>=min
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+max,GetTextHeightPix(NumGadget))
      Else
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+min,GetTextHeightPix(NumGadget))  
      EndIf 
      
    Case #PB_GadgetType_ButtonImage ;================ 
      If option <> -1
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , ImageWidth(option),ImageHeight(option))  
      EndIf 
      
      ;Case #PB_GadgetType_Image;no effects ;================
      
      ;Case #PB_GadgetType_IPAddress;There's a bug somewhere ;================
      ;old=GetGadgetState(NumGadget)
      ;SetGadgetState(NumGadget, MakeIPAddress(192, 192, 192, 192))
      ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget),GetTextHeightPix(NumGadget))  
      ;SetGadgetState(NumGadget, old)  
      
    Case  #PB_GadgetType_ListView ;================
      marge=28
      min=SendMessage_(GadgetID(NumGadget),#LB_GETITEMHEIGHT,0,0)
      ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),CountGadgetItems(NumGadget)*GetTextHeightPix(NumGadget))         
      If option = -1 ; all
        ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),CountGadgetItems(NumGadget)*GetTextHeightPix(NumGadget))
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),min*(CountGadgetItems(NumGadget)+1))  
      Else
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),#PB_Ignore) 
      EndIf
      
  EndSelect
  ProcedureReturn #True
EndProcedure 

Procedure.l FitGadgetW(NumGadget, En_Longueur.b=#True, En_Hauteur.b=#True, Option.l=-1)
  Protected  DC, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, ncm.NONCLIENTMETRICS
  Protected Hauteur_case_a_cocher, rc.RECT,sz.SIZE, os, bordure, marge, handleimagelist, okBOOL
  Protected old$, min, max
  Protected BCM_FIRST, BCM_GETIDEALSIZE, BCM_GETTEXTMARGIN, MCM_FIRST, MCM_GETCALENDARBORDER,CBEM_GETIMAGELIST
  Protected pImageInfo.IMAGEINFO
  Protected w,h
  
  Select GadgetType(NumGadget)
    Case #PB_GadgetType_Button ;================ 
      BCM_FIRST            = $1600
      BCM_GETIDEALSIZE     = (BCM_FIRST + $0001) 
      If SendMessage_(GadgetID(NumGadget),BCM_GETIDEALSIZE,0,sz) = #True
        w=sz\cx
        h=sz\cy
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      EndIf
      
    Case #PB_GadgetType_Option ;================
      ncm\cbSize = SizeOf(NONCLIENTMETRICS)
      SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
      DC = GetDC_(0)
      Hauteur_case_a_cocher=Abs(ncm\lfMessageFont\lfheight); c'est aussi sa longueur
      ; GetDeviceCaps_(DC, #LOGPIXELSY)
      ReleaseDC_(0, DC)
      BCM_FIRST            = $1600
      BCM_GETTEXTMARGIN    = BCM_FIRST + $0005
      SendMessage_(GadgetID(NumGadget),BCM_GETTEXTMARGIN,0,rc)
      w=rc\left+rc\right+Hauteur_case_a_cocher+GetTextWidthPix(NumGadget, 1)
      h=GetTextHeightPix(NumGadget,0)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      
    Case #PB_GadgetType_CheckBox ;================
      ncm\cbSize = SizeOf(NONCLIENTMETRICS)
      SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
      DC = GetDC_(0)
      Hauteur_case_a_cocher=Abs(ncm\lfMessageFont\lfheight); c'est aussi sa longueur
      ; GetDeviceCaps_(DC, #LOGPIXELSY)
      ReleaseDC_(0, DC)
      BCM_FIRST            = $1600
      BCM_GETTEXTMARGIN    = BCM_FIRST + $0005
      SendMessage_(GadgetID(NumGadget),BCM_GETTEXTMARGIN,0,rc)
      w=rc\left+rc\right+Hauteur_case_a_cocher+GetTextWidthPix(NumGadget, 1)
      h=GetTextHeightPix(NumGadget,0)
      ResizeGadget(NumGadget, #PB_Ignore, #PB_Ignore, w, h)
      
    Case #PB_GadgetType_Calendar ;================
      SendMessage_(GadgetID(NumGadget),#MCM_GETMINREQRECT,0,rc)
      
      ;        If option= #PB_Calendar_Borderless 
      ;         ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\Right,rc\bottom)
      ;         
      ;       Else
      os=OSVersion()
      If  os=#PB_OS_Windows_Vista Or os=#PB_OS_Windows_Server_2008 Or os= #PB_OS_Windows_7 Or os=#PB_OS_Windows_Future
        MCM_FIRST               = $1000
        MCM_GETCALENDARBORDER   = MCM_FIRST + 31
        bordure= SendMessage_(GadgetID(NumGadget),MCM_GETCALENDARBORDER,0,0)
        w=rc\Right+bordure
        h=rc\bottom+bordure
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      Else
        w=rc\Right+4
        h=rc\bottom+4
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      EndIf
      ;EndIf
      ;========================================================================  
    Case #PB_GadgetType_ComboBox ;================
      CBEM_GETIMAGELIST=1027
      marge=4
      ;Image presente ?
      handleimagelist= SendMessage_(GadgetID(NumGadget),CBEM_GETIMAGELIST ,0,0)
      If handleimagelist
        ;Retrieves information about an image. 
        okBOOL= ImageList_GetImageInfo_(handleimagelist,1,pImageInfo)
        marge+pImageInfo\rcImage\right+4
        If GetTextHeightPix(NumGadget)>pImageInfo\rcImage\bottom
          ;longueur dropdown =26
          w=26+marge+GetLongerTextInListWidthPix(NumGadget)
          h=GetTextHeightPix(NumGadget)
          ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
        Else
          w=26+marge+GetLongerTextInListWidthPix(NumGadget)
          h=0
          ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h ) 
        EndIf
      Else
        w=26+marge+GetLongerTextInListWidthPix(NumGadget)
        h=0
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h);GetTextHeightPix(NumGadget)
      EndIf
      
    Case #PB_GadgetType_Date ;================
      w=26+GetTextWidthPix(NumGadget)
      h=GetTextHeightPix(NumGadget)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      
    Case #PB_GadgetType_Editor ;================
      marge=4
      w=marge+GetLongerTextInListWidthPix(NumGadget)
      h=(CountGadgetItems(NumGadget)-1)*GetHigherTextInListWidthPix(NumGadget)
      
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h) 
      
    Case #PB_GadgetType_String ;================
      marge=SendMessage_(GadgetID(NumGadget),#EM_GETMARGINS,0,0)
      ;Returns the width of the left margin in the LOWORD, And the width of the right margin in the HIWORD.
      w=4+(marge & $FFFF)+((marge >> 16) & $FFFF)+GetTextWidthPix(NumGadget)
      h=GetTextHeightPix(NumGadget)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h) 
      
    Case #PB_GadgetType_Text ;================
      w=GetTextWidthPix(NumGadget,0)
      h=GetTextHeightPix(NumGadget,0)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h) 
      
    Case #PB_GadgetType_HyperLink ;================
      w=GetTextWidthPix(NumGadget,0)
      If option=#PB_HyperLink_Underline
        h=GetTextHeightPix(NumGadget)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h) 
      Else
        h=GetTextHeightPix(NumGadget,0)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)  
      EndIf
      
    Case #PB_GadgetType_Spin ;================
      old$=GetGadgetText(NumGadget)
      min=GetGadgetAttribute(NumGadget, #PB_Spin_Minimum);#PB_Spin_Maximum
      SetGadgetText(NumGadget, Str(min))
      min=GetTextWidthPix(NumGadget,0)
      
      max=GetGadgetAttribute(NumGadget, #PB_Spin_Maximum)
      SetGadgetText(NumGadget, Str(max))
      max=GetTextWidthPix(NumGadget,0)
      
      SetGadgetText(NumGadget, old$)
      marge=20
      h=GetTextHeightPix(NumGadget)
      If max>=min
        w=marge+max
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h)
      Else
        w=marge+min
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h)  
      EndIf 
      
    Case #PB_GadgetType_ButtonImage ;================ 
      If option <> -1
        w=ImageWidth(option)
        h=ImageHeight(option)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h)  
      EndIf 
      
      ;Case #PB_GadgetType_Image;no effects ;================
      
      ;Case #PB_GadgetType_IPAddress;There's a bug somewhere ;================
      ;old=GetGadgetState(NumGadget)
      ;SetGadgetState(NumGadget, MakeIPAddress(192, 192, 192, 192))
      ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget),GetTextHeightPix(NumGadget))  
      ;SetGadgetState(NumGadget, old)  
      
    Case  #PB_GadgetType_ListView ;================
      marge=28
      min=SendMessage_(GadgetID(NumGadget),#LB_GETITEMHEIGHT,0,0)
      ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),CountGadgetItems(NumGadget)*GetTextHeightPix(NumGadget))         
      w=marge+GetLongerTextInListWidthPix(NumGadget)
      If option = -1 ; all
        ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),CountGadgetItems(NumGadget)*GetTextHeightPix(NumGadget))
        h=min*(CountGadgetItems(NumGadget)+1)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h)  
      Else
        h=#PB_Ignore
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w,h) 
      EndIf
      
  EndSelect
  ProcedureReturn w
EndProcedure 

Procedure.l FitGadgetH(NumGadget, En_Longueur.b=#True, En_Hauteur.b=#True, Option.l=-1)
  Protected  DC, tm.TEXTMETRIC, abc.ABC, overhang, hFont, char, ncm.NONCLIENTMETRICS
  Protected Hauteur_case_a_cocher, rc.RECT,sz.SIZE, os, bordure, marge, handleimagelist, okBOOL
  Protected old$, min, max
  Protected BCM_FIRST, BCM_GETIDEALSIZE, BCM_GETTEXTMARGIN, MCM_FIRST, MCM_GETCALENDARBORDER,CBEM_GETIMAGELIST
  Protected pImageInfo.IMAGEINFO
  Protected w,h
  
  Select GadgetType(NumGadget)
    Case #PB_GadgetType_Button ;================ 
      BCM_FIRST            = $1600
      BCM_GETIDEALSIZE     = (BCM_FIRST + $0001) 
      If SendMessage_(GadgetID(NumGadget),BCM_GETIDEALSIZE,0,sz) = #True
        w=sz\cx
        h=sz\cy
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      EndIf
      
    Case #PB_GadgetType_Option ;================
      ncm\cbSize = SizeOf(NONCLIENTMETRICS)
      SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
      DC = GetDC_(0)
      Hauteur_case_a_cocher=Abs(ncm\lfMessageFont\lfheight); c'est aussi sa longueur
      ; GetDeviceCaps_(DC, #LOGPIXELSY)
      ReleaseDC_(0, DC)
      BCM_FIRST            = $1600
      BCM_GETTEXTMARGIN    = BCM_FIRST + $0005
      SendMessage_(GadgetID(NumGadget),BCM_GETTEXTMARGIN,0,rc)
      w=rc\left+rc\right+Hauteur_case_a_cocher+GetTextWidthPix(NumGadget, 1)
      h=GetTextHeightPix(NumGadget,0)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      
    Case #PB_GadgetType_CheckBox ;================
      ncm\cbSize = SizeOf(NONCLIENTMETRICS)
      SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, SizeOf(NONCLIENTMETRICS), @ncm, 0)
      DC = GetDC_(0)
      Hauteur_case_a_cocher=Abs(ncm\lfMessageFont\lfheight); c'est aussi sa longueur
      ; GetDeviceCaps_(DC, #LOGPIXELSY)
      ReleaseDC_(0, DC)
      BCM_FIRST            = $1600
      BCM_GETTEXTMARGIN    = BCM_FIRST + $0005
      SendMessage_(GadgetID(NumGadget),BCM_GETTEXTMARGIN,0,rc)
      w=rc\left+rc\right+Hauteur_case_a_cocher+GetTextWidthPix(NumGadget, 1)
      h=GetTextHeightPix(NumGadget,0)
      ResizeGadget(NumGadget, #PB_Ignore, #PB_Ignore, w, h)
      
    Case #PB_GadgetType_Calendar ;================
      SendMessage_(GadgetID(NumGadget),#MCM_GETMINREQRECT,0,rc)
      
      ;        If option= #PB_Calendar_Borderless 
      ;         ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , rc\Right,rc\bottom)
      ;         
      ;       Else
      os=OSVersion()
      If  os=#PB_OS_Windows_Vista Or os=#PB_OS_Windows_Server_2008 Or os= #PB_OS_Windows_7 Or os=#PB_OS_Windows_Future
        MCM_FIRST               = $1000
        MCM_GETCALENDARBORDER   = MCM_FIRST + 31
        bordure= SendMessage_(GadgetID(NumGadget),MCM_GETCALENDARBORDER,0,0)
        w=rc\Right+bordure
        h=rc\bottom+bordure
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      Else
        w=rc\Right+4
        h=rc\bottom+4
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      EndIf
      ;EndIf
      ;========================================================================  
    Case #PB_GadgetType_ComboBox ;================
      CBEM_GETIMAGELIST=1027
      marge=4
      ;Image presente ?
      handleimagelist= SendMessage_(GadgetID(NumGadget),CBEM_GETIMAGELIST ,0,0)
      If handleimagelist
        ;Retrieves information about an image. 
        okBOOL= ImageList_GetImageInfo_(handleimagelist,1,pImageInfo)
        marge+pImageInfo\rcImage\right+4
        If GetTextHeightPix(NumGadget)>pImageInfo\rcImage\bottom
          ;longueur dropdown =26
          w=26+marge+GetLongerTextInListWidthPix(NumGadget)
          h=GetTextHeightPix(NumGadget)
          ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
        Else
          w=26+marge+GetLongerTextInListWidthPix(NumGadget)
          h=0
          ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h ) 
        EndIf
      Else
        w=26+marge+GetLongerTextInListWidthPix(NumGadget)
        h=0
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h);GetTextHeightPix(NumGadget)
      EndIf
      
    Case #PB_GadgetType_Date ;================
      w=26+GetTextWidthPix(NumGadget)
      h=GetTextHeightPix(NumGadget)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)
      
    Case #PB_GadgetType_Editor ;================
      marge=4
      w=marge+GetLongerTextInListWidthPix(NumGadget)
      h=(CountGadgetItems(NumGadget)-1)*GetHigherTextInListWidthPix(NumGadget)
      
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h) 
      
    Case #PB_GadgetType_String ;================
      marge=SendMessage_(GadgetID(NumGadget),#EM_GETMARGINS,0,0)
      ;Returns the width of the left margin in the LOWORD, And the width of the right margin in the HIWORD.
      w=4+(marge & $FFFF)+((marge >> 16) & $FFFF)+GetTextWidthPix(NumGadget)
      h=GetTextHeightPix(NumGadget)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h) 
      
    Case #PB_GadgetType_Text ;================
      w=GetTextWidthPix(NumGadget,0)
      h=GetTextHeightPix(NumGadget,0)
      ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h) 
      
    Case #PB_GadgetType_HyperLink ;================
      w=GetTextWidthPix(NumGadget,0)
      If option=#PB_HyperLink_Underline
        h=GetTextHeightPix(NumGadget)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h) 
      Else
        h=GetTextHeightPix(NumGadget,0)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , w,h)  
      EndIf
      
    Case #PB_GadgetType_Spin ;================
      old$=GetGadgetText(NumGadget)
      min=GetGadgetAttribute(NumGadget, #PB_Spin_Minimum);#PB_Spin_Maximum
      SetGadgetText(NumGadget, Str(min))
      min=GetTextWidthPix(NumGadget,0)
      
      max=GetGadgetAttribute(NumGadget, #PB_Spin_Maximum)
      SetGadgetText(NumGadget, Str(max))
      max=GetTextWidthPix(NumGadget,0)
      
      SetGadgetText(NumGadget, old$)
      marge=20
      h=GetTextHeightPix(NumGadget)
      If max>=min
        w=marge+max
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h)
      Else
        w=marge+min
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h)  
      EndIf 
      
    Case #PB_GadgetType_ButtonImage ;================ 
      If option <> -1
        w=ImageWidth(option)
        h=ImageHeight(option)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h)  
      EndIf 
      
      ;Case #PB_GadgetType_Image;no effects ;================
      
      ;Case #PB_GadgetType_IPAddress;There's a bug somewhere ;================
      ;old=GetGadgetState(NumGadget)
      ;SetGadgetState(NumGadget, MakeIPAddress(192, 192, 192, 192))
      ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , GetTextWidthPix(NumGadget),GetTextHeightPix(NumGadget))  
      ;SetGadgetState(NumGadget, old)  
      
    Case  #PB_GadgetType_ListView ;================
      marge=28
      min=SendMessage_(GadgetID(NumGadget),#LB_GETITEMHEIGHT,0,0)
      ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),CountGadgetItems(NumGadget)*GetTextHeightPix(NumGadget))         
      w=marge+GetLongerTextInListWidthPix(NumGadget)
      If option = -1 ; all
        ;ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore , marge+GetLongerTextInListWidthPix(NumGadget),CountGadgetItems(NumGadget)*GetTextHeightPix(NumGadget))
        h=min*(CountGadgetItems(NumGadget)+1)
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w ,h)  
      Else
        h=#PB_Ignore
        ResizeGadget(NumGadget,#PB_Ignore ,#PB_Ignore ,w,h) 
      EndIf
      
  EndSelect
  ProcedureReturn h
EndProcedure 
I use it with this example:
Ich benutze es mit diesem Beispiel:

Code: Alles auswählen

;    guilayout_demo5.pb
;    Version 0.1 [2012/05/06]
;    Copyright (C) 2012 Ronny Krueger
;
;    This file is part of AWPB-Tools.
;
;    AWPB-Tools is free software: you can redistribute it and/or modify
;    it under the terms of the GNU Lesser General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    AWPB-Tools is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU Lesser General Public License for more details.
;
;    You should have received a copy of the GNU Lesser General Public License
;    along with AWPB-Tools.  If not, see <http://www.gnu.org/licenses/>.

;EnableExplicit

; CompilerSelect #PB_Compiler_OS 
;   CompilerCase #PB_OS_Windows
;     IncludePath "..\include\awpbtools"
;   CompilerCase #PB_OS_Linux
;     IncludePath "../include/awpbtools"
; CompilerEndSelect

XIncludeFile "awguilayout.pbi"
XIncludeFile "FitGadget.pbi"


Define win, gdg0, gdg1, gdg2, gdg3, gdg4, gdg5
Define *sizer.AWPB_GUILO_Sizer, s1.i, s2.i, s3.i
Define fs0.i, fs1.i, fs2.i, fs3.i, fs4.i, fs5.i

; If LoadFont(1, "Arial", 5)
;   SetGadgetFont(#PB_Default, FontID(1))
; EndIf
    
win = OpenWindow(#PB_Any, 542, 122, 410, 410, "GUI-Layout-Demo", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If IsWindow(win)
  *sizer = AWPB_CreateSizerObj(win)
  If *sizer
    gdg0 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 0 20% height, 100% width")
    option_1=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 1")
    option_2=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 2")
    option_3=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 3")
    SetGadgetState(option_2, 1) 
        
    gdg1 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 1 FIXE - with borders a 10 px, 20% height, 100% width")
    option_4=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 4")
    option_5=OptionGadget(#PB_Any, 60, 0, 1, 1, "Option 5")
    option_6=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 6")
    SetGadgetState(option_2, 1) 
    
    gdg2 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 2 FIXE - 60% height, 50% width")
    option_7=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 7")
    option_8=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 8")
    option_9=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 9")
    SetGadgetState(option_9, 1)
    
    gdg3 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 3 - 30% height, 25% width", #PB_Frame3D_Double)
    gdg4 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 4 - with borders a 5 px, 30% height, 25% width",#PB_Frame3D_Flat )
    gdg5 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 5 FIXE - 60% height, 25% width")
    option_10=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 10")
    option_11=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 11")
    option_12=OptionGadget(#PB_Any, 0, 0, 1, 1, "Option 12")
    SetGadgetState(option_10, 1)
    ; only needed for linux, since title does not resize correctly
    CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    	AWPB_GUILO_Fix_Frame3DGadget_Resize(gdg0)
    	AWPB_GUILO_Fix_Frame3DGadget_Resize(gdg1)
    	AWPB_GUILO_Fix_Frame3DGadget_Resize(gdg2)
    	AWPB_GUILO_Fix_Frame3DGadget_Resize(gdg3)
    	AWPB_GUILO_Fix_Frame3DGadget_Resize(gdg4)
    	AWPB_GUILO_Fix_Frame3DGadget_Resize(gdg5)
    CompilerEndIf
    
    s1  = *sizer\AddSizer(#Null, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 100)
    fs0 = *sizer\AddFramedSizer(s1, gdg0, #AWPB_GUILO_SIZER_HBOX | #AWPB_GUILO_SIZER_REL, 20)
   				*sizer\AddGadget(fs0, option_1, 30)
   				*sizer\AddGadget(fs0, option_2, 30)
   				*sizer\AddGadget(fs0, option_3, 30)
    fs1 = *sizer\AddFramedSizer(s1, gdg1, #AWPB_GUILO_SIZER_HBOX | #AWPB_GUILO_SIZER_FIX, 20)
          *sizer\AddGadget(fs1, option_4, FitGadgetW(option_4)+10)
   				*sizer\AddGadget(fs1, option_5, FitGadgetW(option_5)+10)
   				*sizer\AddGadget(fs1, option_6, FitGadgetW(option_6)+10)
    s2  = *sizer\AddSizer(s1, #AWPB_GUILO_SIZER_HBOX | #AWPB_GUILO_SIZER_REL, 60)
    fs2 = *sizer\AddFramedSizer(s2, gdg2, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_FIX, 50)
          *sizer\AddGadget(fs2, option_7, FitGadgetH(option_7)+5)
   				*sizer\AddGadget(fs2, option_8, FitGadgetH(option_8)+5)
   				*sizer\AddGadget(fs2, option_9, FitGadgetH(option_9)+5)
    s3  = *sizer\AddSizer(s2, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 25)
    fs3 = *sizer\AddFramedSizer(s3, gdg3, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 50)
    fs4 = *sizer\AddFramedSizer(s3, gdg4, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 50)
    fs5 = *sizer\AddFramedSizer(s2, gdg5, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 25)
                                *sizer\AddGadget(fs5, option_10, 30)
   				*sizer\AddGadget(fs5, option_11, 30)
   				*sizer\AddGadget(fs5, option_12, 30)
    *sizer\Finish()
      
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_SizeWindow
          *sizer\Resize()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case win
              CloseWindow(win)
              win = 0
              Break
          EndSelect
      EndSelect
    ForEver
    
    *sizer\Destroy()
  Else
    MessageRequester("Fehler", "Konnte Sizer nicht erstellen") 
  EndIf
Else
  MessageRequester("Fehler", "Konnte Fenster nicht erstellen") 
EndIf

End

Mesa.
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

Neue Version: http://angelzware.bplaced.net/media/gim ... -0_1_7.zip

Dokumentation ist noch nicht vollständig
Es ist jetzt möglich, für jedes Gadget/Frame eine Minimal- und/oder Maximal-Größe anzugeben. Dies entweder durch direkte Vergabe eines Wertes oder den Zeiger auf eine CallBack-Prozedur.
Weiterhin sind die vielen Parameter bei den Prozeduren einer Struktur gewichen, sofern man mehr als die Prozentuale Größe angeben will.

Was mir jetzt fehlt, ist eine gewisse Logik in der Berechnungsfunktion.

Angenommen ein horizontaler Sizer mit 30%, 30%, 40% - Aufteilung.
Gadget 1 überschreitet irgendwann die 30% wegen einer angegebenen Minimalgröße - dann müssen (sofern möglich) die anderen Bereiche angepasst werden. Da fehlt mir noch eine Idee, wie das berechnet werden könnte. (Möglichst effizient, da dies bei jedem resize erfolgen muss). Die jetzigen Min/Max-Berechnungen erfolgen nur beim erstmaligen Berechnen (Finish())

@mesa: Danke für die Beispiele / Links, da die aber nicht alle Gadgets korrekt abdecken, hab ich jetzt erstmal obigen Weg gewählt. Die Prozeduren, wie genau die Höhe/Breite nun berechnet wird, kann der User dann selber festlegen - und damit auch obige abgewandelt benutzen.
CptDark
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Mesa
Beiträge: 16
Registriert: 03.05.2012 18:23

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Mesa »

Hello,

I've got a bug : "Max is not a function..."
Ich habe einen Fehler: "Max ist nicht eine Funktion ..."

Mesa.
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

should be fixed, occured not here since its part of the windows-code; plese redownload V0.1.7
sollte behoben sein, trat bei mir micht auf, da es im windows-code war; bitte V0.1.7 neu laden

This version is still buggy I think, but a big step in my desired direction.
Diese Version ist sicherlich noch fehlerhaft, aber ein großer Schritt in meine gewünschte Richtung.

thx
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Mesa
Beiträge: 16
Registriert: 03.05.2012 18:23

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Mesa »

Hello,

können Sie mir erklären, was ist die Konstante : #AWPB_GUILO_SIZER_HAS_MAXSIZE_FUNC ?
could you explain to me what is the function of the constant #AWPB_GUILO_SIZER_HAS_MAXSIZE_FUNC ?

Thx.

Mesa.
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

I'll try / ich werds versuchen

Code: Alles auswählen

Structure AWPB_GUILO_Sizer_Gadget
	ParentSizer.i ;-> ParentSizer, returned value of AddSizer / AddFramedSizer
	Size.i ; -> as before, size in Percent of the Parentsizer
	MinWidth.i ; -> min and max size
	MaxWidth.i
	MinHeight.i
	MaxHeight.i
	Flags.i
	Align.i
	GadgetID.i ; -> Gadget number of gadget to be added
	BorderLeft.i ; -> Border around the Gadget
	BorderTop.i
	BorderRight.i
	BorderBottom.i
	*OnBeforeResizeCallback.AWPB_GUILO_OnBeforeResize_Proto
	*OnAfterResizeCallback.AWPB_GUILO_OnAfterResize_Proto
	*GetMinGadgetSize.AWPB_GUILO_GetMinGadgetSize_Proto
	*GetMaxGadgetSize.AWPB_GUILO_GetMaxGadgetSize_Proto	
EndStructure
Values for Flags: (only for AddGadgetEx)

Code: Alles auswählen

#AWPB_GUILO_SIZER_HAS_MINSIZE_VAL   ;-> if set, you must assign a value to MinWidth / MinHeight
#AWPB_GUILO_SIZER_HAS_MAXSIZE_VAL	   ; -> if set you must assign a value to MaxWidth / MaxHeight
#AWPB_GUILO_SIZER_HAS_MINSIZE_FUNC   ; -> if set you must assign a pointer to a callback-procedure to GetMinGadgetSize
#AWPB_GUILO_SIZER_HAS_MAXSIZE_FUNC   ; -> if set you must assign a pointer to a callback-procedure to GetMaxGadgetSize
assign a value to align is only neccessary if you set one of the flags above since it will always fill out the sizer if not restricted
Align muss nur ein Wert zugewiesen werden, wenn eines der Size-Flags gesetzt wurde, da die Gadgets standardmäßig den gesamten Sizer ausfüllen

As you might have seen the prototypes for the GetMin/MaxSize-Procs are
Die Prototypen für die GetSize-Funktionen sehen so aus:

Code: Alles auswählen

PrototypeC.i AWPB_GUILO_GetMinGadgetSize_Proto(GadgetID.i, Flag.i)
PrototypeC.i AWPB_GUILO_GetMaxGadgetSize_Proto(GadgetID.i, Flag.i)
so you should write your procedures like

Code: Alles auswählen

ProcedureC.i MyGetMinGadgetSize(GadgetID.i, Flag.i)
;...
EndProcedure
ProcedureC.i MyGetMaxGadgetSize(GadgetID.i, Flag.i)
;...
EndProcedure
Flag is either #AWPB_GUILO_GETWIDTH or #AWPB_GUILO_GETHEIGHT
Flag ist entweder #AWPB_GUILO_GETWIDTH oder #AWPB_GUILO_GETHEIGHT - je nachdem, welche Größe angefordert wird

you have to return the value, it's up to you to calculate the size. GadgetID is the gadgetnumber which size should be calculated
as it is not resized the time this functions are called, you cannot use functions like GadgetWidth() or GadgetX() ...
these procedures are by now called only when you execute the Finish()-Method
Die Prozedur muss den Größenwert zurückgeben, wie er berechnet wird ist egal. GadgetID ist die Nummer das Gadgets. Da dieses zum Zeitpunkt des Prozeduraufrufes noch nicht skaliert wurde, ist es nicht möglich Funktionen wie GadgetWidth() oder GadgetX() zu benutzen.

Documentation will be updated when all is running as expected since its still experimental.
Die Dokumentation wird aktualisiert, sobald alles wie erwartet läuft; bisher ist alles noch experimentell.

Besides the new Max/Min-functionality everything could be used actually.
Ausser der neuen Max/Min-Funktionalität kann eigentlich schon alles benutzt werden.

AWPB_GUILO_Sizer_FramedSizer just extends AWPB_GUILO_Sizer_Gadget by inner borders - all other parameters are equal.
AWPB_GUILO_Sizer_FramedSizer erweitert lediglich AWPB_GUILO_Sizer_Gadget um eine innere Grenze - die anderen Parameter sind identisch.
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Antworten