
proc ShowRessources {} {
    global WDRessources InternalWindowing DialogFrame

    if {$InternalWindowing} {
        set WDRessources $DialogFrame.ressources
        if {![winfo exists $WDRessources]} {
            frame $WDRessources
        }
        
        RegisterDialog "System Ressources Info" $WDRessources ShowRessources {}
    } else {
        set WDRessources .ressources
        if {![winfo exists $WDRessources]} {
            toplevel $WDRessources
            wm title $WDRessources "System Ressources Info"
            wm resizable $WDRessources 0 0
        } else {return}
    }
    
    UpdateRessources

    if {$InternalWindowing} {AlignActiveDialog}
}


proc UpdateRessources {} {
    global ThisGraph goblinMethGeometry WDRessources InternalWindowing DialogFrame \
        DefPadX DefPadY

    destroy $WDRessources.frame1

    frame $WDRessources.frame1

    pack $WDRessources.frame1 \
        -side top -fill x -padx $DefPadX -pady 5m

    label $WDRessources.frame1.label -text "Memory Management:" -anchor w

    label $WDRessources.frame1.heapsize \
        -text "  Current Heap Size: [goblin size]" -anchor w
    label $WDRessources.frame1.maxsize \
        -text "  Maximum Heap Size: [goblin maxsize]" -anchor w
    label $WDRessources.frame1.objects \
        -text "  Current Number of Objects: [goblin #objects]" -anchor w
    label $WDRessources.frame1.fragments \
        -text "  Current Number of Fragments: [goblin #fragments]" -anchor w
    label $WDRessources.frame1.allocs \
        -text "  Total Number of Allocations: [goblin #allocs]" -anchor w

    pack $WDRessources.frame1.label $WDRessources.frame1.heapsize \
        $WDRessources.frame1.maxsize $WDRessources.frame1.objects \
        $WDRessources.frame1.fragments $WDRessources.frame1.allocs -fill x

    
    if {![winfo exists $WDRessources.buttons]} {
        frame $WDRessources.buttons
        button $WDRessources.buttons.update -text "Update" -command { \
            UpdateRessources
        }
    
        button $WDRessources.buttons.done -text "Done" -command { \
            if {$InternalWindowing} {
                DestroyActiveDialog
            } else {
                destroy $WDRessources
            }
        }
    
        pack $WDRessources.buttons.update $WDRessources.buttons.done \
            -side left -fill x -padx 3m

        pack $WDRessources.buttons -padx 3m -pady 3m -side bottom
    }

    if {$InternalWindowing} {pack $WDRessources -anchor nw}
}

if {![info exists WDRessources] || ![winfo exists $WDRessources]} {ShowRessources}

