Aktuelle Zeit: 22.02.2020 08:45

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]




Ein neues Thema erstellen Auf das Thema antworten  [ 15 Beiträge ]  Gehe zu Seite 1, 2  Nächste
Autor Nachricht
 Betreff des Beitrags: MODULE Colorful Progressbar [ALL OS!]
BeitragVerfasst: 08.07.2017 19:05 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
Progressbar module :)

Bild

Update (alpha 4):
- Callbacks verbessert
- Drawing Beispiel geändert

Module:
Code:
;By Mijikai
;PBAR (Progressbar) module
;Version: alpha 4
;Tested on Win10 x64
;PB v.5.60


DeclareModule PBAR
 
  Structure PBAR_DRAW_STRUCT
    Type.b
    State.i
    Percent.i
    Width.i
    Height.i
    Offset.i
    BackColor.l
    FrontColor.l
    FxColor.l
    Custom.i
  EndStructure
 
  Declare.i Create(X.i,Y.i,Width.i,Height.i,Minimal.i,Maximal.i,BackColor.l,FrontColor.l,FxColor.l,Vertical.b)
  Declare.i Set(Gadget.i,State.i)
  Declare.i Get(Gadget.i)
  Declare.i Percent(Gadget.i)
  Declare.i SetColor(Gadget.i,Color.l,Flag.b)
  Declare.i SetColors(Gadget.i,BackColor.l,FrontColor.l,FxColor.l)
  Declare.i SetStateCallback(Gadget.i,Function.i,State.i,Custom.i)
  Declare.i SetDrawCallback(Gadget.i,Function.i,Custom.i)
  Declare.i Free(Gadget.i)
EndDeclareModule

Module PBAR

  Structure PBAR_STRUCT
    Minimal.i
    Maximal.i
    Tick.f
    Factor.f
    Percent.i
    State.i
    Drawing.PBAR_DRAW_STRUCT
    CallbackDraw.i
    CallbackState.i
    CallState.i
    Custom.i
  EndStructure
 
  #PBAR_GRADIENT_FACTOR = 0.8
  #PBAR_BORDER_COLOR = $808080
 
  Prototype.i PBAR_CALLBACK_DRAW(Gadget.i,*Drawing.PBAR_DRAW_STRUCT)
 
  Prototype.i PBAR_CALLBACK_STATE(Gadget.i,State.i,Percent,Custom.i)
 
  Procedure.i Percent(Gadget.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx
      ProcedureReturn *ProgressBarEx\Percent
    EndIf
  EndProcedure
 
  Procedure.i Get(Gadget.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx
      ProcedureReturn *ProgressBarEx\State
    EndIf
  EndProcedure
 
  Procedure.i Set(Gadget.i,State.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    Protected BackState.i
    Protected *CallDraw.PBAR_CALLBACK_DRAW
    Protected *CallState.PBAR_CALLBACK_STATE
    If State > -1 And *ProgressBarEx
      With *ProgressBarEx
        If \Maximal < State
          State = \Maximal
        EndIf
        BackState = State
        If \Minimal
          If State > \Minimal
            State - \Minimal
          Else
            State = #Null
          EndIf
        EndIf
        If StartDrawing(CanvasOutput(Gadget))
          \Percent = \Factor * State
          \Drawing\Offset = \Tick * State
          DrawingMode(#PB_2DDrawing_Default)
          Box(#Null,#Null,GadgetWidth(Gadget),GadgetHeight(Gadget),\Drawing\BackColor)
          If \CallbackDraw
            *CallDraw = \CallbackDraw
            \Drawing\State = BackState
            \Drawing\Percent = \Percent
            *CallDraw(Gadget,@\Drawing)
          Else
            DrawingMode(#PB_2DDrawing_Gradient)
            FrontColor(\Drawing\FrontColor)
            BackColor(\Drawing\FxColor)
            If \Drawing\Type
              LinearGradient(\Drawing\Width/#PBAR_GRADIENT_FACTOR,\Drawing\Offset,#Null,\Drawing\Offset)   
              Box(#Null,#Null,\Drawing\Width,\Drawing\Offset,\Drawing\FrontColor)
            Else
              LinearGradient(\Drawing\Offset,\Drawing\Height/#PBAR_GRADIENT_FACTOR,\Drawing\Offset,#Null)   
              Box(#Null,#Null,\Drawing\Offset,\Drawing\Height,\Drawing\FrontColor)
            EndIf
          EndIf
          DrawingMode(#PB_2DDrawing_Outlined)
          Box(#Null,#Null,GadgetWidth(Gadget),GadgetHeight(Gadget),#PBAR_BORDER_COLOR)
          StopDrawing()
          \State = BackState
          If \CallbackState
            If \State = \CallState
              *CallState = \CallbackState
              If *CallState(Gadget,\State,Percent,\Custom)
                \CallbackState = #Null
              EndIf
            EndIf
          EndIf
          ResizeGadget(Gadget,#PB_Ignore,#PB_Ignore,#PB_Ignore,#PB_Ignore)
          ProcedureReturn #True
        EndIf
      EndWith
    EndIf
  EndProcedure
 
  Procedure.i Create(X.i,Y.i,Width.i,Height.i,Minimal.i,Maximal.i,BackColor.l,FrontColor.l,FxColor.l,Vertical.b)
    Protected *ProgressBarEx.PBAR_STRUCT
    Protected Gadget.i
    If Minimal > -1 And Minimal < Maximal
      *ProgressBarEx = AllocateMemory(SizeOf(PBAR_STRUCT))
      If *ProgressBarEx
        With *ProgressBarEx
          \Drawing\BackColor = BackColor
          \Drawing\FrontColor = FrontColor
          \Drawing\FxColor = FxColor
          Gadget = CanvasGadget(#PB_Any,X,Y,Width,Height)
          If Gadget
            \Drawing\Type = Vertical
            \Minimal = Minimal
            \Maximal = Maximal
            \Factor = \Maximal - \Minimal
            If Vertical
              \Tick = Height / \Factor
            Else
              \Tick = Width / \Factor
            EndIf
            \Factor = 100 / \Factor
            \Drawing\Width = Width
            \Drawing\Height = Height
            SetGadgetData(Gadget,*ProgressBarEx)
            If Set(Gadget,0)
              ProcedureReturn Gadget
            EndIf
            FreeGadget(Gadget)
          EndIf
        EndWith
        FreeMemory(*ProgressBarEx)
      EndIf
    EndIf
  EndProcedure
 
  Procedure.i Free(Gadget.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx
      FreeMemory(*ProgressBarEx)
    EndIf
    FreeGadget(Gadget)
  EndProcedure
 
  Procedure.i SetColors(Gadget.i,BackColor.l,FrontColor.l,FxColor.l)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx
      With *ProgressBarEx
        \Drawing\BackColor = BackColor
        \Drawing\FrontColor = FrontColor
        \Drawing\FxColor = FxColor
        Set(Gadget,\State)
      EndWith
    EndIf
  EndProcedure
 
  Procedure.i SetColor(Gadget.i,Color.l,Flag.b)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx
      With *ProgressBarEx
        Select Flag
          Case 1:\Drawing\FrontColor = Color
          Case 2:\Drawing\FxColor = Color
          Default:\Drawing\BackColor = Color
        EndSelect
        Set(Gadget,\State)
      EndWith
    EndIf
  EndProcedure
 
  Procedure.i SetStateCallback(Gadget.i,Function.i,State.i,Custom.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx And Function
      *ProgressBarEx\CallbackState = Function
      *ProgressBarEx\CallState = State
      *ProgressBarEx\Custom = Custom
      ProcedureReturn #True
    EndIf
  EndProcedure
 
  Procedure.i SetDrawCallback(Gadget.i,Function.i,Custom.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx And Function
      *ProgressBarEx\CallbackDraw = Function
      *ProgressBarEx\Drawing\Custom = Custom
      ProcedureReturn #True
    EndIf
  EndProcedure
 
EndModule


Beispiel:
Code:
Procedure.i PBAR_State(Gadget.i,State.i,Percent.i,Custom.i)
  MessageRequester("CallbackState!","State: " + Str(State))
  ProcedureReturn #True;#True -> Callback gets only called once!
EndProcedure

Procedure.i PBAR_Draw(Gadget.i,*Drawing.PBAR::PBAR_DRAW_STRUCT)
  Protected Offset.i, Count.i
  For Offset = 0 To *Drawing\Offset - 1
    If Count = ImageWidth(*Drawing\Custom) - 1
      Count = 0
    EndIf
    Count + 1
    If GrabImage(*Drawing\Custom,66,Count,0,1,ImageHeight(*Drawing\Custom))
      DrawAlphaImage(ImageID(66),Offset,-5)
      FreeImage(66)
    EndIf
  Next
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(150,2, Str(*Drawing\Percent) + "%")
  ;*Drawing\Offset -> progress relative to the progressbar size (width or height see *Drawing\Type)
  ;*Drawing\Type -> 0 = horizontal / 1 = vertical
EndProcedure

UsePNGImageDecoder()

If OpenWindow(0,0,0,300,250,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  Bar1 = PBAR::Create(10,10,20,200,50,150,#Gray,#Green,#White,#True)
  Bar2 = PBAR::Create(40,40,200,20,0,200,$58260E,$C9A239,$C9FB00,#False)
  Bar3 = PBAR::Create(40,100,200,30,0,100,$58260D,$CB7448,$FFF7C0,#False)
  AddWindowTimer(0,0,10)
  Tile = CatchImage(#PB_Any,?BarTile)
  If Bar1 And Bar2 And Bar3 And Tile: i = 50 
    PBAR::SetStateCallback(Bar1,@PBAR_State(),100,#Null)
    PBAR::SetDrawCallback(Bar2,@PBAR_Draw(),Tile)
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_Timer
          If PBAR::Get(Bar1) > 100
            i = 50
          EndIf
          i + 1
          SetWindowTitle(0,"Bar1: " + Str(PBAR::Percent(Bar1)) + "% - Bar2: " + Str(PBAR::Percent(Bar2)) + "%")
          PBAR::Set(Bar1,i)
          PBAR::Set(Bar2,i)
          PBAR::Set(Bar3,100 - i)
          If Mod(i,10)
            PBAR::SetColor(Bar3,RGB(i * 5,0,100),0)
          EndIf
        Case #PB_Event_CloseWindow
          Break
      EndSelect
    ForEver
    PBAR::Free(Bar1)
    PBAR::Free(Bar2)
    PBAR::Free(Bar3)
  EndIf
EndIf

DataSection
  BarTile:
  ;{File: BarTile.png - Size: 4196 Bytes
  !dw 05089h, 0474Eh, 00A0Dh, 00A1Ah, 00000h, 00D00h, 04849h, 05244h, 00000h, 02000h, 00000h, 02000h, 00608h, 00000h, 07300h, 07A7Ah
  !dw 000F4h, 01000h, 0492Bh, 04144h, 05854h, 001C3h, 01020h, 0EFDFh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00002h, 0EFB5h, 0FFEEh
  !dw 09B6Ah, 000FFh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh, 0EFB5h, 0FFEEh
  !dw 09B6Ah, 000FFh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 002FFh, 0E000h, 01275h
  !dw 0B500h, 0EEEFh, 06AFFh, 0FF9Bh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00000h, 00000h
  !dw 0B500h, 0EEEFh, 06AFFh, 0FF9Bh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00002h, 08B20h
  !dw 000EEh, 075E0h, 00012h, 0EFB5h, 0FFEEh, 09B6Ah, 000FFh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 00000h, 00000h, 0114Bh
  !dw 00012h, 00000h, 00000h, 0EFB5h, 0FFEEh, 09B6Ah, 000FFh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 075E0h, 00212h, 00000h
  !dw 00000h, 02000h, 0EE8Bh, 0E000h, 01275h, 0B500h, 0EEEFh, 06AFFh, 0FF9Bh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00000h, 00000h, 04B00h, 01211h, 09601h
  !dw 00165h, 04B00h, 01211h, 00000h, 00000h, 0B500h, 0EEEFh, 06AFFh, 0FF9Bh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 0E000h, 01275h, 02000h, 0EE8Bh, 00002h
  !dw 0114Bh, 00012h, 00000h, 00000h, 08B20h, 000EEh, 075E0h, 00012h, 0EFB5h, 0FFEEh, 09B6Ah, 000FFh, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 00000h, 00000h, 0114Bh, 00112h, 06596h, 00001h
  !dw 00000h, 00100h, 06596h, 00001h, 0114Bh, 00012h, 00000h, 00000h, 0EFB5h, 0FFEEh, 09B6Ah, 000FFh, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 075E0h, 00012h, 08B20h, 000EEh, 00000h, 00100h
  !dw 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00000h, 00000h, 0E000h, 01275h, 02000h, 0EE8Bh, 04B00h, 01211h, 09601h, 00165h
  !dw 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00000h, 00000h, 04B00h, 01211h, 09601h, 00165h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00000h, 00000h, 04B00h, 01211h, 09601h, 00165h
  !dw 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 0E000h, 01275h, 02000h, 0EE8Bh, 00000h, 00000h, 04B00h, 01211h
  !dw 00001h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 00000h, 00000h, 075E0h, 00012h, 08B20h, 000EEh, 0114Bh
  !dw 00112h, 06596h, 0FF01h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 00000h, 00000h, 0114Bh, 00112h, 06596h, 00001h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 00000h, 00000h, 0114Bh
  !dw 00112h, 06596h, 0FF01h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 075E0h, 00012h, 08B20h, 000EEh, 00000h, 00000h, 0114Bh, 00112h, 06596h
  !dw 00101h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00000h, 00000h, 0E000h, 01275h, 02000h
  !dw 0EE8Bh, 04B00h, 01211h, 0B500h, 0EEEFh, 00000h, 00000h, 04B00h, 01211h, 09601h, 00165h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00000h
  !dw 00000h, 04B00h, 01211h, 0B500h, 0EEEFh, 0E000h, 01275h, 02000h, 0EE8Bh, 00000h, 00000h, 04B00h, 01211h, 09601h, 00165h, 00000h
  !dw 00000h, 00001h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh, 0EFB5h, 000EEh, 00000h, 00000h
  !dw 075E0h, 00012h, 08B20h, 000EEh, 00000h, 00000h, 0114Bh, 00112h, 06596h, 00001h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah, 000FFh
  !dw 0EFB5h, 000EEh, 00000h, 00000h, 075E0h, 00012h, 08B20h, 000EEh, 00000h, 00000h, 0114Bh, 00112h, 06596h, 00001h, 00000h, 00000h
  !dw 00000h, 00100h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 0B500h, 0EEEFh
  !dw 00000h, 00000h, 00000h, 00000h, 04B00h, 01211h, 09601h, 00165h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 06AFFh, 0FF9Bh, 0B500h, 0EEEFh, 00000h, 00000h, 00000h, 00000h, 04B00h, 01211h, 09601h, 00165h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 0FF00h, 09B6Ah
  !dw 0FFFFh, 08A1Fh, 0FFEDh, 09B6Ah, 000FFh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 0FF00h, 09B6Ah, 0FFFFh, 08A1Fh, 0FFEDh, 09B6Ah, 000FFh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 06AFFh, 0FF9Bh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 06AFFh, 0FF9Bh, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h
  !dw 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 00000h, 05692h, 03D1Eh, 00868h, 085BCh, 00000h, 00000h, 04549h, 0444Eh
  !dw 042AEh, 08260h
  ;}
EndDataSection

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Zuletzt geändert von Mijikai am 03.08.2017 12:11, insgesamt 19-mal geändert.

Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 08.07.2017 19:29 
Offline
Benutzeravatar

Registriert: 08.09.2004 00:57
Wohnort: Berlin
:allright:

Läuft auch unter Linux, wenn man die Zeile mit "InvalidateRgn_" auskommentiert. Ausserdem ist im Beispiel die MessageBox_ API gegen die
native Funktion: MessageRequester auszutauschen.

Das Beispiel mit Delay finde ich nicht so berauschend, aber das ist ja nicht entscheidend :wink:

Gruß
Thomas

_________________
PureBasic 5.71 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 19.3 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 08.07.2017 19:49 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
Danke fürs testen :)
Bekommt das Fenster unter Linux trotz WaitWindowEvent() (ohne Fokus und InvalidateRgn_() Ersatz) ein Repaint-Event?
Vielleicht gibt es auch eine allgemeine native Lösung dafür.

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 08.07.2017 21:48 
Offline
Benutzeravatar

Registriert: 08.09.2004 00:57
Wohnort: Berlin
Noch nicht perfekt, aber läuft schon mal:
Code:
;By Mijikai
;PBAR (Progressbar) module
;Version: alpha
;Tested on Win10 x64
;PB v.5.60

DeclareModule PBAR
  EnableExplicit
 
  Declare.i Create(X.i,Y.i,Width.i,Height.i,Minimal.i,Maximal.i,BackColor.l,FrontColor.l,FxColor.l,Vertical.b);Vertical True/False
  Declare.i Set(Gadget.i,State.i)                                                                             ;Set State
  Declare.i Get(Gadget.i)                                                                                     ;Get State
  Declare.i SetColors(Gadget.i,BackColor.l,FrontColor.l,FxColor.l)
  Declare.i SetColor(Gadget.i,Color.l,Flag.b);Flag: 1 = FrontColor/ 2 = FxColor/ else = BackColor
  Declare.i SetCallback(Gadget.i,State.i,Function.i);Call Function if (Progressbar) State = x
  Declare.i Free(Gadget.i)
EndDeclareModule

Module PBAR
  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    ImportC ""
      gtk_widget_get_window(*widget.GtkWidget)
    EndImport
  CompilerEndIf
 
  Structure PBAR_STRUCT
    Type.b
    Minimal.i
    Maximal.i
    Tick.f
    State.i
    BackColor.l
    FrontColor.l
    FxColor.l
    Image.i
    Callback.i
    CallBackState.i
  EndStructure
 
  Prototype.i PBAR_CALLBACK(Gadget.i)
 
  Procedure.i Set(Gadget.i,State.i)
    Protected *CallThis.PBAR_CALLBACK
    Protected *ProgressBarEx.PBAR_STRUCT
    Protected BackState.i
    If State > -1
      *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
      If *ProgressBarEx
        With *ProgressBarEx
          If \Maximal < State
            State = \Maximal
          EndIf
          BackState = State
          If \Minimal
            If State > \Minimal
              State - \Minimal
            Else
              State = 0
            EndIf
          EndIf
          If StartDrawing(ImageOutput(\Image))
            DrawingMode(#PB_2DDrawing_Gradient)     
            BackColor(\BackColor)
            FrontColor(#White)
            If \Type
              CircularGradient(GadgetWidth(Gadget)/2,GadgetHeight(Gadget)/2,GadgetHeight(Gadget))
              Box(0,0,GadgetWidth(Gadget),GadgetHeight(Gadget) * 2,\BackColor)
              FrontColor(\FrontColor)
              BackColor(\FxColor)
              LinearGradient(GadgetWidth(Gadget)/0.8,State * \Tick,0,State * \Tick)   
              Box(0,0,GadgetWidth(Gadget),State * \Tick,\FrontColor)
            Else
              CircularGradient(GadgetWidth(Gadget)/2,GadgetHeight(Gadget)/2,GadgetWidth(Gadget))
              Box(0,0,GadgetWidth(Gadget),GadgetHeight(Gadget) * 2,\BackColor)
              FrontColor(\FrontColor)
              BackColor(\FxColor)
              LinearGradient(State * \Tick,GadgetHeight(Gadget)/0.8,State * \Tick,0)   
              Box(0,0,State * \Tick,GadgetHeight(Gadget),\FrontColor)
            EndIf
            \State = BackState
            StopDrawing()
            SetGadgetState(Gadget,ImageID(\Image))
            If \Callback
              If \CallBackState = \State
                *CallThis = \Callback
                *CallThis(Gadget)
              EndIf
            EndIf
            CompilerSelect #PB_Compiler_OS
              CompilerCase #PB_OS_Linux
                gdk_window_process_updates_(gtk_widget_get_window(GadgetID(Gadget)), #True)
              CompilerCase #PB_OS_Windows
                InvalidateRgn_(GadgetID(Gadget),#Null,#False);Only this is OS specific!
              CompilerCase #PB_OS_MacOS
                ;
            CompilerEndSelect
            ProcedureReturn #True
          EndIf
        EndWith
      EndIf
    EndIf
  EndProcedure
 
  Procedure.i Create(X.i,Y.i,Width.i,Height.i,Minimal.i,Maximal.i,BackColor.l,FrontColor.l,FxColor.l,Vertical.b)
    Protected *ProgressBarEx.PBAR_STRUCT
    Protected Gadget.i
    If Minimal > -1 And Minimal < Maximal
      *ProgressBarEx = AllocateMemory(SizeOf(PBAR_STRUCT))
      If *ProgressBarEx
        With *ProgressBarEx
          \Image = CreateImage(#PB_Any,Width,Height)
          If \Image
            \BackColor = BackColor
            \FrontColor = FrontColor
            \FxColor = FxColor
            Gadget = ImageGadget(#PB_Any,X,Y,Width,Height,ImageID(\Image))
            If Gadget
              \Type = Vertical
              \Minimal = Minimal
              \Maximal = Maximal
              If Vertical
                \Tick = Height / (\Maximal - \Minimal)
              Else
                \Tick = Width / (\Maximal - \Minimal)
              EndIf
              SetGadgetData(Gadget,*ProgressBarEx)
              If Set(Gadget,0)
                ProcedureReturn Gadget
              EndIf
              FreeGadget(Gadget)
            EndIf
            FreeImage(\Image)
          EndIf
        EndWith
        FreeMemory(*ProgressBarEx)
      EndIf
    EndIf
  EndProcedure
 
  Procedure.i Get(Gadget.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx
      ProcedureReturn *ProgressBarEx\State
    EndIf
  EndProcedure
 
  Procedure.i Free(Gadget.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx
      FreeImage(*ProgressBarEx\Image)
      FreeMemory(*ProgressBarEx)
    EndIf
    FreeGadget(Gadget)
  EndProcedure
 
  Procedure.i SetColors(Gadget.i,BackColor.l,FrontColor.l,FxColor.l)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    Protected Backup.i
    If *ProgressBarEx
      With *ProgressBarEx
        Backup = \Callback
        \Callback = 0
        \BackColor = BackColor
        \FrontColor = FrontColor
        \FxColor = FxColor
        Set(Gadget,\State)
        \Callback = Backup
      EndWith
    EndIf
  EndProcedure
 
  Procedure.i SetColor(Gadget.i,Color.l,Flag.b)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    Protected Backup.i
    If *ProgressBarEx
      With *ProgressBarEx
        Backup = \Callback
        \Callback = 0
        Select Flag
          Case 1
            \FrontColor = Color
          Case 2
            \FxColor = Color
          Default
            \BackColor = Color
        EndSelect
        Set(Gadget,\State)
        \Callback = Backup
      EndWith
    EndIf
  EndProcedure
 
  Procedure.i SetCallback(Gadget.i,State.i,Function.i)
    Protected *ProgressBarEx.PBAR_STRUCT = GetGadgetData(Gadget)
    If *ProgressBarEx And Function
      With *ProgressBarEx
        If State > -1
          If State > \Maximal
            State = \Maximal
          EndIf
          \CallBackState = State
        Else
          \CallBackState = \Maximal
        EndIf
        \Callback = Function
        ProcedureReturn #True
      EndIf
    EndWith
  EndProcedure
 
EndModule

CompilerIf #PB_Compiler_IsMainFile
  EnableExplicit
 
  Procedure TestCallback(Gadget.i)
    MessageRequester("Gadget: " + Str(Gadget), "Callback Bar1 @ State: 80!")
  EndProcedure
 
  If OpenWindow(0, 0, 0, 250, 250, "PBAR (Progressbar) module v.alpha",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    Define Bar1 = PBAR::Create(10,10,20,200,50,150,#Gray,#Green,#Black,#True)
    Define Bar2 = PBAR::Create(40,40,200,20,0,200,#White,#White,$691BFB-1000,#False)
    Define i
    AddWindowTimer(0, 1, 100)
   
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_Timer
          If Not i = 100
            i + 1
          Else
            i = 50
          EndIf
          PBAR::Set(Bar1, i)
          PBAR::Set(Bar2, i)
         
        Case #PB_Event_CloseWindow
          Break
      EndSelect
    ForEver
   
    PBAR::Free(Bar1)
    PBAR::Free(Bar2)
   
  EndIf
 
CompilerEndIf


Code angepaßt, siehe nächster Betrag von Omi

// Code nochmals angepaßt :mrgreen:

_________________
PureBasic 5.71 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 19.3 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild


Zuletzt geändert von ts-soft am 09.07.2017 16:47, insgesamt 3-mal geändert.

Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 09.07.2017 08:37 
Offline

Registriert: 25.03.2013 09:59
Hi,
da mir seit einigen Tagen schon eine Schmalspur-ProgressBar im Kopf rumgeistert, die man oben oder unten ohne viel Platzbedarf dazukleistert kommt das Teil gerade recht :D . Schön gemacht.

@TS-Soft:
Leider ist unter Linux-gtk3-PureBasic das *Widget\window nicht mehr zuverlässig mit dem GdkWindow belegt. Ein
Code:
ImportC ""
  gtk_widget_get_window(*widget.GtkWidget)
EndImport
in DeclareModule PBAR,
und der Tausch von
Code:
gdk_window_process_updates_(*Widget\window, #True)
;in
gdk_window_process_updates_(gtk_widget_get_window(*Widget), #True)
würde das Problem zumindest in neueren gtk2 (2.14+) und gtk3 lösen.

Gruß Charly

_________________
PureBasic Linux-API-Library: http://www.chabba.de


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 09.07.2017 10:28 
Offline
Benutzeravatar

Registriert: 25.09.2016 01:42
@ts-soft & @Omi
danke für die Linux adaption :)

_________________

Links:
PureBasic Discord
[ENGINE] 2D Engine Nautilus (Win)
[INCLUDE] GLFW 3.3 Library
[MODULE] Bass Library 2.4 (Win)
[LIBRARY] Hexi Binary2Hex (Win)



Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 09.07.2017 11:13 
Offline
Benutzeravatar

Registriert: 08.09.2004 00:57
Wohnort: Berlin
Danke Omi, mir sind die ganzen Warnings aufgefallen, deswegen der Spruch mit: nicht Perfekt :wink:

Hab den Code von Omi eingebaut und läuft schon mal ohne "Warnings".

Gruß
Thomas

_________________
PureBasic 5.71 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 19.3 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 09.07.2017 14:18 
Offline

Registriert: 25.03.2013 09:59
Danke Thomas,
aber wat nur dieset immer wiederkehrende
Code:
CompilerIf #PB_OS_Linux
bedeuten mag? :wink:
Gruß Charly

_________________
PureBasic Linux-API-Library: http://www.chabba.de


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 09.07.2017 14:50 
Offline
Benutzeravatar

Registriert: 24.11.2004 13:12
Wohnort: Germany
Hallo Thomas,
mal wieder mit schnellen Fingern geschrieben... :mrgreen:
Code:
  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    ImportC ""
      gtk_widget_get_window(*widget.GtkWidget)
    EndImport
  CompilerEndIf

Code:
            CompilerSelect #PB_Compiler_OS
              CompilerCase #PB_OS_Linux
                gdk_window_process_updates_(gtk_widget_get_window(GadgetID(Gadget)), #True)
              CompilerCase #PB_OS_Windows
                InvalidateRgn_(GadgetID(Gadget),#Null,#False);Only this is OS specific!
              CompilerCase #PB_OS_MacOS
                ;
            CompilerEndSelect

_________________
Alles ist möglich, fragt sich nur wie...
Projekte ThreadToGUI / EventDesigner V3 / OOP-BaseClass-Modul / OPC-Helper DLL
PB v3.30 / v5.4x - OS Mac Mini OSX 10.xx / Window 10 Pro. (X64) /Window 7 Pro. (X64) / Window XP Pro. (X86) / Ubuntu 14.04
Downloads auf My Webspace


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags: Re: MODULE Colorful Progressbar PBAR
BeitragVerfasst: 09.07.2017 16:51 
Offline
Benutzeravatar

Registriert: 08.09.2004 00:57
Wohnort: Berlin
Hört auf zu lästern :) , bin im moment etwas eingerostet :mrgreen:
Gibt ja noch ein Leben, neben PureBasic :mrgreen:

Code nochmals angepasst, aber zur Zeit nur unter Linux getestet. Ich denke mal, ich habe die Windows-Version trotzdem nicht zerstört :lol:

Gruß
Thomas

_________________
PureBasic 5.71 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 19.3 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 15 Beiträge ]  Gehe zu Seite 1, 2  Nächste

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 5 Gäste


Sie dürfen keine neuen Themen in diesem Forum erstellen.
Sie dürfen keine Antworten zu Themen in diesem Forum erstellen.
Sie dürfen Ihre Beiträge in diesem Forum nicht ändern.
Sie dürfen Ihre Beiträge in diesem Forum nicht löschen.

Suche nach:
Gehe zu:  

 


Powered by phpBB © 2008 phpBB Group | Deutsche Übersetzung durch phpBB.de
subSilver+ theme by Canver Software, sponsor Sanal Modifiye