Seite 1 von 1

ScrollArea und Font-Attribute

Verfasst: 29.03.2011 18:00
von ozoffi
Hallo!
Ich hoffe auf Eure Hilfe ...

Ich habe ein ScrollAreaGadget, in dem ich Bilder und Beschriftungen (mit TextGadget) anzeige.
Diesen Textgadgets weise ich mit PureColor Fontfarbe und Hintergrundfarbe zu - UND ich setze die Fontattribute (mit SetGadgetFont) für den Font selbst und dessen Größe. Das funktioniert auch alles wunderbar.
Selbst wenn das Fenster von einem Anderen überdeckt wird, bleibt die Anzeige stabil.
Nur, wenn ich den Inhalt des ScrollAreas aus dem Fenster scrolle, werden nur die Font-Attribute für Font und Größe zurückgesetzt. Die Farben bleiben gesetzt.
Wie kann ich das fixen?

Re: ScrollArea und Font-Attribute

Verfasst: 29.03.2011 18:02
von STARGÅTE
Bild

Code bitte.

Re: ScrollArea und Font-Attribute

Verfasst: 01.04.2011 16:58
von ozoffi
Hallo und sorry für das lange Delay ...

Im Grunde ist es das:

Code: Alles auswählen


OpenWindow(#Window_1, 1, 1, 460, 550, "LOKLISTE", #PB_Window_WindowCentered | #PB_Window_Tool |#PB_Window_NoGadgets)
SetWindowColor(#window_1,$a0a0a0)
OldGadgetList = UseGadgetList(WindowID(#window_1)) 
ScrollAreaGadget(#scrollw_1, 0, 0, 460,550, w, h, 10,#PB_ScrollArea_BorderLess )
PureCOLOR_SetGadgetColor(#scrollw_1, $000000, $a0a0a0)
  y=0
  For l = 1 To id
    name(l)=TextGadget(#PB_Any, 5, y+5, 250, 32, name$(l))
    adr(l)=TextGadget(#PB_Any, 260, y+5, 60, 25, adr$(l))
    tnr(l)=TextGadget(#PB_Any, 5, y+90, 35, 40, tnr$(l), #PB_Text_Center)
    t(l)=TextGadget(#PB_Any, 5, y+55, 30, 35, t$, #PB_Text_Center)  
    LoadImage(l,dir$+"Lokbilder\"+lokimage$(l))
    image(l)=ImageGadget(#PB_Any, 45, y+20, 279, 93, ImageID(l))     
    SetGadgetFont(adr(l), LoadFont(#Font_Adresse_1, "LcdD", 18, #PB_Font_Bold|#PB_Font_HighQuality))
    SetGadgetFont(tnr(l), LoadFont(#Font_TraktionNR_1, "Arial", 20, #PB_Font_Bold|#PB_Font_HighQuality))
    SetGadgetFont(t(l), LoadFont(#Font_Traktion_1, "Arial", 20, #PB_Font_Bold|#PB_Font_HighQuality))
    SetGadgetFont(name(l), LoadFont(#Font_Lokname_1, "Arial", 20, #PB_Font_Bold|#PB_Font_HighQuality))   
    PureCOLOR_SetGadgetColor(name(l), $000000, $a0a0a0)
    PureCOLOR_SetGadgetColor(adr(l), $000000, $a0a0a0)
    PureCOLOR_SetGadgetColor(tnr(l), $000000, $a0a0a0)
    PureCOLOR_SetGadgetColor(t(l), $000000, $a0a0a0)
    y=y+120
    Next l       
  UseGadgetList(OldGadgetList) 

Zuerst werden die diversen Werte von einer Textdatei eingelsen, dabei eben in das Array geschrieben und dann halt ausgegeben. Funktioniert super, solange ich nicht scrolle. Dann ist einfach das Fontattribut weg (also kein Arial 20 o.ä. mehr). Die Farbe bleibt...


__________________________________________________
Tags geändert
Quote>Code
01.04.2011
RSBasic

Re: ScrollArea und Font-Attribute

Verfasst: 01.04.2011 18:33
von STARGÅTE
Also, erst mal ist es sehr schlecht, wenn du in der schleife mehrmals die selbe Font lädtst.

Zwar wird sie bei jeden Loop automatisch freigegeben, weil du immer die selben Konstanten nutz, trotzdem ist es kein guter Ansatz.

Da ich die Prozedur PureCOLOR_SetGadgetColor nicht kenne, vermutlich ich das es sich dabei um ein Include/UserLib handelt ...
Da ich deren Quellcode nicht kenne, weiß ich nicht was sie "intern" dem "Gadget" anrichtet ...
vermutlich ist sie der Grund des verschwindens.

Schließlich passiert es mit PB-Funktionen nicht:

Code: Alles auswählen

FontID = FontID(LoadFont(#PB_Any, "Cambria", 16, #PB_Font_Bold|#PB_Font_HighQuality))

Window = OpenWindow(#PB_Any, 0, 0, 800, 600, "LOKLISTE", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)

Gadget = ScrollAreaGadget(#PB_Any, 0, 0, 800, 600, 700, 6000)
SetGadgetColor(Gadget, #PB_Gadget_BackColor, $a0a0a0)
For y = 0 To 6000 Step 30
  Gadget = TextGadget(#PB_Any, 5, y+5, 250, 24, "Nummer "+Str(y))
  SetGadgetFont(Gadget, FontID)
  SetGadgetColor(Gadget, #PB_Gadget_BackColor, $a0a0a0)
  SetGadgetColor(Gadget, #PB_Gadget_FrontColor, $000000)
Next y       

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: ScrollArea und Font-Attribute

Verfasst: 01.04.2011 21:26
von ozoffi
Hallo und danke. Ich werde es so probieren.

Re: ScrollArea und Font-Attribute

Verfasst: 03.04.2011 14:28
von ozoffi
Servus!
Ich wollte nur berichten, dass es definitv das Laden des Fonts IN der Schleife war und nicht der PureColor Befehl -> http://gnozal.ucoz.com/PureCOLOR.htm.

Code: Alles auswählen

 OpenWindow(#Window_1, 1, 1, 460, 550, "LOKLISTE", #PB_Window_WindowCentered | #PB_Window_Tool |#PB_Window_NoGadgets)
 SetWindowColor(#window_1,$f0f0f0)
 OldGadgetList = UseGadgetList(WindowID(#window_1)) 
 
 h=550 : w=460
 If id > 4 : H=1000 : w=443: EndIf
 If id > 8 : H=1500 : w=443: EndIf

ScrollAreaGadget(#scrollw_1, 0, 0, 460,550, w, h, 10,#PB_ScrollArea_BorderLess )
PureCOLOR_SetGadgetColor(#scrollw_1, $000000, $f0f0f0)

arial20=FontID(LoadFont(#PB_Any, "Arial", 20, #PB_Font_Bold|#PB_Font_HighQuality))
lcd=FontID(LoadFont(#PB_Any, "LcdD", 18, #PB_Font_Bold|#PB_Font_HighQuality))

 y=0
  For l = 1 To id
    name(l)=TextGadget(#PB_Any, 5, y+5, 250, 32, name$(l))
    adr(l)=TextGadget(#PB_Any, 260, y+5, 60, 25, adr$(l))
    If tnr$(l)<>"0" : t$="T" : EndIf
    If tnr$(l)="0" Or tnr$(l)=" ": t$=" " :tnr$(l)=" ": EndIf
    tnr(l)=TextGadget(#PB_Any, 5, y+90, 35, 40, tnr$(l), #PB_Text_Center)
    t(l)=TextGadget(#PB_Any, 5, y+55, 30, 35, t$, #PB_Text_Center)  

    LoadImage(l,dir$+"Lokbilder\"+lokimage$(l))
    image(l)=ImageGadget(#PB_Any, 45, y+20, 279, 93, ImageID(l))
   
    SetGadgetFont(adr(l), lcd)
    SetGadgetFont(tnr(l), arial20)
    SetGadgetFont(t(l), arial20)
    SetGadgetFont(name(l), arial20)   
    PureCOLOR_SetGadgetColor(name(l), $000000, $f0f0f0)
    PureCOLOR_SetGadgetColor(adr(l), $000000, $f0f0f0)
    PureCOLOR_SetGadgetColor(tnr(l), $000000, $f0f0f0)
    PureCOLOR_SetGadgetColor(t(l), $000000, $f0f0f0)
    y=y+120
    Next l
   
  UseGadgetList(OldGadgetList) 
  
Danke für den Hinweis - ich fürchte ich werde Euch noch das eine oder ander Mal belästigen ...


__________________________________________________
Tags geändert
Quote>Code
03.04.2011
RSBasic

Re: ScrollArea und Font-Attribute

Verfasst: 03.04.2011 17:03
von RSBasic
@ozoffi
Bitte benutze nicht die Quote-Tags, sondern die Code-Tags, wenn du einen Code veröffentlichen und nicht zitieren möchtest, danke.

Re: ScrollArea und Font-Attribute

Verfasst: 03.04.2011 18:11
von ozoffi
Sorry - wollte Euch nciht ärgern damit - werde es beherzigen.