Seite 1 von 1

Basiscode für einen Schiebeschalter Ein Aus

Verfasst: 13.12.2019 11:41
von hjbremer
Hallo

unter Windows 10 sieht man ab und zu einen Ein-Aus Schalter wo man einen Knopf hin und her schiebt

ich habe hier mal einen Startcode für so einen Button. sozusagen Beta 0.1

es fehlt :
senkrechte Ausführung
schöneres Design wie abgerundete Ecken, bessere Farben, ev. Beschriftung usw.
intelligente State Abfrage, momentan über GetGadgetData().
Schiebegeschwindigkeit bei schnellen und langsamen Rechnern. Delay() ?
bessere Eventverarbeitung
etc.

da Vectordrawing ab PB 5.42 sinnvoll

Ideen und Vorschläge willkommen !

Code: Alles auswählen

Global colorback
Global colorback_on = $ff000000+#Red
Global colorback_off = $ff000000+#Gray 

Global colorknop = $fffedcba

Global abstand = 3

Global knopdelay = 2

Procedure moveknop_Draw(pbnr, x)
   
   br = GadgetWidth(pbnr)
   hh = GadgetHeight(pbnr)  
   r  = (hh - 8) / 2  
   y  = r + 4   
   
   StartVectorDrawing(CanvasVectorOutput(pbnr))
      AddPathBox(0, 0, br, hh): VectorSourceColor(colorback): FillPath()         
      AddPathCircle(x, y, r): VectorSourceColor(colorknop): FillPath()         
   StopVectorDrawing()
   Delay(knopdelay)
   
EndProcedure

Procedure moveknop_Press(pbnr)
   
   state = GetGadgetData(pbnr) 
   
   If state = 0
      state = 1
   Else
      state = 0
   EndIf   
   
   br = GadgetWidth(pbnr)
   hh = GadgetHeight(pbnr)  
   r  = (hh - 8) / 2  
   y  = r + 4   
      
   von = abstand
   bis = br-r-r-abstand
   
   If state = 1
      x = r + abstand -1
      f = 1
   Else      
      x = br - r - abstand +1
      f = -1
   EndIf
   
   For j = von To bis 
      oldback = colorback
      If j = bis And state = 1
         colorback = colorback_on
      EndIf
      x + f
      moveknop_Draw(pbnr, x) 
      colorback = oldback
   Next
   
   SetGadgetData(pbnr, state)
   
EndProcedure

Procedure moveknop_Create(pbnr, x, y, br, hh, state)
   
   CanvasGadget(pbnr, x, y, br, hh)
   
   SetGadgetAttribute(pbnr, #PB_Canvas_Cursor, #PB_Cursor_Hand)
    
    r = (hh - 8) / 2

   If state = 0
      x = r + abstand
      colorback = colorback_off
   Else
      x = br - r - abstand
      colorback = colorback_on
   EndIf   
    
    moveknop_Draw(pbnr, x)    
    
    SetGadgetData(pbnr, state)
    
EndProcedure




If OpenWindow(0, 0, 0, 220, 220, "Canvas example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   
   moveknop_Create(1, 11, 11, 50, 30, 0)
   moveknop_Create(2, 11, 55, 30, 22, 1)
   
   moveknop_Create(3, 11, 90, 90, 50, 1)
   moveknop_Create(4, 11, 150, 90, 50, 0)
   
    
    Repeat
      Event = WaitWindowEvent()
    
      If Event = #PB_Event_Gadget
         
         Select EventGadget() 
               
          Case 1
             
             If EventType() = #PB_EventType_LeftButtonDown                 
                moveknop_Press(1)
             EndIf
     
          Case 2
             
             If EventType() = #PB_EventType_LeftButtonDown                 
                moveknop_Press(2)
             EndIf
     
         Case 3
             
             If EventType() = #PB_EventType_LeftButtonDown                 
                moveknop_Press(3)
             EndIf
     
         Case 4
             
             If EventType() = #PB_EventType_LeftButtonDown                 
                moveknop_Press(4)
             EndIf
     
        EndSelect
      EndIf
    
    Until Event = #PB_Event_CloseWindow
  EndIf

Re: Basiscode für einen Schiebeschalter Ein Aus

Verfasst: 14.12.2019 14:24
von Thorsten1867
Die Idee hat mir so gut gefallen, dass ich sie für meine Gadget-Sammlung übernommen habe:
https://www.purebasic.fr/english/viewto ... 27&t=74210

Re: Basiscode für einen Schiebeschalter Ein Aus - nun V.1.03

Verfasst: 22.12.2019 23:27
von hjbremer
aus dem Basiscode ist mehr geworden, viel mehr wie immer

Code: Alles auswählen

;- Ein-Ausschalter ab PB 5.42 (x86) (x64) für Windows. Linux und MacOs sollte auch gehen.

   ;HJBremer - 12.2019 V.1.03, geschrieben unter Windows 10 mit PB 5.70 LTS (x64) oder (x86)

   ;
   
;Moveknop(pbnr, x, y, width, height, state=0, pbcolor=$f0f0f0)
;     x, y, width, height: Gadgetposition und Größe
;     state: Schalterstellung bei Start, 0 = aus, 1 = ein
;     pbcolor: ParentBackColor ist bei Windows 10 Fenster + Container oft $f0f0f0, Panel = #white

;     wenn mit SetWindowColor() + SetGadgetColor() geändert, muß pbcolor angegeben werden.
;     PB hat keinen Befehl der dies erledigt. GetColor liefert erst wenn SetColor benutzt wurde.

;Moveknop_Value(pbnr, typ, wert)    Aussehen des Knop: Style oder Speed oder Farben einstellen
;     pbnr: Nummer um das Gadget zu identifizieren oder #PB_Default 
;     typ:  #knopstyle
;     wert: 0=normal, 1=Gradientfarbe mit einem Grauwert, 2=GradientColor mit 2 Grauwerten
;                       Gradientfarbe ist grau bis \colorknop
;
;     typ:  #speedloop + #speeddelay dient der Verzögerung um Bewegung zu simulieren
;     wert: für loop ca 10-50, für delay ca 0-10

;     typ:  #colorframe für Rahmen, wenn kein Rahmen gewünscht auf parentbackcolor setzen z.B. $F0F0F0
;     wert: RGB Farbwert

;     typ:  #colorring ist der äussere Rand des Knops
;     typ:  #colorback_on + #colorback_off ist Gadgetfarbe je für on/off
;     typ:  #colorknop_on + #colorknop_off ist Knopfarbe je für on/off
;     typ:  #colortext_on + #colortext_off ist Textfarbe je für on/off 

;     typ:  #showinfo zeigt Textrahmen + pbnr + state, aber nur wenn Text mit SetText zugewiesen wurde.

;Moveknop_Free(pbnr) gibt Structure-Memory frei, wichtig für temporäre Gadgets

;Moveknop_GetState(pbnr) Schalterstellung abfragen ergibt 0 oder 1

;Moveknop_SetState(pbnr, wert) Schalterstellung setzen wert ist 0 oder 1

;Moveknop_SetText(pbnr, text$, texthh, textpos=0) Text  + Textgröße setzen, Text im Knopf oder 
;     text$:   Text für Schalterstellung z.B. "0,1", "on,off"
;     texthh:  Schriftgröße siehe auch Hilfe VectorFont()
;     textpos: Textposition, 0 ist ausserhalb vom Knop, 1 ist im Knop

;Allgemein
;  #PB_Any ist bei Moveknop_Value() erlaubt. Ändert die Voreinstellung
;  #PB_Any ist bei Moveknop() erlaubt. Rückgabewert ist dann die PB Nr.

;  In der MainEventschleife muß immer EventType() abgefragt werden !!!

;  alle Farben sind RGB Werte in HEX, also BGR Reihenfolge. Alpha wird intern in Draw addiert.

DeclareModule MoveButton
   
   Declare.i Moveknop(pbnr, x, y, width, height, state=0, pbcolor=$f0f0f0)
   
   Declare.i Moveknop_Value(pbnr, typ, wert)
   Declare.i Moveknop_Free (pbnr)
   Declare.i Moveknop_GetState(pbnr)
   Declare.i Moveknop_SetState(pbnr, state)
   Declare.i Moveknop_SetText (pbnr, text$, texthh, textpos=0)
   
   Enumeration
      #showinfo
      #knopstyle
      #speedloop
      #speeddelay
      #colorframe
      #colorring
      #colorback_on
      #colorback_off
      #colorknop_on
      #colorknop_off
      #colortext_on
      #colortext_off 
      
   EndEnumeration
   
EndDeclareModule

Module MoveButton
   
   EnableExplicit
   
   ;- Structure
   
   Structure moveknop 
      
      pbnr.i
      width.d           ;Gadget breite/höhe
      height.d 
      
      xknop.d           ;x+y = posi vom knop
      yknop.d
      
      knopgap.d         ;Abstand Knopf von der Gadgetseite 
      framegap.d        ;Abstand Rahmen vom Gadget   
      
      knopsize.d        ;Knopf Durchmesser = 2 x Radius
      knopradius.d      ;vom Knopf
      frameradius.d     ;vom GadgetRahmen
      
      parentbackcolor.i ;ParentFenster Backcolor
      
      colorback.i       ;intern GadgetBackColor
      colorknop.i       ;intern KnopfColor innen
      colortext.i       ;intern Textcolor
      
      colorframe.i      ;Rahmenfarbe      
      colorring.i       ;KnopfColor aussen
      colorback_on.i    ;wenn eingeschaltet
      colorback_off.i   ;wenn aus   
      colorknop_on.i    ;wenn eingeschaltet
      colorknop_off.i   ;wenn aus      
      colortext_on.i    ;wenn eingeschaltet
      colortext_off.i   ;wenn aus 
      
      style.i        ;wenn 1, dann #colorknop_on _off definieren, wobei off dunkler sein muß. $FFDD00 $FF6600
      loop.i         ;anzahl Aufrufe zum Zeichnen für Bewegung vom Knop
      delay.i        ;zusätzliche Verzögerung beim zeichnen
      align.i        ;Ausrichtung vertikal / horizontal 
      state.i        ;off / on = 0 oder 1
      push.i
      
      info.i         ;zeigt Textrahmen etc
      texthh.i       ;Texthöhe siehe Moveknop_Text(pbnr, text$, texthh)
      textpos.i
      text.s         ;intern
      text_on.s      ;text$ für Moveknop_Text() = "on,off"
      text_off.s

   EndStructure
   
   ;- Default Color
   Global default_info = 0
   Global default_loop = 50
   Global default_delay = 2
   Global default_style = 0                  ;
   Global default_colorframe = #Gray 
   Global default_colorring  = #Yellow       ;knop aussen
   Global default_colorback_on  = $bababa    ;hellgrau
   Global default_colorback_off = $999999    ;dunkelgrau
   Global default_colorknop_on  = $11B5FF    ;orange
   Global default_colorknop_off = $666666    ;grau
   Global default_colortext_on  = #Red
   Global default_colortext_off = #Black
   
   Global default_font = LoadFont(#PB_Any, "Consolas", 10, #PB_Font_Bold)
   
   ;- intern   
   
   Procedure.i moveknop_DrawText(*mb.moveknop)
      Protected.d x, y, textboxbr, textboxhh
         
      With *mb         
         VectorFont(FontID(default_font), \texthh)
  
         If \state
            \text = \text_on: \colortext = \colortext_on
         Else
            \text = \text_off: \colortext = \colortext_off
         EndIf
  
         If \align ;Gadget senkrecht            
            textboxbr = \height - (\knopgap*2)
            textboxhh = VectorParagraphHeight(\text, textboxbr, \height)
            
            RotateCoordinates(\xknop, \yknop, 90)  ;Text um Knop-Mittelpunkt drehen
            
            If \textpos ;im Knop
               x = \xknop - textboxbr/2
               y = \yknop - textboxhh/2
               
            Else        ;ausserhalb vom Knop
               x = \xknop - \knopradius
               If \state
                  y = \yknop + \knopradius + \knopgap    ;Text unter dem Knop
               Else
                  y = \yknop - \knopradius - textboxhh - \knopgap    ;Text über dem Knop
               EndIf
            EndIf
    
         Else     ;Gadget waagerecht            
            textboxbr = \width - \knopsize - (\knopgap*3)  
            textboxhh = VectorParagraphHeight(\text, textboxbr, \height)
            
            y = \yknop - textboxhh/2
            If \textpos ;im Knop
               x = \xknop - textboxbr/2
            Else        ;ausserhalb vom Knop
               If \state
                  x = \xknop - \knopradius - \knopgap - textboxbr
               Else
                  x = \xknop + \knopradius + \knopgap
               EndIf
            EndIf
         EndIf
         
         VectorSourceColor($FF000000 | \colortext)
         
         MovePathCursor(x, y) ;DrawVectorParagraph bietet oft bessere Schrift
         DrawVectorParagraph(\text, textboxbr, textboxhh, #PB_VectorParagraph_Center)

         ;Test
         If \info
            VectorSourceColor($FF000000 | #Blue)
            AddPathBox(x, y, textboxbr, textboxhh) : StrokePath(1)            
            ResetCoordinates()
            MovePathCursor(6, 0)
            DrawVectorParagraph(Str(\pbnr) + "-" + Str(\state), textboxbr+5, textboxhh)
         EndIf
         
      EndWith
      
   EndProcedure
 
   Procedure.i moveknop_DrawButton(*mb.moveknop)
      
      Protected j, a = $FF000000   ;Alphawert wird Bitweise OR Color
      
      With *mb
         
         StartVectorDrawing(CanvasVectorOutput(\pbnr))
            
            If \align   ;Senkrecht
               TranslateCoordinates(0, \width): RotateCoordinates(0, 0, 270)     
            EndIf
            
            ;Canvas komplett füllen bzw löschen mit \parentbackcolor
            AddPathBox(0, 0, \width, \height) : VectorSourceColor(a | \parentbackcolor): FillPath()
            
            ;knop Background malen mit Rahmen + runden Ecken
            Protected g = \framegap            ;abstand Rahmen vom CanvasGadget
            Protected h = \height-g-g
            Protected w = \width-g-g
            Protected r = \frameradius
            
            MovePathCursor(g+r, g)     
            
            ;Hilfe + Beispiel für AddPathArc() ist Grrrr...
            AddPathArc(w-r , 0   , w-r  , r   , r, #PB_Path_Relative)    ;oben
            AddPathArc(0   , h-r , -r   , h-r , r, #PB_Path_Relative)    ;rechts
            AddPathArc(-w+r, 0   , -w+r , -r  , r, #PB_Path_Relative)    ;unten
            AddPathArc(0   , -h+r, r    , -h+r, r, #PB_Path_Relative)    ;links
            
            VectorSourceColor(a | \colorframe)   ;Rahmenfarbe
            StrokePath(3, #PB_Path_Preserve)     ;Dicke 3 oder so, Path bleibt offen für FillPath()
            
            VectorSourceColor(a | \colorback)
            FillPath()
            
            ;knop malen
            AddPathCircle(\xknop, \yknop, \knopradius):   VectorSourceColor(a | \colorring): FillPath() 
            
            If \style = 0
               AddPathCircle(\xknop, \yknop, \knopradius-2): VectorSourceColor(a | #Gray): FillPath() 
               AddPathCircle(\xknop, \yknop, \knopradius-3): VectorSourceColor(a | \colorknop): FillPath() 
            Else               
               VectorSourceCircularGradient(\xknop, \yknop, \knopradius-2)               
               VectorSourceGradientColor($FFe6e6e6, 0.0)
               If \style = 2
                  VectorSourceGradientColor($FF888888, 0.8) 
               EndIf
               VectorSourceGradientColor(a | \colorknop, 1.0)               
               FillVectorOutput()               
               ;damit es schöner aussieht
               AddPathCircle(\xknop, \yknop, \knopradius-2): VectorSourceColor(a | \colorknop): StrokePath(1)               
            EndIf
            
            ;Text
            If \texthh : moveknop_DrawText(*mb) : EndIf
            
         StopVectorDrawing()
         Delay(\delay)
         
      EndWith
      
   EndProcedure
   
   Procedure.i moveknop_Press(*mb.moveknop)      
      Protected j, add.d
      
      With *mb
         
         If \state = 0
            \state = 1
            \xknop = \knopradius + \knopgap         
         Else
            \state = 0
            \xknop = \width - \knopradius - \knopgap          
         EndIf   
         
         add = ( \width - \xknop - \xknop) / \loop
         
         ;zeichnet knop mehrmals um Bewegung zu simulieren
         For j = 1 To \loop
            If \state = 1
               If j > \loop/2
                  \colorback = \colorback_on
                  \colorknop = \colorknop_on
                  \colortext = \colortext_on
               EndIf 
            Else
               \colorback = \colorback_off 
               \colorknop = \colorknop_off
               \colortext = \colortext_off
            EndIf
            \xknop + add   
            moveknop_DrawButton(*mb) ;: Debug \xknop
         Next
         
      EndWith
      
   EndProcedure
   
   Procedure.i moveknop_Event()      
      
      Protected *mb.moveknop = GetGadgetData(EventGadget())
      
      If EventType() = #PB_EventType_LeftButtonDown   ;Schalter
         moveknop_Press(*mb)
         
      ElseIf EventType() = #PB_EventType_LeftButtonUp ;Taster = normaler Button
         
         If *mb\push = 1 And *mb\state = 1
            moveknop_Press(*mb)            
         EndIf
         
      EndIf
      
   EndProcedure
   
   Procedure.i moveknop_Check(pbnr)     
      Protected error, text$
      
      If IsGadget(pbnr) = 0
         error = 1: text$ = "unbekannte Gadgetnr: " + pbnr
         
      ElseIf GadgetType(pbnr) <> #PB_GadgetType_Canvas
         error = 2: text$ = "kein CanvasGadget: " + pbnr
         
      ElseIf GetGadgetData(pbnr) = 0
         error = 3: text$ = "kein MoveButton: " + pbnr
      EndIf
      
      If error: MessageRequester("Fehler", text$) : End : EndIf

      ProcedureReturn GetGadgetData(pbnr)      
   EndProcedure
   
   ;- extern 
   
   Procedure.i Moveknop_Value(pbnr, typ, wert)
      
      If pbnr = #PB_Default
         Select typ
            Case #showinfo: default_info = wert 
            Case #knopstyle: default_style = wert
            Case #speedloop: default_loop  = wert
            Case #speeddelay: default_delay = wert               
            Case #colorframe: default_colorframe = wert
            Case #colorring : default_colorring  = wert                  
            Case #colorback_on : default_colorback_on  = wert                  
            Case #colorback_off: default_colorback_off = wert
            Case #colorknop_on : default_colorknop_on  = wert
            Case #colorknop_off: default_colorknop_off = wert 
            Case #colortext_on : default_colortext_on  = wert 
            Case #colortext_off: default_colortext_off = wert     
         EndSelect
         
      Else
         
         Protected *mb.moveknop = moveknop_Check(pbnr)
         
         With *mb            
            Select typ
                  
               Case #showinfo: \info = wert
                  
               Case #speedloop : \loop  = wert
               Case #speeddelay: \delay = wert
                  
               Case #knopstyle : \style = wert
               Case #colorframe: \colorframe = wert
               Case #colorring : \colorring  = wert
                  
               Case #colorback_on
                  \colorback_on = wert :  If \state = 1 : \colorback = wert : EndIf  ;nur wenn on
                  
               Case #colorback_off
                  \colorback_off = wert : If \state = 0 : \colorback = wert : EndIf  ;nur wenn off
                  
               Case #colorknop_on
                  \colorknop_on = wert :  If \state = 1 : \colorknop = wert : EndIf
                  
               Case #colorknop_off
                  \colorknop_off = wert : If \state = 0 : \colorknop = wert : EndIf
                  
               Case #colortext_on
                  \colortext_on = wert :  If \state = 1 : \colortext = wert : EndIf
                  
               Case #colortext_off
                  \colortext_off = wert : If \state = 0 : \colortext = wert : EndIf
                  
            EndSelect
            
            moveknop_DrawButton(*mb)
            
         EndWith
      EndIf   
      
   EndProcedure
   
   Procedure.i Moveknop_Free(pbnr)
      Protected *mb.moveknop = moveknop_Check(pbnr)
      FreeStructure(*mb)
      FreeGadget(pbnr)
   EndProcedure
   
   Procedure.i Moveknop_GetState(pbnr)
      Protected *mb.moveknop = moveknop_Check(pbnr)
      ProcedureReturn *mb\state
   EndProcedure
   
   Procedure.i Moveknop_SetState(pbnr, state)
      Protected *mb.moveknop = moveknop_Check(pbnr)
      If *mb\state <> state
         PostEvent(#PB_Event_Gadget, EventWindow(), pbnr, #PB_EventType_LeftButtonDown)
      EndIf
   EndProcedure
   
   Procedure.i Moveknop_SetText(pbnr, text$, texthh, textpos=0)
      Protected *mb.moveknop = moveknop_Check(pbnr)
      *mb\texthh = texthh
      *mb\textpos = textpos
      *mb\text_on = StringField(text$, 1, ",")
      *mb\text_off = StringField(text$, 2, ",") 
      moveknop_DrawButton(*mb)  
   EndProcedure
   
   Procedure.i Moveknop(pbnr, x, y, width, height, state=0, pbcolor=$f0f0f0)
      
      Protected id, *mb.moveknop = AllocateStructure(moveknop)
      
      id = CanvasGadget(pbnr, x, y, width, height)   
      If pbnr = #PB_Any : pbnr = id : EndIf       
      
      With *mb
         
         If width > height
            \align = 0        ;knop waagerecht      
            \width = width
            \height = height
         Else
            \align = 1        ;knop senkrecht
            \width = height      
            \height = width      
         EndIf
         
         \pbnr = pbnr      
         \state = state                ;on/off = 0 oder 1 
         If state = 2
            \state = 0 : \push = 1
         EndIf
         
         \parentbackcolor = pbcolor    ;Windows 10 + Container = f0f0f0, Panel = #white
         
         \info       = default_info             ;Textrahmen + pbnr + state anzeigen
         \colorframe = default_colorframe       ;Rahmen
         \colorring  = default_colorring        ;knop aussen
         \colorknop_on  = default_colorknop_on  ;Farben
         \colorknop_off = default_colorknop_off         
         \colorback_on  = default_colorback_on
         \colorback_off = default_colorback_off
         \colortext_on  = default_colortext_on
         \colortext_off = default_colortext_off
         
         \loop = default_loop    ;Anzahl Aufrufe von StartDawing() für Bewegung vom Knop
         \delay = default_delay  ;zusätzliche Verzögerung, für loop ab 10, delay ca 2
         \style = default_style  ;
         
         \framegap = 2           ; Abstand Rahmen vom CanvasGadget
         \frameradius = 10       ; Rundung Rahmen
         
         \knopgap = 6                  ; Abstand Knop vonn CanvasGadgetrand
         \knopsize = \height - 12      ; Knopdurchmesser = minus 2 x Gap
         \knopradius = \knopsize / 2   ; KnopRadius
         \yknop = \height /2           ; Mittelpunkt des Kreises     
         
         If \state = 0 ;Aus 
            \xknop = \knopradius + \knopgap
            \colorback = \colorback_off
            \colorknop = \colorknop_off 
         Else
            \xknop = \width - \knopradius - \knopgap
            \colorback = \colorback_on
            \colorknop = \colorknop_on  
         EndIf   
         
      EndWith
      
      SetGadgetData(pbnr, *mb)      
      SetGadgetAttribute(pbnr, #PB_Canvas_Cursor, #PB_Cursor_Hand)   
      BindGadgetEvent(pbnr, @moveknop_Event(), #PB_EventType_LeftButtonDown)
      BindGadgetEvent(pbnr, @moveknop_Event(), #PB_EventType_LeftButtonUp)
      
      moveknop_DrawButton(*mb)  
      
      ProcedureReturn id      
   EndProcedure
   
EndModule

UseModule MoveButton

CompilerIf #PB_Compiler_IsMainFile    
   
   Enumeration      
      #moveknop1 = 1
      #moveknop2
      #moveknop3
      #moveknop4
      #moveknop10 = 10
      #moveknop11
      #moveknop12
      #moveknop13
      #moveknop20 = 20
      #moveknop21
      
      #container
      #panel
      #text
      
   EndEnumeration
   
   ;- Main   
   
   Define event, nr, winflags = #PB_Window_Invisible|#PB_Window_SystemMenu|#PB_Window_ScreenCentered
   
   If OpenWindow(0, 0, 0, 520, 480, "Moveknop example", winflags)
      
      Moveknop_Value(#PB_Default, #showinfo, 0)
      
      Moveknop_Value(#PB_Default, #colorframe, #Black)
      
      Moveknop(#moveknop1, 11, 11, 60, 32)   
      Moveknop(#moveknop2, 11, 75, 60, 100, 1)   
      Moveknop(#moveknop3, 88, 75, 170, 70, 1)
      Moveknop(#moveknop4, 300, 80, 50, 50, 2)
      
      Moveknop_Value(#moveknop2, #knopstyle, 1)
      Moveknop_Value(#moveknop3, #knopstyle, 1)
      Moveknop_Value(#moveknop4, #knopstyle, 2)
    
      Moveknop_Value(#moveknop4, #colorring, $5C5C5C)
      Moveknop_Value(#moveknop4, #colorknop_on, #Red)
      Moveknop_Value(#moveknop4, #colorknop_off, #Gray)
      
      Moveknop_SetText(#moveknop1, "on,off", 12)
      Moveknop_SetText(#moveknop2, "on,off", 18, 1)
      Moveknop_SetText(#moveknop3, "Heizung ein,Ofen aus", 18)
      
      
      ContainerGadget(#container, 10, 222, 222, 222, #PB_Container_Flat)      
         Moveknop(#moveknop10, 10, 15, 100, 60)    
         Moveknop_Value(#moveknop10, #knopstyle, 2)
         Moveknop_Value(#moveknop10, #colorring, $5C5C5C)
         Moveknop_Value(#moveknop10, #colorknop_on, #Green)
         Moveknop_Value(#moveknop10, #colorknop_off, #Red)
         
         Moveknop_SetText(#moveknop10, "on,off", 14, 1)
         
         Moveknop(#moveknop11, 120, 15, 60, 100, 1)    
         Moveknop_SetText(#moveknop11, "on,off", 14, 1)
         
         Moveknop(#moveknop12, 10, 90, 60, 100, 1)    
         Moveknop_SetText(#moveknop12, "ein,aus", 14, 0)
         
         Moveknop(#moveknop13, 80, 130, 110, 60, 1)    
         Moveknop_SetText(#moveknop13, "Open,Close", 15, 0)
         
      CloseGadgetList()
      
      PanelGadget(#panel, 240, 222, 222, 222)      
         AddGadgetItem (#panel, -1, "Panel 1")
         Moveknop(#moveknop20, 10, 15, 36, 60, 1, #White)
         Moveknop_SetText(#moveknop20, "on,off", 12)
         
         AddGadgetItem (#panel, -1, "Panel 2")
         TextGadget(#text, 2, 2, 230, 192, "")
         SetGadgetColor(#text, #PB_Gadget_BackColor, #Green)     
         Moveknop(#moveknop21, 10, 15, 48, 100, 0, #Green)
      CloseGadgetList()
      
      HideWindow(0, 0)
      
      ;- Repeat
      
      Repeat
         Event = WaitWindowEvent()
         
         If Event = #PB_Event_Gadget
            
            Select EventGadget() 
                  
               Case #moveknop1               
                  If EventType() = #PB_EventType_LeftButtonDown 
                     ;diese EventType() Abfrage muß sein !!!!
                     
                     If Moveknop_GetState(#moveknop1)
                        Moveknop_Value(#moveknop3, #colorframe, #Black)
                        Moveknop_Value(#moveknop3, #colorback_on, #Green)
                        Moveknop_Value(#moveknop3, #colorback_off, #Magenta)
                        Moveknop_Value(#moveknop3, #colortext_off, #Black)
                        Moveknop_Value(#moveknop3, #colortext_on, #Blue)
                        
                        Moveknop_Value(#moveknop3, #speedloop, 25)
                        
                        Moveknop_Value(#moveknop10, #colorring, $654321)
                        Moveknop_Value(#moveknop10, #colorknop_on, #Yellow)
                        Moveknop_Value(#moveknop10, #colorknop_off, #Red)
                        Moveknop_Value(#moveknop10, #colorback_on, $11B5FF)
                        Moveknop_Value(#moveknop10, #colorframe, $444444)
                        

                     EndIf
                     
                  EndIf
                  
               Case #moveknop2               
                  If EventType() = #PB_EventType_LeftButtonDown                 
                     Moveknop_SetText(#moveknop3, "Heizung läuft,Heizung aus", 18)
                  EndIf
                  
               Case #moveknop4               
                  If EventType() = #PB_EventType_LeftButtonDown                 
                     Moveknop_SetText(#moveknop3, "Wasser läuft,Ofen aus", 18)
                     Moveknop_SetState(#moveknop3, 0)
                  EndIf
                  

                  
            EndSelect
         EndIf
         
      Until Event = #PB_Event_CloseWindow
   EndIf
   
CompilerEndIf