From 9ba8e6cf38da5196ed7bc878fe452952f3e10638 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Tue, 22 May 2007 15:06:55 +0000 Subject: moved docs --- docs/doctool/Modules/NaturalDocs/Menu/Entry.pm | 201 +++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 docs/doctool/Modules/NaturalDocs/Menu/Entry.pm (limited to 'docs/doctool/Modules/NaturalDocs/Menu') diff --git a/docs/doctool/Modules/NaturalDocs/Menu/Entry.pm b/docs/doctool/Modules/NaturalDocs/Menu/Entry.pm new file mode 100644 index 00000000..af443f5d --- /dev/null +++ b/docs/doctool/Modules/NaturalDocs/Menu/Entry.pm @@ -0,0 +1,201 @@ +############################################################################### +# +# Package: NaturalDocs::Menu::Entry +# +############################################################################### +# +# A class representing an entry in the menu. +# +############################################################################### + +# This file is part of Natural Docs, which is Copyright (C) 2003-2005 Greg Valure +# Natural Docs is licensed under the GPL + +use strict; +use integer; + +package NaturalDocs::Menu::Entry; + + +############################################################################### +# Group: Implementation + +# +# Constants: Members +# +# The object is implemented as a blessed arrayref with the indexes below. +# +# TYPE - The +# TITLE - The title of the entry. +# TARGET - The target of the entry. If the type is , it will be the source . If the type is +# , it will be the URL. If the type is , it will be an arrayref of +# objects representing the group's content. If the type is , it will be +# a . +# FLAGS - Any that apply. +# +use constant TYPE => 0; +use constant TITLE => 1; +use constant TARGET => 2; +use constant FLAGS => 3; +# DEPENDENCY: New() depends on the order of these constants. + + +############################################################################### +# Group: Functions + +# +# Function: New +# +# Creates and returns a new object. +# +# Parameters: +# +# type - The . +# title - The title of the entry. +# target - The target of the entry, if applicable. If the type is , use the source . If the type is +# , use the URL. If the type is , use the . Otherwise set it to undef. +# flags - Any that apply. +# +sub New #(type, title, target, flags) + { + # DEPENDENCY: This gode depends on the order of the constants. + + my $package = shift; + + my $object = [ @_ ]; + bless $object, $package; + + if ($object->[TYPE] == ::MENU_GROUP()) + { $object->[TARGET] = [ ]; }; + if (!defined $object->[FLAGS]) + { $object->[FLAGS] = 0; }; + + return $object; + }; + + +# Function: Type +# Returns the . +sub Type + { return $_[0]->[TYPE]; }; + +# Function: Title +# Returns the title of the entry. +sub Title + { return $_[0]->[TITLE]; }; + +# Function: SetTitle +# Replaces the entry's title. +sub SetTitle #(title) + { $_[0]->[TITLE] = $_[1]; }; + +# +# Function: Target +# +# Returns the target of the entry, if applicable. If the type is , it returns the source . If the type is +# , it returns the URL. If the type is , it returns the . Otherwise it returns undef. +# +sub Target + { + my $self = shift; + + # Group entries are the only time when target won't be undef when it should be. + if ($self->Type() == ::MENU_GROUP()) + { return undef; } + else + { return $self->[TARGET]; }; + }; + +# Function: SetTarget +# Replaces the entry's target. +sub SetTarget #(target) + { $_[0]->[TARGET] = $_[1]; }; + +# Function: Flags +# Returns the . +sub Flags + { return $_[0]->[FLAGS]; }; + +# Function: SetFlags +# Replaces the . +sub SetFlags #(flags) + { $_[0]->[FLAGS] = $_[1]; }; + + + +############################################################################### +# Group: Group Functions +# +# All of these functions assume the type is . Do *not* call any of these without checking first. + + +# +# Function: GroupContent +# +# Returns an arrayref of objects representing the contents of the +# group, or undef otherwise. This arrayref will always exist for 's and can be changed. +# +sub GroupContent + { + return $_[0]->[TARGET]; + }; + + +# +# Function: GroupIsEmpty +# +# If the type is , returns whether the group is empty. +# +sub GroupIsEmpty + { + my $self = shift; + return (scalar @{$self->GroupContent()} > 0); + }; + + +# +# Function: PushToGroup +# +# Pushes the entry to the end of the group content. +# +sub PushToGroup #(entry) + { + my ($self, $entry) = @_; + push @{$self->GroupContent()}, $entry; + }; + + +# +# Function: DeleteFromGroup +# +# Deletes an entry from the group content by index. +# +sub DeleteFromGroup #(index) + { + my ($self, $index) = @_; + + my $groupContent = $self->GroupContent(); + + splice( @$groupContent, $index, 1 ); + }; + + +# +# Function: MarkEndOfOriginal +# +# If the group doesn't already have one, adds a entry to the end and sets the +# flag. +# +sub MarkEndOfOriginal + { + my $self = shift; + + if (($self->Flags() & ::MENU_GROUP_HASENDOFORIGINAL()) == 0) + { + $self->PushToGroup( NaturalDocs::Menu::Entry->New(::MENU_ENDOFORIGINAL(), undef, undef, undef) ); + $self->SetFlags( $self->Flags() | ::MENU_GROUP_HASENDOFORIGINAL() ); + }; + }; + + +1; -- cgit 1.4.1