File: u_tv_sheets.sru
Size: 4038
Date: Mon, 07 Apr 2008 21:31:58 +0200
$PBExportHeader$u_tv_sheets.sru
forward
global type u_tv_sheets from u_base_container
end type
type tv_list from u_tv within u_tv_sheets
end type
type str_tabs from structure within u_tv_sheets
end type
end forward

type str_tabs from structure
   string      classname
   dragobject     object
   string      displaytext
   boolean     active
   boolean     boolean
   boolean     disabled
   boolean     isdynamic
   long     itemhandle
end type

global type u_tv_sheets from u_base_container
integer width = 923
integer height = 672
tv_list tv_list
end type
global u_tv_sheets u_tv_sheets

type variables
Public:
boolean #TreeLeft = TRUE
boolean #PopTreeMenu = TRUE
private:
str_tabs istr_activetab
str_tabs istr_tabs[]
boolean ib_suspendrefresh, ib_suspendevents
end variables

forward prototypes
public subroutine of_addtab (readonly string as_displaytext, readonly dragobject ado_child)
public subroutine of_refresh ()
public subroutine of_suspendrefresh ()
public subroutine of_suspendevents (boolean ab_suspend)
public subroutine of_resumerefresh ()
public subroutine of_addtabs (string as_tabs[], dragobject ado_children[])
public subroutine of_closetab (integer ai_index)
public subroutine of_closealltabs ()
end prototypes

public subroutine of_addtab (readonly string as_displaytext, readonly dragobject ado_child);long ll

SetParent(Handle(ado_child), Handle(this))

ll = UPPERBOUND(istr_tabs) + 1
istr_tabs[ll].displaytext = as_displaytext
istr_tabs[ll].object = ado_child
IF ll = 1 THEN
   istr_tabs[ll].Active = TRUE
   istr_activetab = istr_tabs[ll]
ELSE
   ado_child.Visible = FALSE
END IF

of_Refresh()

IF ll = 1 THEN &
   istr_tabs[ll].object.POST DYNAMIC Show()//Visible = TRUE

end subroutine

public subroutine of_refresh ();IF ib_suspendrefresh THEN RETURN
//do posts
Yield() 
this.TriggerEvent("resize")
IF ISVALID(istr_activetab.Object) THEN &
   istr_activetab.Object.BringToTop = TRUE

end subroutine

public subroutine of_suspendrefresh ();ib_suspendrefresh = TRUE
end subroutine

public subroutine of_suspendevents (boolean ab_suspend);ib_suspendevents = ab_suspend
end subroutine

public subroutine of_resumerefresh ();ib_suspendrefresh = FALSE
of_Refresh()
end subroutine

public subroutine of_addtabs (string as_tabs[], dragobject ado_children[]);str_tabs lstr[]
long ll_count, n

//clear tabs
istr_tabs = lstr
ll_count = UPPERBOUND(as_tabs)
of_Suspendrefresh()
FOR n = 1 to ll_count
   of_addTab(as_tabs[n], ado_children[n])
NEXT
of_Resumerefresh()
end subroutine

public subroutine of_closetab (integer ai_index);long ll_count, n, c
str_tabs lstr[], lstr_empty

//re-index
ll_count = UPPERBOUND(istr_tabs)

IF ai_index = 0 OR ai_index > ll_count THEN RETURN

FOR n = 1 to ll_count
   IF n <> ai_index THEN
      c ++
      lstr[c] = istr_tabs[n]
   ELSE
      IF istr_tabs[ai_index].Active THEN
         IF n > 1 AND n <= ll_count THEN
            istr_activetab = istr_tabs[n - 1]
         ELSE
            IF n = 1 AND n < ll_count THEN
               istr_activetab = istr_tabs[n + 1]
            ELSE
               istr_activetab = lstr_empty
            END IF
         END IF
      END IF
   END IF
NEXT

//hide & close
istr_tabs[ai_index].Object.Visible = FALSE
IF istr_tabs[ai_index].IsDynamic THEN
   of_CloseUserObject(istr_tabs[ai_index].Object)
ELSE
   SetParent(Handle(this), Handle(istr_tabs[ai_index].Object))
END IF

istr_tabs = lstr
tv_list.SelectItem(istr_activetab.itemhandle)

of_Refresh()
end subroutine

public subroutine of_closealltabs ();long ll_count, n

ll_count = UPPERBOUND(istr_tabs)
of_SuspendRefresh()
FOR n = ll_count to 1 STEP -1
   of_CloseTab(n)
NEXT
of_ResumeRefresh()

end subroutine

on u_tv_sheets.create
int iCurrent
call super::create
this.tv_list=create tv_list
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.tv_list
end on

on u_tv_sheets.destroy
call super::destroy
destroy(this.tv_list)
end on

type tv_list from u_tv within u_tv_sheets
integer width = 613
integer taborder = 10
boolean linesatroot = false
end type