| 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::Tablezone | ||
| 16 | # A tablezone object marks out an area on the Gtk3::Grid used by an 'internal' window as being in | ||
| 17 | # use by a single widget, and stores the widget type used | ||
| 18 | |||
| 19 | { package Games::Axmud::Obj::Tablezone; | ||
| 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::Strip::Table->addTableObj | ||
| 35 | # Create a new instance of the tablezone object, each of which marks out an area of the | ||
| 36 | # Gtk3::Grid used by an 'internal' window as being in use by a table object (inheriting | ||
| 37 | # from GA::Generic::Table), and specifies the type of table object used | ||
| 38 | # | ||
| 39 | # Expected arguments | ||
| 40 | # $number | ||
| 41 | # - The tablezone's number within the parent strip object (matches | ||
| 42 | # GA::Strip::Table->zoneCount) | ||
| 43 | # $packageName | ||
| 44 | # - The package name of the table object which fills the space marked out by this | ||
| 45 | # tablezone, e.g. GA::Table::Pane | ||
| 46 | # $left, $top | ||
| 47 | # - The coordinates of the top-left corner of the tablezone on the table | ||
| 48 | # $right, $bottom | ||
| 49 | # - The coordinates of the top-right corner of the tablezone on the table | ||
| 50 | # | ||
| 51 | # Return values | ||
| 52 | # 'undef' on improper arguments | ||
| 53 | # Blessed reference to the newly-created object on success | ||
| 54 | |||
| 55 | my ($class, $number, $packageName, $left, $top, $right, $bottom, $check) = @_; | ||
| 56 | |||
| 57 | # Check for improper arguments | ||
| 58 | if ( | ||
| 59 | ! defined $class || ! defined $number || ! defined $packageName || ! defined $left | ||
| 60 | || ! defined $top || ! defined $right || ! defined $bottom || defined $check | ||
| 61 | ) { | ||
| 62 | return $axmud::CLIENT->writeImproper($class . '->new', @_); | ||
| 63 | } | ||
| 64 | |||
| 65 | # Setup | ||
| 66 | my $self = { | ||
| 67 | _objName => 'tablezone_' . $number, | ||
| 68 | _objClass => $class, | ||
| 69 | _parentFile => undef, # No parent file object | ||
| 70 | _parentWorld => undef, # No parent file object | ||
| 71 | _privFlag => TRUE, # All IVs are private | ||
| 72 | |||
| 73 | # IVs | ||
| 74 | # --- | ||
| 75 | |||
| 76 | # The tablezone's number within the parent strip object (matches | ||
| 77 | # GA::Strip::Table->zoneCount) | ||
| 78 | number => $number, | ||
| 79 | # The package name of the table object which fills the space marked out by this | ||
| 80 | # tablezone, e.g. GA::Table::Pane | ||
| 81 | packageName => $packageName, | ||
| 82 | |||
| 83 | # The coordinates of the tablezone within the strip object's Gtk3::Grid | ||
| 84 | # Coordinates of the top-left corner (e.g. 0x0) | ||
| 85 | left => $left, | ||
| 86 | top => $top, | ||
| 87 | # Coordinates of the bottom-right corner (e.g. 59x59) | ||
| 88 | right => $right, | ||
| 89 | bottom => $bottom, | ||
| 90 | }; | ||
| 91 | |||
| 92 | # Bless the object into existence | ||
| 93 | bless $self, $class; | ||
| 94 | return $self; | ||
| 95 | } | ||
| 96 | |||
| 97 | ################## | ||
| 98 | # Methods | ||
| 99 | |||
| 100 | ################## | ||
| 101 | # Accessors - set | ||
| 102 | |||
| 103 | ################## | ||
| 104 | # Accessors - get | ||
| 105 | |||
| 106 | sub number | ||
| 107 | { $_[0]->{number} } | ||
| 108 | sub packageName | ||
| 109 | { $_[0]->{packageName} } | ||
| 110 | |||
| 111 | sub left | ||
| 112 | { $_[0]->{left} } | ||
| 113 | sub top | ||
| 114 | { $_[0]->{top} } | ||
| 115 | sub right | ||
| 116 | { $_[0]->{right} } | ||
| 117 | sub bottom | ||
| 118 | { $_[0]->{bottom} } | ||
| 119 | } | ||
| 120 | |||
| 121 | # Package must return a true value | ||
| 122 | 1 |