| 1 | # Copyright (C) 2011-2024 A S Lewis | ||
| 2 | # | ||
| 3 | # This program is free software: you can redistribute it and/or modify it under the terms of the GNU | ||
| 4 | # General Public License as published by the Free Software Foundation, either version 3 of the | ||
| 5 | # License, or (at your option) any later version. | ||
| 6 | # | ||
| 7 | # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
| 8 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 9 | # General Public License for more details. | ||
| 10 | # | ||
| 11 | # You should have received a copy of the GNU General Public License along with this program. If not, | ||
| 12 | # see <http://www.gnu.org/licenses/>. | ||
| 13 | # | ||
| 14 | # | ||
| 15 | # Games::Axmud::Obj::Tab | ||
| 16 | # Tab objects, used by pane objects (GA::Table::Pane) to store details about the tab(s) it | ||
| 17 | # contains | ||
| 18 | |||
| 19 | { package Games::Axmud::Obj::Tab; | ||
| 20 | |||
| 21 | use strict; | ||
| 22 | use warnings; | ||
| 23 | # use diagnostics; | ||
| 24 | |||
| 25 | use Glib qw(TRUE FALSE); | ||
| 26 | |||
| 27 | our @ISA = qw(Games::Axmud); | ||
| 28 | |||
| 29 | ################## | ||
| 30 | # Constructors | ||
| 31 | |||
| 32 | sub new { | ||
| 33 | |||
| 34 | # Called by GA::Table::Pane->addSimpleTab and ->addTab | ||
| 35 | # Creates the GA::Obj::Tab, used by pane objects (GA::Table::Pane) to store details about | ||
| 36 | # the tab(s) it contains | ||
| 37 | # | ||
| 38 | # Expected arguments | ||
| 39 | # $number - Unique number of this tab within the parent pane object | ||
| 40 | # $paneObj - The parent GA::Table::Pane object | ||
| 41 | # $session - The GA::Session which controls this tab | ||
| 42 | # $defaultFlag - Flag set to TRUE if the textview object (GA::Obj::Textview) for this | ||
| 43 | # tab will be $self->session's default textview object (where text | ||
| 44 | # received from the world is usually displayed), FALSE otherwise | ||
| 45 | # $textViewObj - The textview object that handles the widgets contained in this tab | ||
| 46 | # $packableObj - The textview object packs a single widget (a Gtk3::TextView or a | ||
| 47 | # Gtk3::VPaned) into a Gtk3::ScrolledWindow. The Gtk3::ScrolledWindow | ||
| 48 | # $packedObj - The single widget packed into the Gtk3::ScrolledWindow | ||
| 49 | # | ||
| 50 | # Optional arguments | ||
| 51 | # $tabWidget - For 'normal' tabs, the widget that is added to a page in the | ||
| 52 | # Gtk3::Notebook (a Gtk3::VBox). Set to 'undef' for simple tabs | ||
| 53 | # $tabLabel - For 'normal' tabs, the Gtk3::Label used. Set to 'undef' for simple | ||
| 54 | # tabs | ||
| 55 | # | ||
| 56 | # Return values | ||
| 57 | # 'undef' on improper arguments | ||
| 58 | # Blessed reference to the newly-created object on success | ||
| 59 | |||
| 60 | my ( | ||
| 61 | $class, $number, $paneObj, $session, $defaultFlag, $textViewObj, $packableObj, | ||
| 62 | $packedObj, $tabWidget, $tabLabel, $check, | ||
| 63 | ) = @_; | ||
| 64 | |||
| 65 | # Local variables | ||
| 66 | my $flag; | ||
| 67 | |||
| 68 | # Check for improper arguments | ||
| 69 | if (! defined $class || ! defined $paneObj || defined $check) { | ||
| 70 | |||
| 71 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 72 | } | ||
| 73 | |||
| 74 | # Use TRUE or FALSE | ||
| 75 | if (! $defaultFlag) { | ||
| 76 | $flag = FALSE; | ||
| 77 | } else { | ||
| 78 | $flag = TRUE; | ||
| 79 | } | ||
| 80 | |||
| 81 | # Setup | ||
| 82 | my $self = { | ||
| 83 | _objName => 'tab', | ||
| 84 | _objClass => $class, | ||
| 85 | _parentFile => undef, # No parent file object | ||
| 86 | _parentWorld => undef, # No parent file object | ||
| 87 | _privFlag => TRUE, # All IVs are private | ||
| 88 | |||
| 89 | # IVs | ||
| 90 | # --- | ||
| 91 | |||
| 92 | # Unique number of this tab within the parent pane object | ||
| 93 | number => $number, | ||
| 94 | # The parent GA::Table::Pane object | ||
| 95 | paneObj => $paneObj, | ||
| 96 | # The GA::Session which controls this tab | ||
| 97 | session => $session, | ||
| 98 | # Flag set to TRUE if the textview object (GA::Obj::Textview) for this tab will be | ||
| 99 | # $self->session's default textview object (where text received from the world is | ||
| 100 | # usually displayed), FALSE otherwise | ||
| 101 | defaultFlag => $flag, | ||
| 102 | # The textview object that handles the widgets contained in this tab | ||
| 103 | textViewObj => $textViewObj, | ||
| 104 | |||
| 105 | # The textview object packs a single widget (a Gtk3::TextView or a Gtk3::VPaned) into | ||
| 106 | # a Gtk3::ScrolledWindow. The Gtk3::ScrolledWindow | ||
| 107 | packableObj => $packableObj, | ||
| 108 | # The single widget packed into the Gtk3::ScrolledWindow | ||
| 109 | packedObj => $packedObj, | ||
| 110 | |||
| 111 | # For 'normal' tabs, the widget that is added to a page in the Gtk3::Notebook (a | ||
| 112 | # Gtk3::VBox). Set to 'undef' for simple tabs | ||
| 113 | tabWidget => $tabWidget, | ||
| 114 | # For 'normal' tabs, the Gtk3::Label used. Set to 'undef' for simple tabs | ||
| 115 | tabLabel => $tabLabel, | ||
| 116 | }; | ||
| 117 | |||
| 118 | # Bless the object into existence | ||
| 119 | bless $self, $class; | ||
| 120 | |||
| 121 | return $self; | ||
| 122 | } | ||
| 123 | |||
| 124 | ################## | ||
| 125 | # Methods | ||
| 126 | |||
| 127 | ################## | ||
| 128 | # Accessors - set | ||
| 129 | |||
| 130 | ################## | ||
| 131 | # Accessors - get | ||
| 132 | |||
| 133 | sub number | ||
| 134 | { $_[0]->{number} } | ||
| 135 | sub paneObj | ||
| 136 | { $_[0]->{paneObj} } | ||
| 137 | sub session | ||
| 138 | { $_[0]->{session} } | ||
| 139 | sub defaultFlag | ||
| 140 | { $_[0]->{defaultFlag} } | ||
| 141 | sub textViewObj | ||
| 142 | { $_[0]->{textViewObj} } | ||
| 143 | |||
| 144 | sub packableObj | ||
| 145 | { $_[0]->{packableObj} } | ||
| 146 | sub packedObj | ||
| 147 | { $_[0]->{packedObj} } | ||
| 148 | |||
| 149 | sub tabWidget | ||
| 150 | { $_[0]->{tabWidget} } | ||
| 151 | sub tabLabel | ||
| 152 | { $_[0]->{tabLabel} } | ||
| 153 | } | ||
| 154 | |||
| 155 | # Package must return a true value | ||
| 156 | 1 |