Created a nice software using SpiderBasic ? Post you link here !
User avatar
Arbrakaan
 
Posts: 64
Joined: Mon Feb 24, 2014 10:54 pm
Location: Geneva

List Sort demo

by Arbrakaan Sun Mar 27, 2016 11:52 am

Hi all, i finally get it working, I don't know if it is the best way to do that... but it work.

Code: Select all
Enumeration
  #Window_0
  #coursier_course_liste
  #coursier_course_liste_canvas
EndEnumeration

Structure CoursePlanningData
  id.i
  posX.i
  posY.i
  color.s
  lineColor.b
  dr.s
  time.s
  urgence.b
  type.b
  complet.b
EndStructure

global coursierCourseCol=4,coursowH=30,lineColorCoursier.b=0,dragOn.b, idc, interval_dragOn=100, dragEnd, idc_pos
global dim CoursePlanning.CoursePlanningData(256)

CoursePlanning(0)\dr = "Dr. 1"
CoursePlanning(0)\time = "08:00"
CoursePlanning(0)\complet= 0

CoursePlanning(1)\dr = "Dr. 2"
CoursePlanning(1)\time = "08:30"
CoursePlanning(1)\complet= 1

CoursePlanning(2)\dr = "Dr. 3"
CoursePlanning(2)\time = "09:30"
CoursePlanning(2)\complet= 0

CoursePlanning(3)\dr = "Dr. 4"
CoursePlanning(3)\time = "09:30"
CoursePlanning(3)\complet= 0

CoursePlanning(4)\dr = "Dr. 5"
CoursePlanning(4)\time = "09:30"
CoursePlanning(4)\complet= 0

procedure Reload()
  if dragOn=1
    ResizeGadget(idc, #PB_Ignore, Round(DesktopMouseY()/coursowH,#PB_Round_Nearest)*coursowH-(coursowH*2)-6, #PB_Ignore, #PB_Ignore)
    dragEnd = (Round(DesktopMouseY()/coursowH,#PB_Round_Nearest)*coursowH-(coursowH*2))/coursowH
    endif
  EndProcedure
 
Procedure draw(i)
  CoursePlanning(i)\id = CanvasGadget(#PB_Any, 0, i*coursowH, GadgetWidth(#coursier_course_liste), coursowH)
  If StartDrawing(CanvasOutput(CoursePlanning(i)\id))
        if lineColorCoursier = 0
          Box(0, 0, GadgetWidth(CoursePlanning(i)\id), coursowH, RGB(240,240,240))
          lineColorCoursier = 1
        else
          Box(0, 0, GadgetWidth(CoursePlanning(i)\id), coursowH, RGB(245,245,245))
          lineColorCoursier = 0
        endif
        if CoursePlanning(i)\complet= 1
            Box(0, 0, GadgetWidth(CoursePlanning(i)\id), coursowH, RGBA(155,195,93,50))
        endif
        for z=0 to coursierCourseCol
          if z<>0
            Line(GadgetWidth(#coursier_course_liste)/coursierCourseCol*z, 0, 1, coursowH, RGB(189,204,213))
          endif
          select z
            case 0
              DrawText((GadgetWidth(#coursier_course_liste)/coursierCourseCol*z)+10, coursowH/2-10, CoursePlanning(i)\dr)
            case 1
              DrawText((GadgetWidth(#coursier_course_liste)/coursierCourseCol*z)+10, coursowH/2-10, CoursePlanning(i)\time)
            case 2
            case 3
          EndSelect
        next
        Line(0, coursowH-1, GadgetWidth(CoursePlanning(i)\id), 1, RGB(189,204,213))
        Line(0, 0, GadgetWidth(CoursePlanning(i)\id), 1, RGB(255,255,255))
        StopDrawing()
      EndIf
EndProcedure

procedure redraw()
  !var filteredArray=a_CoursePlanning.array[v_dragon]._dr;

  !if (v_dragend >= a_CoursePlanning.array[v_idc_pos].length) {
  !        var k = v_dragend - a_CoursePlanning.array[v_idc_pos].length;
  !        while ((k--) + 1) {
  !            a_CoursePlanning.array[v_idc_pos].push(undefined);
  !        }
  !    }
  !    a_CoursePlanning.array.splice(v_dragend, 0, a_CoursePlanning.array.splice(v_idc_pos, 1)[0]);
  ;!this.splice(new_index, 0, this.splice(old_index, 1)[0]);
 
  ;.move(0, 1)
  for i=0 to 30
    FreeGadget(CoursePlanning(i)\id)
  next
  OpenGadgetList(#coursier_course_liste)
    for i=0 to 30
      draw(i)
    next
  CloseGadgetList()
EndProcedure

;Events

Procedure GadgetEvents()
    for i=0 to 30
        if  CoursePlanning(i)\id = EventGadget()
          Select EventType()
            Case #PB_EventType_LeftButtonDown
              ;Debug "Click with left mouse button"+CoursePlanning(i)\id
              idc = CoursePlanning(i)\id
              if dragOn=1
                redraw()
                dragOn=0
              else
                dragOn=1
                idc_pos = i
                OpenGadgetList(#coursier_course_liste)
                CanvasGadget(idc, 0, coursowH, GadgetWidth(#coursier_course_liste), coursowH/4)
                StartDrawing(CanvasOutput(idc))
                  Box(0, 0, GadgetWidth(#coursier_course_liste), coursowH/4, RGB(40,200,40))
                  StopDrawing()
                CloseGadgetList()
              endif
              ;debug"down"
            Case #PB_EventType_RightClick
              Debug "Click with right mouse button"+CoursePlanning(i)\id
            case #PB_EventType_LeftButtonUp

            EndSelect
            Break
         endif
       next
EndProcedure
   
OpenWindow(#Window_0,0,0,WindowWidth(#Window_0),WindowHeight(#Window_0),"Calandar",#PB_Window_Background)
AddWindowTimer(#Window_0, 0, interval_dragOn)
ScrollAreaGadget(#coursier_course_liste, 10, 50, WindowHeight(#Window_0), WindowHeight(#Window_0)-60,WindowHeight(#Window_0), WindowHeight(#Window_0)-50)
    for i=0 to 30
      draw(i)
    next
    CloseGadgetList()
   
    BindEvent(#PB_Event_Gadget, @GadgetEvents())
    BindEvent(#PB_Event_Timer, @Reload())
Return to Showcase

Who is online

Users browsing this forum: No registered users and 2 guests