diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 29abb8bc..00000000 --- a/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -*.app -*.debug -*.profile -*.palette -*obj -.gdbinit diff --git a/.github/scripts/dependencies.sh b/.github/scripts/dependencies.sh new file mode 100755 index 00000000..a0a33601 --- /dev/null +++ b/.github/scripts/dependencies.sh @@ -0,0 +1,99 @@ +#! /usr/bin/env sh + +set -ex + +install_gnustep_make() { + echo "::group::GNUstep Make" + cd $DEPS_PATH + git clone -q -b ${TOOLS_MAKE_BRANCH:-master} https://github.com/gnustep/tools-make.git + cd tools-make + MAKE_OPTS= + if [ -n "$HOST" ]; then + MAKE_OPTS="$MAKE_OPTS --host=$HOST" + fi + if [ -n "$RUNTIME_VERSION" ]; then + MAKE_OPTS="$MAKE_OPTS --with-runtime-abi=$RUNTIME_VERSION" + fi + ./configure --prefix=$INSTALL_PATH --with-library-combo=$LIBRARY_COMBO $MAKE_OPTS || cat config.log + make install + + echo Objective-C build flags: + $INSTALL_PATH/bin/gnustep-config --objc-flags + echo "::endgroup::" +} + +install_libobjc2() { + echo "::group::libobjc2" + cd $DEPS_PATH + git clone -q https://github.com/gnustep/libobjc2.git + cd libobjc2 + git submodule sync + git submodule update --init + mkdir build + cd build + cmake \ + -DTESTS=off \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DGNUSTEP_INSTALL_TYPE=NONE \ + -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PATH \ + ../ + make install + echo "::endgroup::" +} + +install_libdispatch() { + echo "::group::libdispatch" + cd $DEPS_PATH + # will reference upstream after https://github.com/apple/swift-corelibs-libdispatch/pull/534 is merged + git clone -q -b system-blocksruntime https://github.com/ngrewe/swift-corelibs-libdispatch.git libdispatch + mkdir libdispatch/build + cd libdispatch/build + # -Wno-error=void-pointer-to-int-cast to work around build error in queue.c due to -Werror + cmake \ + -DBUILD_TESTING=off \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PATH \ + -DCMAKE_C_FLAGS="-Wno-error=void-pointer-to-int-cast" \ + -DINSTALL_PRIVATE_HEADERS=1 \ + -DBlocksRuntime_INCLUDE_DIR=$INSTALL_PATH/include \ + -DBlocksRuntime_LIBRARIES=$INSTALL_PATH/lib/libobjc.so \ + ../ + make install + echo "::endgroup::" +} + +install_gnustep_gui() { + echo "::group::GNUstep GUI" + cd $DEPS_PATH + . $INSTALL_PATH/share/GNUstep/Makefiles/GNUstep.sh + git clone -q -b ${LIBS_GUI_BRANCH:-master} https://github.com/gnustep/libs-gui.git + cd libs-gui + ./configure + make + make install + echo "::endgroup::" +} + +install_gnustep_base() { + echo "::group::GNUstep Base" + cd $DEPS_PATH + . $INSTALL_PATH/share/GNUstep/Makefiles/GNUstep.sh + git clone -q -b ${LIBS_BASE_BRANCH:-master} https://github.com/gnustep/libs-base.git + cd libs-base + ./configure + make + make install + echo "::endgroup::" +} + +mkdir -p $DEPS_PATH + +# Windows MSVC toolchain uses tools-windows-msvc scripts to install non-GNUstep dependencies +if [ "$LIBRARY_COMBO" = "ng-gnu-gnu" -a "$IS_WINDOWS_MSVC" != "true" ]; then + install_libobjc2 + install_libdispatch +fi + +install_gnustep_make +install_gnustep_base +install_gnustep_gui diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..afe2643f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,126 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + inputs: + tools_make_branch: + description: "tools-make branch" + default: "master" + required: true + libs_base_branch: + description: "libs-base branch" + default: "master" + required: true + libs_back_branch: + description: "libs-back branch" + default: "master" + required: true + +env: + APT_PACKAGES: >- + pkg-config + libgnutls28-dev + libffi-dev + libicu-dev + libxml2-dev + libxslt1-dev + libssl-dev + libavahi-client-dev + zlib1g-dev + gnutls-bin + libcurl4-gnutls-dev + libgmp-dev + libcairo2-dev + + # packages for GCC Objective-C runtime + APT_PACKAGES_gcc: >- + libobjc-10-dev + libblocksruntime-dev + gobjc + + # packages for libobjc2 / libdispatch + APT_PACKAGES_clang: >- + libpthread-workqueue-dev + +jobs: + ########### Linux ########### + linux: + name: ${{ matrix.name }} + runs-on: ubuntu-latest + # don't run pull requests from local branches twice + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + + strategy: + fail-fast: false + matrix: + include: + - name: Ubuntu x64 GCC + library-combo: gnu-gnu-gnu + CC: gcc + CXX: g++ + + - name: Ubuntu x64 Clang gnustep-1.9 + library-combo: ng-gnu-gnu + runtime-version: gnustep-1.9 + CC: clang + CXX: clang++ + + - name: Ubuntu x64 Clang gnustep-2.0 + library-combo: ng-gnu-gnu + runtime-version: gnustep-2.0 + CC: clang + CXX: clang++ + + env: + SRC_PATH: ${{ github.workspace }}/source + DEPS_PATH: ${{ github.workspace }}/dependencies + INSTALL_PATH: ${{ github.workspace }}/build + CC: ${{ matrix.CC }} + CXX: ${{ matrix.CXX }} + LIBRARY_COMBO: ${{ matrix.library-combo }} + RUNTIME_VERSION: ${{ matrix.runtime-version }} + + defaults: + run: + working-directory: ${{ env.SRC_PATH }} + + steps: + - uses: actions/checkout@v3 + with: + path: ${{ env.SRC_PATH }} + + - name: Install packages + run: | + sudo apt-get -q -y update + sudo apt-get -q -y install $APT_PACKAGES $APT_PACKAGES_${{ matrix.library-combo == 'ng-gnu-gnu' && 'clang' || 'gcc' }} + + # gnustep-2.0 runtime requires ld.gold or lld + if [ "$RUNTIME_VERSION" = "gnustep-2.0" ]; then + sudo update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.gold" 10 + fi + + - name: Install dependencies + env: + TOOLS_MAKE_BRANCH: ${{github.event.inputs.tools_make_branch}} + LIBS_BASE_BRANCH: ${{github.event.inputs.libs_base_branch}} + LIBS_GUI_BRANCH: ${{github.event.inputs.libs_gui_branch}} + run: ./.github/scripts/dependencies.sh + + - name: Build source for Gorm + run: . $INSTALL_PATH/share/GNUstep/Makefiles/GNUstep.sh && make && make install + + - name: Run tests + run: | + . $INSTALL_PATH/share/GNUstep/Makefiles/GNUstep.sh + make check + + - name: Upload logs + uses: actions/upload-artifact@v3 + if: always() + with: + name: Logs - ${{ matrix.name }} + path: | + ${{ env.SRC_PATH }}/config.log + ${{ env.SRC_PATH }}/Tests/tests.log \ No newline at end of file diff --git a/.gitignore b/.gitignore index 23dc3ac9..a3208370 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,7 @@ *.profile *.palette *.plugin +.gdbinit obj -InterfaceBuilder +derived_src +*.framework diff --git a/Applications/GNUmakefile b/Applications/GNUmakefile new file mode 100644 index 00000000..39034acf --- /dev/null +++ b/Applications/GNUmakefile @@ -0,0 +1,22 @@ +# +# GNUmakefile - Generated by ProjectCenter +# +ifeq ($(GNUSTEP_MAKEFILES),) + GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null) +endif +ifeq ($(GNUSTEP_MAKEFILES),) + $(error You need to set GNUSTEP_MAKEFILES before compiling!) +endif + +include $(GNUSTEP_MAKEFILES)/common.make + +# Generator bundles +SUBPROJECTS = \ + Gorm + +# +# Makefiles +# +-include GNUmakefile.preamble +include $(GNUSTEP_MAKEFILES)/aggregate.make +-include GNUmakefile.postamble diff --git a/ANNOUNCE b/Applications/Gorm/ANNOUNCE similarity index 100% rename from ANNOUNCE rename to Applications/Gorm/ANNOUNCE diff --git a/Applications/Gorm/English.lproj/Gorm.gorm/data.classes b/Applications/Gorm/English.lproj/Gorm.gorm/data.classes new file mode 100644 index 00000000..5255e46e --- /dev/null +++ b/Applications/Gorm/English.lproj/Gorm.gorm/data.classes @@ -0,0 +1,128 @@ +{ + "## Comment" = "Do NOT change this file, Gorm maintains it"; + FirstResponder = { + Actions = ( + "addAttributeToClass:", + "alignSelectedObjects:", + "arrangeSelectedObjects:", + "createClassFiles:", + "createSubclass:", + "endTesting:", + "exportStrings:", + "exportXLIFFDocument:", + "groupSelectionInBox:", + "groupSelectionInMatrix:", + "groupSelectionInScrollView:", + "groupSelectionInSplitView:", + "groupSelectionInView:", + "guideline:", + "importXLIFFDocument:", + "inspector:", + "instantiateClass:", + "loadClass:", + "loadImage:", + "loadPalette:", + "loadSound:", + "newAction:", + "orderFrontFontPanel:", + "palettes:", + "preferencesPanel:", + "remove:", + "selectAllItems:", + "setName:", + "testinterface:", + "translate:", + "ungroup:" + ); + Super = NSObject; + }; + Gorm = { + Actions = ( + "editClass:", + "createSubclass:", + "testInterface:", + "setName:", + "selectAllItems:", + "paste:", + "palettes:", + "loadSound:", + "loadPalette:", + "inspector:", + "infoPanel:", + "endTesting:", + "delete:", + "cut:", + "copy:", + "close:", + "miniaturize:", + "debug:", + "loadImage:", + "orderFrontFontPanel:", + "ungroup:", + "groupSelectionInScrollView:", + "groupSelectionInBox:", + "groupSelectionInSplitView:", + "remove:", + "addAttributeToClass:", + "instantiateClass:", + "createClassFiles:", + "loadClass:", + "preferencesPanel:", + "guideline:", + "print:", + "groupSelectionInView:", + "groupSelectionInMatrix:" + ); + Outlets = ( + gormMenu, + guideLineMenuItem + ); + Super = NSApplication; + }; + GormAppDelegate = { + Actions = ( + "copy:", + "cut:", + "delete:", + "endTesting:", + "groupSelectionInBox:", + "groupSelectionInSplitView:", + "inspector:", + "loadImage:", + "loadSound:", + "ungroup:", + "palettes:", + "paste:", + "preferencesPanel:", + "selectAllItems:", + "setName:", + "testinterface:", + "loadPalette:", + "createClassFiles:", + "createSubclass:", + "groupSelectionInScrollView:", + "groupSelectionInView:", + "guideline:", + "instantiateClass:", + "loadClass:", + "addAttributeToClass:", + "remove:", + "exportXLIFFDocument:", + "importXLIFFDocument:", + "exportStrings:", + "translate:" + ); + Outlets = ( + gormMenu, + guideLineMenuItem + ); + Super = NSObject; + }; + GormDocumentController = { + Actions = ( + ); + Outlets = ( + ); + Super = NSDocumentController; + }; +} \ No newline at end of file diff --git a/Palettes/4Data/GormNSComboBoxInspector.gorm/data.info b/Applications/Gorm/English.lproj/Gorm.gorm/data.info similarity index 65% rename from Palettes/4Data/GormNSComboBoxInspector.gorm/data.info rename to Applications/Gorm/English.lproj/Gorm.gorm/data.info index 744f736a..a97a2a90 100644 Binary files a/Palettes/4Data/GormNSComboBoxInspector.gorm/data.info and b/Applications/Gorm/English.lproj/Gorm.gorm/data.info differ diff --git a/Applications/Gorm/English.lproj/Gorm.gorm/objects.gorm b/Applications/Gorm/English.lproj/Gorm.gorm/objects.gorm new file mode 100644 index 00000000..1aec9496 Binary files /dev/null and b/Applications/Gorm/English.lproj/Gorm.gorm/objects.gorm differ diff --git a/English.lproj/Gorm.rtfd/TXT.rtf b/Applications/Gorm/English.lproj/Gorm.rtfd/TXT.rtf similarity index 100% rename from English.lproj/Gorm.rtfd/TXT.rtf rename to Applications/Gorm/English.lproj/Gorm.rtfd/TXT.rtf diff --git a/Applications/Gorm/English.lproj/GormLanguageViewController.gorm/data.classes b/Applications/Gorm/English.lproj/GormLanguageViewController.gorm/data.classes new file mode 100644 index 00000000..cabfd246 --- /dev/null +++ b/Applications/Gorm/English.lproj/GormLanguageViewController.gorm/data.classes @@ -0,0 +1,21 @@ +{ + "## Comment" = "Do NOT change this file, Gorm maintains it"; + FirstResponder = { + Actions = ( + "updateTargetLanguage:", + "updateSourceLanguage:" + ); + Super = NSObject; + }; + GormLanguageViewController = { + Actions = ( + "updateTargetLanguage:", + "updateSourceLanguage:" + ); + Outlets = ( + targetLanguage, + sourceLanguage + ); + Super = NSViewController; + }; +} \ No newline at end of file diff --git a/English.lproj/GormNSSplitViewInspector.gorm/data.info b/Applications/Gorm/English.lproj/GormLanguageViewController.gorm/data.info similarity index 65% rename from English.lproj/GormNSSplitViewInspector.gorm/data.info rename to Applications/Gorm/English.lproj/GormLanguageViewController.gorm/data.info index 26bb98e9..a97a2a90 100644 Binary files a/English.lproj/GormNSSplitViewInspector.gorm/data.info and b/Applications/Gorm/English.lproj/GormLanguageViewController.gorm/data.info differ diff --git a/Applications/Gorm/English.lproj/GormLanguageViewController.gorm/objects.gorm b/Applications/Gorm/English.lproj/GormLanguageViewController.gorm/objects.gorm new file mode 100644 index 00000000..d3503946 Binary files /dev/null and b/Applications/Gorm/English.lproj/GormLanguageViewController.gorm/objects.gorm differ diff --git a/Applications/Gorm/GNUmakefile b/Applications/Gorm/GNUmakefile new file mode 100644 index 00000000..62fc49f2 --- /dev/null +++ b/Applications/Gorm/GNUmakefile @@ -0,0 +1,171 @@ +# GNUmakefile: main makefile for GNUstep Object Relationship Modeller +# +# Copyright (C) 1999,2002,2003 Free Software Foundation, Inc. +# +# Author: Gregory John Casamento +# Date: 2003 +# Author: Richard Frith-Macdonald +# Date: 1999 +# +# This file is part of GNUstep. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +ifeq ($(GNUSTEP_MAKEFILES),) + GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null) + ifeq ($(GNUSTEP_MAKEFILES),) + $(warning ) + $(warning Unable to obtain GNUSTEP_MAKEFILES setting from gnustep-config!) + $(warning Perhaps gnustep-make is not properly installed,) + $(warning so gnustep-config is not in your PATH.) + $(warning ) + $(warning Your PATH is currently $(PATH)) + $(warning ) + endif +endif + +ifeq ($(GNUSTEP_MAKEFILES),) + $(error You need to set GNUSTEP_MAKEFILES before compiling!) +endif + +PACKAGE_NAME = gorm +export PACKAGE_NAME +include $(GNUSTEP_MAKEFILES)/common.make + +CVS_MODULE_NAME = gorm +SVN_MODULE_NAME = gorm +SVN_BASE_URL = svn+ssh://svn.gna.org/svn/gnustep/apps + + +include ../../Version + +# +# Each palette is a subproject +# +SUBPROJECTS = \ + Palettes + +# +# MAIN APP +# +APP_NAME = Gorm +Gorm_PRINCIPAL_CLASS=Gorm +Gorm_APPLICATION_ICON=Gorm.tiff +Gorm_RESOURCE_FILES = \ + GormInfo.plist \ + Resources/Defaults.plist \ + Resources/language-codes.plist \ + Palettes/0Menus/0Menus.palette \ + Palettes/1Windows/1Windows.palette \ + Palettes/2Controls/2Controls.palette \ + Palettes/3Containers/3Containers.palette \ + Palettes/4Data/4Data.palette \ + Images/FileIcon_gmodel.tiff \ + Images/GormEHCoil.tiff \ + Images/GormEHLine.tiff \ + Images/GormEVCoil.tiff \ + Images/GormEVLine.tiff \ + Images/GormFile.tiff \ + Images/GormMenu.tiff \ + Images/GormMHCoil.tiff \ + Images/GormMHLine.tiff \ + Images/GormMVCoil.tiff \ + Images/GormMVLine.tiff \ + Images/GormNib.tiff \ + Images/GormPalette.tiff \ + Images/Gorm.tiff \ + Images/GormSourceTag.tiff \ + Images/GormTargetTag.tiff \ + Images/GormLinkImage.tiff \ + Images/GormTesting.tiff \ + Images/Sunday_seurat.tiff \ + Images/number_formatter.tiff \ + Images/date_formatter.tiff \ + Images/iconAbove_nib.tiff \ + Images/iconBelow_nib.tiff \ + Images/iconBottomLeft_nib.tiff \ + Images/iconBottom_nib.tiff \ + Images/iconBottomRight_nib.tiff \ + Images/iconCenterLeft_nib.tiff \ + Images/iconCenter_nib.tiff \ + Images/iconCenterRight_nib.tiff \ + Images/iconLeft_nib.tiff \ + Images/iconOnly_nib.tiff \ + Images/iconRight_nib.tiff \ + Images/iconTopLeft_nib.tiff \ + Images/iconTop_nib.tiff \ + Images/iconTopRight_nib.tiff \ + Images/centeralign_nib.tiff \ + Images/justifyalign_nib.tiff \ + Images/leftalign_nib.tiff \ + Images/naturalalign_nib.tiff \ + Images/rightalign_nib.tiff \ + Images/bezel_nib.tiff \ + Images/button_nib.tiff \ + Images/centeralign_nib.tiff \ + Images/iconAbove_nib.tiff \ + Images/iconBelow_nib.tiff \ + Images/iconBottomLeft_nib.tiff \ + Images/iconBottom_nib.tiff \ + Images/iconBottomRight_nib.tiff \ + Images/iconCenterLeft_nib.tiff \ + Images/iconCenter_nib.tiff \ + Images/iconCenterRight_nib.tiff \ + Images/iconLeft_nib.tiff \ + Images/iconOnly_nib.tiff \ + Images/iconRight_nib.tiff \ + Images/iconTopLeft_nib.tiff \ + Images/iconTop_nib.tiff \ + Images/iconTopRight_nib.tiff \ + Images/justifyalign_nib.tiff \ + Images/leftalign_nib.tiff \ + Images/line_nib.tiff \ + Images/naturalalign_nib.tiff \ + Images/noBorder_nib.tiff \ + Images/photoframe_nib.tiff \ + Images/ridge_nib.tiff \ + Images/rightalign_nib.tiff \ + Images/shortbutton_nib.tiff \ + Images/tabbot_nib.tiff \ + Images/tabtop_nib.tiff \ + Images/titleOnly_nib.tiff \ + Images/LeftArr.tiff \ + Images/RightArr.tiff \ + +Gorm_LOCALIZED_RESOURCE_FILES = \ + Gorm.gorm \ + GormLanguageViewController.gorm \ + Gorm.rtfd + +Gorm_LANGUAGES = \ + English + +Gorm_HEADERS = \ + GormAppDelegate.h \ + GormLanguageViewController.h + +Gorm_OBJC_FILES = \ + GormAppDelegate.m \ + GormLanguageViewController.m \ + main.m + +-include GNUmakefile.preamble +-include GNUmakefile.local + +include $(GNUSTEP_MAKEFILES)/aggregate.make +include $(GNUSTEP_MAKEFILES)/application.make + +-include GNUmakefile.postamble diff --git a/Applications/Gorm/GNUmakefile.postamble b/Applications/Gorm/GNUmakefile.postamble new file mode 100644 index 00000000..815ea766 --- /dev/null +++ b/Applications/Gorm/GNUmakefile.postamble @@ -0,0 +1,41 @@ +# +# GNUmakefile.postamble +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# +# Author: Gregory John Casamento +# +# This file is part of GNUstep +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; see the file COPYING.LIB. +# If not, write to the Free Software Foundation, +# 51 Franklin Street, Fifth Floor, Boston, MA 02111 +# USA. +# + +# Define this variable if not defined for backwards-compatibility as +# it is only available in gnustep-make >= 2.0.5 +ifeq ($(LN_S_RECURSIVE),) + LN_S_RECURSIVE = $(LN_S) +endif + +before-all:: + +after-all:: + +after-clean:: + +after-distclean:: + +after-clean:: diff --git a/GNUmakefile.preamble b/Applications/Gorm/GNUmakefile.preamble similarity index 81% rename from GNUmakefile.preamble rename to Applications/Gorm/GNUmakefile.preamble index 9f6674a2..2e0df3b0 100644 --- a/GNUmakefile.preamble +++ b/Applications/Gorm/GNUmakefile.preamble @@ -26,18 +26,17 @@ # ADDITIONAL_OBJCFLAGS += -Wall -Werror ADDITIONAL_GUI_LIBS += \ -lGormCore \ - -lGorm \ -lGormObjCHeaderParser \ - -lGormPrefs + -lInterfaceBuilder \ ADDITIONAL_INCLUDE_DIRS += \ - -IInterfaceBuilder \ - -IGormObjCHeaderParser \ - -IGormPrefs \ - -IGormCore - + -I../../InterfaceBuilder \ + -I../../GormObjCHeaderParser \ + -I../../GormCore \ + -I../.. \ + -I. + ADDITIONAL_LIB_DIRS += \ - -LGormLib/$(GNUSTEP_OBJ_DIR) \ - -LGormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -LGormPrefs/$(GNUSTEP_OBJ_DIR) \ - -LGormCore/$(GNUSTEP_OBJ_DIR) + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../GormCore/GormCore.framework \ diff --git a/Gorm.spec.in b/Applications/Gorm/Gorm.spec.in similarity index 100% rename from Gorm.spec.in rename to Applications/Gorm/Gorm.spec.in diff --git a/Applications/Gorm/GormAppDelegate.h b/Applications/Gorm/GormAppDelegate.h new file mode 100644 index 00000000..9d29f7c2 --- /dev/null +++ b/Applications/Gorm/GormAppDelegate.h @@ -0,0 +1,98 @@ +/* GormAppDelegate.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#ifndef GormAppDelegate_H_INCLUDE +#define GormAppDelegate_H_INCLUDE + +#import + +#import +#import + +#import + +@class NSDictionary; +@class NSImage; +@class NSMenu; +@class NSMutableArray; +@class NSSet; +@class GormLanguageViewController; + +@interface GormAppDelegate : GormAbstractDelegate +{ + @private + GormLanguageViewController *_vc; +} + +// preferences +- (IBAction) preferencesPanel: (id) sender; + +// Cut/Paste operations +- (IBAction) copy: (id)sender; +- (IBAction) cut: (id)sender; +- (IBAction) paste: (id)sender; +- (IBAction) delete: (id)sender; +- (IBAction) selectAllItems: (id)sender; + +// palettes/inspectors. +- (IBAction) inspector: (id) sender; +- (IBAction) palettes: (id) sender; +- (IBAction) loadPalette: (id) sender; + +// sound & images +- (IBAction) loadSound: (id) sender; +- (IBAction) loadImage: (id) sender; + +// grouping/layout +- (IBAction) groupSelectionInSplitView: (id)sender; +- (IBAction) groupSelectionInBox: (id)sender; +- (IBAction) groupSelectionInScrollView: (id)sender; +- (IBAction) ungroup: (id)sender; + +// Classes actions +- (IBAction) createSubclass: (id)sender; +- (IBAction) loadClass: (id)sender; +- (IBAction) createClassFiles: (id)sender; +- (IBAction) instantiateClass: (id)sender; +- (IBAction) addAttributeToClass: (id)sender; +- (IBAction) remove: (id)sender; + +// Palettes Actions... +- (IBAction) inspector: (id) sender; +- (IBAction) palettes: (id) sender; +- (IBAction) loadPalette: (id) sender; + +// Translation +- (IBAction) importXLIFFDocument: (id)sender; +- (IBAction) exportXLIFFDocument: (id)sender; +- (IBAction) translate: (id)sender; +- (IBAction) exportStrings: (id)sender; + +// Print +- (IBAction) print: (id)sender; + +@end + +#endif // GormAppDelegate_H_INCLUDE diff --git a/Applications/Gorm/GormAppDelegate.m b/Applications/Gorm/GormAppDelegate.m new file mode 100644 index 00000000..956af648 --- /dev/null +++ b/Applications/Gorm/GormAppDelegate.m @@ -0,0 +1,791 @@ +/* GormAppDelegate.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#import +#import +#import + +#import +#import + +#import "GormAppDelegate.h" +#import "GormLanguageViewController.h" + +@interface GormDocument (Private) + +- (NSMutableArray *) _collectAllObjects; + +@end + +@implementation GormAppDelegate + +// App delegate... +- (BOOL)applicationShouldOpenUntitledFile: (NSApplication *)sender +{ + if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) == + NSWindows95InterfaceStyle) + { + return YES; + } + + return NO; +} + +- (void) applicationOpenUntitledFile: (NSApplication *)sender +{ + GormDocumentController *dc = [GormDocumentController sharedDocumentController]; + // open a new document and build an application type document by default... + [dc newDocument: sender]; +} + + +- (void) applicationDidFinishLaunching: (NSNotification *)n +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + if ( [defaults boolForKey: @"ShowInspectors"] ) + { + [[[self inspectorsManager] panel] makeKeyAndOrderFront: self]; + } + if ( [defaults boolForKey: @"ShowPalettes"] ) + { + [[[self palettesManager] panel] makeKeyAndOrderFront: self]; + } +} + +- (void) applicationWillTerminate: (NSNotification *)n +{ + [[NSUserDefaults standardUserDefaults] + setBool: [[[self inspectorsManager] panel] isVisible] + forKey: @"ShowInspectors"]; + [[NSUserDefaults standardUserDefaults] + setBool: [[[self palettesManager] panel] isVisible] + forKey: @"ShowPalettes"]; +} + +- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *)sender +{ + if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) == + NSWindows95InterfaceStyle) + { + GormDocumentController *docController; + docController = [GormDocumentController sharedDocumentController]; + + if ([[docController documents] count] > 0) + { + return NO; + } + else + { + return YES; + } + } + + return NO; +} + + +- (BOOL) validateMenuItem: (NSMenuItem*)item +{ + GormDocument *active = (GormDocument*)[self activeDocument]; + SEL action = [item action]; + GormClassManager *cm = nil; + NSArray *s = nil; + + // if we have an active document... + if(active != nil) + { + cm = [active classManager]; + s = [_selectionOwner selection]; + } + + if(sel_isEqual(action, @selector(loadPalette:))) + { + return YES; + } + else if (sel_isEqual(action, @selector(close:)) + || sel_isEqual(action, @selector(miniaturize:))) + { + if (active == nil) + { + return NO; + } + } + else if (sel_isEqual(action, @selector(testInterface:))) + { + if (active == nil) + { + return NO; + } + } + else if (sel_isEqual(action, @selector(copy:))) + { + if ([s count] == 0) + { + return NO; + } + else + { + id o = [s objectAtIndex: 0]; + NSString *n = [active nameForObject: o]; + if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"]) + { + return NO; + } + } + + return [_selectionOwner respondsToSelector: @selector(copySelection)]; + } + else if (sel_isEqual(action, @selector(cut:))) + { + if ([s count] == 0) + { + return NO; + } + else + { + id o = [s objectAtIndex: 0]; + NSString *n = [active nameForObject: o]; + if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"]) + { + return NO; + } + } + + return ([_selectionOwner respondsToSelector: @selector(copySelection)] + && [_selectionOwner respondsToSelector: @selector(deleteSelection)]); + } + else if (sel_isEqual(action, @selector(delete:))) + { + if ([s count] == 0) + { + return NO; + } + else + { + id o = [s objectAtIndex: 0]; + NSString *n = [active nameForObject: o]; + if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"]) + { + return NO; + } + } + + return [_selectionOwner respondsToSelector: @selector(deleteSelection)]; + } + else if (sel_isEqual(action, @selector(paste:))) + { + if ([s count] == 0) + { + return NO; + } + else + { + id o = [s objectAtIndex: 0]; + NSString *n = [active nameForObject: o]; + + if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"]) + { + return NO; + } + } + + return [_selectionOwner respondsToSelector: @selector(pasteInSelection)]; + } + else if (sel_isEqual(action, @selector(setName:))) + { + NSString *n; + id o; + + if ([s count] == 0) + { + return NO; + } + if ([s count] > 1) + { + return NO; + } + o = [s objectAtIndex: 0]; + n = [active nameForObject: o]; + + if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"] + || [n isEqual: @"NSFont"] || [n isEqual: @"NSMenu"]) + { + return NO; + } + else if(![active isTopLevelObject: o]) + { + return NO; + } + } + else if(sel_isEqual(action, @selector(createSubclass:)) || + sel_isEqual(action, @selector(loadClass:)) || + sel_isEqual(action, @selector(createClassFiles:)) || + sel_isEqual(action, @selector(instantiateClass:)) || + sel_isEqual(action, @selector(addAttributeToClass:)) || + sel_isEqual(action, @selector(remove:))) + { + if(active == nil) + { + return NO; + } + + if(![active isEditingClasses]) + { + return NO; + } + + if(sel_isEqual(action, @selector(createSubclass:))) + { + NSArray *s = [_selectionOwner selection]; + id o = nil; + NSString *name = nil; + + if([s count] == 0 || [s count] > 1) + return NO; + + o = [s objectAtIndex: 0]; + name = [o className]; + + if([active classIsSelected] == NO) + { + return NO; + } + + if([name isEqual: @"FirstResponder"]) + return NO; + } + + if(sel_isEqual(action, @selector(createClassFiles:)) || + sel_isEqual(action, @selector(remove:))) + { + id o = nil; + NSString *name = nil; + + if ([s count] == 0) + { + return NO; + } + if ([s count] > 1) + { + return NO; + } + + o = [s objectAtIndex: 0]; + name = [o className]; + if(![cm isCustomClass: name]) + { + return NO; + } + } + + if(sel_isEqual(action, @selector(instantiateClass:))) + { + id o = nil; + NSString *name = nil; + + if ([s count] == 0) + { + return NO; + } + if ([s count] > 1) + { + return NO; + } + + if([active classIsSelected] == NO) + { + return NO; + } + + o = [s objectAtIndex: 0]; + name = [o className]; + if(name != nil) + { + id cm = [self classManager]; + return [cm canInstantiateClassNamed: name]; + } + } + } + else if(sel_isEqual(action, @selector(loadSound:)) || + sel_isEqual(action, @selector(loadImage:)) || + sel_isEqual(action, @selector(debug:))) + { + if(active == nil) + { + return NO; + } + } + + return YES; +} + + +- (IBAction) stop: (id)sender +{ + if(_isTesting == NO) + { + // [super stop: sender]; + } + else + { + [self endTesting: sender]; + } +} + +- (IBAction) miniaturize: (id)sender +{ + NSWindow *window = [(GormDocument *)[self activeDocument] window]; + + [window miniaturize: self]; +} + +/** Info Menu Actions */ +- (IBAction) preferencesPanel: (id) sender +{ + if(! _preferencesController) + { + _preferencesController = [[GormPrefController alloc] init]; + } + + [[_preferencesController panel] makeKeyAndOrderFront:nil]; +} + +/** Document Menu Actions */ +- (IBAction) close: (id)sender +{ + GormDocument *document = (GormDocument *)[self activeDocument]; + if([document canCloseDocument]) + { + [document close]; + } +} + +- (IBAction) debug: (id) sender +{ + [[self activeDocument] performSelector: @selector(printAllEditors)]; +} + +- (IBAction) loadSound: (id) sender +{ + [(GormDocument *)[self activeDocument] openSound: sender]; +} + +- (IBAction) loadImage: (id) sender +{ + [(GormDocument *)[self activeDocument] openImage: sender]; +} + + +/** Edit Menu Actions */ + +- (IBAction) copy: (id)sender +{ + if ([[_selectionOwner selection] count] == 0 + || [_selectionOwner respondsToSelector: @selector(copySelection)] == NO) + return; + + if([self isConnecting]) + { + [self stopConnecting]; + } + + [(id)_selectionOwner copySelection]; +} + + +- (IBAction) cut: (id)sender +{ + if ([[_selectionOwner selection] count] == 0 + || [_selectionOwner respondsToSelector: @selector(copySelection)] == NO + || [_selectionOwner respondsToSelector: @selector(deleteSelection)] == NO) + return; + + if([self isConnecting]) + { + [self stopConnecting]; + } + + [(id)_selectionOwner copySelection]; + [(id)_selectionOwner deleteSelection]; +} + +- (IBAction) paste: (id)sender +{ + if ([_selectionOwner respondsToSelector: @selector(pasteInSelection)] == NO) + return; + + if([self isConnecting]) + { + [self stopConnecting]; + } + + [(id)_selectionOwner pasteInSelection]; +} + + +- (IBAction) delete: (id)sender +{ + if ([[_selectionOwner selection] count] == 0 + || [_selectionOwner respondsToSelector: @selector(deleteSelection)] == NO) + return; + + if([self isConnecting]) + { + [self stopConnecting]; + } + + [(id)_selectionOwner deleteSelection]; +} + +- (IBAction) selectAll: (id)sender +{ + if ([[_selectionOwner selection] count] == 0 + || [_selectionOwner respondsToSelector: @selector(deleteSelection)] == NO) + return; + + if([self isConnecting]) + { + [self stopConnecting]; + } + + [(id)_selectionOwner deleteSelection]; +} + +- (IBAction) selectAllItems: (id)sender +{ + return; +} + +/** Grouping */ + +- (IBAction) groupSelectionInSplitView: (id)sender +{ + if ([[_selectionOwner selection] count] < 2 + || [_selectionOwner respondsToSelector: @selector(groupSelectionInSplitView)] == NO) + return; + + [(GormGenericEditor *)_selectionOwner groupSelectionInSplitView]; +} + +- (IBAction) groupSelectionInBox: (id)sender +{ + if ([_selectionOwner respondsToSelector: @selector(groupSelectionInBox)] == NO) + return; + [(GormGenericEditor *)_selectionOwner groupSelectionInBox]; +} + +- (IBAction) groupSelectionInView: (id)sender +{ + if ([_selectionOwner respondsToSelector: @selector(groupSelectionInView)] == NO) + return; + [(GormGenericEditor *)_selectionOwner groupSelectionInView]; +} + +- (IBAction) groupSelectionInScrollView: (id)sender +{ + if ([_selectionOwner respondsToSelector: @selector(groupSelectionInScrollView)] == NO) + return; + [(GormGenericEditor *)_selectionOwner groupSelectionInScrollView]; +} + +- (IBAction) groupSelectionInMatrix: (id)sender +{ + if ([_selectionOwner respondsToSelector: @selector(groupSelectionInMatrix)] == NO) + return; + [(GormGenericEditor *)_selectionOwner groupSelectionInMatrix]; +} + +- (IBAction) ungroup: (id)sender +{ + // NSLog(@"ungroup: _selectionOwner %@", _selectionOwner); + if ([_selectionOwner respondsToSelector: @selector(ungroup)] == NO) + return; + [(GormGenericEditor *)_selectionOwner ungroup]; +} + +/** Classes actions */ + +- (IBAction) createSubclass: (id)sender +{ + [(GormDocument *)[self activeDocument] createSubclass: sender]; +} + +- (IBAction) loadClass: (id)sender +{ + // Call the current document and create the class + // descibed by the header + [(GormDocument *)[self activeDocument] loadClass: sender]; +} + +- (IBAction) createClassFiles: (id)sender +{ + [(GormDocument *)[self activeDocument] createClassFiles: sender]; +} + +- (IBAction) instantiateClass: (id)sender +{ + [(GormDocument *)[self activeDocument] instantiateClass: sender]; +} + +- (IBAction) addAttributeToClass: (id)sender +{ + [(GormDocument *)[self activeDocument] addAttributeToClass: sender]; +} + +- (IBAction) remove: (id)sender +{ + [(GormDocument *)[self activeDocument] remove: sender]; +} + +/** Palettes Actions... */ + +- (IBAction) inspector: (id) sender +{ + [[[self inspectorsManager] panel] makeKeyAndOrderFront: self]; +} + +- (IBAction) palettes: (id) sender +{ + [[[self palettesManager] panel] makeKeyAndOrderFront: self]; +} + +- (IBAction) loadPalette: (id) sender +{ + [[self palettesManager] openPalette: sender]; +} + +// Translation +- (IBAction) importXLIFFDocument: (id)sender +{ + NSArray *fileTypes = [NSArray arrayWithObjects: @"xliff", nil]; + NSOpenPanel *oPanel = [NSOpenPanel openPanel]; + int result; + + [oPanel setAllowsMultipleSelection: NO]; + [oPanel setCanChooseFiles: YES]; + [oPanel setCanChooseDirectories: NO]; + result = [oPanel runModalForDirectory: nil + file: nil + types: fileTypes]; + if (result == NSOKButton) + { + GormDocument *doc = (GormDocument *)[self activeDocument]; + NSMutableArray *allObjects = [doc _collectAllObjects]; + NSString *filename = [oPanel filename]; + NSEnumerator *en = nil; + id obj = nil; + BOOL result = NO; + + NS_DURING + { + GormXLIFFDocument *xd = [GormXLIFFDocument xliffWithGormDocument: doc]; + result = [xd importXLIFFDocumentWithName: filename]; + } + NS_HANDLER + { + NSString *message = [localException reason]; + NSRunAlertPanel(_(@"Problem loading XLIFF"), + message, nil, nil, nil); + } + NS_ENDHANDLER; + + // If actual translation was done, then refresh the objects... + if (result == YES) + { + [doc touch]; // mark the document as modified... + + // change to translated values. + en = [allObjects objectEnumerator]; + while((obj = [en nextObject]) != nil) + { + if([obj isKindOfClass: [NSView class]]) + { + [obj setNeedsDisplay: YES]; + } + + // redisplay/flush, if the object is a window. + if([obj isKindOfClass: [NSWindow class]]) + { + NSWindow *w = (NSWindow *)obj; + [w setViewsNeedDisplay: YES]; + [w disableFlushWindow]; + [[w contentView] setNeedsDisplay: YES]; + [[w contentView] displayIfNeeded]; + [w enableFlushWindow]; + [w flushWindowIfNeeded]; + } + } + } + } +} + +- (IBAction) exportXLIFFDocument: (id)sender +{ + NSSavePanel *savePanel = [NSSavePanel savePanel]; + NSBundle *bundle = [NSBundle bundleForClass: [GormLanguageViewController class]]; + NSModalResponse result = 0; + GormDocument *doc = (GormDocument *)[self activeDocument]; + + if (doc != nil) + { + NSString *fn = [[doc fileURL] path]; + + fn = [[fn lastPathComponent] stringByDeletingPathExtension]; + fn = [fn stringByAppendingPathExtension: @"xliff"]; + _vc = [[GormLanguageViewController alloc] + initWithNibName: @"GormLanguageViewController" + bundle: bundle]; + + + NSDebugLog(@"view = %@, _vc = %@", [_vc view], _vc); + + [savePanel setTitle: @"Export XLIFF"]; + [savePanel setAccessoryView: [_vc view]]; + [savePanel setDelegate: self]; + // [savePanel setURL: [NSURL fileURLWithPath: fn]]; + + result = [savePanel runModalForDirectory: nil + file: fn]; + if (NSModalResponseOK == result) + { + NSString *filename = [[savePanel URL] path]; + GormXLIFFDocument *xd = [GormXLIFFDocument xliffWithGormDocument: doc]; + + [xd exportXLIFFDocumentWithName: filename + withSourceLanguage: [_vc sourceLanguageIdentifier] + andTargetLanguage: [_vc targetLanguageIdentifier]]; + } + } +} + +- (NSString *) panel: (id)sender + userEnteredFilename: (NSString *)filename + confirmed: (BOOL)flag +{ + if (flag == YES) + { + NSDebugLog(@"Writing the document... %@", filename); + } + else + { + NSDebugLog(@"%@ not saved", filename); + } + return filename; +} + +/** + * This method is used to translate all of the strings in the file from one language + * into another. This is helpful when attempting to translate an application for use + * in different locales. + */ +- (IBAction) translate: (id)sender +{ + NSArray *fileTypes = [NSArray arrayWithObjects: @"strings", nil]; + NSOpenPanel *oPanel = [NSOpenPanel openPanel]; + int result; + + [oPanel setAllowsMultipleSelection: NO]; + [oPanel setCanChooseFiles: YES]; + [oPanel setCanChooseDirectories: NO]; + result = [oPanel runModalForDirectory: nil + file: nil + types: fileTypes]; + if (result == NSOKButton) + { + GormDocument *doc = (GormDocument *)[self activeDocument]; + NSMutableArray *allObjects = [doc _collectAllObjects]; + NSString *filename = [oPanel filename]; + NSEnumerator *en = nil; + id obj = nil; + + NS_DURING + { + [doc importStringsFromFile: filename]; + } + NS_HANDLER + { + NSString *message = [localException reason]; + NSRunAlertPanel(_(@"Problem loading strings"), + message, nil, nil, nil); + } + NS_ENDHANDLER; + + [doc touch]; // mark the document as modified... + + // change to translated values. + en = [allObjects objectEnumerator]; + while((obj = [en nextObject]) != nil) + { + if([obj isKindOfClass: [NSView class]]) + { + [obj setNeedsDisplay: YES]; + } + + // redisplay/flush, if the object is a window. + if([obj isKindOfClass: [NSWindow class]]) + { + NSWindow *w = (NSWindow *)obj; + [w setViewsNeedDisplay: YES]; + [w disableFlushWindow]; + [[w contentView] setNeedsDisplay: YES]; + [[w contentView] displayIfNeeded]; + [w enableFlushWindow]; + [w flushWindowIfNeeded]; + } + } + } +} + +/** + * This method is used to export all strings in a document to a file for Language + * translation. This allows the user to see all of the strings which can be translated + * and allows the user to provide a translateion for each of them. + */ +- (IBAction) exportStrings: (id)sender +{ + NSSavePanel *sp = [NSSavePanel savePanel]; + int result; + + [sp setRequiredFileType: @"strings"]; + [sp setTitle: _(@"Save strings file as...")]; + result = [sp runModalForDirectory: NSHomeDirectory() + file: nil]; + if (result == NSOKButton) + { + NSString *filename = [sp filename]; + GormDocument *doc = (GormDocument *)[self activeDocument]; + + [doc exportStringsToFile: filename]; + } +} + +// Print +- (IBAction) print: (id) sender +{ + [[NSApp keyWindow] print: sender]; +} + +@end diff --git a/GormInfo.plist b/Applications/Gorm/GormInfo.plist similarity index 89% rename from GormInfo.plist rename to Applications/Gorm/GormInfo.plist index dc19a7d6..a16c5a30 100644 --- a/GormInfo.plist +++ b/Applications/Gorm/GormInfo.plist @@ -1,7 +1,9 @@ { NSIcon = "Gorm.tiff"; NSMainNibFile = "Gorm.gorm"; + NSPrincipalClass = "NSApplication"; NSRole = "Editor"; + NSTypes = ( { NSName = "GSGormFileType"; @@ -22,7 +24,7 @@ { NSName = "GSNibFileType"; NSHumanReadableName = "Cocoa Nib"; - NSRole = Viewer; + NSRole = Editor; NSDocumentClass = GormDocument; NSUnixExtensions = ( "nib" ); NSIcon = "GormNib.tiff"; @@ -38,7 +40,7 @@ { NSName = "GSXibFileType"; NSHumanReadableName = "Cocoa Xib"; - NSRole = Viewer; + NSRole = Editor; NSDocumentClass = GormDocument; NSUnixExtensions = ( "xib" ); NSIcon = "GormNib.tiff"; @@ -48,18 +50,19 @@ NSIcon = "GormPalette.tiff"; } ); + ApplicationDescription = "[GNUstep | Graphical] Object Relationship Modeller"; ApplicationIcon = "Gorm.tiff"; ApplicationName = "Gorm"; - ApplicationRelease = "Gorm 1.3.1 (Release)"; + ApplicationRelease = "Gorm 1.5.0 (Unreleased)"; Authors = ("Gregory John Casamento ", "Adam Fedor ", "Richard Frith-Macdonald ", "Wolfgang Lux ", "Pierre-Yves Rivaille ", "Sergii Stoian "); - Copyright = "Copyright (C) 1999-2022 FSF"; + Copyright = "Copyright (C) 1999-2023 FSF"; CopyrightDescription = "Released under the GNU General Public License 3.0"; - NSBuildVersion = "1.3.1 Jan 15 2022"; + NSBuildVersion = "1.5.0"; GSDesktopInstallationDomain=SYSTEM; } diff --git a/Applications/Gorm/GormLanguageViewController.h b/Applications/Gorm/GormLanguageViewController.h new file mode 100644 index 00000000..6062e388 --- /dev/null +++ b/Applications/Gorm/GormLanguageViewController.h @@ -0,0 +1,52 @@ +/* GormLanguageViewController.h + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + */ + +#ifndef GormLanguageViewController_H_INCLUDE +#define GormLanguageViewController_H_INCLUDE + +#import + +@class NSDictionary, NSString; + +@interface GormLanguageViewController : NSViewController +{ + IBOutlet id targetLanguage; + IBOutlet id sourceLanguage; + + NSString *sourceLanguageIdentifier; + NSString *targetLanguageIdentifier; + + NSDictionary *ldict; +} + +- (IBAction) updateTargetLanguage: (id)sender; +- (IBAction) updateSourceLanguage: (id)sender; + +- (NSString *) sourceLanguageIdentifier; +- (NSString *) targetLanguageIdentifier; + + +@end + +#endif // GormLanguageViewController_H_INCLUDE diff --git a/Applications/Gorm/GormLanguageViewController.m b/Applications/Gorm/GormLanguageViewController.m new file mode 100644 index 00000000..fe7e32e2 --- /dev/null +++ b/Applications/Gorm/GormLanguageViewController.m @@ -0,0 +1,119 @@ +/* GormLanguageViewController.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + */ + +#import +#import +#import +#import + +#import + +#import "GormLanguageViewController.h" + +@implementation GormLanguageViewController + +- (void) selectPreferredLanguage +{ + NSString *language = [[NSLocale preferredLanguages] objectAtIndex: 0]; + NSInteger i = [[ldict allKeys] indexOfObject: language]; + + NSDebugLog(@"language = %@", language); + + // Set the default translation to the current language + [sourceLanguage selectItemAtIndex: i]; + [targetLanguage selectItemAtIndex: i]; + + // Set them since the above doesn't invoke the method that sets them. + [self updateTargetLanguage: self]; + [self updateSourceLanguage: self]; +} + + +- (void) viewDidLoad +{ + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + NSString *path = [bundle pathForResource: @"language-codes" ofType: @"plist"]; + + [super viewDidLoad]; + if (path != nil) + { + [targetLanguage removeAllItems]; + [sourceLanguage removeAllItems]; + + NSDebugLog(@"path = %@", path); + + ldict = [[NSDictionary alloc] initWithContentsOfFile: path]; + if (ldict != nil) + { + NSEnumerator *en = [ldict keyEnumerator]; + id k = nil; + + while ((k = [en nextObject]) != nil) + { + NSString *v = [ldict objectForKey: k]; + NSString *itemTitle = [NSString stringWithFormat: @"%@ (%@)", k, v]; + + [targetLanguage addItemWithTitle: itemTitle]; + [sourceLanguage addItemWithTitle: itemTitle]; + } + + // Select preferred language in pop up... + [self selectPreferredLanguage]; + } + } + else + { + NSLog(@"Unable to load language codes"); + } +} + +- (void) dealloc +{ + RELEASE(ldict); + [super dealloc]; +} + +- (IBAction) updateTargetLanguage: (id)sender +{ + NSInteger i = [targetLanguage indexOfSelectedItem]; + targetLanguageIdentifier = [[ldict allKeys] objectAtIndex: i]; +} + +- (IBAction) updateSourceLanguage: (id)sender +{ + NSInteger i = [sourceLanguage indexOfSelectedItem]; + sourceLanguageIdentifier = [[ldict allKeys] objectAtIndex: i]; +} + +- (NSString *) sourceLanguageIdentifier +{ + return sourceLanguageIdentifier; +} + +- (NSString *) targetLanguageIdentifier +{ + return targetLanguageIdentifier; +} + +@end diff --git a/INSTALL b/Applications/Gorm/INSTALL similarity index 100% rename from INSTALL rename to Applications/Gorm/INSTALL diff --git a/Images/FileIcon_gmodel.tiff b/Applications/Gorm/Images/FileIcon_gmodel.tiff old mode 100755 new mode 100644 similarity index 100% rename from Images/FileIcon_gmodel.tiff rename to Applications/Gorm/Images/FileIcon_gmodel.tiff diff --git a/Images/Gorm.tiff b/Applications/Gorm/Images/Gorm.tiff similarity index 100% rename from Images/Gorm.tiff rename to Applications/Gorm/Images/Gorm.tiff diff --git a/Images/GormEHCoil.tiff b/Applications/Gorm/Images/GormEHCoil.tiff similarity index 100% rename from Images/GormEHCoil.tiff rename to Applications/Gorm/Images/GormEHCoil.tiff diff --git a/Images/GormEHLine.tiff b/Applications/Gorm/Images/GormEHLine.tiff similarity index 100% rename from Images/GormEHLine.tiff rename to Applications/Gorm/Images/GormEHLine.tiff diff --git a/Images/GormEVCoil.tiff b/Applications/Gorm/Images/GormEVCoil.tiff similarity index 100% rename from Images/GormEVCoil.tiff rename to Applications/Gorm/Images/GormEVCoil.tiff diff --git a/Images/GormEVLine.tiff b/Applications/Gorm/Images/GormEVLine.tiff similarity index 100% rename from Images/GormEVLine.tiff rename to Applications/Gorm/Images/GormEVLine.tiff diff --git a/Images/GormFile.tiff b/Applications/Gorm/Images/GormFile.tiff similarity index 100% rename from Images/GormFile.tiff rename to Applications/Gorm/Images/GormFile.tiff diff --git a/Images/GormLinkImage.tiff b/Applications/Gorm/Images/GormLinkImage.tiff similarity index 100% rename from Images/GormLinkImage.tiff rename to Applications/Gorm/Images/GormLinkImage.tiff diff --git a/Images/GormMHCoil.tiff b/Applications/Gorm/Images/GormMHCoil.tiff similarity index 100% rename from Images/GormMHCoil.tiff rename to Applications/Gorm/Images/GormMHCoil.tiff diff --git a/Images/GormMHLine.tiff b/Applications/Gorm/Images/GormMHLine.tiff similarity index 100% rename from Images/GormMHLine.tiff rename to Applications/Gorm/Images/GormMHLine.tiff diff --git a/Images/GormMVCoil.tiff b/Applications/Gorm/Images/GormMVCoil.tiff similarity index 100% rename from Images/GormMVCoil.tiff rename to Applications/Gorm/Images/GormMVCoil.tiff diff --git a/Images/GormMVLine.tiff b/Applications/Gorm/Images/GormMVLine.tiff similarity index 100% rename from Images/GormMVLine.tiff rename to Applications/Gorm/Images/GormMVLine.tiff diff --git a/Images/GormMenu.tiff b/Applications/Gorm/Images/GormMenu.tiff similarity index 100% rename from Images/GormMenu.tiff rename to Applications/Gorm/Images/GormMenu.tiff diff --git a/Images/GormNib.tiff b/Applications/Gorm/Images/GormNib.tiff similarity index 100% rename from Images/GormNib.tiff rename to Applications/Gorm/Images/GormNib.tiff diff --git a/Images/GormPalette.tiff b/Applications/Gorm/Images/GormPalette.tiff similarity index 100% rename from Images/GormPalette.tiff rename to Applications/Gorm/Images/GormPalette.tiff diff --git a/Images/GormSourceTag.tiff b/Applications/Gorm/Images/GormSourceTag.tiff old mode 100755 new mode 100644 similarity index 100% rename from Images/GormSourceTag.tiff rename to Applications/Gorm/Images/GormSourceTag.tiff diff --git a/Images/GormTargetTag.tiff b/Applications/Gorm/Images/GormTargetTag.tiff old mode 100755 new mode 100644 similarity index 100% rename from Images/GormTargetTag.tiff rename to Applications/Gorm/Images/GormTargetTag.tiff diff --git a/Images/GormTesting.tiff b/Applications/Gorm/Images/GormTesting.tiff similarity index 100% rename from Images/GormTesting.tiff rename to Applications/Gorm/Images/GormTesting.tiff diff --git a/Images/LeftArr.tiff b/Applications/Gorm/Images/LeftArr.tiff similarity index 100% rename from Images/LeftArr.tiff rename to Applications/Gorm/Images/LeftArr.tiff diff --git a/Images/RightArr.tiff b/Applications/Gorm/Images/RightArr.tiff similarity index 100% rename from Images/RightArr.tiff rename to Applications/Gorm/Images/RightArr.tiff diff --git a/Images/Sunday_seurat.tiff b/Applications/Gorm/Images/Sunday_seurat.tiff similarity index 100% rename from Images/Sunday_seurat.tiff rename to Applications/Gorm/Images/Sunday_seurat.tiff diff --git a/Images/bezel_nib.tiff b/Applications/Gorm/Images/bezel_nib.tiff similarity index 100% rename from Images/bezel_nib.tiff rename to Applications/Gorm/Images/bezel_nib.tiff diff --git a/Images/button_nib.tiff b/Applications/Gorm/Images/button_nib.tiff similarity index 100% rename from Images/button_nib.tiff rename to Applications/Gorm/Images/button_nib.tiff diff --git a/Images/centeralign_nib.tiff b/Applications/Gorm/Images/centeralign_nib.tiff similarity index 100% rename from Images/centeralign_nib.tiff rename to Applications/Gorm/Images/centeralign_nib.tiff diff --git a/Images/date_formatter.tiff b/Applications/Gorm/Images/date_formatter.tiff similarity index 100% rename from Images/date_formatter.tiff rename to Applications/Gorm/Images/date_formatter.tiff diff --git a/Images/iconAbove_nib.tiff b/Applications/Gorm/Images/iconAbove_nib.tiff similarity index 100% rename from Images/iconAbove_nib.tiff rename to Applications/Gorm/Images/iconAbove_nib.tiff diff --git a/Images/iconBelow_nib.tiff b/Applications/Gorm/Images/iconBelow_nib.tiff similarity index 100% rename from Images/iconBelow_nib.tiff rename to Applications/Gorm/Images/iconBelow_nib.tiff diff --git a/Images/iconBottomLeft_nib.tiff b/Applications/Gorm/Images/iconBottomLeft_nib.tiff similarity index 100% rename from Images/iconBottomLeft_nib.tiff rename to Applications/Gorm/Images/iconBottomLeft_nib.tiff diff --git a/Images/iconBottomRight_nib.tiff b/Applications/Gorm/Images/iconBottomRight_nib.tiff similarity index 100% rename from Images/iconBottomRight_nib.tiff rename to Applications/Gorm/Images/iconBottomRight_nib.tiff diff --git a/Images/iconBottom_nib.tiff b/Applications/Gorm/Images/iconBottom_nib.tiff similarity index 100% rename from Images/iconBottom_nib.tiff rename to Applications/Gorm/Images/iconBottom_nib.tiff diff --git a/Images/iconCenterLeft_nib.tiff b/Applications/Gorm/Images/iconCenterLeft_nib.tiff similarity index 100% rename from Images/iconCenterLeft_nib.tiff rename to Applications/Gorm/Images/iconCenterLeft_nib.tiff diff --git a/Images/iconCenterRight_nib.tiff b/Applications/Gorm/Images/iconCenterRight_nib.tiff similarity index 100% rename from Images/iconCenterRight_nib.tiff rename to Applications/Gorm/Images/iconCenterRight_nib.tiff diff --git a/Images/iconCenter_nib.tiff b/Applications/Gorm/Images/iconCenter_nib.tiff similarity index 100% rename from Images/iconCenter_nib.tiff rename to Applications/Gorm/Images/iconCenter_nib.tiff diff --git a/Images/iconLeft_nib.tiff b/Applications/Gorm/Images/iconLeft_nib.tiff similarity index 100% rename from Images/iconLeft_nib.tiff rename to Applications/Gorm/Images/iconLeft_nib.tiff diff --git a/Images/iconOnly_nib.tiff b/Applications/Gorm/Images/iconOnly_nib.tiff similarity index 100% rename from Images/iconOnly_nib.tiff rename to Applications/Gorm/Images/iconOnly_nib.tiff diff --git a/Images/iconRight_nib.tiff b/Applications/Gorm/Images/iconRight_nib.tiff similarity index 100% rename from Images/iconRight_nib.tiff rename to Applications/Gorm/Images/iconRight_nib.tiff diff --git a/Images/iconTopLeft_nib.tiff b/Applications/Gorm/Images/iconTopLeft_nib.tiff similarity index 100% rename from Images/iconTopLeft_nib.tiff rename to Applications/Gorm/Images/iconTopLeft_nib.tiff diff --git a/Images/iconTopRight_nib.tiff b/Applications/Gorm/Images/iconTopRight_nib.tiff similarity index 100% rename from Images/iconTopRight_nib.tiff rename to Applications/Gorm/Images/iconTopRight_nib.tiff diff --git a/Images/iconTop_nib.tiff b/Applications/Gorm/Images/iconTop_nib.tiff similarity index 100% rename from Images/iconTop_nib.tiff rename to Applications/Gorm/Images/iconTop_nib.tiff diff --git a/Images/justifyalign_nib.tiff b/Applications/Gorm/Images/justifyalign_nib.tiff similarity index 100% rename from Images/justifyalign_nib.tiff rename to Applications/Gorm/Images/justifyalign_nib.tiff diff --git a/Images/leftalign_nib.tiff b/Applications/Gorm/Images/leftalign_nib.tiff similarity index 100% rename from Images/leftalign_nib.tiff rename to Applications/Gorm/Images/leftalign_nib.tiff diff --git a/Images/line_nib.tiff b/Applications/Gorm/Images/line_nib.tiff similarity index 100% rename from Images/line_nib.tiff rename to Applications/Gorm/Images/line_nib.tiff diff --git a/Images/naturalalign_nib.tiff b/Applications/Gorm/Images/naturalalign_nib.tiff similarity index 100% rename from Images/naturalalign_nib.tiff rename to Applications/Gorm/Images/naturalalign_nib.tiff diff --git a/Images/noBorder_nib.tiff b/Applications/Gorm/Images/noBorder_nib.tiff similarity index 100% rename from Images/noBorder_nib.tiff rename to Applications/Gorm/Images/noBorder_nib.tiff diff --git a/Images/number_formatter.tiff b/Applications/Gorm/Images/number_formatter.tiff similarity index 100% rename from Images/number_formatter.tiff rename to Applications/Gorm/Images/number_formatter.tiff diff --git a/Images/photoframe_nib.tiff b/Applications/Gorm/Images/photoframe_nib.tiff similarity index 100% rename from Images/photoframe_nib.tiff rename to Applications/Gorm/Images/photoframe_nib.tiff diff --git a/Images/ridge_nib.tiff b/Applications/Gorm/Images/ridge_nib.tiff similarity index 100% rename from Images/ridge_nib.tiff rename to Applications/Gorm/Images/ridge_nib.tiff diff --git a/Images/rightalign_nib.tiff b/Applications/Gorm/Images/rightalign_nib.tiff similarity index 100% rename from Images/rightalign_nib.tiff rename to Applications/Gorm/Images/rightalign_nib.tiff diff --git a/Images/shortbutton_nib.tiff b/Applications/Gorm/Images/shortbutton_nib.tiff similarity index 100% rename from Images/shortbutton_nib.tiff rename to Applications/Gorm/Images/shortbutton_nib.tiff diff --git a/Images/tabbot_nib.tiff b/Applications/Gorm/Images/tabbot_nib.tiff similarity index 100% rename from Images/tabbot_nib.tiff rename to Applications/Gorm/Images/tabbot_nib.tiff diff --git a/Images/tabtop_nib.tiff b/Applications/Gorm/Images/tabtop_nib.tiff similarity index 100% rename from Images/tabtop_nib.tiff rename to Applications/Gorm/Images/tabtop_nib.tiff diff --git a/Images/titleOnly_nib.tiff b/Applications/Gorm/Images/titleOnly_nib.tiff similarity index 100% rename from Images/titleOnly_nib.tiff rename to Applications/Gorm/Images/titleOnly_nib.tiff diff --git a/NEWS b/Applications/Gorm/NEWS similarity index 100% rename from NEWS rename to Applications/Gorm/NEWS diff --git a/Palettes/0Menus/GNUmakefile b/Applications/Gorm/Palettes/0Menus/GNUmakefile similarity index 100% rename from Palettes/0Menus/GNUmakefile rename to Applications/Gorm/Palettes/0Menus/GNUmakefile diff --git a/Applications/Gorm/Palettes/0Menus/GNUmakefile.preamble b/Applications/Gorm/Palettes/0Menus/GNUmakefile.preamble new file mode 100644 index 00000000..b84b583b --- /dev/null +++ b/Applications/Gorm/Palettes/0Menus/GNUmakefile.preamble @@ -0,0 +1,19 @@ +# Additional include directories the compiler should search +ADDITIONAL_INCLUDE_DIRS += -I../../../.. + +ifeq ($(GNUSTEP_TARGET_OS),mingw32) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore +endif +ifeq ($(GNUSTEP_TARGET_OS),cygwin) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +$(PALETTE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore +endif \ No newline at end of file diff --git a/Palettes/0Menus/GormMenuAttributesInspector.gorm/data.classes b/Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.gorm/data.classes similarity index 100% rename from Palettes/0Menus/GormMenuAttributesInspector.gorm/data.classes rename to Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.gorm/data.classes diff --git a/English.lproj/GormClassInspector.gorm/data.info b/Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.gorm/data.info similarity index 100% rename from English.lproj/GormClassInspector.gorm/data.info rename to Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.gorm/data.info diff --git a/Palettes/0Menus/GormMenuAttributesInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.gorm/objects.gorm similarity index 100% rename from Palettes/0Menus/GormMenuAttributesInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.gorm/objects.gorm diff --git a/Palettes/0Menus/GormMenuAttributesInspector.h b/Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.h similarity index 100% rename from Palettes/0Menus/GormMenuAttributesInspector.h rename to Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.h diff --git a/Palettes/0Menus/GormMenuAttributesInspector.m b/Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.m similarity index 94% rename from Palettes/0Menus/GormMenuAttributesInspector.m rename to Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.m index 35458320..be35f0fd 100644 --- a/Palettes/0Menus/GormMenuAttributesInspector.m +++ b/Applications/Gorm/Palettes/0Menus/GormMenuAttributesInspector.m @@ -79,7 +79,7 @@ } else if ( sender == menuType ) { - GormDocument *doc = (GormDocument *)[(id)NSApp activeDocument]; + GormDocument *doc = (GormDocument *)[(id)[NSApp delegate] activeDocument]; int tag = [[menuType selectedCell] tag]; switch ( tag ) @@ -129,7 +129,7 @@ if ( object == nil ) return; - doc = (GormDocument *)[(id)NSApp activeDocument]; + doc = (GormDocument *)[(id)[NSApp delegate] activeDocument]; [titleText setStringValue: [object title]]; [autoenable setState: ([object realAutoenablesItems]?NSOnState:NSOffState)]; @@ -157,7 +157,7 @@ /* delegate method used for menu title */ - (void)controlTextDidChange:(NSNotification *)aNotification { - GormDocument *doc = (GormDocument *)[(id)NSApp activeDocument]; + GormDocument *doc = (GormDocument *)[(id)[NSApp delegate] activeDocument]; [object setTitle: [titleText stringValue]]; [doc touch]; } diff --git a/Palettes/0Menus/GormMenuDrag.tiff b/Applications/Gorm/Palettes/0Menus/GormMenuDrag.tiff similarity index 100% rename from Palettes/0Menus/GormMenuDrag.tiff rename to Applications/Gorm/Palettes/0Menus/GormMenuDrag.tiff diff --git a/Palettes/0Menus/GormMenuEditor.m b/Applications/Gorm/Palettes/0Menus/GormMenuEditor.m similarity index 97% rename from Palettes/0Menus/GormMenuEditor.m rename to Applications/Gorm/Palettes/0Menus/GormMenuEditor.m index a581dcc5..63408b3a 100644 --- a/Palettes/0Menus/GormMenuEditor.m +++ b/Applications/Gorm/Palettes/0Menus/GormMenuEditor.m @@ -202,11 +202,11 @@ [NSArray arrayWithObject: GormLinkPboardType] owner: self]; [pb setString: name forType: GormLinkPboardType]; - [NSApp displayConnectionBetween: item and: nil]; - [NSApp startConnecting]; + [[NSApp delegate] displayConnectionBetween: item and: nil]; + [[NSApp delegate] startConnecting]; isLinkSource = YES; - [self dragImage: [NSApp linkImage] + [self dragImage: [[NSApp delegate] linkImage] at: dragPoint offset: NSZeroSize event: theEvent @@ -415,7 +415,7 @@ isClosed = YES; [[NSNotificationCenter defaultCenter] removeObserver: self]; - if ([(id)NSApp selectionOwner] == self) + if ([(id)[NSApp delegate] selectionOwner] == self) { [document resignSelectionForEditor: self]; } @@ -570,11 +570,11 @@ { item = [edited itemAtIndex: pos]; } - if (item == [NSApp connectSource]) + if (item == [[NSApp delegate] connectSource]) { item = nil; } - [NSApp displayConnectionBetween: [NSApp connectSource] and: item]; + [[NSApp delegate] displayConnectionBetween: [[NSApp delegate] connectSource] and: item]; return NSDragOperationLink; } else @@ -587,7 +587,7 @@ { if (dragType == GormLinkPboardType) { - [NSApp displayConnectionBetween: [NSApp connectSource] + [[NSApp delegate] displayConnectionBetween: [[NSApp delegate] connectSource] and: nil]; } } @@ -833,8 +833,8 @@ void _attachAll(NSMenu *menu, id document) { id item = [edited itemAtIndex: pos]; - [NSApp displayConnectionBetween: [NSApp connectSource] and: item]; - [NSApp startConnecting]; + [[NSApp delegate] displayConnectionBetween: [[NSApp delegate] connectSource] and: item]; + [[NSApp delegate] startConnecting]; } } else diff --git a/Palettes/0Menus/GormMenuInspectors.m b/Applications/Gorm/Palettes/0Menus/GormMenuInspectors.m similarity index 95% rename from Palettes/0Menus/GormMenuInspectors.m rename to Applications/Gorm/Palettes/0Menus/GormMenuInspectors.m index bd4741cf..3c986b06 100644 --- a/Palettes/0Menus/GormMenuInspectors.m +++ b/Applications/Gorm/Palettes/0Menus/GormMenuInspectors.m @@ -62,7 +62,7 @@ - (void) setObject: (id)anObject { - GormDocument *doc = (GormDocument *)[(id)NSApp activeDocument]; + GormDocument *doc = (GormDocument *)[(id)[NSApp delegate] activeDocument]; ASSIGN(object, nil); // remove reference to old object... [super setObject: anObject]; @@ -87,7 +87,7 @@ - (void) updateMenuType: (id)sender { BOOL flag; - GormDocument *doc = (GormDocument *)[(id)NSApp activeDocument]; + GormDocument *doc = (GormDocument *)[(id)[NSApp delegate] activeDocument]; // look at the values passed back in the matrix. flag = ([[menuType cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO; // windows menu... @@ -155,7 +155,7 @@ - (void)controlTextDidChange:(NSNotification *)aNotification { id o = [aNotification object]; - id doc = [(id)NSApp activeDocument]; + id doc = [(id)[NSApp delegate] activeDocument]; if (o == titleText) { diff --git a/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/data.classes b/Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/data.classes similarity index 100% rename from Palettes/0Menus/GormMenuItemAttributesInspector.gorm/data.classes rename to Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/data.classes diff --git a/English.lproj/GormClassPanel.gorm/data.info b/Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/data.info similarity index 100% rename from English.lproj/GormClassPanel.gorm/data.info rename to Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/data.info diff --git a/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/objects.gorm similarity index 100% rename from Palettes/0Menus/GormMenuItemAttributesInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/objects.gorm diff --git a/Palettes/0Menus/GormMenuItemAttributesInspector.h b/Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.h similarity index 100% rename from Palettes/0Menus/GormMenuItemAttributesInspector.h rename to Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.h diff --git a/Palettes/0Menus/GormMenuItemAttributesInspector.m b/Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.m similarity index 100% rename from Palettes/0Menus/GormMenuItemAttributesInspector.m rename to Applications/Gorm/Palettes/0Menus/GormMenuItemAttributesInspector.m diff --git a/Palettes/0Menus/GormNSMenu.h b/Applications/Gorm/Palettes/0Menus/GormNSMenu.h similarity index 100% rename from Palettes/0Menus/GormNSMenu.h rename to Applications/Gorm/Palettes/0Menus/GormNSMenu.h diff --git a/Palettes/0Menus/GormNSMenu.m b/Applications/Gorm/Palettes/0Menus/GormNSMenu.m similarity index 100% rename from Palettes/0Menus/GormNSMenu.m rename to Applications/Gorm/Palettes/0Menus/GormNSMenu.m diff --git a/Palettes/0Menus/GormNSMenuView.h b/Applications/Gorm/Palettes/0Menus/GormNSMenuView.h similarity index 100% rename from Palettes/0Menus/GormNSMenuView.h rename to Applications/Gorm/Palettes/0Menus/GormNSMenuView.h diff --git a/Palettes/0Menus/GormNSMenuView.m b/Applications/Gorm/Palettes/0Menus/GormNSMenuView.m similarity index 100% rename from Palettes/0Menus/GormNSMenuView.m rename to Applications/Gorm/Palettes/0Menus/GormNSMenuView.m diff --git a/Palettes/0Menus/MenusPalette.m b/Applications/Gorm/Palettes/0Menus/MenusPalette.m similarity index 100% rename from Palettes/0Menus/MenusPalette.m rename to Applications/Gorm/Palettes/0Menus/MenusPalette.m diff --git a/Palettes/0Menus/MenusPalette.tiff b/Applications/Gorm/Palettes/0Menus/MenusPalette.tiff similarity index 100% rename from Palettes/0Menus/MenusPalette.tiff rename to Applications/Gorm/Palettes/0Menus/MenusPalette.tiff diff --git a/Palettes/0Menus/inspectors.m b/Applications/Gorm/Palettes/0Menus/inspectors.m similarity index 100% rename from Palettes/0Menus/inspectors.m rename to Applications/Gorm/Palettes/0Menus/inspectors.m diff --git a/Palettes/0Menus/palette.table b/Applications/Gorm/Palettes/0Menus/palette.table similarity index 100% rename from Palettes/0Menus/palette.table rename to Applications/Gorm/Palettes/0Menus/palette.table diff --git a/Palettes/1Windows/Drawer.tiff b/Applications/Gorm/Palettes/1Windows/Drawer.tiff similarity index 100% rename from Palettes/1Windows/Drawer.tiff rename to Applications/Gorm/Palettes/1Windows/Drawer.tiff diff --git a/Palettes/1Windows/DrawerSmall.tiff b/Applications/Gorm/Palettes/1Windows/DrawerSmall.tiff similarity index 100% rename from Palettes/1Windows/DrawerSmall.tiff rename to Applications/Gorm/Palettes/1Windows/DrawerSmall.tiff diff --git a/Palettes/1Windows/GNUmakefile b/Applications/Gorm/Palettes/1Windows/GNUmakefile similarity index 100% rename from Palettes/1Windows/GNUmakefile rename to Applications/Gorm/Palettes/1Windows/GNUmakefile diff --git a/Applications/Gorm/Palettes/1Windows/GNUmakefile.preamble b/Applications/Gorm/Palettes/1Windows/GNUmakefile.preamble new file mode 100644 index 00000000..b84b583b --- /dev/null +++ b/Applications/Gorm/Palettes/1Windows/GNUmakefile.preamble @@ -0,0 +1,19 @@ +# Additional include directories the compiler should search +ADDITIONAL_INCLUDE_DIRS += -I../../../.. + +ifeq ($(GNUSTEP_TARGET_OS),mingw32) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore +endif +ifeq ($(GNUSTEP_TARGET_OS),cygwin) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +$(PALETTE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore +endif \ No newline at end of file diff --git a/Palettes/1Windows/GormDrawerAttributesInspector.gorm/data.classes b/Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.gorm/data.classes similarity index 100% rename from Palettes/1Windows/GormDrawerAttributesInspector.gorm/data.classes rename to Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.gorm/data.classes diff --git a/English.lproj/GormConnectionInspector.gorm/data.info b/Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.gorm/data.info similarity index 100% rename from English.lproj/GormConnectionInspector.gorm/data.info rename to Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.gorm/data.info diff --git a/Palettes/1Windows/GormDrawerAttributesInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.gorm/objects.gorm similarity index 100% rename from Palettes/1Windows/GormDrawerAttributesInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.gorm/objects.gorm diff --git a/Palettes/1Windows/GormDrawerAttributesInspector.h b/Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.h similarity index 100% rename from Palettes/1Windows/GormDrawerAttributesInspector.h rename to Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.h diff --git a/Palettes/1Windows/GormDrawerAttributesInspector.m b/Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.m similarity index 100% rename from Palettes/1Windows/GormDrawerAttributesInspector.m rename to Applications/Gorm/Palettes/1Windows/GormDrawerAttributesInspector.m diff --git a/Palettes/1Windows/GormNSWindowInspector.gorm/data.classes b/Applications/Gorm/Palettes/1Windows/GormNSWindowInspector.gorm/data.classes similarity index 100% rename from Palettes/1Windows/GormNSWindowInspector.gorm/data.classes rename to Applications/Gorm/Palettes/1Windows/GormNSWindowInspector.gorm/data.classes diff --git a/English.lproj/GormCustomClassInspector.gorm/data.info b/Applications/Gorm/Palettes/1Windows/GormNSWindowInspector.gorm/data.info similarity index 100% rename from English.lproj/GormCustomClassInspector.gorm/data.info rename to Applications/Gorm/Palettes/1Windows/GormNSWindowInspector.gorm/data.info diff --git a/Palettes/1Windows/GormNSWindowInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/1Windows/GormNSWindowInspector.gorm/objects.gorm similarity index 100% rename from Palettes/1Windows/GormNSWindowInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/1Windows/GormNSWindowInspector.gorm/objects.gorm diff --git a/Palettes/1Windows/GormNSWindowSizeInspector.gorm/data.classes b/Applications/Gorm/Palettes/1Windows/GormNSWindowSizeInspector.gorm/data.classes similarity index 100% rename from Palettes/1Windows/GormNSWindowSizeInspector.gorm/data.classes rename to Applications/Gorm/Palettes/1Windows/GormNSWindowSizeInspector.gorm/data.classes diff --git a/English.lproj/GormDummyInspector.gorm/data.info b/Applications/Gorm/Palettes/1Windows/GormNSWindowSizeInspector.gorm/data.info similarity index 100% rename from English.lproj/GormDummyInspector.gorm/data.info rename to Applications/Gorm/Palettes/1Windows/GormNSWindowSizeInspector.gorm/data.info diff --git a/Palettes/1Windows/GormNSWindowSizeInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/1Windows/GormNSWindowSizeInspector.gorm/objects.gorm similarity index 100% rename from Palettes/1Windows/GormNSWindowSizeInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/1Windows/GormNSWindowSizeInspector.gorm/objects.gorm diff --git a/Palettes/1Windows/GormWindowAttributesInspector.h b/Applications/Gorm/Palettes/1Windows/GormWindowAttributesInspector.h similarity index 100% rename from Palettes/1Windows/GormWindowAttributesInspector.h rename to Applications/Gorm/Palettes/1Windows/GormWindowAttributesInspector.h diff --git a/Palettes/1Windows/GormWindowAttributesInspector.m b/Applications/Gorm/Palettes/1Windows/GormWindowAttributesInspector.m similarity index 96% rename from Palettes/1Windows/GormWindowAttributesInspector.m rename to Applications/Gorm/Palettes/1Windows/GormWindowAttributesInspector.m index e5287d52..001509a6 100644 --- a/Palettes/1Windows/GormWindowAttributesInspector.m +++ b/Applications/Gorm/Palettes/1Windows/GormWindowAttributesInspector.m @@ -121,14 +121,14 @@ /* visible at launch time */ else if ( sender == visibleButton ) { - GormDocument *doc = (GormDocument*)[(id)NSApp activeDocument]; + GormDocument *doc = (GormDocument*)[(id)[NSApp delegate] activeDocument]; [doc setObject: object isVisibleAtLaunch: [visibleButton state]]; } /* deferred */ else if ( sender == deferredButton ) { - GormDocument *doc = (GormDocument*)[(id)NSApp activeDocument]; + GormDocument *doc = (GormDocument*)[(id)[NSApp delegate] activeDocument]; [doc setObject: object isDeferred: [deferredButton state]]; } @@ -176,7 +176,7 @@ if ( object == nil ) return; - doc = (GormDocument*)[(id)NSApp activeDocument]; + doc = (GormDocument*)[(id)[NSApp delegate] activeDocument]; /* Title */ [[titleForm cellAtIndex: 0] setStringValue: [object title] ]; diff --git a/Palettes/1Windows/GormWindowSizeInspector.h b/Applications/Gorm/Palettes/1Windows/GormWindowSizeInspector.h similarity index 100% rename from Palettes/1Windows/GormWindowSizeInspector.h rename to Applications/Gorm/Palettes/1Windows/GormWindowSizeInspector.h diff --git a/Palettes/1Windows/GormWindowSizeInspector.m b/Applications/Gorm/Palettes/1Windows/GormWindowSizeInspector.m similarity index 100% rename from Palettes/1Windows/GormWindowSizeInspector.m rename to Applications/Gorm/Palettes/1Windows/GormWindowSizeInspector.m diff --git a/Palettes/1Windows/WindowDrag.tiff b/Applications/Gorm/Palettes/1Windows/WindowDrag.tiff similarity index 100% rename from Palettes/1Windows/WindowDrag.tiff rename to Applications/Gorm/Palettes/1Windows/WindowDrag.tiff diff --git a/Palettes/1Windows/WindowsPalette.h b/Applications/Gorm/Palettes/1Windows/WindowsPalette.h similarity index 100% rename from Palettes/1Windows/WindowsPalette.h rename to Applications/Gorm/Palettes/1Windows/WindowsPalette.h diff --git a/Palettes/1Windows/WindowsPalette.m b/Applications/Gorm/Palettes/1Windows/WindowsPalette.m similarity index 100% rename from Palettes/1Windows/WindowsPalette.m rename to Applications/Gorm/Palettes/1Windows/WindowsPalette.m diff --git a/Palettes/1Windows/WindowsPalette.tiff b/Applications/Gorm/Palettes/1Windows/WindowsPalette.tiff similarity index 100% rename from Palettes/1Windows/WindowsPalette.tiff rename to Applications/Gorm/Palettes/1Windows/WindowsPalette.tiff diff --git a/Palettes/1Windows/inspectors.m b/Applications/Gorm/Palettes/1Windows/inspectors.m similarity index 94% rename from Palettes/1Windows/inspectors.m rename to Applications/Gorm/Palettes/1Windows/inspectors.m index e3f025c5..d8aabfb0 100644 --- a/Palettes/1Windows/inspectors.m +++ b/Applications/Gorm/Palettes/1Windows/inspectors.m @@ -63,7 +63,7 @@ if (image == nil) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path = [bundle pathForImageResource: @"GormWindow"]; image = [[NSImage alloc] initWithContentsOfFile: path]; } @@ -83,7 +83,7 @@ if (image == nil) { - NSBundle *bundle = [NSBundle bundleForClass: [WindowsPalette class]]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path = [bundle pathForImageResource: @"DrawerSmall"]; image = [[NSImage alloc] initWithContentsOfFile: path]; } diff --git a/Palettes/1Windows/palette.table b/Applications/Gorm/Palettes/1Windows/palette.table similarity index 100% rename from Palettes/1Windows/palette.table rename to Applications/Gorm/Palettes/1Windows/palette.table diff --git a/Palettes/2Controls/ControlsPalette.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/data.classes similarity index 91% rename from Palettes/2Controls/ControlsPalette.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/data.classes index 7bb7d0ac..c8dc8ae2 100644 --- a/Palettes/2Controls/ControlsPalette.gorm/data.classes +++ b/Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/data.classes @@ -4,6 +4,7 @@ Actions = ( ); Outlets = ( + "_prototypePopUp" ); Super = IBPalette; }; diff --git a/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/data.info similarity index 65% rename from Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/data.info index 744f736a..70a46922 100644 Binary files a/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.info and b/Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/data.info differ diff --git a/Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/objects.gorm new file mode 100644 index 00000000..a83334d0 Binary files /dev/null and b/Applications/Gorm/Palettes/2Controls/ControlsPalette.gorm/objects.gorm differ diff --git a/Palettes/2Controls/ControlsPalette.m b/Applications/Gorm/Palettes/2Controls/ControlsPalette.m similarity index 81% rename from Palettes/2Controls/ControlsPalette.m rename to Applications/Gorm/Palettes/2Controls/ControlsPalette.m index ec71922f..8568da96 100644 --- a/Palettes/2Controls/ControlsPalette.m +++ b/Applications/Gorm/Palettes/2Controls/ControlsPalette.m @@ -1,10 +1,10 @@ /** - main.m + ControlsPalette.m - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2024 Free Software Foundation, Inc. Author: Gregory John Casamento - Date: 2004 + Date: 2024, 2004 This file is part of GNUstep. @@ -23,14 +23,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ - #include - #include #include "GormNSPopUpButton.h" @interface ControlsPalette: IBPalette +{ + IBOutlet NSPopUpButton *_prototypePopUp; +} @end @@ -62,16 +63,28 @@ - (void) finishInstantiate { - NSView *contents; - id v; + NSView *contentView = [originalWindow contentView]; + NSArray *allItems = nil; + NSEnumerator *en = nil; + id item = nil; + + _prototypePopUp = [[GormNSPopUpButton alloc] initWithFrame: NSMakeRect(71.0, 157.0, 102.0, 24.0)]; + [_prototypePopUp addItemWithTitle: @"Item #0"]; + [_prototypePopUp addItemWithTitle: @"Item #1"]; + [_prototypePopUp addItemWithTitle: @"Item #2"]; + [_prototypePopUp setAutoenablesItems: YES]; + + allItems = [[_prototypePopUp menu] itemArray]; + en = [allItems objectEnumerator]; + while ((item = [en nextObject]) != nil) + { + [item setTarget: nil]; + [item setAction: NULL]; // @selector(_popUpItemAction:)]; + [item setEnabled: YES]; + } - contents = [originalWindow contentView]; - v = [[GormNSPopUpButton alloc] initWithFrame: NSMakeRect(73, 159, 70, 22)]; - [v addItemWithTitle: @"Item 1"]; - [v addItemWithTitle: @"Item 2"]; - [v addItemWithTitle: @"Item 3"]; - [contents addSubview: v]; - RELEASE(v); + [contentView addSubview: _prototypePopUp]; + AUTORELEASE(_prototypePopUp); } - (void) willInspectObject: (NSNotification *)notification diff --git a/Palettes/2Controls/ControlsPalette.tiff b/Applications/Gorm/Palettes/2Controls/ControlsPalette.tiff similarity index 100% rename from Palettes/2Controls/ControlsPalette.tiff rename to Applications/Gorm/Palettes/2Controls/ControlsPalette.tiff diff --git a/Palettes/2Controls/GNUmakefile b/Applications/Gorm/Palettes/2Controls/GNUmakefile similarity index 100% rename from Palettes/2Controls/GNUmakefile rename to Applications/Gorm/Palettes/2Controls/GNUmakefile diff --git a/Applications/Gorm/Palettes/2Controls/GNUmakefile.preamble b/Applications/Gorm/Palettes/2Controls/GNUmakefile.preamble new file mode 100644 index 00000000..b84b583b --- /dev/null +++ b/Applications/Gorm/Palettes/2Controls/GNUmakefile.preamble @@ -0,0 +1,19 @@ +# Additional include directories the compiler should search +ADDITIONAL_INCLUDE_DIRS += -I../../../.. + +ifeq ($(GNUSTEP_TARGET_OS),mingw32) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore +endif +ifeq ($(GNUSTEP_TARGET_OS),cygwin) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +$(PALETTE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore +endif \ No newline at end of file diff --git a/Palettes/2Controls/GormBoxAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormBoxAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormBoxAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormBoxAttributesInspector.h diff --git a/Palettes/2Controls/GormBoxAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormBoxAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormBoxAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormBoxAttributesInspector.m diff --git a/Palettes/2Controls/GormButtonAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormButtonAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormButtonAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormButtonAttributesInspector.h diff --git a/Palettes/2Controls/GormButtonAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormButtonAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormButtonAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormButtonAttributesInspector.m diff --git a/Palettes/2Controls/GormButtonEditor.h b/Applications/Gorm/Palettes/2Controls/GormButtonEditor.h similarity index 100% rename from Palettes/2Controls/GormButtonEditor.h rename to Applications/Gorm/Palettes/2Controls/GormButtonEditor.h diff --git a/Palettes/2Controls/GormButtonEditor.m b/Applications/Gorm/Palettes/2Controls/GormButtonEditor.m similarity index 98% rename from Palettes/2Controls/GormButtonEditor.m rename to Applications/Gorm/Palettes/2Controls/GormButtonEditor.m index c111e6b0..8dc9aaf9 100644 --- a/Palettes/2Controls/GormButtonEditor.m +++ b/Applications/Gorm/Palettes/2Controls/GormButtonEditor.m @@ -295,7 +295,7 @@ static NSRect oldFrame; { [_EO setTitle: [[aNotification object] string]]; [_EO setNeedsDisplay: NO]; - [[(id)NSApp inspectorsManager] updateSelection]; + [[(id)[NSApp delegate] inspectorsManager] updateSelection]; } - (void) textDidEndEditing: (NSNotification *)aNotification @@ -359,7 +359,7 @@ static NSRect oldFrame; while (!done_editing) { NSEventType eType; - e = [NSApp nextEventMatchingMask: eventMask + e = [[NSApp delegate] nextEventMatchingMask: eventMask untilDate: future inMode: NSEventTrackingRunLoopMode dequeue: YES]; diff --git a/Palettes/2Controls/GormCellAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormCellAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormCellAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormCellAttributesInspector.h diff --git a/Palettes/2Controls/GormCellAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormCellAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormCellAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormCellAttributesInspector.m diff --git a/Palettes/2Controls/GormCellSizeInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormCellSizeInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormCellSizeInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormCellSizeInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.gorm/data.info diff --git a/Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormCellSizeInspector.h b/Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.h similarity index 100% rename from Palettes/2Controls/GormCellSizeInspector.h rename to Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.h diff --git a/Palettes/2Controls/GormCellSizeInspector.m b/Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.m similarity index 95% rename from Palettes/2Controls/GormCellSizeInspector.m rename to Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.m index d288d4e6..6e0bc267 100644 --- a/Palettes/2Controls/GormCellSizeInspector.m +++ b/Applications/Gorm/Palettes/2Controls/GormCellSizeInspector.m @@ -73,7 +73,7 @@ - (void) ok: (id)sender { - id document = [(id)NSApp activeDocument]; + id document = [(id)[NSApp delegate] activeDocument]; id parent = [document parentOfObject: object]; if ([parent respondsToSelector: @selector(cellSize)]) @@ -108,7 +108,7 @@ { if (anObject != nil && anObject != object) { - id document = [(id)NSApp activeDocument]; + id document = [(id)[NSApp delegate] activeDocument]; id parent = [document parentOfObject: anObject]; ASSIGN(object, anObject); diff --git a/Palettes/2Controls/GormColorWellAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormColorWellAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormColorWellAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormColorWellAttributesInspector.h diff --git a/Palettes/2Controls/GormColorWellAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormColorWellAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormColorWellAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormColorWellAttributesInspector.m diff --git a/Palettes/2Controls/GormFormAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormFormAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormFormAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormFormAttributesInspector.h diff --git a/Palettes/2Controls/GormFormAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormFormAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormFormAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormFormAttributesInspector.m diff --git a/Palettes/2Controls/GormMatrixAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormMatrixAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormMatrixAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormMatrixAttributesInspector.h diff --git a/Palettes/2Controls/GormMatrixAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormMatrixAttributesInspector.m similarity index 98% rename from Palettes/2Controls/GormMatrixAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormMatrixAttributesInspector.m index 12a857f5..d3c7f3af 100644 --- a/Palettes/2Controls/GormMatrixAttributesInspector.m +++ b/Applications/Gorm/Palettes/2Controls/GormMatrixAttributesInspector.m @@ -56,7 +56,7 @@ NSUInteger colsStepperValue; - (void) _displayObject: (id)obj resize: (BOOL)resize { - id document = [(id)NSApp documentForObject: obj]; + id document = [(id)[NSApp delegate] documentForObject: obj]; id editor = [document editorForObject: obj create: NO]; NSRect eoFrame = [editor frame]; @@ -103,7 +103,7 @@ NSUInteger colsStepperValue; - (void) _refreshCellsComparingWithOldCells: (NSArray *)oldCells { - id document = [(id)NSApp activeDocument]; + id document = [(id)[NSApp delegate] activeDocument]; NSArray *newCells = [[self object] cells]; NSUInteger newCount = [newCells count]; NSUInteger oldCount = [oldCells count]; diff --git a/Palettes/2Controls/GormNSBoxInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSBoxInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSBoxInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSBoxInspector.gorm/data.classes diff --git a/English.lproj/GormImageInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSBoxInspector.gorm/data.info similarity index 100% rename from English.lproj/GormImageInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSBoxInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSBoxInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSBoxInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSBoxInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSBoxInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormNSButtonInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSButtonInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSButtonInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSButtonInspector.gorm/data.classes diff --git a/English.lproj/GormObjectInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSButtonInspector.gorm/data.info similarity index 100% rename from English.lproj/GormObjectInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSButtonInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSButtonInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSButtonInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSButtonInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSButtonInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormNSCellInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSCellInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSCellInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSCellInspector.gorm/data.classes diff --git a/English.lproj/GormPalettePanel.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSCellInspector.gorm/data.info similarity index 100% rename from English.lproj/GormPalettePanel.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSCellInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSCellInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSCellInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSCellInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSCellInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormNSColorWellInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSColorWellInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSColorWellInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSColorWellInspector.gorm/data.classes diff --git a/English.lproj/GormScrollViewAttributesInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSColorWellInspector.gorm/data.info similarity index 100% rename from English.lproj/GormScrollViewAttributesInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSColorWellInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSColorWellInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSColorWellInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSColorWellInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSColorWellInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormNSFormInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSFormInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSFormInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSFormInspector.gorm/data.classes diff --git a/English.lproj/GormSetName.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSFormInspector.gorm/data.info similarity index 100% rename from English.lproj/GormSetName.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSFormInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSFormInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSFormInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSFormInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSFormInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormNSMatrixInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSMatrixInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSMatrixInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSMatrixInspector.gorm/data.classes diff --git a/English.lproj/GormSoundInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSMatrixInspector.gorm/data.info similarity index 100% rename from English.lproj/GormSoundInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSMatrixInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSMatrixInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSMatrixInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSMatrixInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSMatrixInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormNSPopUpButton.h b/Applications/Gorm/Palettes/2Controls/GormNSPopUpButton.h similarity index 100% rename from Palettes/2Controls/GormNSPopUpButton.h rename to Applications/Gorm/Palettes/2Controls/GormNSPopUpButton.h diff --git a/Palettes/2Controls/GormNSPopUpButton.m b/Applications/Gorm/Palettes/2Controls/GormNSPopUpButton.m similarity index 76% rename from Palettes/2Controls/GormNSPopUpButton.m rename to Applications/Gorm/Palettes/2Controls/GormNSPopUpButton.m index 7ee2e05a..4ef66934 100644 --- a/Palettes/2Controls/GormNSPopUpButton.m +++ b/Applications/Gorm/Palettes/2Controls/GormNSPopUpButton.m @@ -1,5 +1,29 @@ -#include +/** + main.m + Copyright (C) 2024 Free Software Foundation, Inc. + + Author: Gregory John Casamento + Date: 2024 + + This file is part of GNUstep. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +*/ + +#include #include "GormNSPopUpButton.h" Class _gormnspopupbuttonCellClass = 0; @@ -65,6 +89,7 @@ Class _gormnspopupbuttonCellClass = 0; * Override this here, since themes may override it. * Always want to show the menu view since it's editable. */ +/* - (void) attachPopUpWithFrame: (NSRect)cellFrame inView: (NSView *)controlView { @@ -127,4 +152,6 @@ Class _gormnspopupbuttonCellClass = 0; name: NSMenuDidSendActionNotification object: _menu]; } +*/ + @end diff --git a/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.classes diff --git a/Palettes/3Containers/GormNSTableViewInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.info similarity index 65% rename from Palettes/3Containers/GormNSTableViewInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.info index 744f736a..70a46922 100644 Binary files a/Palettes/3Containers/GormNSTableViewInspector.gorm/data.info and b/Applications/Gorm/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.info differ diff --git a/Applications/Gorm/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/objects.gorm new file mode 100644 index 00000000..0e2cf11f Binary files /dev/null and b/Applications/Gorm/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/objects.gorm differ diff --git a/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.classes diff --git a/Applications/Gorm/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.info new file mode 100644 index 00000000..70a46922 Binary files /dev/null and b/Applications/Gorm/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.info differ diff --git a/Applications/Gorm/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/objects.gorm new file mode 100644 index 00000000..070970b5 Binary files /dev/null and b/Applications/Gorm/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/objects.gorm differ diff --git a/Palettes/2Controls/GormNSSliderInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSSliderInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSSliderInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSSliderInspector.gorm/data.classes diff --git a/English.lproj/GormViewSizeInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSSliderInspector.gorm/data.info similarity index 100% rename from English.lproj/GormViewSizeInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSSliderInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSSliderInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSSliderInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSSliderInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSSliderInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormNSStepperInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSStepperInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSStepperInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSStepperInspector.gorm/data.classes diff --git a/Palettes/0Menus/GormMenuAttributesInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSStepperInspector.gorm/data.info similarity index 100% rename from Palettes/0Menus/GormMenuAttributesInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSStepperInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSStepperInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSStepperInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSStepperInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSStepperInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormNSTextFieldInspector.gorm/data.classes b/Applications/Gorm/Palettes/2Controls/GormNSTextFieldInspector.gorm/data.classes similarity index 100% rename from Palettes/2Controls/GormNSTextFieldInspector.gorm/data.classes rename to Applications/Gorm/Palettes/2Controls/GormNSTextFieldInspector.gorm/data.classes diff --git a/Palettes/0Menus/GormMenuItemAttributesInspector.gorm/data.info b/Applications/Gorm/Palettes/2Controls/GormNSTextFieldInspector.gorm/data.info similarity index 100% rename from Palettes/0Menus/GormMenuItemAttributesInspector.gorm/data.info rename to Applications/Gorm/Palettes/2Controls/GormNSTextFieldInspector.gorm/data.info diff --git a/Palettes/2Controls/GormNSTextFieldInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/2Controls/GormNSTextFieldInspector.gorm/objects.gorm similarity index 100% rename from Palettes/2Controls/GormNSTextFieldInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/2Controls/GormNSTextFieldInspector.gorm/objects.gorm diff --git a/Palettes/2Controls/GormPopUpButtonAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormPopUpButtonAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormPopUpButtonAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormPopUpButtonAttributesInspector.h diff --git a/Palettes/2Controls/GormPopUpButtonAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormPopUpButtonAttributesInspector.m similarity index 86% rename from Palettes/2Controls/GormPopUpButtonAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormPopUpButtonAttributesInspector.m index 5c77430d..e4648ee1 100644 --- a/Palettes/2Controls/GormPopUpButtonAttributesInspector.m +++ b/Applications/Gorm/Palettes/2Controls/GormPopUpButtonAttributesInspector.m @@ -69,16 +69,22 @@ { if (sender == typeMatrix) { - BOOL pullsDown = [[sender selectedCell] tag]; - id selectedItem; + BOOL pullsDown = [[sender selectedCell] tag] == YES ? YES : NO; + NSArray *itemArray = [[object itemArray] copy]; + NSEnumerator *en = [itemArray objectEnumerator]; + id o = nil; + + [object removeAllItems]; [object setPullsDown: pullsDown]; - selectedItem = [object selectedItem]; - [object selectItem: nil]; - [object selectItem: selectedItem]; - [pullDownTitleForm setEnabled: pullsDown]; - [[pullDownTitleForm cellAtIndex: 0] - setStringValue: pullsDown ? [object title] : @""]; - [pullDownArrowPopUp setEnabled: pullsDown]; + while ((o = [en nextObject]) != nil) + { + id mi = nil; + + [object addItemWithTitle: [o title]]; + mi = [object lastItem]; + [mi setAction: NULL]; // @selector(_popUpItemAction:)]; + [mi setTarget: nil]; + } } else if (sender == autoenableSwitch) { @@ -122,7 +128,7 @@ pullsDown = [object pullsDown]; [typeMatrix selectCellWithTag: pullsDown]; - [autoenableSwitch setState: [object autoenablesItems]]; + [autoenableSwitch setState: ([object autoenablesItems] ? NSOnState : NSOffState)]; [enableSwitch setState: [object isEnabled]]; [[tagForm cellAtRow: 0 column: 0] setIntValue: [object tag]]; [[defaultItemForm cellAtRow: 0 column: 0] setIntValue: [object indexOfSelectedItem]]; diff --git a/Palettes/2Controls/GormPopUpButtonEditor.m b/Applications/Gorm/Palettes/2Controls/GormPopUpButtonEditor.m similarity index 100% rename from Palettes/2Controls/GormPopUpButtonEditor.m rename to Applications/Gorm/Palettes/2Controls/GormPopUpButtonEditor.m diff --git a/Palettes/2Controls/GormProgressIndicatorAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormProgressIndicatorAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormProgressIndicatorAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormProgressIndicatorAttributesInspector.h diff --git a/Palettes/2Controls/GormProgressIndicatorAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormProgressIndicatorAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormProgressIndicatorAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormProgressIndicatorAttributesInspector.m diff --git a/Palettes/2Controls/GormSliderAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormSliderAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormSliderAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormSliderAttributesInspector.h diff --git a/Palettes/2Controls/GormSliderAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormSliderAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormSliderAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormSliderAttributesInspector.m diff --git a/Palettes/2Controls/GormStepperAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormStepperAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormStepperAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormStepperAttributesInspector.h diff --git a/Palettes/2Controls/GormStepperAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormStepperAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormStepperAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormStepperAttributesInspector.m diff --git a/Palettes/2Controls/GormTextFieldAttributesInspector.h b/Applications/Gorm/Palettes/2Controls/GormTextFieldAttributesInspector.h similarity index 100% rename from Palettes/2Controls/GormTextFieldAttributesInspector.h rename to Applications/Gorm/Palettes/2Controls/GormTextFieldAttributesInspector.h diff --git a/Palettes/2Controls/GormTextFieldAttributesInspector.m b/Applications/Gorm/Palettes/2Controls/GormTextFieldAttributesInspector.m similarity index 100% rename from Palettes/2Controls/GormTextFieldAttributesInspector.m rename to Applications/Gorm/Palettes/2Controls/GormTextFieldAttributesInspector.m diff --git a/Palettes/2Controls/inspectors.m b/Applications/Gorm/Palettes/2Controls/inspectors.m similarity index 100% rename from Palettes/2Controls/inspectors.m rename to Applications/Gorm/Palettes/2Controls/inspectors.m diff --git a/Palettes/2Controls/palette.table b/Applications/Gorm/Palettes/2Controls/palette.table similarity index 100% rename from Palettes/2Controls/palette.table rename to Applications/Gorm/Palettes/2Controls/palette.table diff --git a/Palettes/3Containers/ContainersPalette.m b/Applications/Gorm/Palettes/3Containers/ContainersPalette.m similarity index 100% rename from Palettes/3Containers/ContainersPalette.m rename to Applications/Gorm/Palettes/3Containers/ContainersPalette.m diff --git a/Palettes/3Containers/ContainersPalette.tiff b/Applications/Gorm/Palettes/3Containers/ContainersPalette.tiff similarity index 100% rename from Palettes/3Containers/ContainersPalette.tiff rename to Applications/Gorm/Palettes/3Containers/ContainersPalette.tiff diff --git a/Palettes/3Containers/GNUmakefile b/Applications/Gorm/Palettes/3Containers/GNUmakefile similarity index 100% rename from Palettes/3Containers/GNUmakefile rename to Applications/Gorm/Palettes/3Containers/GNUmakefile diff --git a/Applications/Gorm/Palettes/3Containers/GNUmakefile.preamble b/Applications/Gorm/Palettes/3Containers/GNUmakefile.preamble new file mode 100644 index 00000000..b84b583b --- /dev/null +++ b/Applications/Gorm/Palettes/3Containers/GNUmakefile.preamble @@ -0,0 +1,19 @@ +# Additional include directories the compiler should search +ADDITIONAL_INCLUDE_DIRS += -I../../../.. + +ifeq ($(GNUSTEP_TARGET_OS),mingw32) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore +endif +ifeq ($(GNUSTEP_TARGET_OS),cygwin) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +$(PALETTE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore +endif \ No newline at end of file diff --git a/Palettes/3Containers/GormBrowserAttributesInspector.h b/Applications/Gorm/Palettes/3Containers/GormBrowserAttributesInspector.h similarity index 100% rename from Palettes/3Containers/GormBrowserAttributesInspector.h rename to Applications/Gorm/Palettes/3Containers/GormBrowserAttributesInspector.h diff --git a/Palettes/3Containers/GormBrowserAttributesInspector.m b/Applications/Gorm/Palettes/3Containers/GormBrowserAttributesInspector.m similarity index 100% rename from Palettes/3Containers/GormBrowserAttributesInspector.m rename to Applications/Gorm/Palettes/3Containers/GormBrowserAttributesInspector.m diff --git a/Palettes/3Containers/GormNSBrowser.h b/Applications/Gorm/Palettes/3Containers/GormNSBrowser.h similarity index 100% rename from Palettes/3Containers/GormNSBrowser.h rename to Applications/Gorm/Palettes/3Containers/GormNSBrowser.h diff --git a/Palettes/3Containers/GormNSBrowser.m b/Applications/Gorm/Palettes/3Containers/GormNSBrowser.m similarity index 100% rename from Palettes/3Containers/GormNSBrowser.m rename to Applications/Gorm/Palettes/3Containers/GormNSBrowser.m diff --git a/Palettes/3Containers/GormNSBrowserInspector.gorm/data.classes b/Applications/Gorm/Palettes/3Containers/GormNSBrowserInspector.gorm/data.classes similarity index 100% rename from Palettes/3Containers/GormNSBrowserInspector.gorm/data.classes rename to Applications/Gorm/Palettes/3Containers/GormNSBrowserInspector.gorm/data.classes diff --git a/Palettes/1Windows/GormDrawerAttributesInspector.gorm/data.info b/Applications/Gorm/Palettes/3Containers/GormNSBrowserInspector.gorm/data.info similarity index 100% rename from Palettes/1Windows/GormDrawerAttributesInspector.gorm/data.info rename to Applications/Gorm/Palettes/3Containers/GormNSBrowserInspector.gorm/data.info diff --git a/Palettes/3Containers/GormNSBrowserInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/3Containers/GormNSBrowserInspector.gorm/objects.gorm similarity index 100% rename from Palettes/3Containers/GormNSBrowserInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/3Containers/GormNSBrowserInspector.gorm/objects.gorm diff --git a/Palettes/3Containers/GormNSOutlineView.h b/Applications/Gorm/Palettes/3Containers/GormNSOutlineView.h similarity index 100% rename from Palettes/3Containers/GormNSOutlineView.h rename to Applications/Gorm/Palettes/3Containers/GormNSOutlineView.h diff --git a/Palettes/3Containers/GormNSOutlineView.m b/Applications/Gorm/Palettes/3Containers/GormNSOutlineView.m similarity index 100% rename from Palettes/3Containers/GormNSOutlineView.m rename to Applications/Gorm/Palettes/3Containers/GormNSOutlineView.m diff --git a/Palettes/3Containers/GormNSTableColumnInspector.gorm/data.classes b/Applications/Gorm/Palettes/3Containers/GormNSTableColumnInspector.gorm/data.classes similarity index 100% rename from Palettes/3Containers/GormNSTableColumnInspector.gorm/data.classes rename to Applications/Gorm/Palettes/3Containers/GormNSTableColumnInspector.gorm/data.classes diff --git a/Palettes/1Windows/GormNSWindowInspector.gorm/data.info b/Applications/Gorm/Palettes/3Containers/GormNSTableColumnInspector.gorm/data.info similarity index 100% rename from Palettes/1Windows/GormNSWindowInspector.gorm/data.info rename to Applications/Gorm/Palettes/3Containers/GormNSTableColumnInspector.gorm/data.info diff --git a/Palettes/3Containers/GormNSTableColumnInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/3Containers/GormNSTableColumnInspector.gorm/objects.gorm similarity index 100% rename from Palettes/3Containers/GormNSTableColumnInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/3Containers/GormNSTableColumnInspector.gorm/objects.gorm diff --git a/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.classes b/Applications/Gorm/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.classes similarity index 100% rename from Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.classes rename to Applications/Gorm/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.classes diff --git a/Palettes/1Windows/GormNSWindowSizeInspector.gorm/data.info b/Applications/Gorm/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.info similarity index 100% rename from Palettes/1Windows/GormNSWindowSizeInspector.gorm/data.info rename to Applications/Gorm/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/data.info diff --git a/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/objects.gorm similarity index 100% rename from Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/3Containers/GormNSTableColumnSizeInspector.gorm/objects.gorm diff --git a/Palettes/3Containers/GormNSTableView.h b/Applications/Gorm/Palettes/3Containers/GormNSTableView.h similarity index 100% rename from Palettes/3Containers/GormNSTableView.h rename to Applications/Gorm/Palettes/3Containers/GormNSTableView.h diff --git a/Palettes/3Containers/GormNSTableView.m b/Applications/Gorm/Palettes/3Containers/GormNSTableView.m similarity index 100% rename from Palettes/3Containers/GormNSTableView.m rename to Applications/Gorm/Palettes/3Containers/GormNSTableView.m diff --git a/Palettes/3Containers/GormNSTableViewInspector.gorm/data.classes b/Applications/Gorm/Palettes/3Containers/GormNSTableViewInspector.gorm/data.classes similarity index 100% rename from Palettes/3Containers/GormNSTableViewInspector.gorm/data.classes rename to Applications/Gorm/Palettes/3Containers/GormNSTableViewInspector.gorm/data.classes diff --git a/Palettes/2Controls/ControlsPalette.gorm/data.info b/Applications/Gorm/Palettes/3Containers/GormNSTableViewInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/ControlsPalette.gorm/data.info rename to Applications/Gorm/Palettes/3Containers/GormNSTableViewInspector.gorm/data.info diff --git a/Palettes/3Containers/GormNSTableViewInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/3Containers/GormNSTableViewInspector.gorm/objects.gorm similarity index 100% rename from Palettes/3Containers/GormNSTableViewInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/3Containers/GormNSTableViewInspector.gorm/objects.gorm diff --git a/Palettes/3Containers/GormTabViewAttributesInspector.h b/Applications/Gorm/Palettes/3Containers/GormTabViewAttributesInspector.h similarity index 100% rename from Palettes/3Containers/GormTabViewAttributesInspector.h rename to Applications/Gorm/Palettes/3Containers/GormTabViewAttributesInspector.h diff --git a/Palettes/3Containers/GormTabViewAttributesInspector.m b/Applications/Gorm/Palettes/3Containers/GormTabViewAttributesInspector.m similarity index 97% rename from Palettes/3Containers/GormTabViewAttributesInspector.m rename to Applications/Gorm/Palettes/3Containers/GormTabViewAttributesInspector.m index afbfeeaa..67720f4e 100644 --- a/Palettes/3Containers/GormTabViewAttributesInspector.m +++ b/Applications/Gorm/Palettes/3Containers/GormTabViewAttributesInspector.m @@ -121,7 +121,7 @@ { int i; NSTabViewItem *newTabItem; - id document = [(id)NSApp documentForObject: object]; + id document = [(id)[NSApp delegate] documentForObject: object]; for (i=([object numberOfTabViewItems]+1);i<=newNumber;i++) { @@ -139,7 +139,7 @@ for (i=([object numberOfTabViewItems]-1);i>=newNumber;i--) { id item = [object tabViewItemAtIndex:i]; - id document = [(id)NSApp documentForObject: item]; + id document = [(id)[NSApp delegate] documentForObject: item]; [object selectFirstTabViewItem: self]; [object removeTabViewItem: item]; diff --git a/Palettes/3Containers/GormTabViewEditor.h b/Applications/Gorm/Palettes/3Containers/GormTabViewEditor.h similarity index 100% rename from Palettes/3Containers/GormTabViewEditor.h rename to Applications/Gorm/Palettes/3Containers/GormTabViewEditor.h diff --git a/Palettes/3Containers/GormTabViewEditor.m b/Applications/Gorm/Palettes/3Containers/GormTabViewEditor.m similarity index 83% rename from Palettes/3Containers/GormTabViewEditor.m rename to Applications/Gorm/Palettes/3Containers/GormTabViewEditor.m index 92522ade..995bbade 100644 --- a/Palettes/3Containers/GormTabViewEditor.m +++ b/Applications/Gorm/Palettes/3Containers/GormTabViewEditor.m @@ -29,10 +29,15 @@ #include "GormTabViewEditor.h" -#define _EO ((NSTabView *)_editedObject) +// #define _EO ((NSTabView *)_editedObject) @implementation GormTabViewEditor +- (NSTabView *) _eo +{ + return (NSTabView *)_editedObject; +} + - (void) setOpened: (BOOL) flag { [super setOpened: flag]; @@ -44,30 +49,38 @@ - (NSArray *) selection { - return [NSArray arrayWithObject: _EO]; + return [NSArray arrayWithObject: [self _eo]]; } +// +// ignore this warning since this works... the editor that may be returned in some cases +// passes on unrecognized selectors to its editedObject, so this will not cause an +// issue. +// +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wobjc-method-access" - (BOOL) activate { if ([super activate]) { currentView = nil; - [_EO setDelegate: self]; + [[self _eo] setDelegate: self]; [self - tabView: _EO - didSelectTabViewItem: [_EO selectedTabViewItem]]; + tabView: [self _eo] + didSelectTabViewItem: [[self _eo] selectedTabViewItem]]; return YES; } return NO; } +#pragma GCC diagnostic pop - (void) deactivate { if (activated == YES) { [self deactivateSubeditors]; - [_EO setDelegate: nil]; + [[self _eo] setDelegate: nil]; [super deactivate]; } } @@ -80,7 +93,7 @@ { if ([parent respondsToSelector: @selector(selection)] && - [[parent selection] containsObject: _EO]) + [[parent selection] containsObject: [self _eo]]) { IBKnobPosition knob = IBNoneKnobPosition; NSPoint mouseDownPoint = @@ -106,7 +119,7 @@ return; } - if ([[_EO hitTest: [theEvent locationInWindow]] + if ([[[self _eo] hitTest: [theEvent locationInWindow]] isDescendantOf: currentView]) { NSDebugLog(@"md %@ descendant of", self); @@ -119,7 +132,7 @@ NSDebugLog(@"md %@ not descendant of", self); if ([currentView isOpened] == YES) [currentView setOpened: NO]; - [_EO mouseDown: theEvent]; + [[self _eo] mouseDown: theEvent]; } } diff --git a/Palettes/3Containers/GormTabViewInspector.gorm/data.classes b/Applications/Gorm/Palettes/3Containers/GormTabViewInspector.gorm/data.classes similarity index 100% rename from Palettes/3Containers/GormTabViewInspector.gorm/data.classes rename to Applications/Gorm/Palettes/3Containers/GormTabViewInspector.gorm/data.classes diff --git a/English.lproj/GormPrefGeneral.gorm/data.info b/Applications/Gorm/Palettes/3Containers/GormTabViewInspector.gorm/data.info similarity index 100% rename from English.lproj/GormPrefGeneral.gorm/data.info rename to Applications/Gorm/Palettes/3Containers/GormTabViewInspector.gorm/data.info diff --git a/Palettes/3Containers/GormTabViewInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/3Containers/GormTabViewInspector.gorm/objects.gorm similarity index 100% rename from Palettes/3Containers/GormTabViewInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/3Containers/GormTabViewInspector.gorm/objects.gorm diff --git a/Palettes/3Containers/GormTableColumnAttributesInspector.h b/Applications/Gorm/Palettes/3Containers/GormTableColumnAttributesInspector.h similarity index 100% rename from Palettes/3Containers/GormTableColumnAttributesInspector.h rename to Applications/Gorm/Palettes/3Containers/GormTableColumnAttributesInspector.h diff --git a/Palettes/3Containers/GormTableColumnAttributesInspector.m b/Applications/Gorm/Palettes/3Containers/GormTableColumnAttributesInspector.m similarity index 94% rename from Palettes/3Containers/GormTableColumnAttributesInspector.m rename to Applications/Gorm/Palettes/3Containers/GormTableColumnAttributesInspector.m index fe849f1c..88a1dc62 100644 --- a/Palettes/3Containers/GormTableColumnAttributesInspector.m +++ b/Applications/Gorm/Palettes/3Containers/GormTableColumnAttributesInspector.m @@ -71,7 +71,7 @@ - (NSString *)_getCellClassName { id cell = [[self object] dataCell]; - NSString *customClassName = [[(id)NSApp classManager] customClassForObject: cell]; + NSString *customClassName = [[(id)[NSApp delegate] classManager] customClassForObject: cell]; NSString *result = nil; if(customClassName == nil) @@ -150,8 +150,8 @@ /* set Button */ else if (sender == setButton || sender == cellTable) { - id classManager = [(id)NSApp classManager]; - id doc = [(id)NSApp activeDocument]; + id classManager = [(id)[NSApp delegate] classManager]; + id doc = [(id)[NSApp delegate] activeDocument]; id cell = nil; int i = [cellTable selectedRow]; NSArray *list = [classManager allSubclassesOf: @"NSCell"]; @@ -231,7 +231,7 @@ if ( object == nil ) return; - list = [[(id)NSApp classManager] allSubclassesOf: @"NSCell"]; + list = [[(id)[NSApp delegate] classManager] allSubclassesOf: @"NSCell"]; cellClassName = [self _getCellClassName]; index = [list indexOfObject: cellClassName]; @@ -310,7 +310,7 @@ // replace by an NSBrowser ? - (NSInteger) numberOfRowsInTableView: (NSTableView *)tv { - NSArray *list = [[(id)NSApp classManager] allSubclassesOf: @"NSCell"]; + NSArray *list = [[(id)[NSApp delegate] classManager] allSubclassesOf: @"NSCell"]; return [list count]; } @@ -318,7 +318,7 @@ objectValueForTableColumn: (NSTableColumn *)tc row: (NSInteger)rowIndex { - NSArray *list = [[(id)NSApp classManager] allSubclassesOf: @"NSCell"]; + NSArray *list = [[(id)[NSApp delegate] classManager] allSubclassesOf: @"NSCell"]; id value = nil; if([list count] > 0) { diff --git a/Palettes/3Containers/GormTableColumnSizeInspector.h b/Applications/Gorm/Palettes/3Containers/GormTableColumnSizeInspector.h similarity index 100% rename from Palettes/3Containers/GormTableColumnSizeInspector.h rename to Applications/Gorm/Palettes/3Containers/GormTableColumnSizeInspector.h diff --git a/Palettes/3Containers/GormTableColumnSizeInspector.m b/Applications/Gorm/Palettes/3Containers/GormTableColumnSizeInspector.m similarity index 100% rename from Palettes/3Containers/GormTableColumnSizeInspector.m rename to Applications/Gorm/Palettes/3Containers/GormTableColumnSizeInspector.m diff --git a/Palettes/3Containers/GormTableViewAttributesInspector.h b/Applications/Gorm/Palettes/3Containers/GormTableViewAttributesInspector.h similarity index 100% rename from Palettes/3Containers/GormTableViewAttributesInspector.h rename to Applications/Gorm/Palettes/3Containers/GormTableViewAttributesInspector.h diff --git a/Palettes/3Containers/GormTableViewAttributesInspector.m b/Applications/Gorm/Palettes/3Containers/GormTableViewAttributesInspector.m similarity index 100% rename from Palettes/3Containers/GormTableViewAttributesInspector.m rename to Applications/Gorm/Palettes/3Containers/GormTableViewAttributesInspector.m diff --git a/Palettes/3Containers/GormTableViewEditor.h b/Applications/Gorm/Palettes/3Containers/GormTableViewEditor.h similarity index 100% rename from Palettes/3Containers/GormTableViewEditor.h rename to Applications/Gorm/Palettes/3Containers/GormTableViewEditor.h diff --git a/Palettes/3Containers/GormTableViewEditor.m b/Applications/Gorm/Palettes/3Containers/GormTableViewEditor.m similarity index 98% rename from Palettes/3Containers/GormTableViewEditor.m rename to Applications/Gorm/Palettes/3Containers/GormTableViewEditor.m index ab6f4a0d..0c23e384 100644 --- a/Palettes/3Containers/GormTableViewEditor.m +++ b/Applications/Gorm/Palettes/3Containers/GormTableViewEditor.m @@ -310,10 +310,10 @@ static NSText *_textObject; [NSArray arrayWithObject: GormLinkPboardType] owner: self]; [pb setString: name forType: GormLinkPboardType]; - [NSApp displayConnectionBetween: col and: nil]; - [NSApp startConnecting]; + [[NSApp delegate] displayConnectionBetween: col and: nil]; + [[NSApp delegate] startConnecting]; - [self dragImage: [NSApp linkImage] + [self dragImage: [[NSApp delegate] linkImage] at: dragPoint offset: NSZeroSize event: theEvent @@ -465,7 +465,7 @@ static NSText *_textObject; } } - [NSApp displayConnectionBetween: [NSApp connectSource] + [[NSApp delegate] displayConnectionBetween: [[NSApp delegate] connectSource] and: destination]; return NSDragOperationLink; } diff --git a/Palettes/3Containers/GormTableViewSizeInspector.h b/Applications/Gorm/Palettes/3Containers/GormTableViewSizeInspector.h similarity index 100% rename from Palettes/3Containers/GormTableViewSizeInspector.h rename to Applications/Gorm/Palettes/3Containers/GormTableViewSizeInspector.h diff --git a/Palettes/3Containers/GormTableViewSizeInspector.m b/Applications/Gorm/Palettes/3Containers/GormTableViewSizeInspector.m similarity index 100% rename from Palettes/3Containers/GormTableViewSizeInspector.m rename to Applications/Gorm/Palettes/3Containers/GormTableViewSizeInspector.m diff --git a/Palettes/3Containers/inspectors.m b/Applications/Gorm/Palettes/3Containers/inspectors.m similarity index 100% rename from Palettes/3Containers/inspectors.m rename to Applications/Gorm/Palettes/3Containers/inspectors.m diff --git a/Palettes/3Containers/palette.table b/Applications/Gorm/Palettes/3Containers/palette.table similarity index 100% rename from Palettes/3Containers/palette.table rename to Applications/Gorm/Palettes/3Containers/palette.table diff --git a/Palettes/4Data/DataPalette.m b/Applications/Gorm/Palettes/4Data/DataPalette.m similarity index 99% rename from Palettes/4Data/DataPalette.m rename to Applications/Gorm/Palettes/4Data/DataPalette.m index 63e9cff3..cb5e6c38 100644 --- a/Palettes/4Data/DataPalette.m +++ b/Applications/Gorm/Palettes/4Data/DataPalette.m @@ -370,7 +370,7 @@ int defaultDateFormatIndex = 3; if([obj respondsToSelector: @selector(setFormatter:)]) { // Touch the document... - [[(id)NSApp activeDocument] touch]; + [[(id)[NSApp delegate] activeDocument] touch]; [obj setFormatter: formatter]; RETAIN(formatter); diff --git a/Palettes/4Data/DataPalette.tiff b/Applications/Gorm/Palettes/4Data/DataPalette.tiff similarity index 100% rename from Palettes/4Data/DataPalette.tiff rename to Applications/Gorm/Palettes/4Data/DataPalette.tiff diff --git a/Palettes/4Data/GNUmakefile b/Applications/Gorm/Palettes/4Data/GNUmakefile similarity index 100% rename from Palettes/4Data/GNUmakefile rename to Applications/Gorm/Palettes/4Data/GNUmakefile diff --git a/Applications/Gorm/Palettes/4Data/GNUmakefile.preamble b/Applications/Gorm/Palettes/4Data/GNUmakefile.preamble new file mode 100644 index 00000000..b84b583b --- /dev/null +++ b/Applications/Gorm/Palettes/4Data/GNUmakefile.preamble @@ -0,0 +1,19 @@ +# Additional include directories the compiler should search +ADDITIONAL_INCLUDE_DIRS += -I../../../.. + +ifeq ($(GNUSTEP_TARGET_OS),mingw32) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore +endif +ifeq ($(GNUSTEP_TARGET_OS),cygwin) +ADDITIONAL_LIB_DIRS += \ + -L../../../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../../../GormCore/GormCore.framework + +$(PALETTE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore +endif \ No newline at end of file diff --git a/Palettes/4Data/GormDateFormatterAttributesInspector.h b/Applications/Gorm/Palettes/4Data/GormDateFormatterAttributesInspector.h similarity index 100% rename from Palettes/4Data/GormDateFormatterAttributesInspector.h rename to Applications/Gorm/Palettes/4Data/GormDateFormatterAttributesInspector.h diff --git a/Palettes/4Data/GormDateFormatterAttributesInspector.m b/Applications/Gorm/Palettes/4Data/GormDateFormatterAttributesInspector.m similarity index 97% rename from Palettes/4Data/GormDateFormatterAttributesInspector.m rename to Applications/Gorm/Palettes/4Data/GormDateFormatterAttributesInspector.m index d9270791..fc5cd92c 100644 --- a/Palettes/4Data/GormDateFormatterAttributesInspector.m +++ b/Applications/Gorm/Palettes/4Data/GormDateFormatterAttributesInspector.m @@ -59,12 +59,12 @@ extern NSArray *predefinedDateFormats; NSDateFormatter *fmtr; // Set the document as modifed... - [[(id)NSApp activeDocument] touch]; + [[(id)[NSApp delegate] activeDocument] touch]; if (sender == detachButton) { [[object cell] setFormatter: nil]; - [[(id)NSApp activeDocument] setSelectionFromEditor: nil]; + [[(id)[NSApp delegate] activeDocument] setSelectionFromEditor: nil]; } else { diff --git a/Palettes/4Data/GormImageViewAttributesInspector.h b/Applications/Gorm/Palettes/4Data/GormImageViewAttributesInspector.h similarity index 100% rename from Palettes/4Data/GormImageViewAttributesInspector.h rename to Applications/Gorm/Palettes/4Data/GormImageViewAttributesInspector.h diff --git a/Palettes/4Data/GormImageViewAttributesInspector.m b/Applications/Gorm/Palettes/4Data/GormImageViewAttributesInspector.m similarity index 100% rename from Palettes/4Data/GormImageViewAttributesInspector.m rename to Applications/Gorm/Palettes/4Data/GormImageViewAttributesInspector.m diff --git a/Palettes/4Data/GormNSComboBoxAttributesInspector.h b/Applications/Gorm/Palettes/4Data/GormNSComboBoxAttributesInspector.h similarity index 100% rename from Palettes/4Data/GormNSComboBoxAttributesInspector.h rename to Applications/Gorm/Palettes/4Data/GormNSComboBoxAttributesInspector.h diff --git a/Palettes/4Data/GormNSComboBoxAttributesInspector.m b/Applications/Gorm/Palettes/4Data/GormNSComboBoxAttributesInspector.m similarity index 100% rename from Palettes/4Data/GormNSComboBoxAttributesInspector.m rename to Applications/Gorm/Palettes/4Data/GormNSComboBoxAttributesInspector.m diff --git a/Palettes/4Data/GormNSComboBoxInspector.gorm/data.classes b/Applications/Gorm/Palettes/4Data/GormNSComboBoxInspector.gorm/data.classes similarity index 100% rename from Palettes/4Data/GormNSComboBoxInspector.gorm/data.classes rename to Applications/Gorm/Palettes/4Data/GormNSComboBoxInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormNSBoxInspector.gorm/data.info b/Applications/Gorm/Palettes/4Data/GormNSComboBoxInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSBoxInspector.gorm/data.info rename to Applications/Gorm/Palettes/4Data/GormNSComboBoxInspector.gorm/data.info diff --git a/Palettes/4Data/GormNSComboBoxInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/4Data/GormNSComboBoxInspector.gorm/objects.gorm similarity index 100% rename from Palettes/4Data/GormNSComboBoxInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/4Data/GormNSComboBoxInspector.gorm/objects.gorm diff --git a/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.classes b/Applications/Gorm/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.classes similarity index 100% rename from Palettes/4Data/GormNSDateFormatterInspector.gorm/data.classes rename to Applications/Gorm/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.classes diff --git a/Applications/Gorm/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.info b/Applications/Gorm/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.info new file mode 100644 index 00000000..70a46922 Binary files /dev/null and b/Applications/Gorm/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.info differ diff --git a/Applications/Gorm/Palettes/4Data/GormNSDateFormatterInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/4Data/GormNSDateFormatterInspector.gorm/objects.gorm new file mode 100644 index 00000000..7acc8503 Binary files /dev/null and b/Applications/Gorm/Palettes/4Data/GormNSDateFormatterInspector.gorm/objects.gorm differ diff --git a/Palettes/4Data/GormNSImageViewInspector.gorm/data.classes b/Applications/Gorm/Palettes/4Data/GormNSImageViewInspector.gorm/data.classes similarity index 100% rename from Palettes/4Data/GormNSImageViewInspector.gorm/data.classes rename to Applications/Gorm/Palettes/4Data/GormNSImageViewInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormNSButtonInspector.gorm/data.info b/Applications/Gorm/Palettes/4Data/GormNSImageViewInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSButtonInspector.gorm/data.info rename to Applications/Gorm/Palettes/4Data/GormNSImageViewInspector.gorm/data.info diff --git a/Palettes/4Data/GormNSImageViewInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/4Data/GormNSImageViewInspector.gorm/objects.gorm similarity index 100% rename from Palettes/4Data/GormNSImageViewInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/4Data/GormNSImageViewInspector.gorm/objects.gorm diff --git a/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.classes b/Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.classes similarity index 91% rename from Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.classes rename to Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.classes index d5b81113..1f8e0939 100644 --- a/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.classes +++ b/Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.classes @@ -4,15 +4,16 @@ Actions = ( ); Outlets = ( + formatTable, + detachButton, addThousandSeparatorSwitch, commaPointSwitch, formatForm, - formatTable, localizeSwitch, negativeField, negativeRedSwitch, positiveField, - detachButton + zeroField ); Super = IBInspector; }; diff --git a/Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.info b/Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.info new file mode 100644 index 00000000..70a46922 Binary files /dev/null and b/Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.info differ diff --git a/Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/objects.gorm new file mode 100644 index 00000000..ec56fddb Binary files /dev/null and b/Applications/Gorm/Palettes/4Data/GormNSNumberFormatterInspector.gorm/objects.gorm differ diff --git a/Palettes/4Data/GormNSTextViewInspector.gorm/data.classes b/Applications/Gorm/Palettes/4Data/GormNSTextViewInspector.gorm/data.classes similarity index 100% rename from Palettes/4Data/GormNSTextViewInspector.gorm/data.classes rename to Applications/Gorm/Palettes/4Data/GormNSTextViewInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormNSCellInspector.gorm/data.info b/Applications/Gorm/Palettes/4Data/GormNSTextViewInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSCellInspector.gorm/data.info rename to Applications/Gorm/Palettes/4Data/GormNSTextViewInspector.gorm/data.info diff --git a/Palettes/4Data/GormNSTextViewInspector.gorm/objects.gorm b/Applications/Gorm/Palettes/4Data/GormNSTextViewInspector.gorm/objects.gorm similarity index 100% rename from Palettes/4Data/GormNSTextViewInspector.gorm/objects.gorm rename to Applications/Gorm/Palettes/4Data/GormNSTextViewInspector.gorm/objects.gorm diff --git a/Palettes/4Data/GormNumberFormatterAttributesInspector.h b/Applications/Gorm/Palettes/4Data/GormNumberFormatterAttributesInspector.h similarity index 80% rename from Palettes/4Data/GormNumberFormatterAttributesInspector.h rename to Applications/Gorm/Palettes/4Data/GormNumberFormatterAttributesInspector.h index 83018e35..6c4912b8 100644 --- a/Palettes/4Data/GormNumberFormatterAttributesInspector.h +++ b/Applications/Gorm/Palettes/4Data/GormNumberFormatterAttributesInspector.h @@ -31,15 +31,16 @@ @interface GormNumberFormatterAttributesInspector : IBInspector { - id addThousandSeparatorSwitch; - id commaPointSwitch; - id formatForm; - id formatTable; - id localizeSwitch; - id negativeField; - id negativeRedSwitch; - id positiveField; - id detachButton; + IBOutlet id addThousandSeparatorSwitch; + IBOutlet id commaPointSwitch; + IBOutlet id formatForm; + IBOutlet id formatTable; + IBOutlet id negativeRedSwitch; + IBOutlet id detachButton; + IBOutlet id localizeSwitch; + IBOutlet id positiveField; + IBOutlet id negativeField; + IBOutlet id zeroField; } @end diff --git a/Palettes/4Data/GormNumberFormatterAttributesInspector.m b/Applications/Gorm/Palettes/4Data/GormNumberFormatterAttributesInspector.m similarity index 86% rename from Palettes/4Data/GormNumberFormatterAttributesInspector.m rename to Applications/Gorm/Palettes/4Data/GormNumberFormatterAttributesInspector.m index c60d049f..2460c0a1 100644 --- a/Palettes/4Data/GormNumberFormatterAttributesInspector.m +++ b/Applications/Gorm/Palettes/4Data/GormNumberFormatterAttributesInspector.m @@ -51,8 +51,10 @@ extern NSArray *predefinedNumberFormats; else { NSNumberFormatter *fmtr = [[NSNumberFormatter alloc] init]; - [fmtr setFormat: [NSNumberFormatter defaultFormat]]; + + [fmtr setFormat: [NSNumberFormatter defaultFormat]]; [[positiveField cell] setFormatter: fmtr]; + [[zeroField cell] setFormatter: fmtr]; [[negativeField cell] setFormatter: fmtr]; } } @@ -61,14 +63,17 @@ extern NSArray *predefinedNumberFormats; - (void) updateAppearanceFieldsWithFormat: (NSString *)format; { - [[[positiveField cell] formatter] setFormat: format]; [[positiveField cell] setObjectValue: - [NSDecimalNumber decimalNumberWithString: @"123456.789"]]; - + [NSDecimalNumber decimalNumberWithString: @"123456.789"]]; + + [[[zeroField cell] formatter] setFormat: format]; + [[zeroField cell] setObjectValue: + [NSDecimalNumber decimalNumberWithString: @"0.000"]]; + [[[negativeField cell] formatter] setFormat: format]; [[negativeField cell] setObjectValue: - [NSDecimalNumber decimalNumberWithString: @"-123456.789"]]; + [NSDecimalNumber decimalNumberWithString: @"-123456.789"]]; } - (void) ok: (id)sender @@ -79,12 +84,12 @@ extern NSArray *predefinedNumberFormats; NSNumberFormatter *fmtr = [cell formatter]; // Mark as changed... - [[(id)NSApp activeDocument] touch]; + [[(id)[NSApp delegate] activeDocument] touch]; if (sender == detachButton) { [cell setFormatter: nil]; - [[(id)NSApp activeDocument] setSelectionFromEditor: nil]; + [[(id)[NSApp delegate] activeDocument] setSelectionFromEditor: nil]; } else { @@ -98,28 +103,27 @@ extern NSArray *predefinedNumberFormats; zeroFmt = [NSNumberFormatter zeroFormatAtIndex:row]; negativeFmt = [NSNumberFormatter negativeFormatAtIndex:row]; fullFmt = [NSNumberFormatter formatAtIndex:row]; - - // Update Appearance samples - [self updateAppearanceFieldsWithFormat: fullFmt]; - - // Update editable format fields - [[formatForm cellAtIndex:0] setStringValue: VSTR(positiveFmt)]; - [[formatForm cellAtIndex:1] setStringValue: VSTR(zeroFmt)]; - [[formatForm cellAtIndex:2] setStringValue: VSTR(negativeFmt)]; - [fmtr setFormat:fullFmt]; + // Update Appearance samples + [self updateAppearanceFieldsWithFormat: fullFmt]; + // Update editable format fields + [[formatForm cellAtIndex:0] setStringValue: VSTR(positiveFmt)]; + [[formatForm cellAtIndex:1] setStringValue: VSTR(zeroFmt)]; + [[formatForm cellAtIndex:2] setStringValue: VSTR(negativeFmt)]; + + [fmtr setFormat:fullFmt]; } } else if (sender == formatForm) { NSUInteger idx; - positiveFmt = [[sender cellAtIndex:0] stringValue]; - zeroFmt = [[sender cellAtIndex:1] stringValue]; - negativeFmt = [[sender cellAtIndex:2] stringValue]; - minValue = [[sender cellAtIndex:3] stringValue]; - maxValue = [[sender cellAtIndex:4] stringValue]; + positiveFmt = [[sender cellAtIndex: 0] stringValue]; + zeroFmt = [[sender cellAtIndex: 1] stringValue]; + negativeFmt = [[sender cellAtIndex: 2] stringValue]; + minValue = [[sender cellAtIndex: 3] stringValue]; + maxValue = [[sender cellAtIndex: 4] stringValue]; NSDebugLog(@"min,max: %@, %@", minValue, maxValue); fullFmt = [NSString stringWithFormat:@"%@;%@;%@", diff --git a/Palettes/4Data/GormTextViewAttributesInspector.h b/Applications/Gorm/Palettes/4Data/GormTextViewAttributesInspector.h similarity index 100% rename from Palettes/4Data/GormTextViewAttributesInspector.h rename to Applications/Gorm/Palettes/4Data/GormTextViewAttributesInspector.h diff --git a/Palettes/4Data/GormTextViewAttributesInspector.m b/Applications/Gorm/Palettes/4Data/GormTextViewAttributesInspector.m similarity index 100% rename from Palettes/4Data/GormTextViewAttributesInspector.m rename to Applications/Gorm/Palettes/4Data/GormTextViewAttributesInspector.m diff --git a/Palettes/4Data/GormTextViewEditor.h b/Applications/Gorm/Palettes/4Data/GormTextViewEditor.h similarity index 100% rename from Palettes/4Data/GormTextViewEditor.h rename to Applications/Gorm/Palettes/4Data/GormTextViewEditor.h diff --git a/Palettes/4Data/GormTextViewEditor.m b/Applications/Gorm/Palettes/4Data/GormTextViewEditor.m similarity index 97% rename from Palettes/4Data/GormTextViewEditor.m rename to Applications/Gorm/Palettes/4Data/GormTextViewEditor.m index 14fda8bf..8d008428 100644 --- a/Palettes/4Data/GormTextViewEditor.m +++ b/Applications/Gorm/Palettes/4Data/GormTextViewEditor.m @@ -116,7 +116,7 @@ if (destination == nil) destination = _editedObject; - [NSApp displayConnectionBetween: [NSApp connectSource] + [[NSApp delegate] displayConnectionBetween: [[NSApp delegate] connectSource] and: destination]; return NSDragOperationLink; } diff --git a/Palettes/4Data/GormTextViewSizeInspector.h b/Applications/Gorm/Palettes/4Data/GormTextViewSizeInspector.h similarity index 100% rename from Palettes/4Data/GormTextViewSizeInspector.h rename to Applications/Gorm/Palettes/4Data/GormTextViewSizeInspector.h diff --git a/Palettes/4Data/GormTextViewSizeInspector.m b/Applications/Gorm/Palettes/4Data/GormTextViewSizeInspector.m similarity index 100% rename from Palettes/4Data/GormTextViewSizeInspector.m rename to Applications/Gorm/Palettes/4Data/GormTextViewSizeInspector.m diff --git a/Palettes/4Data/inspectors.m b/Applications/Gorm/Palettes/4Data/inspectors.m similarity index 100% rename from Palettes/4Data/inspectors.m rename to Applications/Gorm/Palettes/4Data/inspectors.m diff --git a/Palettes/4Data/palette.table b/Applications/Gorm/Palettes/4Data/palette.table similarity index 100% rename from Palettes/4Data/palette.table rename to Applications/Gorm/Palettes/4Data/palette.table diff --git a/Palettes/GNUmakefile b/Applications/Gorm/Palettes/GNUmakefile similarity index 100% rename from Palettes/GNUmakefile rename to Applications/Gorm/Palettes/GNUmakefile diff --git a/README b/Applications/Gorm/README similarity index 100% rename from README rename to Applications/Gorm/README diff --git a/Resources/Defaults.plist b/Applications/Gorm/Resources/Defaults.plist similarity index 100% rename from Resources/Defaults.plist rename to Applications/Gorm/Resources/Defaults.plist diff --git a/Applications/Gorm/Resources/language-codes.plist b/Applications/Gorm/Resources/language-codes.plist new file mode 100644 index 00000000..72d04250 --- /dev/null +++ b/Applications/Gorm/Resources/language-codes.plist @@ -0,0 +1,188 @@ +{ + alpha2 = English; + aa = Afar; + ab = Abkhazian; + ae = Avestan; + af = Afrikaans; + ak = Akan; + am = Amharic; + an = Aragonese; + ar = Arabic; + as = Assamese; + av = Avaric; + ay = Aymara; + az = Azerbaijani; + ba = Bashkir; + be = Belarusian; + bg = Bulgarian; + bh = Bihari; + bi = Bislama; + bm = Bambara; + bn = Bengali; + bo = Tibetan; + br = Breton; + bs = Bosnian; + ca = Catalan; + ce = Chechen; + ch = Chamorro; + co = Corsican; + cr = Cree; + cs = Czech; + cu = ChurchSlavic; + cv = Chuvash; + cy = Welsh; + da = Danish; + de = German; + dv = Divehi; + dz = Dzongkha; + ee = Ewe; + el = Greek; + en = English; + eo = Esperanto; + es = Spanish; + et = Estonian; + eu = Basque; + fa = Persian; + ff = Fulah; + fi = Finnish; + fj = Fijian; + fo = Faroese; + fr = French; + fy = WesternFrisian; + ga = Irish; + gd = Gaelic; + gl = Galician; + gn = Guarani; + gu = Gujarati; + gv = Manx; + ha = Hausa; + he = Hebrew; + hi = Hindi; + ho = HiriMotu; + hr = Croatian; + ht = Haitian; + hu = Hungarian; + hy = Armenian; + hz = Herero; + ia = Interlingua; + id = Indonesian; + ie = Interlingue; + ig = Igbo; + ii = Nuosu; + ik = Inupiaq; + io = Ido; + is = Icelandic; + it = Italian; + iu = Inuktitut; + ja = Japanese; + jv = Javanese; + ka = Georgian; + kg = Kongo; + ki = Kikuyu; + kj = Kuanyama; + kk = Kazakh; + kl = Kalaallisut; + km = CentralKhmer; + kn = Kannada; + ko = Korean; + kr = Kanuri; + ks = Kashmiri; + ku = Kurdish; + kv = Komi; + kw = Cornish; + ky = Kirghiz; + la = Latin; + lb = Luxembourgish; + lg = Ganda; + li = Limburgan; + ln = Lingala; + lo = Lao; + lt = Lithuanian; + lu = "Luba-Katanga"; + lv = Latvian; + mg = Malagasy; + mh = Marshallese; + mi = Maori; + mk = Macedonian; + ml = Malayalam; + mn = Mongolian; + mr = Marathi; + ms = Malay; + mt = Maltese; + my = Burmese; + na = Nauru; + nb = Bokmal; + nd = NdebeleNorth; + ne = Nepali; + ng = Ndonga; + nl = Dutch; + nn = Norsk; + no = Norwegian; + nr = Ndebele; + nv = Navajo; + ny = Chichewa; + oc = Occitan; + oj = Ojibwa; + om = Oromo; + or = Oriya; + os = Ossetian; + pa = Panjabi; + Punjabi = Punjabi; + pi = Pali; + pl = Polish; + ps = Pushto; + pt = Portuguese; + qu = Quechua; + rm = Romansh; + rn = Rundi; + ro = Romanian; + ru = Russian; + rw = Kinyarwanda; + sa = Sanskrit; + sc = Sardinian; + sd = Sindhi; + se = NorthernSami; + sg = Sango; + si = Sinhala; + sk = Slovak; + sl = Slovenian; + sm = Samoan; + sn = Shona; + so = Somali; + sq = Albanian; + sr = Serbian; + ss = Swati; + st = Sotho; + su = Sundanese; + sv = Swedish; + sw = Swahili; + ta = Tamil; + te = Telugu; + tg = Tajik; + th = Thai; + ti = Tigrinya; + tk = Turkmen; + tl = Tagalog; + tn = Tswana; + to = Tonga; + tr = Turkish; + ts = Tsonga; + tt = Tatar; + tw = Twi; + ty = Tahitian; + ug = Uighur; + uk = Ukrainian; + ur = Urdu; + uz = Uzbek; + ve = Venda; + vi = Vietnamese; + vo = Volapuk; + wa = Walloon; + wo = Wolof; + xh = Xhosa; + yi = Yiddish; + yo = Yoruba; + za = Zhuang; + zh = Chinese; + zu = Zulu; +} \ No newline at end of file diff --git a/TODO b/Applications/Gorm/TODO similarity index 100% rename from TODO rename to Applications/Gorm/TODO diff --git a/main.m b/Applications/Gorm/main.m similarity index 100% rename from main.m rename to Applications/Gorm/main.m diff --git a/Applications/README.md b/Applications/README.md new file mode 100644 index 00000000..a3fa0a0a --- /dev/null +++ b/Applications/README.md @@ -0,0 +1,7 @@ +# Applications directory +This directory holds the Gorm application and any other apps which might be written using the framework Gorm provides. +The future plans for this directory are to also contain a Plugins directory to facilitate editing Gorm files and other +model files in YCode (an upcoming GNUstep IDE) as the plugins would conform to a protocol usable by YCode. + +An advantage of this approach is that there would be no direct dependencies between YCode and Gorm, but YCode could +still utilize Gorm's features. diff --git a/ChangeLog b/ChangeLog index 8d79e15b..f6166bfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2024-12-29 Gregory John Casamento + + * GormCore/English.lproj/GormObjectOutlineView.gorm/data.classes + * GormCore/GNUmakefile + * GormCore/GormDocument.h + * GormCore/GormDocument.m + * GormCore/GormGenericEditor.h + * GormCore/GormObjectEditor.h + * GormCore/GormObjectEditor.m + * GormCore/GormObjectMainView.h + * GormCore/GormObjectMainView.m + * GormCore/GormObjectOutlineView.h + * GormCore/GormObjectOutlineView.m + * GormCore/GormObjectViewController.h + * GormCore/GormObjectViewController.m: Add support for + outline view of objects. + +2024-12-25 Gregory John Casamento + + * GormObjCHeaderParser/OCClass.m: Improve parsing + to allow getting information from .m files/categories. + 2023-01-15 Gregory John Casamento * ANNOUNCE diff --git a/Documentation/ANNOUNCE b/Documentation/ANNOUNCE new file mode 100644 index 00000000..c8c6d4f5 --- /dev/null +++ b/Documentation/ANNOUNCE @@ -0,0 +1,48 @@ +1 ANNOUNCE +********** + +This is version 1.4.0 of Gorm. + +1.1 What is Gorm? +================= + +Gorm is an acronym for Graphic Object Relationship modeler (or perhaps +GNUstep Object Relationship Modeler). + + Gorm is a clone of the Cocoa (OpenStep/NeXTSTEP) 'Interface Builder' +application for GNUstep. + +1.2 Noteworthy changes in version '1.4.0' +========================================= + + * Fix issue with saving a gorm from a nib file. + * Fix issue with saving a gorm file from a xib. + * Add XLIF support for language translation. + * Add capability to generate XIB file. + * Add gormtool command-line tool. Allows some gorm work without the + gui + * Fixes and some improvements to structure Gorm as framework/app. + +1.3 How can I get support for this software? +============================================ + +You may wish to use the GNUstep discussion mailing list for general +questions and discussion. Look at the GNUstep Web Pages for more +information regarding GNUstep resources + +1.4 Where can you get it? How can you compile it? +================================================= + +You can download sources and rpms (for some machines) from +. + +1.5 Where do I send bug reports? +================================ + +Bug reports can be sent to . + +1.6 Obtaining GNU Software +========================== + +Check out the GNUstep web site. (), and the +GNU web site. () diff --git a/Documentation/Makefile.postamble b/Documentation/Makefile.postamble index eec0d00a..8ba7cacc 100644 --- a/Documentation/Makefile.postamble +++ b/Documentation/Makefile.postamble @@ -15,15 +15,11 @@ before-all:: version.texi autogsdoc -MakeFrames YES \ -DocumentationDirectory InterfaceBuilder \ -Declared InterfaceBuilder \ - ../GormLib/*.h 2> /dev/null + ../InterfaceBuilder/*.h 2> /dev/null autogsdoc -MakeFrames YES \ -DocumentationDirectory GormCore \ -Declared GormCore \ ../GormCore/*.h 2> /dev/null - autogsdoc -MakeFrames YES \ - -DocumentationDirectory GormPrefs \ - -Declared GormPrefs \ - ../GormPrefs/*.h 2> /dev/null autogsdoc -MakeFrames YES \ -DocumentationDirectory GormObjCHeaderParser \ -Declared GormObjCHeaderParser \ @@ -53,7 +49,6 @@ after-clean:: rm -f version.texi rm -rf InterfaceBuilder rm -rf GormCore - rm -rf GormPrefs rm -rf GormObjCHeaderParser # Things to do before distcleaning @@ -79,5 +74,3 @@ version.texi: ../Version regenerate: mv ANNOUNCE README INSTALL NEWS .. - - diff --git a/Documentation/NEWS b/Documentation/NEWS new file mode 100644 index 00000000..a56f6af4 --- /dev/null +++ b/Documentation/NEWS @@ -0,0 +1,664 @@ +1 Noteworthy changes in version '1.4.0' +======================================= + + * Fix issue with saving a gorm from a nib file. + * Fix issue with saving a gorm file from a xib. + * Add XLIF support for language translation. + * Add capability to generate XIB file. + * Add gormtool command-line tool. Allows some gorm work without the + gui + * Fixes and some improvements to structure Gorm as framework/app. + +2 Noteworthy changes in version '1.3.1' +======================================= + + * Fix issue with cells appearing in top level editor + * Make nibs read only since saving is unstable + * Add XIB reading so that they can be loaded by Gorm + * Add storyboard file to list of supported files so that an icon is + displayed, does not support reading yet. + * Fix testing model mode + * Bug fixes in GormClassManager, GormDocument, etc. + +3 Noteworthy changes in version '1.2.28' +======================================== + + * Improved NSScrollView handling. + * Added NSMatrix to Group menu to make it easier to create NSMatrix + objects + * Improved inspector for NSMatrix. Added ability to add rows/columns + * Fixed NSMatrix selection problems when grouped in an NSScrollView + * Fixes and other improvements to inspectors. Corrected issue where + Gorm's menu stays present during testing mode. + +4 Noteworthy changes in version '1.2.26' +======================================== + + * Refactoring of palettes by Sergii Stoian to correct usability + issues in Gorm. + * Refactoring of handling and rearrangment of controls in inspectors + for usuability. + * Stability fixes to make Gorm easier to use. + * Autosizing of views corrected in many inspectors + * Improvements in error handling. + +5 Noteworthy changes in version '1.2.24' +======================================== + + * Fix for issue where Gorm was referencing private variables. This + caused a crash when built with clang. + +6 Noteworthy changes in version '1.2.23' +======================================== + + * Fix for issue where NSPanel was being saved as an NSWindow in some + cases. + +7 Noteworthy changes in version '1.2.22' +======================================== + + * Fix for bug#45040: Fix allows Gorm custom class functionality to + work normally on OpenBSD/NetBSD/FreeBSD. + * Fixes for Solaris + * Memory leak fixes. + * Objective-C parser improvements. + +8 Noteworthy changes in version '1.2.20' +======================================== + + * Bug fixes #28643, #32827 + * Corrected issues with updating document when there is a change. + * Add cells as objects to the document so they can be properly + edited. + * Changes to prevent recursive frame change notifications. + +9 Noteworthy changes in version '1.2.18' +======================================== + + * Code cleanup, removal of warnings when building with clang. + * Removal of use of call to objc_poseAs(..) which was preventing + building with newer runtimes. + * Stability improvements. + +10 Noteworthy changes in version '1.2.16' +========================================= + + * XIB reading. + * Bug fixes for standalone views. + * Stability changes. + +11 Noteworthy changes in version '1.2.12' +========================================= + +Requires: gnustep-base-1.20.0, gnustep-gui-0.18.0. Reason: Parts of the +runtime which Gorm used were refactored and it was necessary to make +corresponding changes in Gorm to use it. + + * Correction for bugs #27295, 28643, 29085. + * Added a DO server which allows modification of internal data + structures using a simple interface. + * Tooltips now show the object name and the object type for + informational purposes. + * Opens default document when using NSWindows95InterfaceStyle. + +12 Noteworthy changes in version '1.2.10' +========================================= + + * Correction for bug #25401 + * Correction for some nib loading issues. + * Limited support for standalone views. + * Fixes for various bugs. + +13 Noteworthy changes in version '1.2.8' +======================================== + +Requires: gnustep-gui-0.16.0. It will not compile without this version +of the library. Reason: Nib and Gorm loading were moved to a more +sensible file structure. Additionally, Nib loading was refactored. + + * Correction for bug#25001. + * Correction for bug#25111. + * Fixes for nib encoding to use the proper template class instances. + * Changes to use new headers. + +14 Noteworthy changes in version '1.2.6' +======================================== + + * Corrections to allow Gorm to build and run properly on the Darwin + operating system. + * Corrected sizing of Controls Palette. + * Added preliminary support for IBPlugin API. + * Added preferences panel to add plugins dynamically. + * Moved load/save logic for gorm, gmodel, and nib to plugins. This + change should allow plugins for virtually any format to be + read/written by Gorm. + * Correction for bug#24146, bug#23889. + +15 Noteworthy changes in version '1.2.4' +======================================== + +Requires: gnustep-gui-0.13.2. Reason: Due to changes in popupbutton +controller logic. + + * Corrected bug#'s 19640, 21845, 19792, 15637, 17892, 18171. + * Added error panel to show the detected inconsistencies in a file. + * Added preference setting to turn on or off the gorm file repair + logic. + * Added capability to repair logic to fix window level issue. + * Added ruler switch to scroll view inspector. + +16 Noteworthy changes in version '1.2.2' +======================================== + +Requires: gnustep-gui-0.13.0. + + * Moved to GPLv3 + * Added text field to NSTableColumn inspector to allow editing of + table column title. + * Corrected issue with selection. + * Added button modifiers for special keys to button inspectors. + * Corrected issue with loading of older gorm files. + * Fix to allow Gorm's menus to be Mac-style, but not the one being + edited. + * Other miscellaneous bug corrections. + +17 Noteworthy changes in version '1.2.1' +======================================== + + * Minor corrections to previous release. + +18 Noteworthy changes in version '1.2.0' +======================================== + + * Corrections to some editors to not change selection if connection + is in progress. + * Force menu style to NSNextStepInterfaceStyle for editing purposes. + * Correction for memory issue when closing document. + * Minor bug fixes. + +19 Noteworthy changes in version '1.1.0' +======================================== + + * Changed Gorm architecture to use NSDocument classes. + * Abstracted model loading mechanism. This was done by implementing + a set of "Loader" and "Builder" classes which handle filling in the + data structures in Gorm and exporting them to external formats. + * Implemented GormNibWrapperLoader and GormNibWrapperBuilder for + reading and writing Cocoa NIB files. + * Implemented GormGormWrapperLoader and GormGormWrapperBuilder for + reading and writing GNUstep Gorm files + * Implemented GormGModelWrapperLoader for reading GNUstep gmodel + files. + * Updated icon + * A number of bugs have been addressed in this release. + +20 Noteworthy changes in version '1.0.8' +======================================== + +This is a bugfix release. + + * Correction for bug#16587. + * Correction for handling non-string identifiers in tableviews. + +21 Noteworthy changes in version '1.0.6' +======================================== + +This is a bugfix release. + + * Entirely new icon set, for palettes, gorm, gmodel, nib and the + application. + * Replaced some of the images for the inspectors. + * Corrected the following bugs since the last release: #16049, + #16050, #15988, #16049, #15989, #15987, #15817, #15780, #15642, + #15556. + * Changed formatting in some of the inspectors so that they are + easier to navigate. + +22 Noteworthy changes in version '1.0.4' +======================================== + +This is a bugfix release. + + * Corrected some bug#15236 with window style mask settings. + * Corrected bug#15236, which caused window fields in the inspector + not to update when the field was being edited and a new window is + selected. + * Corrected bug #15178. + * Corrected problem with standalone views + +23 Noteworthy changes in version '1.0.2' +======================================== + +This is a bugfix release. + + * Fixed some bugs with table column selection. + * Corrected a minor problem in the custom class inspector. + +24 Noteworthy changes in version '1.0.0' +======================================== + +PLEASE NOTE: This version of Gorm requires base 1.11.1 and gui 0.10.1 to +be installed (gnustep-startup-0.13.0). + + * All inspectors are now modeled in .gorm files. + * Added autosizing to form attributes inspector. + * Utilize and maintain parent/child data structure more pervasively + * Reorganized code in palettes for cleaner implementation. + * Removed code to check for user bundles, since bugs in Camaelon + which prompted those changes were fixed long ago. + * Added documentation to GormCore + +25 Noteworthy changes in version '0.11.0' +========================================= + + * Improved implementation of canSubstituteForClass: the default + implementation of this method tests the classes to see if + initWithCoder: or encodeWithCoder: is implemented on a subclass to + determine automatically if that class has the same encoding + signature as the original class, if it does, it can be substituted. + * Improved handling of classes which use cell classes in the custom + class inspector. The inspector now autmatically replaces the cell + class with the appropriate one when the user selects a given + subclass. + * Browser based class editor in document panel. This interface is + more like the one on OSX. The user now has a choice in preferences + to determine which view they would like to use. + * Translation tools. The Document->Translate menu allows the user to + export string and import strings in the strings format, so that + someone can easily translate just the strings in the file and + doesn't need to directly edit anything in Gorm. The strings file + can then be loaded back into Gorm and all of the relevant strings + are updated. + * Alignment tools. In the new Layout menu there are options to align + views, center views, bring views to front or push them to the back + of the view layers. + * Implementation of IBViewResourceDraggingDelegate. This allows + updating of the pull down in the inspectors panel dynamically. It + requires the developer of a palette to implement some code to + enable this, as on OSX. + * Lots of bugfixes and usability changes are also included in this + release. + +26 Noteworthy changes in version '0.9.10' +========================================= + + * Gorm now has a full implementation of canSubstituteForClass: which + is used to determine if a class can be substituted in the custom + class inspector. This allows classes added in palettes to say + whether or not they can be used as a subsitute for a kit class. + * Better separation of Gorm into libraries. As well as the ability + to compile on windows with a simple: "make install" + * Implementation of IBResourceManager class. This class is used by + palettes to register drag types to be considered by the top level + editors in the document window: object, sound, image, class. + * Gorm now is able to switch views in the document window when you + drag a file into it. If it's an image it will switch to the image + view, if it's a sound, the sound view, an object the object view + etc or if it's a class (a .h file) it will switch to the classes + view. + * Drag and drop parsing of header files (if you hadn't gathered from + the previous item). + * Better support for standalone views. while the user cannot + instantiate from the classes view (there were too many problems + with this approach). They can now drag any view from the palette + into the objects view and have it work. + * A myriad of bug fixes. + +27 Noteworthy changes in version '0.9.2' +======================================== + +NOTE: This is mainly a bugfix release. + + * Some improvements to the procedure for removing connections. + * Corrected various issues with header parsing. + * Now closes windows which were opened during interface testing such + as font panels, info panels, etc. + * Minor corrections to background color for a number of inspectors. + * Improvements to gmodel importation. + * Better detection of when the user is utilizing a user bundle. Gorm + will now warn the user with a panel. + * Various improvements in documentation + +28 Noteworthy changes in version '0.9.0' +======================================== + + * Images/Sounds can now be dragged into a matrix cell. + * Fully implemented date and number formatter inspectors (these + classes still need work in GUI). + * Added warning panel if the user attempts to edit a .gorm file + created with a newer version of Gorm + * Modified data.classes format so that only those actions + specifically added to FirstResponder are listed. + * Greatly improved gmodel importation. (experimental) + * It's now possible to add methods to classes which are not custom. + This allows the user to add actions which may have been added to + those classes by categories. + * Completely new header parser implemented. + * Improved cut/paste. It's now possible to use cut/paste from almost + anywhere. The class editor now fully supports it. + * Improved implementation of some of the InterfaceBuilder framework + classes. + * Object editor will now remove all instances of a class that has + been deleted from the class editor. + * The class inspector and the classes view will now apply stricter + rules to names of actions and outlets to ensure that they are + properly entered. + * All inspectors work perfectly with customized colors. + * Fixed a number of bugs. + +29 Noteworthy changes in version '0.8.0' +======================================== + +PLEASE NOTE: It is important for this release that you upgrade to Gorm +0.8.0 when using Gorm with the new GNUstep libraries (base-1.10.0 and +gui-0.9.4). This version of Gorm contains some features which are +reliant on changes made in those versions of the libraries. It is +stated in Gorm's documentation (the Gorm.texi file) that this is +required, but I felt it important enough to also mention it here so that +it is known beyond a reasonable doubt. + + * New gorm file version. + * Full custom palette support + * Palette preferences panel to allow the user to configure palettes + to load + * Experimental: Standalone views. This feature is to allow the use + of a view without the need of a containing window. This allows + developers to treat these views as they would any other top level + object in the .gorm file. This is experimental functionality. + * Improved NSTableColumn inspector. The new inspector allows the + user to change the data cell used for a given column. This allows + the user to select from a list of cell subclasses and set the + appropriate custom or non-custom one they want to appear in that + column of the table. + * Improved layout of some of the inspectors. + * Removed old class parser. The parser was somewhat buggy and was + actually causing some issues. A new parser will be available in + the next version of Gorm. For now users will need to use the class + inspector or the outline view to enter classes into Gorm. + * Experimental: "File" section. This is essentially a per-file + preference which allows the user to control which version of + GNUstep a given file will be compatible with. It also lists the + potential compatibility issues with the selected version. + * Improved controls palette. New items for some of the standard font + replace the old "Title" widget which was a System-14 font. The new + widgets use a selection of the standard System font to allow the + user to easily build a gui using these and reducing the amount of + time the user needs to spend fiddling with the font panel. + +30 Noteworthy changes in version '0.7.7' +======================================== + + * Important bugfixes in editor classes. + * Rearranged some of the editor classes to be in the palettes which + contain the classes they are responsible for editing + (GormButtonEditor & GormTabViewEditor). + * Image and Sound editors will now display system default images or + sounds if they are available. + * Document window now uses an NSToolbar (experimental). + * Improved the layout of some of the inspectors. + * Corrected some minor issues in the inspectors + * Added code to allow NSTableView and NSOutlineView to show some data + during testing + * Gorm will now show an alert panel when a model fails to load or + test properly. + +31 Noteworthy changes in version '0.7.6' +======================================== + +This release is mainly a bugfix release for 0.7.5. + + * Improved .gmodel support + * Corrections to previous repair feature. + * Important bugfixes for Menu editing. + * Important bugfixes for class inspector. + +32 Noteworthy changes in version '0.7.5' +======================================== + + * The 'reparent' feature in the class inspector. This allows the + user to change the class hierarchy from within Gorm. + * Some important bugfixes + * a property 'GormRepairFileOnLoad' (untested) which should repaire + old .gorm files... It is HIGHLY recommended that Gorm not be run + with this on constantly and that you back up any files which you + want to repair before opening them with this option turned on. + * A shelf inspector in prefs that lets you expand the size of the + names in the object view.. + * Support for NSFontManager + * A way to restore a complete NSMenu if it's deleted (a new palette + entry for NSMenu, not just an item) + +33 Noteworthy changes in version '0.6.0' +======================================== + + * Several major bugs corrected. + * Clarified some of the inspectors + * Menu items are now properly enabled/disabled when appropriate + * More descriptive title displayed when a class is being edited. + +34 Noteworthy changes in version '0.5.0' +======================================== + + * Enabled defer in NSWindow inspector. + * Added code to the connection inspector to prevent erroneous + connections. + * Added support for upgrading of old .gorm files using the older + template mechanism + * Grouping with an NSSplitView now operates using the relative + positions of the views in the window. + * Custom Class inspector now shows all subclasses, not just direct + custom subclasses. + * Bug fixes, eliminated memory leak, code cleanup, etc. + +35 Noteworthy changes in version '0.4.0' +======================================== + + * New Menu and Menu Item inspectors. + * User can now specify the Services and Windows menus in the menu + inspector. + * User can specify a non-custom subclass as well as a custom one to + replace the class when the .gorm is unarchived. This can be used + to turn a NSTextField into NSSecureTextField and etc. + * New set name panel. + * New switch control on the font panel to allow the user to specify + if a font is encoded with its default size or not. + * Added NSStepper and NSStepperCell to the class list to allow + creation of custom subclasses. + * Windows and Services menus now function correctly. + +36 Noteworthy changes in version '0.3.1' +======================================== + + * New custom class system. + * Images now persist correctly when added to a button or view. + * Fixed DND + * Various bugfixes + +37 Noteworthy changes in version '0.3.0' +======================================== + + * Preferences added. + * User can now enable and disable guidlines for easier editing. + * Refactored code into GormLib which is a clone of the + InterfaceBuilder framework. This facilitates creating palettes and + inspectors outside of Gorm. + * Added class inspector for easier editing of classes. This gives + the user the option to use either the outline view or the inspector + to edit new classes. + * Added inspectors for the following: NSScrollView, + NSProgressIndicator, NSColorWell, GormImageInspector (for images + added to .gorm files). + * Improved look of NSTabView inspector. + * Removed all warnings from the code. + * various bug fixes. + +38 Noteworthy changes in version '0.2.5'. +========================================= + +Many fixes and improvements to make the app work better. + + * Better parsing of headers + * Interface code redone as gorm files. + * Re-add multiple selection via mouse drag. + +39 Noteworthy changes in version '0.2.0' snapshot. +================================================== + +Gobs of improvements, mostly due to the hard work of Gregory John +Casamento and Pierre-Yves Rivaille. Thanks guys! + + * Custom class support/translations implemented. + * Added NSScrollView, NSPopupButton, NSOutlineView, NSTableView + editing. + * Improved test mode support. + * Improved drag n' drop support on many items. + * Intelligent placement hints. + * Read gmodel files. + * More inspectors. + * Sound and Image support. + * gorm files were changed to directory wrappers for more flexibility. + +40 Noteworthy changes in version '0.1.0' +======================================== + + * load/parses class files for entry into class list. + * Pallete/inspectors for date and number formatters + * Pallete/Inspectors for browsers and tableViews + * NSStepper, NSForm, NSPopupButton pallete item and inspector + * Most inspectors greatly improved and fleshed out. + * Custom views added. + * Ability to edit cells in a matrix. + * Ability to change the font of some objects. + +41 Noteworthy changes in version '0.0.3' +======================================== + + * Create stub .m and .h files from new classes + * Works better with ProjectCenter. + * Handle Ctrl-Drag and Alt-Drag of objects - automatic conversion to + matrices and/or increase decrease rows and cols. + * Edit NSForms titles in place. + * Edit NSBoxes and add subviews. + * Support for custom objects. + +42 Noteworthy changes in version '0.0.2' +======================================== + + * Add popup and pulldown menu controls + * Menu support + * More inspectors + * Some support for connections + * Much more fleshed out - too numerous to mention. + +43 Noteworthy changes in version '0.0.1' +======================================== + + * 8th December 1999 + + * Save/Load 'nib' documents (binary archived data) + + This works so far as it can be tested - but that's just + archives containing windows or panels so far. + + * Load palettes + + Loading of palettes works. You can load palettes from the + 'Tools' menu. Gorm automatically loads all the palettes from + its Resources directory. + + * Basic framework + + So far, the app provides a basic framework that needs fleshing + out. + * It has a palettes manager object that allows you to + select a palette and drag items from the palette into + your document. + + * It has a special per-document editor object, which keeps + track of a matrix of icons representing the top-level + objects in the document. + + * It has an inspector manager class, which updates the + inspector panel when the selected object is changed by an + editor. + + * It has special inspectors for handling an empty selection + or a multiple selection. + + * Palettes + + Four palettes (three of which are empty at present) are built + and installed in the apps Resources directory. + + The Window palette is more fully fleshed out than the other + palettes. It permits windows and panels to be created in + Gorm. If provides the start of a window attributes inspector. + + * 18 December 1999 + + * You can drag views from a palette into a window or panel. + * You can select views in a window by clicking on them, + shift-clicking (for multiple selection), or click-drag on the + window background to select views in a box. + * You can delete/cut/copy/paste views betwen windows. + * You can move views in a window by clicking on them and + dragging. + * You can resize views by clicking on their knobs and dragging. + * You can control-drag to mark source and destination views for + a connection. + + * Next task - inspectors. + + The connection inspector needs to be implemented to complete + the process of establishing connections. The size inspector + needs to be implemented to set autosizing parameters for a + view. + + Once these are done, the object editor needs to be made to + support connections so that we can connect between objects + other than views, then we need to write a menu editor. + + * 22 December 1999 + + * Connections inspector is now working - but it needs some + effort to tidy it up. + * Class info (outlets and actions) is specified in + 'ClassInformation.plist' and needs to be present so that the + app knows what outlets/actions an object has (and therefore + what connections can be made). + + * The view size inspector is working - allowing you to set the + size of the subviews within a window. + + * The attributes inspector for 'FilesOwner' is working, so you + can define the class of the files owner (it defaults to + NSApplication). + + * There is a crude panel for setting the name of the selected + object. + + * I've created a couple of new images and got rid of the two + NeXT images that were lurking in there. + + * There is a Testing directory, with a GormTest application that + lets you load a nib for testing - it assumes that the nib will + set its FilesOwners delegate to point to a window, and makes + that window the key window ... + + * 23 December 1999 + + Last work before christmas ... + + Various bits of tidying up plus - + + Added an evil hack of a generic attributes inspector ... This + looks through all the methods of the selected object to find those + taking a single argument and beginning with 'set'. It makes all + these setting methods (whose argument is a simple scalar type or an + object) available for you to invoke from the inspector panel. + + This makes it possible to set pretty much any attribute of any + object, but you do need to have the GNUstep header files to hand, + so you can tell what numeric values to enter to achieve a desired + result. + diff --git a/Documentation/README.md b/Documentation/README.md new file mode 100644 index 00000000..1745ebbf --- /dev/null +++ b/Documentation/README.md @@ -0,0 +1,3 @@ +# Documentation directory + +This directory contains documentation for the Gorm application as well as the frameworks used in it's functionality. diff --git a/Documentation/news.texi b/Documentation/news.texi index 7c262fbd..242de97f 100644 --- a/Documentation/news.texi +++ b/Documentation/news.texi @@ -4,6 +4,21 @@ @include version.texi @end ifset +@section Noteworthy changes in version @samp{1.4.0} + +@itemize @bullet +@item Fix issue with saving a gorm from a nib file. +@item Fix issue with saving a gorm file from a xib. +@item Add XLIF support for language translation. +@item Add capability to generate XIB file. +@item Add gormtool command-line tool. Allows some gorm work without the gui +@item Fixes and some improvements to structure Gorm as framework/app. +@end itemize + +@c ==================================================================== +@c Keep the next line just below the list of changes in most recent version. +@ifclear ANNOUNCE-ONLY + @section Noteworthy changes in version @samp{1.3.1} @itemize @bullet @@ -15,10 +30,6 @@ @item Bug fixes in GormClassManager, GormDocument, etc. @end itemize -@c ==================================================================== -@c Keep the next line just below the list of changes in most recent version. -@ifclear ANNOUNCE-ONLY - @section Noteworthy changes in version @samp{1.2.28} @itemize @bullet diff --git a/English.lproj/Gorm.gorm/data.classes b/English.lproj/Gorm.gorm/data.classes deleted file mode 100644 index ed146645..00000000 --- a/English.lproj/Gorm.gorm/data.classes +++ /dev/null @@ -1,65 +0,0 @@ -{ - "## Comment" = "Do NOT change this file, Gorm maintains it"; - FirstResponder = { - Actions = ( - "alignSelectedObjects:", - "arrangeSelectedObjects:", - "exportStrings:", - "groupSelectionInView:", - "groupSelectionInMatrix:", - "orderFrontFontPanel:", - "translate:" - ); - Super = NSObject; - }; - Gorm = { - Actions = ( - "editClass:", - "createSubclass:", - "testInterface:", - "setName:", - "selectAllItems:", - "paste:", - "palettes:", - "loadSound:", - "loadPalette:", - "inspector:", - "infoPanel:", - "endTesting:", - "delete:", - "cut:", - "copy:", - "close:", - "miniaturize:", - "debug:", - "loadImage:", - "orderFrontFontPanel:", - "ungroup:", - "groupSelectionInScrollView:", - "groupSelectionInBox:", - "groupSelectionInSplitView:", - "remove:", - "addAttributeToClass:", - "instantiateClass:", - "createClassFiles:", - "loadClass:", - "preferencesPanel:", - "guideline:", - "print:", - "groupSelectionInView:", - "groupSelectionInMatrix:" - ); - Outlets = ( - gormMenu, - guideLineMenuItem - ); - Super = NSApplication; - }; - GormDocumentController = { - Actions = ( - ); - Outlets = ( - ); - Super = NSDocumentController; - }; -} \ No newline at end of file diff --git a/English.lproj/Gorm.gorm/objects.gorm b/English.lproj/Gorm.gorm/objects.gorm deleted file mode 100644 index db95a8a0..00000000 Binary files a/English.lproj/Gorm.gorm/objects.gorm and /dev/null differ diff --git a/English.lproj/GormClassInspector.gorm/objects.gorm b/English.lproj/GormClassInspector.gorm/objects.gorm deleted file mode 100644 index 64987177..00000000 Binary files a/English.lproj/GormClassInspector.gorm/objects.gorm and /dev/null differ diff --git a/English.lproj/GormDocument.gorm/data.info b/English.lproj/GormDocument.gorm/data.info deleted file mode 100644 index 6cfa7dce..00000000 Binary files a/English.lproj/GormDocument.gorm/data.info and /dev/null differ diff --git a/English.lproj/GormDocument.gorm/objects.gorm b/English.lproj/GormDocument.gorm/objects.gorm deleted file mode 100644 index b78ac3b8..00000000 Binary files a/English.lproj/GormDocument.gorm/objects.gorm and /dev/null differ diff --git a/English.lproj/GormObjectInspector.gorm/objects.gorm b/English.lproj/GormObjectInspector.gorm/objects.gorm deleted file mode 100644 index 51c02ccf..00000000 Binary files a/English.lproj/GormObjectInspector.gorm/objects.gorm and /dev/null differ diff --git a/GNUmakefile b/GNUmakefile index 508998fd..663b84db 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -41,6 +41,7 @@ ifeq ($(GNUSTEP_MAKEFILES),) $(error You need to set GNUSTEP_MAKEFILES before compiling!) endif +VERSION = 1.4.0 PACKAGE_NAME = gorm export PACKAGE_NAME include $(GNUSTEP_MAKEFILES)/common.make @@ -49,158 +50,21 @@ CVS_MODULE_NAME = gorm SVN_MODULE_NAME = gorm SVN_BASE_URL = svn+ssh://svn.gna.org/svn/gnustep/apps - -include ./Version - # # Each palette is a subproject # SUBPROJECTS = \ + InterfaceBuilder \ GormObjCHeaderParser \ - GormLib \ GormCore \ - GormPrefs \ - Palettes \ - Plugins - -# -# MAIN APP -# -APP_NAME = Gorm -Gorm_PRINCIPAL_CLASS=Gorm -Gorm_APPLICATION_ICON=Gorm.tiff -Gorm_RESOURCE_FILES = \ - GormInfo.plist \ - Resources/ClassInformation.plist \ - Resources/VersionProfiles.plist \ - Resources/Defaults.plist \ - Palettes/0Menus/0Menus.palette \ - Palettes/1Windows/1Windows.palette \ - Palettes/2Controls/2Controls.palette \ - Palettes/3Containers/3Containers.palette \ - Palettes/4Data/4Data.palette \ - Palettes/5Formatters/5Formatters.palette \ - Palettes/6GridStack/6GridStack.palette \ - Plugins/Gorm/Gorm.plugin \ - Plugins/Nib/Nib.plugin \ - Plugins/GModel/GModel.plugin \ - Plugins/Xib/Xib.plugin \ - Images/GormClass.tiff \ - Images/GormFilesOwner.tiff \ - Images/GormFirstResponder.tiff \ - Images/GormFontManager.tiff \ - Images/GormImage.tiff \ - Images/GormWindow.tiff \ - Images/GormMenu.tiff \ - Images/GormObject.tiff \ - Images/GormSound.tiff \ - Images/GormUnknown.tiff \ - Images/GormSourceTag.tiff \ - Images/GormTargetTag.tiff \ - Images/GormLinkImage.tiff \ - Images/GormEHCoil.tiff \ - Images/GormEHLine.tiff \ - Images/GormEVCoil.tiff \ - Images/GormEVLine.tiff \ - Images/GormMHCoil.tiff \ - Images/GormMHLine.tiff \ - Images/GormMVCoil.tiff \ - Images/GormMVLine.tiff \ - Images/Gorm.tiff \ - Images/GormFile.tiff \ - Images/GormNib.tiff \ - Images/GormPalette.tiff \ - Images/leftalign_nib.tiff \ - Images/rightalign_nib.tiff \ - Images/centeralign_nib.tiff \ - Images/justifyalign_nib.tiff \ - Images/naturalalign_nib.tiff \ - Images/iconAbove_nib.tiff \ - Images/iconBelow_nib.tiff \ - Images/iconLeft_nib.tiff \ - Images/iconOnly_nib.tiff \ - Images/iconRight_nib.tiff \ - Images/titleOnly_nib.tiff \ - Images/line_nib.tiff \ - Images/bezel_nib.tiff \ - Images/noBorder_nib.tiff \ - Images/ridge_nib.tiff \ - Images/button_nib.tiff \ - Images/shortbutton_nib.tiff \ - Images/photoframe_nib.tiff \ - Images/date_formatter.tiff \ - Images/number_formatter.tiff \ - Images/Sunday_seurat.tiff \ - Images/iconBottomLeft_nib.tiff \ - Images/iconBottomRight_nib.tiff \ - Images/iconBottom_nib.tiff \ - Images/iconCenterLeft_nib.tiff \ - Images/iconCenterRight_nib.tiff \ - Images/iconCenter_nib.tiff \ - Images/iconTopLeft_nib.tiff \ - Images/iconTopRight_nib.tiff \ - Images/iconTop_nib.tiff \ - Images/GormAction.tiff \ - Images/GormOutlet.tiff \ - Images/GormActionSelected.tiff \ - Images/GormOutletSelected.tiff \ - Images/FileIcon_gmodel.tiff \ - Images/tabtop_nib.tiff \ - Images/tabbot_nib.tiff \ - Images/GormView.tiff \ - Images/LeftArr.tiff \ - Images/RightArr.tiff \ - Images/GormTesting.tiff \ - Images/outlineView.tiff \ - Images/browserView.tiff - -Gorm_LOCALIZED_RESOURCE_FILES = \ - GormClassEditor.gorm \ - GormClassInspector.gorm \ - GormClassPanel.gorm \ - GormConnectionInspector.gorm \ - GormCustomClassInspector.gorm \ - GormDocument.gorm \ - GormDummyInspector.gorm \ - GormFontView.gorm \ - GormHelpInspector.gorm \ - Gorm.gorm \ - GormImageInspector.gorm \ - GormInconsistenciesPanel.gorm \ - GormInspectorPanel.gorm \ - GormObjectInspector.gorm \ - GormNSSplitViewInspector.gorm \ - GormPalettePanel.gorm \ - GormPrefColors.gorm \ - GormPreferences.gorm \ - GormPrefGeneral.gorm \ - GormPrefGuideline.gorm \ - GormPrefHeaders.gorm \ - GormPrefPalettes.gorm \ - GormPrefPlugins.gorm \ - GormScrollViewAttributesInspector.gorm \ - GormSetName.gorm \ - GormShelfPref.gorm \ - GormSoundInspector.gorm \ - GormViewSizeInspector.gorm \ - Gorm.rtfd - -Gorm_LANGUAGES = \ - English - -Gorm_HEADERS = - -Gorm_OBJC_FILES = \ - Gorm.m \ - main.m - -# Gorm_ADDITIONAL_NATIVE_LIBS = m + Plugins \ + Applications \ + Tools -include GNUmakefile.preamble -include GNUmakefile.local include $(GNUSTEP_MAKEFILES)/aggregate.make -include $(GNUSTEP_MAKEFILES)/application.make -include GNUmakefile.postamble diff --git a/GNUmakefile.postamble b/GNUmakefile.postamble index 1eea4028..65702c80 100644 --- a/GNUmakefile.postamble +++ b/GNUmakefile.postamble @@ -1,44 +1,8 @@ -# -# GNUmakefile.postamble -# -# Copyright (C) 2003 Free Software Foundation, Inc. -# -# Author: Gregory John Casamento -# -# This file is part of GNUstep -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Library General Public -# License as published by the Free Software Foundation; either -# version 2 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Library General Public License for more details. -# -# You should have received a copy of the GNU Library General Public -# License along with this library; see the file COPYING.LIB. -# If not, write to the Free Software Foundation, -# 51 Franklin Street, Fifth Floor, Boston, MA 02111 -# USA. -# - -# Define this variable if not defined for backwards-compatibility as -# it is only available in gnustep-make >= 2.0.5 -ifeq ($(LN_S_RECURSIVE),) - LN_S_RECURSIVE = $(LN_S) -endif - -before-all:: - $(RM_LN_S) InterfaceBuilder; \ - $(LN_S_RECURSIVE) GormLib InterfaceBuilder +# GNUmakefile -- copy all plugins after-all:: - -after-clean:: - -after-distclean:: - -after-clean:: - $(RM_LN_S) InterfaceBuilder + echo "Copying Plugins..." + cp -r Plugins/GModel/*.plugin GormCore/GormCore.framework/Resources + cp -r Plugins/Gorm/*.plugin GormCore/GormCore.framework/Resources + cp -r Plugins/Nib/*.plugin GormCore/GormCore.framework/Resources + cp -r Plugins/Xib/*.plugin GormCore/GormCore.framework/Resources diff --git a/Gorm.m b/Gorm.m deleted file mode 100644 index 31c3f361..00000000 --- a/Gorm.m +++ /dev/null @@ -1,1424 +0,0 @@ -/* Gorm.m - * - * Copyright (C) 1999, 2003 Free Software Foundation, Inc. - * - * Author: Richard Frith-Macdonald - * Author: Gregory John Casamento - * Date: 1999, 2003, 2004 - * - * This file is part of GNUstep. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 - * USA. - */ - - -#include -#include - -#include - -@interface Gorm : NSApplication -{ - GormPrefController *preferencesController; - GormClassManager *classManager; - GormInspectorsManager *inspectorsManager; - GormPalettesManager *palettesManager; - GormPluginManager *pluginManager; - id selectionOwner; - BOOL isConnecting; - BOOL isTesting; - id testContainer; - id gormMenu; - NSMenu *mainMenu; // saves the main menu... - NSMenu *servicesMenu; // saves the services menu... - NSMenu *classMenu; // so we can set it for the class view - NSMenuItem *guideLineMenuItem; - NSDictionary *menuLocations; - NSImage *linkImage; - NSImage *sourceImage; - NSImage *targetImage; - NSImage *gormImage; - NSImage *testingImage; - id connectSource; - id connectDestination; - NSMutableArray *testingWindows; - NSSet *topObjects; -} - -// handle notifications the object recieves. -- (void) handleNotification: (NSNotification*)aNotification; -@end - -// Handle server protocol methods... -@interface Gorm (GormServer) -@end - -@implementation Gorm - -- (id) activeDocument -{ - return [[NSDocumentController sharedDocumentController] currentDocument]; -} - -/* - NSApplication override to make Inspector's shortcuts available globally -*/ -- (void) sendEvent: (NSEvent *)theEvent -{ - if ([theEvent type] == NSKeyDown) - { - NSPanel *inspector = [[self inspectorsManager] panel]; - if ([inspector performKeyEquivalent: theEvent] != NO) - { - [inspector orderFront: self]; - return; - } - } - [super sendEvent: theEvent]; -} - -/* - NSApp -*/ -- (id) init -{ - self = [super init]; - if (self != nil) - { - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - NSNotificationCenter *ndc = [NSDistributedNotificationCenter defaultCenter]; - NSBundle *bundle = [NSBundle mainBundle]; - NSString *path; - NSConnection *conn = [NSConnection defaultConnection]; - - path = [bundle pathForImageResource: @"GormLinkImage"]; - linkImage = [[NSImage alloc] initWithContentsOfFile: path]; - path = [bundle pathForImageResource: @"GormSourceTag"]; - sourceImage = [[NSImage alloc] initWithContentsOfFile: path]; - path = [bundle pathForImageResource: @"GormTargetTag"]; - targetImage = [[NSImage alloc] initWithContentsOfFile: path]; - path = [bundle pathForImageResource: @"Gorm"]; - gormImage = [[NSImage alloc] initWithContentsOfFile: path]; - path = [bundle pathForImageResource: @"GormTesting"]; - testingImage = [[NSImage alloc] initWithContentsOfFile: path]; - - // regular notifications... - [nc addObserver: self - selector: @selector(handleNotification:) - name: IBSelectionChangedNotification - object: nil]; - [nc addObserver: self - selector: @selector(handleNotification:) - name: IBWillCloseDocumentNotification - object: nil]; - - // distibuted notifications... - [ndc addObserver: self - selector: @selector(handleNotification:) - name: @"GormAddClassNotification" - object: nil]; - [ndc addObserver: self - selector: @selector(handleNotification:) - name: @"GormDeleteClassNotification" - object: nil]; - [ndc addObserver: self - selector: @selector(handleNotification:) - name: @"GormParseClassNotification" - object: nil]; - - /* - * establish registration domain defaults from file. - */ - path = [bundle pathForResource: @"Defaults" ofType: @"plist"]; - if (path != nil) - { - NSDictionary *dict; - - dict = [NSDictionary dictionaryWithContentsOfFile: path]; - if (dict != nil) - { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - [defaults registerDefaults: dict]; - } - } - - /* - * load the interface... - */ - if(![NSBundle loadNibNamed: @"Gorm" owner: self]) - { - NSLog(@"Failed to load interface"); - exit(-1); - } - - /* - * Make sure the palettes/plugins managers exist, so that the - * editors and inspectors provided in the standard palettes - * are available. - */ - [self palettesManager]; - [self pluginManager]; - - /* - * set the delegate. - */ - [self setDelegate: self]; - - /* - * Start the server - */ - [conn setRootObject: self]; - if([conn registerName: @"GormServer"] == NO) - { - NSLog(@"Could not register GormServer"); - } - } - return self; -} - - -- (void) dealloc -{ - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - - [nc removeObserver: self]; - RELEASE(inspectorsManager); - RELEASE(palettesManager); - RELEASE(classManager); - [super dealloc]; -} - -- (void) stop: (id)sender -{ - if(isTesting == NO) - { - [super stop: sender]; - } - else - { - [self endTesting: sender]; - } -} - -- (BOOL)applicationShouldOpenUntitledFile: (NSApplication *)sender -{ - if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) == - NSWindows95InterfaceStyle) - { - return YES; - } - - return NO; -} - -- (void) applicationOpenUntitledFile: (id)sender -{ - GormDocumentController *dc = [NSDocumentController sharedDocumentController]; - // open a new document and build an application type document by default... - [dc newDocument: sender]; -} - -- (void) applicationDidFinishLaunching: (NSApplication*)sender -{ - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - if ( [defaults boolForKey: @"ShowInspectors"] ) - { - [[[self inspectorsManager] panel] makeKeyAndOrderFront: self]; - } - if ( [defaults boolForKey: @"ShowPalettes"] ) - { - [[[self palettesManager] panel] makeKeyAndOrderFront: self]; - } -} - -- (void) applicationWillTerminate: (NSApplication*)sender -{ - [[NSUserDefaults standardUserDefaults] - setBool: [[[self inspectorsManager] panel] isVisible] - forKey: @"ShowInspectors"]; - [[NSUserDefaults standardUserDefaults] - setBool: [[[self palettesManager] panel] isVisible] - forKey: @"ShowPalettes"]; -} - -- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (id)sender -{ - if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) == - NSWindows95InterfaceStyle) - { - NSDocumentController *docController; - docController = [NSDocumentController sharedDocumentController]; - - if ([[docController documents] count] > 0) - { - return NO; - } - else - { - return YES; - } - } - else - { - return NO; - } -} - -- (GormClassManager*) classManager -{ - id document = [self activeDocument]; - - if (document != nil) return [document classManager]; - - /* kept in the case one want access to the classManager without document */ - else if (classManager == nil) - { - classManager = [[GormClassManager alloc] init]; - } - return classManager; - -} - -- (id) connectDestination -{ - return connectDestination; -} - -- (id) connectSource -{ - return connectSource; -} - -- (void) displayConnectionBetween: (id)source - and: (id)destination -{ - NSWindow *window; - NSRect rect; - - - if (source != connectSource) - { - if (connectSource != nil) - { - window = [(GormDocument *)[self activeDocument] windowAndRect: &rect - forObject: connectSource]; - if (window != nil) - { - NSView *view = [[window contentView] superview]; - - rect.origin.x --; - rect.size.width ++; - - rect.size.height ++; - - [window disableFlushWindow]; - [view displayRect: rect]; - - [window enableFlushWindow]; - [window flushWindow]; - } - } - connectSource = source; - } - if (destination != connectDestination) - { - if (connectDestination != nil) - { - window = [(GormDocument *)[self activeDocument] windowAndRect: &rect - forObject: connectDestination]; - if (window != nil) - { - NSView *view = [[window contentView] superview]; - - /* - * Erase image from old location. - */ - rect.origin.x --; - rect.size.width ++; - rect.size.height ++; - - [view lockFocus]; - [view displayRect: rect]; - [view unlockFocus]; - [window flushWindow]; - } - } - connectDestination = destination; - } - if (connectSource != nil) - { - window = [(GormDocument *)[self activeDocument] windowAndRect: &rect forObject: connectSource]; - if (window != nil) - { - NSView *view = [[window contentView] superview]; - NSRect imageRect = rect; - - imageRect.origin.x++; - //rect.size.width--; - //rect.size.height--; - [view lockFocus]; - [[NSColor greenColor] set]; - NSFrameRectWithWidth(rect, 1); - - [sourceImage compositeToPoint: imageRect.origin - operation: NSCompositeSourceOver]; - [view unlockFocus]; - [window flushWindow]; - } - } - if (connectDestination != nil && connectDestination == connectSource) - { - window = [(GormDocument *)[self activeDocument] windowAndRect: &rect - forObject: connectDestination]; - if (window != nil) - { - NSView *view = [[window contentView] superview]; - NSRect imageRect = rect; - - imageRect.origin.x += 3; - imageRect.origin.y += 2; - // rect.size.width -= 5; - // rect.size.height -= 5; - [view lockFocus]; - [[NSColor purpleColor] set]; - NSFrameRectWithWidth(rect, 1); - - imageRect.origin.x += [targetImage size].width; - [targetImage compositeToPoint: imageRect.origin - operation: NSCompositeSourceOver]; - [view unlockFocus]; - [window flushWindow]; - } - } - else if (connectDestination != nil) - { - window = [(GormDocument *)[self activeDocument] windowAndRect: &rect - forObject: connectDestination]; - if (window != nil) - { - NSView *view = [[window contentView] superview]; - NSRect imageRect = rect; - - imageRect.origin.x++; - // rect.size.width--; - // rect.size.height--; - [view lockFocus]; - [[NSColor purpleColor] set]; - NSFrameRectWithWidth(rect, 1); - - [targetImage compositeToPoint: imageRect.origin - operation: NSCompositeSourceOver]; - [view unlockFocus]; - [window flushWindow]; - } - } -} - -/** Info Menu Actions */ -- (void) preferencesPanel: (id) sender -{ - if(! preferencesController) - { - preferencesController = [[GormPrefController alloc] init]; - } - - [[preferencesController panel] makeKeyAndOrderFront:nil]; -} - -/** Document Menu Actions */ -- (void) close: (id)sender -{ - GormDocument *document = (GormDocument *)[self activeDocument]; - if([document canCloseDocument]) - { - [document close]; - } -} - -- (void) debug: (id) sender -{ - [[self activeDocument] performSelector: @selector(printAllEditors)]; -} - -- (void) loadSound: (id) sender -{ - [(GormDocument *)[self activeDocument] openSound: sender]; -} - -- (void) loadImage: (id) sender -{ - [(GormDocument *)[self activeDocument] openImage: sender]; -} - -- (void) arrangeInFront: (id)sender -{ - if([self isTestingInterface] == NO) - { - [super arrangeInFront: sender]; - } -} - -- (void) testInterface: (id)sender -{ - if (isTesting == YES) - { - return; - } - else - { - // top level objects - NS_DURING - { - NSUserDefaults *defaults; - NSNotificationCenter *notifCenter = [NSNotificationCenter defaultCenter]; - GormDocument *activeDoc = (GormDocument*)[self activeDocument]; - NSData *data; - NSArchiver *archiver; - NSEnumerator *en; - NSDictionary *substituteClasses = [palettesManager substituteClasses]; - NSString *subClassName; - id obj; - id savedDelegate = [NSApp delegate]; - - // which windows were open when testing started... - testingWindows = [[NSMutableArray alloc] init]; - en = [[self windows] objectEnumerator]; - while((obj = [en nextObject]) != nil) - { - if([obj isVisible]) - { - [testingWindows addObject: obj]; - } - } - - // set here, so that beginArchiving and endArchiving do not use templates. - isTesting = YES; - [self setApplicationIconImage: testingImage]; - archiver = [[NSArchiver alloc] init]; - [activeDoc deactivateEditors]; - [archiver encodeClassName: @"GormCustomView" - intoClassName: @"GormTestCustomView"]; - - // substitute classes from palettes. - en = [substituteClasses keyEnumerator]; - while((subClassName = [en nextObject]) != nil) - { - NSString *realClassName = [substituteClasses objectForKey: subClassName]; - - if([realClassName isEqualToString: @"NSTableView"] || - [realClassName isEqualToString: @"NSOutlineView"] || - [realClassName isEqualToString: @"NSBrowser"]) - { - continue; - } - - [archiver encodeClassName: subClassName - intoClassName: realClassName]; - } - - // do not allow custom classes during testing. - [GSClassSwapper setIsInInterfaceBuilder: YES]; - [archiver encodeRootObject: activeDoc]; - data = RETAIN([archiver archiverData]); // Released below... - [activeDoc reactivateEditors]; - RELEASE(archiver); - [GSClassSwapper setIsInInterfaceBuilder: NO]; - - // signal the start of testing... - [notifCenter postNotificationName: IBWillBeginTestingInterfaceNotification - object: self]; - - if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES) - { - [selectionOwner makeSelectionVisible: NO]; - } - - defaults = [NSUserDefaults standardUserDefaults]; - menuLocations = [[defaults objectForKey: @"NSMenuLocations"] copy]; - [defaults removeObjectForKey: @"NSMenuLocations"]; - servicesMenu = [self servicesMenu]; - - testContainer = [NSUnarchiver unarchiveObjectWithData: data]; - if (testContainer != nil) - { - NSMutableDictionary *nameTable = [testContainer nameTable]; - NSMenu *aMenu = [nameTable objectForKey: @"NSMenu"]; - - [self setMainMenu: aMenu]; - // initialize the context. - RETAIN(testContainer); - topObjects = [testContainer topLevelObjects]; - - [nameTable removeObjectForKey: @"NSServicesMenu"]; - [nameTable removeObjectForKey: @"NSWindowsMenu"]; - [testContainer awakeWithContext: nil]; - [NSApp setDelegate: savedDelegate]; // makes sure the delegate isn't reset. - - /* - * If the model didn't have a main menu, create one, - * otherwise, ensure that 'quit' ends testing mode. - */ - if (aMenu == nil) - { - NSMenu *testMenu; - - testMenu = [[NSMenu alloc] initWithTitle: _(@"Test Menu (Gorm)")]; - [testMenu addItemWithTitle: _(@"Quit Test") - action: @selector(deferredEndTesting:) - keyEquivalent: @"q"]; - [self setMainMenu: testMenu]; // released, when the menu is reset in endTesting. - } - else - { - NSMenu *testMenu = [self mainMenu]; - NSString *newTitle = [[testMenu title] stringByAppendingString: @" (Gorm)"]; - NSArray *items = findAll(testMenu); - NSEnumerator *en = [items objectEnumerator]; - id item; - BOOL found = NO; - - while((item = [en nextObject]) != nil) - { - if([item isKindOfClass: [NSMenuItem class]]) - { - SEL action = [item action]; - if(sel_isEqual(action, @selector(terminate:))) - { - found = YES; - [item setTitle: _(@"Quit Test")]; - [item setTarget: self]; - [item setAction: @selector(deferredEndTesting:)]; - } - } - } - - // releast the items... - RELEASE(items); - - // set the menu up so that it's easy to tell we're testing and how to quit. - [testMenu setTitle: newTitle]; - if(found == NO) - { - [testMenu addItemWithTitle: _(@"Quit Test") - action: @selector(deferredEndTesting:) - keyEquivalent: @"q"]; - } - } - - // so we don't get the warning... - [self setServicesMenu: nil]; - [[self mainMenu] display]; - en = [[self windows] objectEnumerator]; - while((obj = [en nextObject]) != nil) - { - if([obj isVisible]) - { - [obj makeKeyAndOrderFront: self]; - } - } - - // we're now in testing mode. - [notifCenter postNotificationName: IBDidBeginTestingInterfaceNotification - object: self]; - - [NSApp unhide: self]; - } - - RELEASE(data); - } - NS_HANDLER - { - // reset the application after the error. - NSLog(@"Problem while testing interface: %@", - [localException reason]); - NSRunAlertPanel(_(@"Problem While Testing Interface"), - [NSString stringWithFormat: @"Make sure connections are to appropriate objects.\n" - @"Exception: %@", - [localException reason]], - _(@"OK"), nil, nil); - [self endTesting: self]; - } - NS_ENDHANDLER; - } -} - - -/** Edit Menu Actions */ - -- (void) copy: (id)sender -{ - if ([[selectionOwner selection] count] == 0 - || [selectionOwner respondsToSelector: @selector(copySelection)] == NO) - return; - - if([self isConnecting]) - { - [self stopConnecting]; - } - - [(id)selectionOwner copySelection]; -} - - -- (void) cut: (id)sender -{ - if ([[selectionOwner selection] count] == 0 - || [selectionOwner respondsToSelector: @selector(copySelection)] == NO - || [selectionOwner respondsToSelector: @selector(deleteSelection)] == NO) - return; - - if([self isConnecting]) - { - [self stopConnecting]; - } - - [(id)selectionOwner copySelection]; - [(id)selectionOwner deleteSelection]; -} - -- (void) paste: (id)sender -{ - if ([selectionOwner respondsToSelector: @selector(pasteInSelection)] == NO) - return; - - if([self isConnecting]) - { - [self stopConnecting]; - } - - [(id)selectionOwner pasteInSelection]; -} - - -- (void) delete: (id)sender -{ - if ([[selectionOwner selection] count] == 0 - || [selectionOwner respondsToSelector: @selector(deleteSelection)] == NO) - return; - - if([self isConnecting]) - { - [self stopConnecting]; - } - - [(id)selectionOwner deleteSelection]; -} - -- (void) selectAll: (id)sender -{ - if ([[selectionOwner selection] count] == 0 - || [selectionOwner respondsToSelector: @selector(deleteSelection)] == NO) - return; - - if([self isConnecting]) - { - [self stopConnecting]; - } - - [(id)selectionOwner deleteSelection]; -} - -/* -- (void) selectAllItems: (id)sender -{ - return; -} -*/ - -- (void) setName: (id)sender -{ - GormSetNameController *panel; - int returnPanel; - NSTextField *textField; - NSArray *selectionArray = [selectionOwner selection]; - id obj = [selectionArray objectAtIndex: 0]; - NSString *name; - - if([(GormDocument *)[self activeDocument] isTopLevelObject: obj]) - { - panel = [[GormSetNameController alloc] init]; - returnPanel = [panel runAsModal]; - textField = [panel textField]; - - if (returnPanel == NSAlertDefaultReturn) - { - name = [[textField stringValue] stringByTrimmingSpaces]; - if (name != nil && [name isEqual: @""] == NO) - { - [[self activeDocument] setName: name forObject: obj]; - } - } - RELEASE(panel); - } -} - -- (void) guideline: (id) sender -{ - [[NSNotificationCenter defaultCenter] postNotificationName: GormToggleGuidelineNotification - object:nil]; - if ( [guideLineMenuItem tag] == 0 ) - { - [guideLineMenuItem setTitle:_(@"Turn GuideLine On")]; - [guideLineMenuItem setTag:1]; - } - else if ( [guideLineMenuItem tag] == 1) - { - [guideLineMenuItem setTitle:_(@"Turn GuideLine Off")]; - [guideLineMenuItem setTag:0]; - } -} - - -- (void) orderFrontFontPanel: (id) sender -{ - NSFontPanel *fontPanel = [NSFontPanel sharedFontPanel]; - GormFontViewController *gfvc = - [GormFontViewController sharedGormFontViewController]; - [fontPanel setAccessoryView: [gfvc view]]; - [[NSFontManager sharedFontManager] orderFrontFontPanel: self]; -} - -/** Grouping */ - -- (void) groupSelectionInSplitView: (id)sender -{ - if ([[selectionOwner selection] count] < 2 - || [selectionOwner respondsToSelector: @selector(groupSelectionInSplitView)] == NO) - return; - - [(GormGenericEditor *)selectionOwner groupSelectionInSplitView]; -} - -- (void) groupSelectionInBox: (id)sender -{ - if ([selectionOwner respondsToSelector: @selector(groupSelectionInBox)] == NO) - return; - [(GormGenericEditor *)selectionOwner groupSelectionInBox]; -} - -- (void) groupSelectionInView: (id)sender -{ - if ([selectionOwner respondsToSelector: @selector(groupSelectionInView)] == NO) - return; - [(GormGenericEditor *)selectionOwner groupSelectionInView]; -} - -- (void) groupSelectionInScrollView: (id)sender -{ - if ([selectionOwner respondsToSelector: @selector(groupSelectionInScrollView)] == NO) - return; - [(GormGenericEditor *)selectionOwner groupSelectionInScrollView]; -} - -- (void) groupSelectionInMatrix: (id)sender -{ - if ([selectionOwner respondsToSelector: @selector(groupSelectionInMatrix)] == NO) - return; - [(GormGenericEditor *)selectionOwner groupSelectionInMatrix]; -} - -- (void) ungroup: (id)sender -{ - // NSLog(@"ungroup: selectionOwner %@", selectionOwner); - if ([selectionOwner respondsToSelector: @selector(ungroup)] == NO) - return; - [(GormGenericEditor *)selectionOwner ungroup]; -} - -/** Classes actions */ - -- (void) createSubclass: (id)sender -{ - [(GormDocument *)[self activeDocument] createSubclass: sender]; -} - -- (void) loadClass: (id)sender -{ - // Call the current document and create the class - // descibed by the header - [(GormDocument *)[self activeDocument] loadClass: sender]; -} - -- (void) createClassFiles: (id)sender -{ - [(GormDocument *)[self activeDocument] createClassFiles: sender]; -} - -- (void) instantiateClass: (id)sender -{ - [(GormDocument *)[self activeDocument] instantiateClass: sender]; -} - -- (void) addAttributeToClass: (id)sender -{ - [(GormDocument *)[self activeDocument] addAttributeToClass: sender]; -} - -- (void) remove: (id)sender -{ - [(GormDocument *)[self activeDocument] remove: sender]; -} - -/** Palettes Actions... */ - -- (void) inspector: (id) sender -{ - [[[self inspectorsManager] panel] makeKeyAndOrderFront: self]; -} - -- (void) palettes: (id) sender -{ - [[[self palettesManager] panel] makeKeyAndOrderFront: self]; -} - -- (void) loadPalette: (id) sender -{ - [[self palettesManager] openPalette: sender]; -} - -/** Testing methods... */ - -- (void) deferredEndTesting: (id) sender -{ - [[NSRunLoop currentRunLoop] - performSelector: @selector(endTesting:) - target: self - argument: nil - order: 5000 - modes: [NSArray arrayWithObjects: - NSDefaultRunLoopMode, - NSModalPanelRunLoopMode, - NSEventTrackingRunLoopMode, nil]]; -} - -- (id) endTesting: (id)sender -{ - if (isTesting == NO) - { - return nil; - } - else - { - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - NSUserDefaults *defaults; - NSEnumerator *e; - id val; - - [nc postNotificationName: IBWillEndTestingInterfaceNotification - object: self]; - - /* - * Make sure windows will go away when the container is destroyed. - */ - e = [topObjects objectEnumerator]; - while ((val = [e nextObject]) != nil) - { - if ([val isKindOfClass: [NSWindow class]] == YES) - { - [val close]; - } - } - - /* - * Make sure any peripheral windows: font panels, etc. which are brought - * up by the interface being tested are also closed. - */ - e = [[self windows] objectEnumerator]; - while ((val = [e nextObject]) != nil) - { - if ([testingWindows containsObject: val] == NO && - [val isKindOfClass: [NSWindow class]] && - [val isVisible]) - { - [val orderOut: self]; - } - } - - // prevent saving of this, if the menuLocations have not previously been set. - if(menuLocations != nil) - { - defaults = [NSUserDefaults standardUserDefaults]; - [defaults setObject: menuLocations forKey: @"NSMenuLocations"]; - DESTROY(menuLocations); - } - - [self setMainMenu: mainMenu]; - [self setApplicationIconImage: gormImage]; - - NS_DURING - { - [self setServicesMenu: servicesMenu]; - } - NS_HANDLER - { - NSDebugLog(@"Exception while setting services menu"); - } - NS_ENDHANDLER - - [mainMenu display]; // bring it to the front... - isTesting = NO; - - if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES) - { - [selectionOwner makeSelectionVisible: YES]; - } - [nc postNotificationName: IBDidEndTestingInterfaceNotification - object: self]; - - - DESTROY(testingWindows); - - // deallocate - RELEASE(testContainer); - - return self; - } -} - -- (void) handleNotification: (NSNotification*)notification -{ - NSString *name = [notification name]; - id obj = [notification object]; - - if ([name isEqual: IBSelectionChangedNotification]) - { - /* - * If we are connecting - stop it - a change in selection must mean - * that the connection process has ended. - */ - if ([self isConnecting] == YES) - { - [self stopConnecting]; - } - [selectionOwner makeSelectionVisible: NO]; - selectionOwner = obj; - [[self inspectorsManager] updateSelection]; - } - else if ([name isEqual: IBWillCloseDocumentNotification]) - { - selectionOwner = nil; - } - else if ([name isEqual: @"GormAddClassNotification"]) - { - id obj = [notification object]; - [self addClass: obj]; - } - else if ([name isEqual: @"GormDeleteClassNotification"]) - { - id obj = [notification object]; - [self deleteClass: obj]; - } - else if ([name isEqual: @"GormParseClassNotification"]) - { - NSString *pathToClass = (NSString *)[notification object]; - GormClassManager *cm = [(GormDocument *)[self activeDocument] classManager]; - [cm parseHeader: pathToClass]; - } -} - -- (void) awakeFromNib -{ - // set the menu... - mainMenu = (NSMenu *)gormMenu; -} - - -- (GormInspectorsManager*) inspectorsManager -{ - if (inspectorsManager == nil) - { - inspectorsManager = (GormInspectorsManager *)[GormInspectorsManager sharedInspectorManager]; - } - return inspectorsManager; -} - - -- (BOOL) isConnecting -{ - return isConnecting; -} - -- (BOOL) isTestingInterface -{ - return isTesting; -} - -- (NSImage*) linkImage -{ - return linkImage; -} - - -- (id) miniaturize: (id)sender -{ - NSWindow *window = [(GormDocument *)[self activeDocument] window]; - - [window miniaturize: self]; - return nil; -} - -- (GormPalettesManager*) palettesManager -{ - if (palettesManager == nil) - { - palettesManager = [[GormPalettesManager alloc] init]; - } - return palettesManager; -} - -- (GormPluginManager*) pluginManager -{ - if (pluginManager == nil) - { - pluginManager = [[GormPluginManager alloc] init]; - } - return pluginManager; -} - -- (id) selectionOwner -{ - return (id)selectionOwner; -} - -- (id) selectedObject -{ - return [[selectionOwner selection] lastObject]; -} - -- (id) documentForObject: (id)object -{ - NSEnumerator *en = [[[NSDocumentController sharedDocumentController] - documents] - objectEnumerator]; - id doc = nil; - id result = nil; - - while((doc = [en nextObject]) != nil) - { - if([doc containsObject: object]) - { - result = doc; - break; - } - } - - return result; -} - -- (void) startConnecting -{ - if (isConnecting == YES) - { - return; - } - if (connectSource == nil) - { - return; - } - if (connectDestination - && [[self activeDocument] containsObject: connectDestination] == NO) - { - NSLog(@"Oops - connectDestination not in active document"); - return; - } - if ([[self activeDocument] containsObject: connectSource] == NO) - { - NSLog(@"Oops - connectSource not in active document"); - return; - } - isConnecting = YES; - [[self inspectorsManager] updateSelection]; -} - -- (void) stopConnecting -{ - [self displayConnectionBetween: nil and: nil]; - isConnecting = NO; - connectSource = nil; - connectDestination = nil; -} - -- (BOOL) validateMenuItem: (NSMenuItem*)item -{ - GormDocument *active = (GormDocument*)[self activeDocument]; - SEL action = [item action]; - GormClassManager *cm = nil; - NSArray *s = nil; - - // if we have an active document... - if(active != nil) - { - cm = [active classManager]; - s = [selectionOwner selection]; - } - - if (sel_isEqual(action, @selector(close:)) - || sel_isEqual(action, @selector(miniaturize:))) - { - if (active == nil) - return NO; - } - else if (sel_isEqual(action, @selector(testInterface:))) - { - if (active == nil) - return NO; - } - else if (sel_isEqual(action, @selector(copy:))) - { - if ([s count] == 0) - return NO; - else - { - id o = [s objectAtIndex: 0]; - NSString *n = [active nameForObject: o]; - if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"]) - { - return NO; - } - } - - return [selectionOwner respondsToSelector: @selector(copySelection)]; - } - else if (sel_isEqual(action, @selector(cut:))) - { - if ([s count] == 0) - return NO; - else - { - id o = [s objectAtIndex: 0]; - NSString *n = [active nameForObject: o]; - if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"]) - { - return NO; - } - } - - return ([selectionOwner respondsToSelector: @selector(copySelection)] - && [selectionOwner respondsToSelector: @selector(deleteSelection)]); - } - else if (sel_isEqual(action, @selector(delete:))) - { - if ([s count] == 0) - return NO; - else - { - id o = [s objectAtIndex: 0]; - NSString *n = [active nameForObject: o]; - if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"]) - { - return NO; - } - } - - return [selectionOwner respondsToSelector: @selector(deleteSelection)]; - } - else if (sel_isEqual(action, @selector(paste:))) - { - if ([s count] == 0) - return NO; - else - { - id o = [s objectAtIndex: 0]; - NSString *n = [active nameForObject: o]; - if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"]) - { - return NO; - } - } - - return [selectionOwner respondsToSelector: @selector(pasteInSelection)]; - } - else if (sel_isEqual(action, @selector(setName:))) - { - NSString *n; - id o; - - if ([s count] == 0) - { - return NO; - } - if ([s count] > 1) - { - return NO; - } - o = [s objectAtIndex: 0]; - n = [active nameForObject: o]; - - if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"] - || [n isEqual: @"NSFont"] || [n isEqual: @"NSMenu"]) - { - return NO; - } - else if(![active isTopLevelObject: o]) - { - return NO; - } - } - else if(sel_isEqual(action, @selector(createSubclass:)) || - sel_isEqual(action, @selector(loadClass:)) || - sel_isEqual(action, @selector(createClassFiles:)) || - sel_isEqual(action, @selector(instantiateClass:)) || - sel_isEqual(action, @selector(addAttributeToClass:)) || - sel_isEqual(action, @selector(remove:))) - { - if(active == nil) - { - return NO; - } - - if(![active isEditingClasses]) - { - return NO; - } - - if(sel_isEqual(action, @selector(createSubclass:))) - { - NSArray *s = [selectionOwner selection]; - id o = nil; - NSString *name = nil; - - if([s count] == 0 || [s count] > 1) - return NO; - - o = [s objectAtIndex: 0]; - name = [o className]; - - if([active classIsSelected] == NO) - { - return NO; - } - - if([name isEqual: @"FirstResponder"]) - return NO; - } - - if(sel_isEqual(action, @selector(createClassFiles:)) || - sel_isEqual(action, @selector(remove:))) - { - id o = nil; - NSString *name = nil; - - if ([s count] == 0) - { - return NO; - } - if ([s count] > 1) - { - return NO; - } - - o = [s objectAtIndex: 0]; - name = [o className]; - if(![cm isCustomClass: name]) - { - return NO; - } - } - - if(sel_isEqual(action, @selector(instantiateClass:))) - { - id o = nil; - NSString *name = nil; - - if ([s count] == 0) - { - return NO; - } - if ([s count] > 1) - { - return NO; - } - - if([active classIsSelected] == NO) - { - return NO; - } - - o = [s objectAtIndex: 0]; - name = [o className]; - if(name != nil) - { - id cm = [self classManager]; - return [cm canInstantiateClassNamed: name]; - } - } - } - else if(sel_isEqual(action, @selector(loadSound:)) || - sel_isEqual(action, @selector(loadImage:)) || - sel_isEqual(action, @selector(debug:))) - { - if(active == nil) - { - return NO; - } - } - - return YES; -} - -- (NSMenu*) classMenu -{ - return classMenu; -} - -- (void) print: (id) sender -{ - [[self keyWindow] print: sender]; -} - -- (void) selectAllItems: (id)sender -{ -} - -@end - -@implementation Gorm (GormServer) - -// Methods to support external apps adding and deleting -// classes from the current document... -- (void) addClass: (NSDictionary *) dict -{ - GormDocument *doc = (GormDocument *)[self activeDocument]; - GormClassManager *cm = [doc classManager]; - NSArray *outlets = [dict objectForKey: @"outlets"]; - NSArray *actions = [dict objectForKey: @"actions"]; - NSString *className = [dict objectForKey: @"className"]; - NSString *superClassName = [dict objectForKey: @"superClassName"]; - - // If the class is known, delete it before proceeding. - if([cm isKnownClass: className]) - { - [cm removeClassNamed: className]; - } - - // Add the class to the class manager. - [cm addClassNamed: className - withSuperClassNamed: superClassName - withActions: actions - withOutlets: outlets]; -} - -- (void) deleteClass: (NSString *) className -{ - GormDocument *doc = (GormDocument *)[self activeDocument]; - GormClassManager *cm = [doc classManager]; - - [cm removeClassNamed: className]; -} - -@end diff --git a/English.lproj/GormClassEditor.gorm/data.classes b/GormCore/English.lproj/GormClassEditor.gorm/data.classes similarity index 100% rename from English.lproj/GormClassEditor.gorm/data.classes rename to GormCore/English.lproj/GormClassEditor.gorm/data.classes diff --git a/English.lproj/GormClassEditor.gorm/data.info b/GormCore/English.lproj/GormClassEditor.gorm/data.info similarity index 100% rename from English.lproj/GormClassEditor.gorm/data.info rename to GormCore/English.lproj/GormClassEditor.gorm/data.info diff --git a/English.lproj/GormClassEditor.gorm/objects.gorm b/GormCore/English.lproj/GormClassEditor.gorm/objects.gorm similarity index 100% rename from English.lproj/GormClassEditor.gorm/objects.gorm rename to GormCore/English.lproj/GormClassEditor.gorm/objects.gorm diff --git a/English.lproj/GormClassInspector.gorm/data.classes b/GormCore/English.lproj/GormClassInspector.gorm/data.classes similarity index 72% rename from English.lproj/GormClassInspector.gorm/data.classes rename to GormCore/English.lproj/GormClassInspector.gorm/data.classes index 27fc5d4e..bbf8731f 100644 --- a/English.lproj/GormClassInspector.gorm/data.classes +++ b/GormCore/English.lproj/GormClassInspector.gorm/data.classes @@ -28,18 +28,18 @@ "selectAction:" ); Outlets = ( - classField, - tabView, - removeOutlet, - addAction, - actionTable, - outletTable, - removeAction, - addOutlet, - selectClass, - parentClass, - search, - searchText + "_classField", + "_tabView", + "_removeOutlet", + "_addAction", + "_actionTable", + "_outletTable", + "_removeAction", + "_addOutlet", + "_selectClass", + "_parentClass", + "_search", + "_searchText" ); Super = IBInspector; }; diff --git a/GormCore/English.lproj/GormClassInspector.gorm/data.info b/GormCore/English.lproj/GormClassInspector.gorm/data.info new file mode 100644 index 00000000..a97a2a90 Binary files /dev/null and b/GormCore/English.lproj/GormClassInspector.gorm/data.info differ diff --git a/GormCore/English.lproj/GormClassInspector.gorm/objects.gorm b/GormCore/English.lproj/GormClassInspector.gorm/objects.gorm new file mode 100644 index 00000000..265b4931 Binary files /dev/null and b/GormCore/English.lproj/GormClassInspector.gorm/objects.gorm differ diff --git a/English.lproj/GormClassPanel.gorm/data.classes b/GormCore/English.lproj/GormClassPanel.gorm/data.classes similarity index 100% rename from English.lproj/GormClassPanel.gorm/data.classes rename to GormCore/English.lproj/GormClassPanel.gorm/data.classes diff --git a/Palettes/2Controls/GormNSColorWellInspector.gorm/data.info b/GormCore/English.lproj/GormClassPanel.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSColorWellInspector.gorm/data.info rename to GormCore/English.lproj/GormClassPanel.gorm/data.info diff --git a/English.lproj/GormClassPanel.gorm/objects.gorm b/GormCore/English.lproj/GormClassPanel.gorm/objects.gorm similarity index 100% rename from English.lproj/GormClassPanel.gorm/objects.gorm rename to GormCore/English.lproj/GormClassPanel.gorm/objects.gorm diff --git a/English.lproj/GormConnectionInspector.gorm/data.classes b/GormCore/English.lproj/GormConnectionInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormConnectionInspector.gorm/data.classes rename to GormCore/English.lproj/GormConnectionInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormNSFormInspector.gorm/data.info b/GormCore/English.lproj/GormConnectionInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSFormInspector.gorm/data.info rename to GormCore/English.lproj/GormConnectionInspector.gorm/data.info diff --git a/English.lproj/GormConnectionInspector.gorm/objects.gorm b/GormCore/English.lproj/GormConnectionInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormConnectionInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormConnectionInspector.gorm/objects.gorm diff --git a/English.lproj/GormCustomClassInspector.gorm/data.classes b/GormCore/English.lproj/GormCustomClassInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormCustomClassInspector.gorm/data.classes rename to GormCore/English.lproj/GormCustomClassInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormNSMatrixInspector.gorm/data.info b/GormCore/English.lproj/GormCustomClassInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSMatrixInspector.gorm/data.info rename to GormCore/English.lproj/GormCustomClassInspector.gorm/data.info diff --git a/English.lproj/GormCustomClassInspector.gorm/objects.gorm b/GormCore/English.lproj/GormCustomClassInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormCustomClassInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormCustomClassInspector.gorm/objects.gorm diff --git a/English.lproj/GormDocument.gorm/data.classes b/GormCore/English.lproj/GormDocument.gorm/data.classes similarity index 100% rename from English.lproj/GormDocument.gorm/data.classes rename to GormCore/English.lproj/GormDocument.gorm/data.classes diff --git a/GormCore/English.lproj/GormDocument.gorm/data.info b/GormCore/English.lproj/GormDocument.gorm/data.info new file mode 100644 index 00000000..70a46922 Binary files /dev/null and b/GormCore/English.lproj/GormDocument.gorm/data.info differ diff --git a/GormCore/English.lproj/GormDocument.gorm/objects.gorm b/GormCore/English.lproj/GormDocument.gorm/objects.gorm new file mode 100644 index 00000000..8b1aa901 Binary files /dev/null and b/GormCore/English.lproj/GormDocument.gorm/objects.gorm differ diff --git a/English.lproj/GormDummyInspector.gorm/data.classes b/GormCore/English.lproj/GormDummyInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormDummyInspector.gorm/data.classes rename to GormCore/English.lproj/GormDummyInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.info b/GormCore/English.lproj/GormDummyInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSPopUpButtonInspector.gorm/data.info rename to GormCore/English.lproj/GormDummyInspector.gorm/data.info diff --git a/English.lproj/GormDummyInspector.gorm/objects.gorm b/GormCore/English.lproj/GormDummyInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormDummyInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormDummyInspector.gorm/objects.gorm diff --git a/English.lproj/GormFontView.gorm/data.classes b/GormCore/English.lproj/GormFontView.gorm/data.classes similarity index 100% rename from English.lproj/GormFontView.gorm/data.classes rename to GormCore/English.lproj/GormFontView.gorm/data.classes diff --git a/English.lproj/GormFontView.gorm/data.info b/GormCore/English.lproj/GormFontView.gorm/data.info similarity index 100% rename from English.lproj/GormFontView.gorm/data.info rename to GormCore/English.lproj/GormFontView.gorm/data.info diff --git a/English.lproj/GormFontView.gorm/objects.gorm b/GormCore/English.lproj/GormFontView.gorm/objects.gorm similarity index 100% rename from English.lproj/GormFontView.gorm/objects.gorm rename to GormCore/English.lproj/GormFontView.gorm/objects.gorm diff --git a/English.lproj/GormHelpInspector.gorm/data.classes b/GormCore/English.lproj/GormHelpInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormHelpInspector.gorm/data.classes rename to GormCore/English.lproj/GormHelpInspector.gorm/data.classes diff --git a/English.lproj/GormHelpInspector.gorm/data.info b/GormCore/English.lproj/GormHelpInspector.gorm/data.info similarity index 100% rename from English.lproj/GormHelpInspector.gorm/data.info rename to GormCore/English.lproj/GormHelpInspector.gorm/data.info diff --git a/English.lproj/GormHelpInspector.gorm/objects.gorm b/GormCore/English.lproj/GormHelpInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormHelpInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormHelpInspector.gorm/objects.gorm diff --git a/English.lproj/GormImageInspector.gorm/data.classes b/GormCore/English.lproj/GormImageInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormImageInspector.gorm/data.classes rename to GormCore/English.lproj/GormImageInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.info b/GormCore/English.lproj/GormImageInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/data.info rename to GormCore/English.lproj/GormImageInspector.gorm/data.info diff --git a/English.lproj/GormImageInspector.gorm/objects.gorm b/GormCore/English.lproj/GormImageInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormImageInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormImageInspector.gorm/objects.gorm diff --git a/English.lproj/GormInconsistenciesPanel.gorm/data.classes b/GormCore/English.lproj/GormInconsistenciesPanel.gorm/data.classes similarity index 100% rename from English.lproj/GormInconsistenciesPanel.gorm/data.classes rename to GormCore/English.lproj/GormInconsistenciesPanel.gorm/data.classes diff --git a/English.lproj/GormInconsistenciesPanel.gorm/data.info b/GormCore/English.lproj/GormInconsistenciesPanel.gorm/data.info similarity index 100% rename from English.lproj/GormInconsistenciesPanel.gorm/data.info rename to GormCore/English.lproj/GormInconsistenciesPanel.gorm/data.info diff --git a/English.lproj/GormInconsistenciesPanel.gorm/objects.gorm b/GormCore/English.lproj/GormInconsistenciesPanel.gorm/objects.gorm similarity index 100% rename from English.lproj/GormInconsistenciesPanel.gorm/objects.gorm rename to GormCore/English.lproj/GormInconsistenciesPanel.gorm/objects.gorm diff --git a/English.lproj/GormInspectorPanel.gorm/data.classes b/GormCore/English.lproj/GormInspectorPanel.gorm/data.classes similarity index 100% rename from English.lproj/GormInspectorPanel.gorm/data.classes rename to GormCore/English.lproj/GormInspectorPanel.gorm/data.classes diff --git a/English.lproj/GormInspectorPanel.gorm/data.info b/GormCore/English.lproj/GormInspectorPanel.gorm/data.info similarity index 100% rename from English.lproj/GormInspectorPanel.gorm/data.info rename to GormCore/English.lproj/GormInspectorPanel.gorm/data.info diff --git a/English.lproj/GormInspectorPanel.gorm/objects.gorm b/GormCore/English.lproj/GormInspectorPanel.gorm/objects.gorm similarity index 100% rename from English.lproj/GormInspectorPanel.gorm/objects.gorm rename to GormCore/English.lproj/GormInspectorPanel.gorm/objects.gorm diff --git a/English.lproj/GormNSSplitViewInspector.gorm/data.classes b/GormCore/English.lproj/GormNSSplitViewInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormNSSplitViewInspector.gorm/data.classes rename to GormCore/English.lproj/GormNSSplitViewInspector.gorm/data.classes diff --git a/English.lproj/Gorm.gorm/data.info b/GormCore/English.lproj/GormNSSplitViewInspector.gorm/data.info similarity index 100% rename from English.lproj/Gorm.gorm/data.info rename to GormCore/English.lproj/GormNSSplitViewInspector.gorm/data.info diff --git a/English.lproj/GormNSSplitViewInspector.gorm/objects.gorm b/GormCore/English.lproj/GormNSSplitViewInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormNSSplitViewInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormNSSplitViewInspector.gorm/objects.gorm diff --git a/English.lproj/GormObjectInspector.gorm/data.classes b/GormCore/English.lproj/GormObjectInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormObjectInspector.gorm/data.classes rename to GormCore/English.lproj/GormObjectInspector.gorm/data.classes diff --git a/GormCore/English.lproj/GormObjectInspector.gorm/data.info b/GormCore/English.lproj/GormObjectInspector.gorm/data.info new file mode 100644 index 00000000..70a46922 Binary files /dev/null and b/GormCore/English.lproj/GormObjectInspector.gorm/data.info differ diff --git a/GormCore/English.lproj/GormObjectInspector.gorm/objects.gorm b/GormCore/English.lproj/GormObjectInspector.gorm/objects.gorm new file mode 100644 index 00000000..d4ff35ad Binary files /dev/null and b/GormCore/English.lproj/GormObjectInspector.gorm/objects.gorm differ diff --git a/GormCore/English.lproj/GormObjectOutlineView.gorm/data.classes b/GormCore/English.lproj/GormObjectOutlineView.gorm/data.classes new file mode 100644 index 00000000..251616d3 --- /dev/null +++ b/GormCore/English.lproj/GormObjectOutlineView.gorm/data.classes @@ -0,0 +1,25 @@ +{ + "## Comment" = "Do NOT change this file, Gorm maintains it"; + FirstResponder = { + Actions = ( + "iconView:", + "editorButton:", + "outlineView:" + ); + Super = NSObject; + }; + GormObjectViewController = { + Actions = ( + "iconView:", + "outlineView:", + "editorButton:" + ); + Outlets = ( + displayView, + iconButton, + outlineButton, + editorButton + ); + Super = NSViewController; + }; +} \ No newline at end of file diff --git a/GormCore/English.lproj/GormObjectOutlineView.gorm/data.info b/GormCore/English.lproj/GormObjectOutlineView.gorm/data.info new file mode 100644 index 00000000..70a46922 Binary files /dev/null and b/GormCore/English.lproj/GormObjectOutlineView.gorm/data.info differ diff --git a/GormCore/English.lproj/GormObjectOutlineView.gorm/editor.tiff b/GormCore/English.lproj/GormObjectOutlineView.gorm/editor.tiff new file mode 100644 index 00000000..d099cb0f Binary files /dev/null and b/GormCore/English.lproj/GormObjectOutlineView.gorm/editor.tiff differ diff --git a/GormCore/English.lproj/GormObjectOutlineView.gorm/iconView.tiff b/GormCore/English.lproj/GormObjectOutlineView.gorm/iconView.tiff new file mode 100644 index 00000000..940ed4c3 Binary files /dev/null and b/GormCore/English.lproj/GormObjectOutlineView.gorm/iconView.tiff differ diff --git a/GormCore/English.lproj/GormObjectOutlineView.gorm/objects.gorm b/GormCore/English.lproj/GormObjectOutlineView.gorm/objects.gorm new file mode 100644 index 00000000..99ff94af Binary files /dev/null and b/GormCore/English.lproj/GormObjectOutlineView.gorm/objects.gorm differ diff --git a/Images/outlineView.tiff b/GormCore/English.lproj/GormObjectOutlineView.gorm/outlineView.tiff similarity index 100% rename from Images/outlineView.tiff rename to GormCore/English.lproj/GormObjectOutlineView.gorm/outlineView.tiff diff --git a/English.lproj/GormPalettePanel.gorm/data.classes b/GormCore/English.lproj/GormPalettePanel.gorm/data.classes similarity index 100% rename from English.lproj/GormPalettePanel.gorm/data.classes rename to GormCore/English.lproj/GormPalettePanel.gorm/data.classes diff --git a/Palettes/2Controls/GormNSSliderInspector.gorm/data.info b/GormCore/English.lproj/GormPalettePanel.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSSliderInspector.gorm/data.info rename to GormCore/English.lproj/GormPalettePanel.gorm/data.info diff --git a/English.lproj/GormPalettePanel.gorm/objects.gorm b/GormCore/English.lproj/GormPalettePanel.gorm/objects.gorm similarity index 100% rename from English.lproj/GormPalettePanel.gorm/objects.gorm rename to GormCore/English.lproj/GormPalettePanel.gorm/objects.gorm diff --git a/English.lproj/GormPrefColors.gorm/data.classes b/GormCore/English.lproj/GormPrefColors.gorm/data.classes similarity index 100% rename from English.lproj/GormPrefColors.gorm/data.classes rename to GormCore/English.lproj/GormPrefColors.gorm/data.classes diff --git a/English.lproj/GormPrefColors.gorm/data.info b/GormCore/English.lproj/GormPrefColors.gorm/data.info similarity index 100% rename from English.lproj/GormPrefColors.gorm/data.info rename to GormCore/English.lproj/GormPrefColors.gorm/data.info diff --git a/English.lproj/GormPrefColors.gorm/objects.gorm b/GormCore/English.lproj/GormPrefColors.gorm/objects.gorm similarity index 100% rename from English.lproj/GormPrefColors.gorm/objects.gorm rename to GormCore/English.lproj/GormPrefColors.gorm/objects.gorm diff --git a/English.lproj/GormPrefGeneral.gorm/data.classes b/GormCore/English.lproj/GormPrefGeneral.gorm/data.classes similarity index 100% rename from English.lproj/GormPrefGeneral.gorm/data.classes rename to GormCore/English.lproj/GormPrefGeneral.gorm/data.classes diff --git a/English.lproj/GormPrefGuideline.gorm/data.info b/GormCore/English.lproj/GormPrefGeneral.gorm/data.info similarity index 100% rename from English.lproj/GormPrefGuideline.gorm/data.info rename to GormCore/English.lproj/GormPrefGeneral.gorm/data.info diff --git a/English.lproj/GormPrefGeneral.gorm/objects.gorm b/GormCore/English.lproj/GormPrefGeneral.gorm/objects.gorm similarity index 100% rename from English.lproj/GormPrefGeneral.gorm/objects.gorm rename to GormCore/English.lproj/GormPrefGeneral.gorm/objects.gorm diff --git a/English.lproj/GormPrefGuideline.gorm/data.classes b/GormCore/English.lproj/GormPrefGuideline.gorm/data.classes similarity index 100% rename from English.lproj/GormPrefGuideline.gorm/data.classes rename to GormCore/English.lproj/GormPrefGuideline.gorm/data.classes diff --git a/English.lproj/GormPreferences.gorm/data.info b/GormCore/English.lproj/GormPrefGuideline.gorm/data.info similarity index 100% rename from English.lproj/GormPreferences.gorm/data.info rename to GormCore/English.lproj/GormPrefGuideline.gorm/data.info diff --git a/English.lproj/GormPrefGuideline.gorm/objects.gorm b/GormCore/English.lproj/GormPrefGuideline.gorm/objects.gorm similarity index 100% rename from English.lproj/GormPrefGuideline.gorm/objects.gorm rename to GormCore/English.lproj/GormPrefGuideline.gorm/objects.gorm diff --git a/English.lproj/GormPrefHeaders.gorm/data.classes b/GormCore/English.lproj/GormPrefHeaders.gorm/data.classes similarity index 100% rename from English.lproj/GormPrefHeaders.gorm/data.classes rename to GormCore/English.lproj/GormPrefHeaders.gorm/data.classes diff --git a/English.lproj/GormPrefHeaders.gorm/data.info b/GormCore/English.lproj/GormPrefHeaders.gorm/data.info similarity index 100% rename from English.lproj/GormPrefHeaders.gorm/data.info rename to GormCore/English.lproj/GormPrefHeaders.gorm/data.info diff --git a/English.lproj/GormPrefHeaders.gorm/objects.gorm b/GormCore/English.lproj/GormPrefHeaders.gorm/objects.gorm similarity index 100% rename from English.lproj/GormPrefHeaders.gorm/objects.gorm rename to GormCore/English.lproj/GormPrefHeaders.gorm/objects.gorm diff --git a/English.lproj/GormPrefPalettes.gorm/data.classes b/GormCore/English.lproj/GormPrefPalettes.gorm/data.classes similarity index 100% rename from English.lproj/GormPrefPalettes.gorm/data.classes rename to GormCore/English.lproj/GormPrefPalettes.gorm/data.classes diff --git a/English.lproj/GormPrefPalettes.gorm/data.info b/GormCore/English.lproj/GormPrefPalettes.gorm/data.info similarity index 100% rename from English.lproj/GormPrefPalettes.gorm/data.info rename to GormCore/English.lproj/GormPrefPalettes.gorm/data.info diff --git a/English.lproj/GormPrefPalettes.gorm/objects.gorm b/GormCore/English.lproj/GormPrefPalettes.gorm/objects.gorm similarity index 100% rename from English.lproj/GormPrefPalettes.gorm/objects.gorm rename to GormCore/English.lproj/GormPrefPalettes.gorm/objects.gorm diff --git a/English.lproj/GormPrefPlugins.gorm/data.classes b/GormCore/English.lproj/GormPrefPlugins.gorm/data.classes similarity index 100% rename from English.lproj/GormPrefPlugins.gorm/data.classes rename to GormCore/English.lproj/GormPrefPlugins.gorm/data.classes diff --git a/English.lproj/GormPrefPlugins.gorm/data.info b/GormCore/English.lproj/GormPrefPlugins.gorm/data.info similarity index 100% rename from English.lproj/GormPrefPlugins.gorm/data.info rename to GormCore/English.lproj/GormPrefPlugins.gorm/data.info diff --git a/English.lproj/GormPrefPlugins.gorm/objects.gorm b/GormCore/English.lproj/GormPrefPlugins.gorm/objects.gorm similarity index 100% rename from English.lproj/GormPrefPlugins.gorm/objects.gorm rename to GormCore/English.lproj/GormPrefPlugins.gorm/objects.gorm diff --git a/English.lproj/GormPreferences.gorm/data.classes b/GormCore/English.lproj/GormPreferences.gorm/data.classes similarity index 100% rename from English.lproj/GormPreferences.gorm/data.classes rename to GormCore/English.lproj/GormPreferences.gorm/data.classes diff --git a/Palettes/3Containers/GormTabViewInspector.gorm/data.info b/GormCore/English.lproj/GormPreferences.gorm/data.info similarity index 100% rename from Palettes/3Containers/GormTabViewInspector.gorm/data.info rename to GormCore/English.lproj/GormPreferences.gorm/data.info diff --git a/English.lproj/GormPreferences.gorm/objects.gorm b/GormCore/English.lproj/GormPreferences.gorm/objects.gorm similarity index 100% rename from English.lproj/GormPreferences.gorm/objects.gorm rename to GormCore/English.lproj/GormPreferences.gorm/objects.gorm diff --git a/English.lproj/GormScrollViewAttributesInspector.gorm/data.classes b/GormCore/English.lproj/GormScrollViewAttributesInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormScrollViewAttributesInspector.gorm/data.classes rename to GormCore/English.lproj/GormScrollViewAttributesInspector.gorm/data.classes diff --git a/Palettes/2Controls/GormNSStepperInspector.gorm/data.info b/GormCore/English.lproj/GormScrollViewAttributesInspector.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSStepperInspector.gorm/data.info rename to GormCore/English.lproj/GormScrollViewAttributesInspector.gorm/data.info diff --git a/English.lproj/GormScrollViewAttributesInspector.gorm/objects.gorm b/GormCore/English.lproj/GormScrollViewAttributesInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormScrollViewAttributesInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormScrollViewAttributesInspector.gorm/objects.gorm diff --git a/English.lproj/GormSetName.gorm/Gorm.tiff b/GormCore/English.lproj/GormSetName.gorm/Gorm.tiff similarity index 100% rename from English.lproj/GormSetName.gorm/Gorm.tiff rename to GormCore/English.lproj/GormSetName.gorm/Gorm.tiff diff --git a/English.lproj/GormSetName.gorm/data.classes b/GormCore/English.lproj/GormSetName.gorm/data.classes similarity index 100% rename from English.lproj/GormSetName.gorm/data.classes rename to GormCore/English.lproj/GormSetName.gorm/data.classes diff --git a/Palettes/2Controls/GormNSTextFieldInspector.gorm/data.info b/GormCore/English.lproj/GormSetName.gorm/data.info similarity index 100% rename from Palettes/2Controls/GormNSTextFieldInspector.gorm/data.info rename to GormCore/English.lproj/GormSetName.gorm/data.info diff --git a/English.lproj/GormSetName.gorm/objects.gorm b/GormCore/English.lproj/GormSetName.gorm/objects.gorm similarity index 100% rename from English.lproj/GormSetName.gorm/objects.gorm rename to GormCore/English.lproj/GormSetName.gorm/objects.gorm diff --git a/English.lproj/GormShelfPref.gorm/data.classes b/GormCore/English.lproj/GormShelfPref.gorm/data.classes similarity index 100% rename from English.lproj/GormShelfPref.gorm/data.classes rename to GormCore/English.lproj/GormShelfPref.gorm/data.classes diff --git a/English.lproj/GormShelfPref.gorm/data.info b/GormCore/English.lproj/GormShelfPref.gorm/data.info similarity index 100% rename from English.lproj/GormShelfPref.gorm/data.info rename to GormCore/English.lproj/GormShelfPref.gorm/data.info diff --git a/English.lproj/GormShelfPref.gorm/objects.gorm b/GormCore/English.lproj/GormShelfPref.gorm/objects.gorm similarity index 100% rename from English.lproj/GormShelfPref.gorm/objects.gorm rename to GormCore/English.lproj/GormShelfPref.gorm/objects.gorm diff --git a/English.lproj/GormSoundInspector.gorm/data.classes b/GormCore/English.lproj/GormSoundInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormSoundInspector.gorm/data.classes rename to GormCore/English.lproj/GormSoundInspector.gorm/data.classes diff --git a/Palettes/3Containers/GormNSBrowserInspector.gorm/data.info b/GormCore/English.lproj/GormSoundInspector.gorm/data.info similarity index 100% rename from Palettes/3Containers/GormNSBrowserInspector.gorm/data.info rename to GormCore/English.lproj/GormSoundInspector.gorm/data.info diff --git a/English.lproj/GormSoundInspector.gorm/ff.tiff b/GormCore/English.lproj/GormSoundInspector.gorm/ff.tiff similarity index 100% rename from English.lproj/GormSoundInspector.gorm/ff.tiff rename to GormCore/English.lproj/GormSoundInspector.gorm/ff.tiff diff --git a/English.lproj/GormSoundInspector.gorm/objects.gorm b/GormCore/English.lproj/GormSoundInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormSoundInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormSoundInspector.gorm/objects.gorm diff --git a/English.lproj/GormSoundInspector.gorm/pause.tiff b/GormCore/English.lproj/GormSoundInspector.gorm/pause.tiff similarity index 100% rename from English.lproj/GormSoundInspector.gorm/pause.tiff rename to GormCore/English.lproj/GormSoundInspector.gorm/pause.tiff diff --git a/English.lproj/GormSoundInspector.gorm/play.tiff b/GormCore/English.lproj/GormSoundInspector.gorm/play.tiff similarity index 100% rename from English.lproj/GormSoundInspector.gorm/play.tiff rename to GormCore/English.lproj/GormSoundInspector.gorm/play.tiff diff --git a/English.lproj/GormSoundInspector.gorm/rec.tiff b/GormCore/English.lproj/GormSoundInspector.gorm/rec.tiff similarity index 100% rename from English.lproj/GormSoundInspector.gorm/rec.tiff rename to GormCore/English.lproj/GormSoundInspector.gorm/rec.tiff diff --git a/English.lproj/GormSoundInspector.gorm/rw.tiff b/GormCore/English.lproj/GormSoundInspector.gorm/rw.tiff similarity index 100% rename from English.lproj/GormSoundInspector.gorm/rw.tiff rename to GormCore/English.lproj/GormSoundInspector.gorm/rw.tiff diff --git a/English.lproj/GormSoundInspector.gorm/stop.tiff b/GormCore/English.lproj/GormSoundInspector.gorm/stop.tiff similarity index 100% rename from English.lproj/GormSoundInspector.gorm/stop.tiff rename to GormCore/English.lproj/GormSoundInspector.gorm/stop.tiff diff --git a/English.lproj/GormViewSizeInspector.gorm/data.classes b/GormCore/English.lproj/GormViewSizeInspector.gorm/data.classes similarity index 100% rename from English.lproj/GormViewSizeInspector.gorm/data.classes rename to GormCore/English.lproj/GormViewSizeInspector.gorm/data.classes diff --git a/Palettes/3Containers/GormNSTableColumnInspector.gorm/data.info b/GormCore/English.lproj/GormViewSizeInspector.gorm/data.info similarity index 100% rename from Palettes/3Containers/GormNSTableColumnInspector.gorm/data.info rename to GormCore/English.lproj/GormViewSizeInspector.gorm/data.info diff --git a/English.lproj/GormViewSizeInspector.gorm/objects.gorm b/GormCore/English.lproj/GormViewSizeInspector.gorm/objects.gorm similarity index 100% rename from English.lproj/GormViewSizeInspector.gorm/objects.gorm rename to GormCore/English.lproj/GormViewSizeInspector.gorm/objects.gorm diff --git a/GormCore/GNUmakefile b/GormCore/GNUmakefile index e927ebaf..87ae1bf8 100644 --- a/GormCore/GNUmakefile +++ b/GormCore/GNUmakefile @@ -29,17 +29,16 @@ include $(GNUSTEP_MAKEFILES)/common.make PACKAGE_NAME=GormCore -LIBRARY_VAR=GORMCORE -LIBRARY_NAME=GormCore -GormCore_HEADER_FILES_DIR=. -GormCore_HEADER_FILES_INSTALL_DIR=/GormCore +FRAMEWORK_VAR=GORMCORE +FRAMEWORK_NAME=GormCore ADDITIONAL_INCLUDE_DIRS = -I.. srcdir = . -include ../Version +SUBPROJECTS = GormCore_HEADER_FILES = \ GormCore.h \ + GormAbstractDelegate.h \ GormBoxEditor.h \ GormClassEditor.h \ GormClassInspector.h \ @@ -49,6 +48,7 @@ GormCore_HEADER_FILES = \ GormControlEditor.h \ GormCustomClassInspector.h \ GormCustomView.h \ + GormDefines.h \ GormDocument.h \ GormDocumentController.h \ GormDocumentWindow.h \ @@ -69,6 +69,7 @@ GormCore_HEADER_FILES = \ GormNSWindow.h \ GormObjectEditor.h \ GormObjectInspector.h \ + GormObjectViewController.h \ GormOpenGLView.h \ GormOutlineView.h \ GormPalettesManager.h \ @@ -102,9 +103,23 @@ GormCore_HEADER_FILES = \ NSCell+GormAdditions.h \ NSColorWell+GormExtensions.h \ NSFontManager+GormExtensions.h \ - NSView+GormExtensions.h + NSView+GormExtensions.h \ + GormGeneralPref.h \ + GormGuidelinePref.h \ + GormHeadersPref.h \ + GormPalettesPref.h \ + GormPluginsPref.h \ + GormPrefController.h \ + GormPrefs.h \ + GormShelfPref.h \ + GormXLIFFDocument.h \ + GormXLIFFDocument.h \ + GormXLIFFDocument.h \ + GormXLIFFDocument.h \ + GormXLIFFDocument.h \ GormCore_OBJC_FILES = \ + GormAbstractDelegate.m \ GormBoxEditor.m \ GormClassEditor.m \ GormClassInspector.m \ @@ -134,6 +149,7 @@ GormCore_OBJC_FILES = \ GormNSWindow.m \ GormObjectEditor.m \ GormObjectInspector.m \ + GormObjectViewController.m \ GormOpenGLView.m \ GormOutlineView.m \ GormPalettesManager.m \ @@ -165,12 +181,85 @@ GormCore_OBJC_FILES = \ NSColorWell+GormExtensions.m \ NSFontManager+GormExtensions.m \ NSView+GormExtensions.m \ - GormPrivate.m + GormPrivate.m \ + GormGeneralPref.m \ + GormGuidelinePref.m \ + GormHeadersPref.m \ + GormPalettesPref.m \ + GormPluginsPref.m \ + GormPrefController.m \ + GormShelfPref.m \ + GormXLIFFDocument.m \ + +GormCore_RESOURCE_FILES = \ + Images/GormActionSelected.tiff \ + Images/GormAction.tiff \ + Images/GormClass.tiff \ + Images/GormCopyImage.tiff \ + Images/GormEHCoil.tiff \ + Images/GormEHLine.tiff \ + Images/GormEVCoil.tiff \ + Images/GormEVLine.tiff \ + Images/GormFile.tiff \ + Images/GormFilesOwner.tiff \ + Images/GormFirstResponder.tiff \ + Images/GormFontManager.tiff \ + Images/GormImage.tiff \ + Images/GormMenu.tiff \ + Images/GormMHCoil.tiff \ + Images/GormMHLine.tiff \ + Images/GormMVCoil.tiff \ + Images/GormMVLine.tiff \ + Images/GormObject.tiff \ + Images/GormOutletSelected.tiff \ + Images/GormOutlet.tiff \ + Images/GormSound.tiff \ + Images/GormUnknown.tiff \ + Images/GormView.tiff \ + Images/GormWindow.tiff \ + Images/browserView.tiff \ + Images/outlineView.tiff \ + Images/iconView.tiff \ + Images/editor.tiff \ + Resources/VersionProfiles.plist \ + Resources/ClassInformation.plist + +GormCore_LANGUAGES = English + +GormCore_LOCALIZED_RESOURCE_FILES = \ + GormClassEditor.gorm \ + GormClassInspector.gorm \ + GormClassPanel.gorm \ + GormConnectionInspector.gorm \ + GormCustomClassInspector.gorm \ + GormDocument.gorm \ + GormDummyInspector.gorm \ + GormFontView.gorm \ + GormHelpInspector.gorm \ + GormImageInspector.gorm \ + GormInconsistenciesPanel.gorm \ + GormInspectorPanel.gorm \ + GormNSSplitViewInspector.gorm \ + GormObjectInspector.gorm \ + GormObjectOutlineView.gorm \ + GormPalettePanel.gorm \ + GormPrefColors.gorm \ + GormPreferences.gorm \ + GormPrefGeneral.gorm \ + GormPrefGuideline.gorm \ + GormPrefHeaders.gorm \ + GormPrefPalettes.gorm \ + GormPrefPlugins.gorm \ + GormScrollViewAttributesInspector.gorm \ + GormSetName.gorm \ + GormShelfPref.gorm \ + GormSoundInspector.gorm \ + GormViewSizeInspector.gorm -include GNUmakefile.preamble -include GNUmakefile.local include $(GNUSTEP_MAKEFILES)/aggregate.make -include $(GNUSTEP_MAKEFILES)/library.make +include $(GNUSTEP_MAKEFILES)/framework.make -include GNUmakefile.postamble diff --git a/GormCore/GNUmakefile.preamble b/GormCore/GNUmakefile.preamble index 2f018d93..d2fcd5b3 100644 --- a/GormCore/GNUmakefile.preamble +++ b/GormCore/GNUmakefile.preamble @@ -22,19 +22,19 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA # -# ADDITIONAL_OBJCFLAGS += -Wall -Werror -ADDITIONAL_GUI_LIBS += \ - -lGorm \ - -lGormObjCHeaderParser +ADDITIONAL_INCLUDE_DIRS += -I../.. ifeq ($(GNUSTEP_TARGET_OS),mingw32) ADDITIONAL_LIB_DIRS += \ - -L../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) -else -ADDITIONAL_LIB_DIRS += \ - -L../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) -endif + -L../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ -GormCore_LIBRARIES_DEPEND_UPON += -lGormObjCHeaderParser +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormObjCHeaderParser +endif +ifeq ($(GNUSTEP_TARGET_OS),cygwin) +ADDITIONAL_LIB_DIRS += \ + -L../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + +$(BUNDLE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormObjCHeaderParser +endif \ No newline at end of file diff --git a/GormCore/GormAbstractDelegate.h b/GormCore/GormAbstractDelegate.h new file mode 100644 index 00000000..15ddde43 --- /dev/null +++ b/GormCore/GormAbstractDelegate.h @@ -0,0 +1,87 @@ +/* GormAppDelegate.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#ifndef GNUSTEP_GormAbstractDelegate_H +#define GNUSTEP_GormAbstractDelegate_H + +#import +#import + +#import +#import + +@class NSDictionary; +@class NSImage; +@class NSMenu; +@class NSMutableArray; +@class NSSet; +@class GormPrefController; +@class GormClassManager; +@class GormPalettesManager; +@class GormPluginManager; +@class NSDockTile; + +@interface GormAbstractDelegate : NSObject +{ + IBOutlet id _gormMenu; + IBOutlet id _guideLineMenuItem; + + GormPrefController *_preferencesController; + GormClassManager *_classManager; + GormInspectorsManager *_inspectorsManager; + GormPalettesManager *_palettesManager; + GormPluginManager *_pluginManager; + id _selectionOwner; + BOOL _isConnecting; + BOOL _isTesting; + id _testContainer; + NSMenu *_mainMenu; // saves the main menu... + NSMenu *_servicesMenu; // saves the services menu... + NSMenu *_classMenu; // so we can set it for the class view + NSDictionary *_menuLocations; + NSImage *_linkImage; + NSImage *_sourceImage; + NSImage *_targetImage; + NSImage *_gormImage; + NSImage *_testingImage; + id _connectSource; + id _connectDestination; + NSMutableArray *_testingWindows; + NSSet *_topObjects; + NSDockTile *_dockTile; +} + +// testing the interface +- (IBAction) deferredEndTesting: (id) sender; +- (IBAction) testInterface: (id)sender; +- (IBAction) endTesting: (id)sender; + +// Testing... +- (void) setTestingInterface: (BOOL)testing; +- (BOOL) isTestingInterface; + +@end + +#endif // import guard diff --git a/GormCore/GormAbstractDelegate.m b/GormCore/GormAbstractDelegate.m new file mode 100644 index 00000000..225014b3 --- /dev/null +++ b/GormCore/GormAbstractDelegate.m @@ -0,0 +1,994 @@ +/* GormAppDelegate.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#import +#import +#import + +#import +#import + +#import "GormAbstractDelegate.h" +#import "GormDocument.h" +#import "GormDocumentController.h" +#import "GormFontViewController.h" +#import "GormFunctions.h" +#import "GormGenericEditor.h" +#import "GormPluginManager.h" +#import "GormPrefController.h" +#import "GormPrivate.h" +#import "GormSetNameController.h" + +@implementation GormAbstractDelegate + +/* + GormAppDelegate +*/ +- (id) init +{ + self = [super init]; + + if (self != nil) + { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + NSNotificationCenter *ndc = [NSDistributedNotificationCenter defaultCenter]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + NSConnection *conn = [NSConnection defaultConnection]; + NSString *path = nil; + + if ([self isInTool] == NO) + { + path = [bundle pathForImageResource: @"GormLinkImage"]; + _linkImage = [[NSImage alloc] initWithContentsOfFile: path]; + path = [bundle pathForImageResource: @"GormSourceTag"]; + _sourceImage = [[NSImage alloc] initWithContentsOfFile: path]; + path = [bundle pathForImageResource: @"GormTargetTag"]; + _targetImage = [[NSImage alloc] initWithContentsOfFile: path]; + path = [bundle pathForImageResource: @"Gorm"]; + _gormImage = [[NSImage alloc] initWithContentsOfFile: path]; + path = [bundle pathForImageResource: @"GormTesting"]; + _testingImage = [[NSImage alloc] initWithContentsOfFile: path]; + } + + // Initialize ivars + _isTesting = NO; + + // regular notifications... + [nc addObserver: self + selector: @selector(handleNotification:) + name: IBSelectionChangedNotification + object: nil]; + [nc addObserver: self + selector: @selector(handleNotification:) + name: IBWillCloseDocumentNotification + object: nil]; + + // distibuted notifications... + [ndc addObserver: self + selector: @selector(handleNotification:) + name: @"GormAddClassNotification" + object: nil]; + [ndc addObserver: self + selector: @selector(handleNotification:) + name: @"GormDeleteClassNotification" + object: nil]; + [ndc addObserver: self + selector: @selector(handleNotification:) + name: @"GormParseClassNotification" + object: nil]; + + /* + * establish registration domain defaults from file. + */ + path = [bundle pathForResource: @"Defaults" ofType: @"plist"]; + if (path != nil) + { + NSDictionary *dict; + + dict = [NSDictionary dictionaryWithContentsOfFile: path]; + if (dict != nil) + { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + + [defaults registerDefaults: dict]; + } + } + + /* + * Make sure the palettes/plugins managers exist, so that the + * editors and inspectors provided in the standard palettes + * are available. + */ + [self palettesManager]; + [self pluginManager]; + [GormDocumentController sharedDocumentController]; + + /* + * Start the server + */ + if ([self isInTool] == NO) + { + [conn setRootObject: self]; + if([conn registerName: @"GormServer"] == NO) + { + NSLog(@"Could not register GormServer"); + } + } + } + + return self; +} + +- (void) dealloc +{ + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + + [nc removeObserver: self]; + RELEASE(_inspectorsManager); + RELEASE(_palettesManager); + RELEASE(_classManager); + [super dealloc]; +} + +// Handle all alerts here... + +- (BOOL) shouldUpgradeOlderArchive +{ + NSInteger retval = NSRunAlertPanel(_(@"Compatibility Warning"), + _(@"Saving will update this gorm to the latest version \n" + @"which may not be compatible with some previous versions \n" + @"of GNUstep."), + _(@"Save"), + _(@"Don't Save"), nil, nil); + + return (retval == NSAlertDefaultReturn); +} + +- (BOOL) shouldLoadNewerArchive +{ + NSInteger retval = NSRunAlertPanel(_(@"Gorm Build Mismatch"), + _(@"The file being loaded was created with a newer build, continue?"), + _(@"OK"), + _(@"Cancel"), + nil, + nil); + + return (retval == NSAlertDefaultReturn); +} + +- (BOOL) shouldBreakConnectionsForClassNamed: (NSString *)className +{ + NSInteger retval = -1; + NSString *title = [NSString stringWithFormat: @"%@",_(@"Modifying Class")]; + NSString *msg; + NSString *msgFormat = _(@"This will break all connections to " + @"actions/outlets to instances of class '%@' and it's subclasses. Continue?"); + + msg = [NSString stringWithFormat: msgFormat, className]; + + // ask the user if he/she wants to continue... + retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); + + return (retval == NSAlertDefaultReturn); +} + +- (BOOL) shouldRenameConnectionsForClassNamed: (NSString *)className toClassName: (NSString *)newName +{ + NSInteger retval = -1; + NSString *title = [NSString stringWithFormat: @"%@", _(@"Modifying Class")]; + NSString *msgFormat = _(@"Change class name '%@' to '%@'. Continue?"); + NSString *msg = [NSString stringWithFormat: + msgFormat, + className, newName]; + + // ask the user if he/she wants to continue... + retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); + return (retval == NSAlertDefaultReturn); +} + +- (BOOL) shouldBreakConnectionsModifyingLabel: (NSString *)name isAction: (BOOL)action prompted: (BOOL)prompted +{ + NSString *title; + NSString *msg; + NSInteger retval = -1; + + if(prompted == NO) + { + title = [NSString stringWithFormat: + @"Modifying %@",(action==YES?@"Action":@"Outlet")]; + msg = [NSString stringWithFormat: + _(@"This will break all connections to '%@'. Continue?"), name]; + retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); + // prompted = YES; + } + + return (retval == NSAlertDefaultReturn); +} + +- (void) couldNotParseClassAtPath: (NSString *)path +{ + NSString *file = [path lastPathComponent]; + NSString *message = [NSString stringWithFormat: + _(@"Unable to parse class in %@"),file]; + NSRunAlertPanel(_(@"Problem parsing class"), + message, + nil, nil, nil); +} + +- (void) exceptionWhileParsingClass: (NSException *)localException +{ + NSString *message = [localException reason]; + NSRunAlertPanel(_(@"Problem parsing class"), + message, + nil, nil, nil); +} + +- (BOOL) shouldBreakConnectionsReparsingClass: (NSString *)className +{ + NSString *title = [NSString stringWithFormat: @"%@", + _(@"Reparsing Class")]; + NSString *messageFormat = _(@"This may break connections to " + @"actions/outlets to instances of class '%@' " + @"and it's subclasses. Continue?"); + NSString *msg = [NSString stringWithFormat: messageFormat, + className]; + NSInteger retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); + + return (retval == NSAlertDefaultReturn); +} + +// Gorm specific methods... +- (BOOL) isInTool +{ + return NO; +} + +- (id) activeDocument +{ + return [[GormDocumentController sharedDocumentController] currentDocument]; +} + +- (GormClassManager*) classManager +{ + id document = [self activeDocument]; + + if (document != nil) return [document classManager]; + + /* kept in the case one want access to the classManager without document */ + else if (_classManager == nil) + { + _classManager = [[GormClassManager alloc] init]; + } + return _classManager; + +} + +- (id) connectDestination +{ + return _connectDestination; +} + +- (id) connectSource +{ + return _connectSource; +} + +- (void) displayConnectionBetween: (id)source + and: (id)destination +{ + NSWindow *window; + NSRect rect; + + + if (source != _connectSource) + { + if (_connectSource != nil) + { + window = [(GormDocument *)[self activeDocument] windowAndRect: &rect + forObject: _connectSource]; + if (window != nil) + { + NSView *view = [[window contentView] superview]; + + rect.origin.x --; + rect.size.width ++; + + rect.size.height ++; + + [window disableFlushWindow]; + [view displayRect: rect]; + + [window enableFlushWindow]; + [window flushWindow]; + } + } + _connectSource = source; + } + if (destination != _connectDestination) + { + if (_connectDestination != nil) + { + window = [(GormDocument *)[self activeDocument] windowAndRect: &rect + forObject: _connectDestination]; + if (window != nil) + { + NSView *view = [[window contentView] superview]; + + /* + * Erase image from old location. + */ + rect.origin.x --; + rect.size.width ++; + rect.size.height ++; + + [view lockFocus]; + [view displayRect: rect]; + [view unlockFocus]; + [window flushWindow]; + } + } + _connectDestination = destination; + } + if (_connectSource != nil) + { + window = [(GormDocument *)[self activeDocument] windowAndRect: &rect forObject: _connectSource]; + if (window != nil) + { + NSView *view = [[window contentView] superview]; + NSRect imageRect = rect; + + imageRect.origin.x++; + //rect.size.width--; + //rect.size.height--; + [view lockFocus]; + [[NSColor greenColor] set]; + NSFrameRectWithWidth(rect, 1); + + [_sourceImage compositeToPoint: imageRect.origin + operation: NSCompositeSourceOver]; + [view unlockFocus]; + [window flushWindow]; + } + } + if (_connectDestination != nil && _connectDestination == _connectSource) + { + window = [(GormDocument *)[self activeDocument] windowAndRect: &rect + forObject: _connectDestination]; + if (window != nil) + { + NSView *view = [[window contentView] superview]; + NSRect imageRect = rect; + + imageRect.origin.x += 3; + imageRect.origin.y += 2; + // rect.size.width -= 5; + // rect.size.height -= 5; + [view lockFocus]; + [[NSColor purpleColor] set]; + NSFrameRectWithWidth(rect, 1); + + imageRect.origin.x += [_targetImage size].width; + [_targetImage compositeToPoint: imageRect.origin + operation: NSCompositeSourceOver]; + [view unlockFocus]; + [window flushWindow]; + } + } + else if (_connectDestination != nil) + { + window = [(GormDocument *)[self activeDocument] windowAndRect: &rect + forObject: _connectDestination]; + if (window != nil) + { + NSView *view = [[window contentView] superview]; + NSRect imageRect = rect; + + imageRect.origin.x++; + // rect.size.width--; + // rect.size.height--; + [view lockFocus]; + [[NSColor purpleColor] set]; + NSFrameRectWithWidth(rect, 1); + + [_targetImage compositeToPoint: imageRect.origin + operation: NSCompositeSourceOver]; + [view unlockFocus]; + [window flushWindow]; + } + } +} + +- (IBAction) testInterface: (id)sender +{ + if (_isTesting == NO || [self isInTool]) + { + // top level objects + NS_DURING + { + NSUserDefaults *defaults; + NSNotificationCenter *notifCenter = [NSNotificationCenter defaultCenter]; + GormDocument *activeDoc = (GormDocument*)[self activeDocument]; + NSData *data; + NSArchiver *archiver; + NSEnumerator *en; + NSDictionary *substituteClasses = [_palettesManager substituteClasses]; + NSString *subClassName; + id obj; + id savedDelegate = [NSApp delegate]; + NSMenu *modelMenu = [activeDoc objectForName: @"NSMenu"]; + + + // which windows were open when testing started... + _testingWindows = [[NSMutableArray alloc] init]; + en = [[NSApp windows] objectEnumerator]; + while((obj = [en nextObject]) != nil) + { + if([obj isVisible]) + { + [_testingWindows addObject: obj]; + if ([activeDoc window] != obj) + { + [obj close]; // close the visible windows... + } + } + } + + // set here, so that beginArchiving and endArchiving do not use templates. + _isTesting = YES; + // [NSApp setApplicationIconImage: _testingImage]; + + // Set up the dock tile... + _dockTile = [[NSDockTile alloc] init]; + [_dockTile setShowsApplicationBadge: YES]; + [_dockTile setBadgeLabel: @"Test!"]; + + // Encode palette classes with their equivalent substitutes + archiver = [[NSArchiver alloc] init]; + [activeDoc deactivateEditors]; + if ([self isInTool] == NO) + { + [archiver encodeClassName: @"GormCustomView" + intoClassName: @"GormTestCustomView"]; + + // substitute classes from palettes. + en = [substituteClasses keyEnumerator]; + while((subClassName = [en nextObject]) != nil) + { + NSString *realClassName = [substituteClasses objectForKey: subClassName]; + + if([realClassName isEqualToString: @"NSTableView"] || + [realClassName isEqualToString: @"NSOutlineView"] || + [realClassName isEqualToString: @"NSBrowser"]) + { + continue; + } + + [archiver encodeClassName: subClassName + intoClassName: realClassName]; + } + } + + // do not allow custom classes during testing. + [GSClassSwapper setIsInInterfaceBuilder: YES]; + [archiver encodeRootObject: activeDoc]; + data = RETAIN([archiver archiverData]); // Released below... + [activeDoc reactivateEditors]; + RELEASE(archiver); + [GSClassSwapper setIsInInterfaceBuilder: NO]; + + // signal the start of testing... + [notifCenter postNotificationName: IBWillBeginTestingInterfaceNotification + object: self]; + + if ([_selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES) + { + [_selectionOwner makeSelectionVisible: NO]; + } + + defaults = [NSUserDefaults standardUserDefaults]; + _menuLocations = [[defaults objectForKey: @"NSMenuLocations"] copy]; + [defaults removeObjectForKey: @"NSMenuLocations"]; + _servicesMenu = [NSApp servicesMenu]; + + _testContainer = [NSUnarchiver unarchiveObjectWithData: data]; + if (_testContainer != nil) + { + NSMutableDictionary *nameTable = [_testContainer nameTable]; + NSMenu *aMenu = [nameTable objectForKey: @"NSMenu"]; + + _mainMenu = [NSApp mainMenu]; // save the menu before testing... + [[NSApp mainMenu] close]; + [NSApp setMainMenu: aMenu]; + // initialize the context. + RETAIN(_testContainer); + _topObjects = [_testContainer topLevelObjects]; + + [nameTable removeObjectForKey: @"NSServicesMenu"]; + [nameTable removeObjectForKey: @"NSWindowsMenu"]; + [_testContainer awakeWithContext: nil]; + [NSApp setDelegate: savedDelegate]; // makes sure the delegate isn't reset. + + /* + * If the model didn't have a main menu, create one, + * otherwise, ensure that 'quit' ends testing mode. + */ + + SEL endSelector = NULL; + + endSelector = @selector(deferredEndTesting:); + if ([self isInTool]) + { + endSelector = @selector(endTestingNow:); + } + + + if (aMenu == nil) + { + NSMenu *testMenu; + + testMenu = [[NSMenu alloc] initWithTitle: _(@"Test Menu (Gorm)")]; + [testMenu addItemWithTitle: _(@"Quit Test") + action: endSelector + keyEquivalent: @"q"]; + [NSApp setMainMenu: testMenu]; // released, when the menu is reset in endTesting. + } + else + { + NSMenu *testMenu = [NSApp mainMenu]; + NSString *newTitle = [[testMenu title] stringByAppendingString: @" (Gorm)"]; + NSArray *items = findAll(testMenu); + NSEnumerator *en = [items objectEnumerator]; + id item; + BOOL found = NO; + + while((item = [en nextObject]) != nil) + { + if([item isKindOfClass: [NSMenuItem class]]) + { + SEL action = [item action]; + if(sel_isEqual(action, @selector(terminate:))) + { + found = YES; + [item setTitle: _(@"Quit Test")]; + [item setTarget: self]; + [item setAction: endSelector]; + } + } + } + + // releast the items... + RELEASE(items); + + // set the menu up so that it's easy to tell we're testing and how to quit. + [testMenu setTitle: newTitle]; + if(found == NO) + { + [testMenu addItemWithTitle: _(@"Quit Test") + action: endSelector + keyEquivalent: @"q"]; + } + } + + [modelMenu close]; + + // so we don't get the warning... + [NSApp setServicesMenu: nil]; + [[NSApp mainMenu] display]; + en = [[NSApp windows] objectEnumerator]; + while((obj = [en nextObject]) != nil) + { + if([obj isVisible]) + { + [obj makeKeyAndOrderFront: self]; + } + } + + // we're now in testing mode. + [notifCenter postNotificationName: IBDidBeginTestingInterfaceNotification + object: self]; + + [NSApp unhide: self]; + } + + RELEASE(data); + } + NS_HANDLER + { + // reset the application after the error. + NSLog(@"Problem while testing interface: %@", + [localException reason]); + NSRunAlertPanel(_(@"Problem While Testing Interface"), + [NSString stringWithFormat: @"Make sure connections are to appropriate objects.\n" + @"Exception: %@", + [localException reason]], + _(@"OK"), nil, nil); + [self endTesting: self]; + } + NS_ENDHANDLER; + } +} + +- (IBAction) setName: (id)sender +{ + GormSetNameController *panel; + int returnPanel; + NSTextField *textField; + NSArray *selectionArray = [_selectionOwner selection]; + id obj = [selectionArray objectAtIndex: 0]; + NSString *name; + + if([(GormDocument *)[self activeDocument] isTopLevelObject: obj]) + { + panel = [[GormSetNameController alloc] init]; + returnPanel = [panel runAsModal]; + textField = [panel textField]; + + if (returnPanel == NSAlertDefaultReturn) + { + name = [[textField stringValue] stringByTrimmingSpaces]; + if (name != nil && [name isEqual: @""] == NO) + { + [[self activeDocument] setName: name forObject: obj]; + } + } + RELEASE(panel); + } +} + +- (IBAction) guideline: (id) sender +{ + [[NSNotificationCenter defaultCenter] postNotificationName: GormToggleGuidelineNotification + object:nil]; + if ( [_guideLineMenuItem tag] == 0 ) + { + [_guideLineMenuItem setTitle:_(@"Turn GuideLine On")]; + [_guideLineMenuItem setTag:1]; + } + else if ( [_guideLineMenuItem tag] == 1) + { + [_guideLineMenuItem setTitle:_(@"Turn GuideLine Off")]; + [_guideLineMenuItem setTag:0]; + } +} + +- (IBAction) orderFrontFontPanel: (id) sender +{ + NSFontPanel *fontPanel = [NSFontPanel sharedFontPanel]; + GormFontViewController *gfvc = + [GormFontViewController sharedGormFontViewController]; + [fontPanel setAccessoryView: [gfvc view]]; + [[NSFontManager sharedFontManager] orderFrontFontPanel: self]; +} + +/** Testing methods... */ +- (IBAction) endTestingNow: (id)sender +{ + [NSApp terminate: self]; +} + +- (IBAction) deferredEndTesting: (id) sender +{ + [[NSRunLoop currentRunLoop] + performSelector: @selector(endTesting:) + target: self + argument: nil + order: 5000 + modes: [NSArray arrayWithObjects: + NSDefaultRunLoopMode, + NSModalPanelRunLoopMode, + NSEventTrackingRunLoopMode, nil]]; +} + +- (IBAction) endTesting: (id)sender +{ + if (_isTesting) + { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + NSUserDefaults *defaults; + NSEnumerator *e; + id val; + + [nc postNotificationName: IBWillEndTestingInterfaceNotification + object: self]; + + /* + * Make sure windows will go away when the container is destroyed. + */ + e = [_topObjects objectEnumerator]; + while ((val = [e nextObject]) != nil) + { + if ([val isKindOfClass: [NSWindow class]] == YES) + { + [val close]; + } + } + + /* + * Make sure any peripheral windows: font panels, etc. which are brought + * up by the interface being tested are also closed. + */ + e = [[NSApp windows] objectEnumerator]; + while ((val = [e nextObject]) != nil) + { + if ([_testingWindows containsObject: val] == NO && + [val isKindOfClass: [NSWindow class]] && + [val isVisible]) + { + [val orderOut: self]; + } + } + + // prevent saving of this, if the _menuLocations have not previously been set. + if(_menuLocations != nil) + { + defaults = [NSUserDefaults standardUserDefaults]; + [defaults setObject: _menuLocations forKey: @"NSMenuLocations"]; + DESTROY(_menuLocations); + } + + // Restore windows and menus... + [NSApp setMainMenu: _mainMenu]; + [NSApp setApplicationIconImage: _gormImage]; + [[NSApp mainMenu] display]; + + RELEASE(_dockTile); + + e = [_testingWindows objectEnumerator]; + while ((val = [e nextObject]) != nil) + { + [val orderFront: self]; + } + + NS_DURING + { + [NSApp setServicesMenu: _servicesMenu]; + } + NS_HANDLER + { + NSDebugLog(@"Exception while setting services menu"); + } + NS_ENDHANDLER + + _isTesting = NO; + + if ([_selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES) + { + [_selectionOwner makeSelectionVisible: YES]; + } + [nc postNotificationName: IBDidEndTestingInterfaceNotification + object: self]; + + + DESTROY(_testingWindows); + + // deallocate + RELEASE(_testContainer); + } +} + +// end of menu actions... + +- (void) handleNotification: (NSNotification*)notification +{ + NSString *name = [notification name]; + id obj = [notification object]; + + if ([name isEqual: IBSelectionChangedNotification]) + { + /* + * If we are connecting - stop it - a change in selection must mean + * that the connection process has ended. + */ + if ([self isConnecting] == YES) + { + [self stopConnecting]; + } + [_selectionOwner makeSelectionVisible: NO]; + _selectionOwner = obj; + [[self inspectorsManager] updateSelection]; + } + else if ([name isEqual: IBWillCloseDocumentNotification]) + { + _selectionOwner = nil; + } + else if ([name isEqual: @"GormAddClassNotification"]) + { + id obj = [notification object]; + [self addClass: obj]; + } + else if ([name isEqual: @"GormDeleteClassNotification"]) + { + id obj = [notification object]; + [self deleteClass: obj]; + } + else if ([name isEqual: @"GormParseClassNotification"]) + { + NSString *pathToClass = (NSString *)[notification object]; + GormClassManager *cm = [(GormDocument *)[self activeDocument] classManager]; + [cm parseHeader: pathToClass]; + } +} + +- (void) awakeFromNib +{ + // set the menu... + _mainMenu = (NSMenu *)_gormMenu; +} + +- (GormInspectorsManager*) inspectorsManager +{ + if (_inspectorsManager == nil) + { + _inspectorsManager = (GormInspectorsManager *)[GormInspectorsManager sharedInspectorManager]; + } + return _inspectorsManager; +} + +- (BOOL) isConnecting +{ + return _isConnecting; +} + +- (BOOL) isTestingInterface +{ + return _isTesting; +} + +- (void) setTestingInterface: (BOOL)testing +{ + _isTesting = testing; +} + +- (NSImage*) linkImage +{ + return _linkImage; +} + +- (GormPalettesManager*) palettesManager +{ + if (_palettesManager == nil) + { + _palettesManager = [[GormPalettesManager alloc] init]; + } + return _palettesManager; +} + +- (GormPluginManager*) pluginManager +{ + if (_pluginManager == nil) + { + _pluginManager = [[GormPluginManager alloc] init]; + } + return _pluginManager; +} + +- (id) selectionOwner +{ + return (id)_selectionOwner; +} + +- (id) selectedObject +{ + return [[_selectionOwner selection] lastObject]; +} + +- (id) documentForObject: (id)object +{ + NSEnumerator *en = [[[GormDocumentController sharedDocumentController] + documents] + objectEnumerator]; + id doc = nil; + id result = nil; + + while((doc = [en nextObject]) != nil) + { + if([doc containsObject: object]) + { + result = doc; + break; + } + } + + return result; +} + +- (void) startConnecting +{ + if (_isConnecting == YES) + { + return; + } + if (_connectSource == nil) + { + return; + } + if (_connectDestination + && [[self activeDocument] containsObject: _connectDestination] == NO) + { + NSLog(@"Oops - _connectDestination not in active document"); + return; + } + if ([[self activeDocument] containsObject: _connectSource] == NO) + { + NSLog(@"Oops - _connectSource not in active document"); + return; + } + _isConnecting = YES; + [[self inspectorsManager] updateSelection]; +} + +- (void) stopConnecting +{ + [self displayConnectionBetween: nil and: nil]; + _isConnecting = NO; + _connectSource = nil; + _connectDestination = nil; +} + +- (NSMenu*) classMenu +{ + return _classMenu; +} + +// Methods to support external apps adding and deleting +// classes from the current document... +- (void) addClass: (NSDictionary *) dict +{ + GormDocument *doc = (GormDocument *)[self activeDocument]; + GormClassManager *cm = [doc classManager]; + NSArray *outlets = [dict objectForKey: @"outlets"]; + NSArray *actions = [dict objectForKey: @"actions"]; + NSString *className = [dict objectForKey: @"className"]; + NSString *superClassName = [dict objectForKey: @"superClassName"]; + + // If the class is known, delete it before proceeding. + if([cm isKnownClass: className]) + { + [cm removeClassNamed: className]; + } + + // Add the class to the class manager. + [cm addClassNamed: className + withSuperClassNamed: superClassName + withActions: actions + withOutlets: outlets]; +} + +- (void) deleteClass: (NSString *) className +{ + GormDocument *doc = (GormDocument *)[self activeDocument]; + GormClassManager *cm = [doc classManager]; + + [cm removeClassNamed: className]; +} + +- (void) exceptionWhileLoadingModel: (NSString *)errorMessage +{ + NSRunAlertPanel(_(@"Exception"), + errorMessage, + nil, nil, nil); +} + +@end diff --git a/GormCore/GormClassEditor.m b/GormCore/GormClassEditor.m index 81074cef..6cc12dd1 100644 --- a/GormCore/GormClassEditor.m +++ b/GormCore/GormClassEditor.m @@ -56,8 +56,13 @@ NSImage *browserImage = nil; { if(self == [GormClassEditor class]) { - outlineImage = [NSImage imageNamed: @"outlineView"]; - browserImage = [NSImage imageNamed: @"browserView"]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + NSString *path = nil; + + path = [bundle pathForImageResource: @"outlineView"]; + outlineImage = [[NSImage alloc] initWithContentsOfFile: path]; + path = [bundle pathForImageResource: @"browserView"]; + browserImage = [[NSImage alloc] initWithContentsOfFile: path]; } } @@ -66,7 +71,9 @@ NSImage *browserImage = nil; self = [super init]; if (self != nil) { - if([NSBundle loadNibNamed: @"GormClassEditor" owner: self]) + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + + if([bundle loadNibNamed: @"GormClassEditor" owner: self topLevelObjects: NULL]) { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSRect scrollRect = [classesView frame]; // = {{0, 0}, {340, 188}}; @@ -114,7 +121,7 @@ NSImage *browserImage = nil; [outlineView setIndentationPerLevel: 10]; [outlineView setAttributeOffset: 30]; [outlineView setRowHeight: 18]; - [outlineView setMenu: [(id)NSApp classMenu]]; + [outlineView setMenu: [(id)[NSApp delegate] classMenu]]; [outlineView setBackgroundColor: color]; // add the table columns... @@ -146,7 +153,7 @@ NSImage *browserImage = nil; RELEASE(tableColumn); // expand all of the items in the classesView... - [outlineView expandItem: @"NSObject"]; + // [outlineView expandItem: @"NSObject"]; [outlineView setFrame: scrollRect]; // allocate the NSBrowser view. @@ -852,73 +859,14 @@ NSImage *browserImage = nil; */ - (id) instantiateClass: (id)sender { - NSString *object = [self selectedClassName]; - GSNibItem *item = nil; + NSString *className = [self selectedClassName]; + NSString *theName = nil; - if([object isEqualToString: @"FirstResponder"]) + theName = [document instantiateClassNamed: className]; + if (theName == nil) { return nil; } - - if([classManager canInstantiateClassNamed: object] == NO) - { - return nil; - } - - if([classManager isSuperclass: @"NSView" linkedToClass: object] || - [object isEqual: @"NSView"]) - { - Class cls; - NSString *className = object; - BOOL isCustom = [classManager isCustomClass: object]; - id instance; - - if(isCustom) - { - className = [classManager nonCustomSuperClassOf: object]; - } - - // instantiate the object or it's substitute... - cls = NSClassFromString(className); - if([cls respondsToSelector: @selector(allocSubstitute)]) - { - instance = [cls allocSubstitute]; - } - else - { - instance = [cls alloc]; - } - - // give it some initial dimensions... - if([instance respondsToSelector: @selector(initWithFrame:)]) - { - instance = [instance initWithFrame: NSMakeRect(10,10,380,280)]; - } - else - { - instance = [instance init]; - } - - // add it to the top level objects... - [document attachObject: instance toParent: nil]; - - // we want to record if it's custom or not and act appropriately... - if(isCustom) - { - NSString *name = [document nameForObject: instance]; - [classManager setCustomClass: object - forName: name]; - } - - [document changeToViewWithTag: 0]; - NSLog(@"Instantiate NSView subclass %@",object); - } - else - { - item = [[GormObjectProxy alloc] initWithClassName: object]; - [document attachObject: item toParent: nil]; - [document changeToViewWithTag: 0]; - } return self; } @@ -937,7 +885,7 @@ NSImage *browserImage = nil; */ - (id) loadClass: (id)sender { - NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", nil]; + NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", @"m", @"mm", nil]; NSOpenPanel *oPanel = [NSOpenPanel openPanel]; int result; @@ -974,7 +922,7 @@ NSImage *browserImage = nil; message, nil, nil, nil); } - NS_ENDHANDLER + NS_ENDHANDLER; } return nil; diff --git a/GormCore/GormClassInspector.h b/GormCore/GormClassInspector.h index 660f97d1..890cdbf4 100644 --- a/GormCore/GormClassInspector.h +++ b/GormCore/GormClassInspector.h @@ -35,28 +35,28 @@ @interface GormClassInspector : IBInspector { // outlets - id actionTable; - id addAction; - id addOutlet; - id classField; - id outletTable; - id parentClass; - id removeAction; - id removeOutlet; - id selectClass; - id search; - id searchText; - id tabView; + id _actionTable; + id _addAction; + id _addOutlet; + id _classField; + id _outletTable; + id _parentClass; + id _removeAction; + id _removeOutlet; + id _selectClass; + id _search; + id _searchText; + id _tabView; // internal vars - NSString *currentClass; - id theobject; - id actionData; - id outletData; - id parentClassData; + NSString *_currentClass; + id _theobject; + id _actionData; + id _outletData; + id _parentClassData; // class manager.. - GormClassManager *classManager; + GormClassManager *_classManager; } - (void) addAction: (id)sender; - (void) removeAction: (id)sender; diff --git a/GormCore/GormClassInspector.m b/GormCore/GormClassInspector.m index 9cc11fbd..24983450 100644 --- a/GormCore/GormClassInspector.m +++ b/GormCore/GormClassInspector.m @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Library General Public + You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -84,7 +84,7 @@ NSNotificationCenter *nc = nil; @implementation GormOutletDataSource - (NSInteger) numberOfRowsInTableView: (NSTableView *)tv { - NSArray *list = [[(id)NSApp classManager] allOutletsForClassNamed: [inspector _currentClass]]; + NSArray *list = [[(id)[NSApp delegate] classManager] allOutletsForClassNamed: [inspector _currentClass]]; return [list count]; } @@ -92,8 +92,11 @@ NSNotificationCenter *nc = nil; objectValueForTableColumn: (NSTableColumn *)tc row: (NSInteger)rowIndex { - NSArray *list = [[(id)NSApp classManager] allOutletsForClassNamed: [inspector _currentClass]]; + NSArray *list = [[(id)[NSApp delegate] classManager] allOutletsForClassNamed: [inspector _currentClass]]; id value = nil; + + list = [list sortedArrayUsingSelector: @selector(compare:)]; + if([list count] > 0) { value = [list objectAtIndex: rowIndex]; @@ -106,13 +109,15 @@ objectValueForTableColumn: (NSTableColumn *)tc forTableColumn: (NSTableColumn *)tc row: (NSInteger)rowIndex { - id classManager = [(id)NSApp classManager]; + id classManager = [(id)[NSApp delegate] classManager]; NSString *currentClass = [inspector _currentClass]; NSArray *list = [classManager allOutletsForClassNamed: currentClass]; + list = [list sortedArrayUsingSelector: @selector(compare:)]; + NSString *name = [list objectAtIndex: rowIndex]; NSString *formattedOutlet = formatOutlet( (NSString *)anObject ); - GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; - + GormDocument *document = (GormDocument *)[(id )[NSApp delegate] activeDocument]; + if(![name isEqual: formattedOutlet]) { BOOL removed = [document @@ -144,7 +149,7 @@ objectValueForTableColumn: (NSTableColumn *)tc @implementation GormActionDataSource - (NSInteger) numberOfRowsInTableView: (NSTableView *)tv { - NSArray *list = [[(id)NSApp classManager] allActionsForClassNamed: [inspector _currentClass]]; + NSArray *list = [[(id)[NSApp delegate] classManager] allActionsForClassNamed: [inspector _currentClass]]; return [list count]; } @@ -152,7 +157,8 @@ objectValueForTableColumn: (NSTableColumn *)tc objectValueForTableColumn: (NSTableColumn *)tc row: (NSInteger)rowIndex { - NSArray *list = [[(id)NSApp classManager] allActionsForClassNamed: [inspector _currentClass]]; + NSArray *list = [[(id)[NSApp delegate] classManager] allActionsForClassNamed: [inspector _currentClass]]; + list = [list sortedArrayUsingSelector: @selector(compare:)]; return [list objectAtIndex: rowIndex]; } @@ -161,12 +167,14 @@ objectValueForTableColumn: (NSTableColumn *)tc forTableColumn: (NSTableColumn *)tc row: (NSInteger)rowIndex { - id classManager = [(id)NSApp classManager]; + id classManager = [(id)[NSApp delegate] classManager]; NSString *currentClass = [inspector _currentClass]; NSArray *list = [classManager allActionsForClassNamed: currentClass]; + list = [list sortedArrayUsingSelector: @selector(compare:)]; + NSString *name = [list objectAtIndex: rowIndex]; NSString *formattedAction = formatAction( (NSString *)anObject ); - GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; + GormDocument *document = (GormDocument *)[(id )[NSApp delegate] activeDocument]; if(![name isEqual: formattedAction]) { @@ -199,7 +207,7 @@ objectValueForTableColumn: (NSTableColumn *)tc @implementation GormClassesDataSource - (NSInteger) numberOfRowsInTableView: (NSTableView *)tv { - NSArray *list = [[(id)NSApp classManager] allClassNames]; + NSArray *list = [[(id)[NSApp delegate] classManager] allClassNames]; return [list count]; } @@ -207,8 +215,10 @@ objectValueForTableColumn: (NSTableColumn *)tc objectValueForTableColumn: (NSTableColumn *)tc row: (NSInteger)rowIndex { - NSArray *list = [[(id)NSApp classManager] allClassNames]; + NSArray *list = [[(id)[NSApp delegate] classManager] allClassNames]; id value = nil; + + list = [list sortedArrayUsingSelector: @selector(compare:)]; if([list count] > 0) { value = [list objectAtIndex: rowIndex]; @@ -245,23 +255,26 @@ objectValueForTableColumn: (NSTableColumn *)tc self = [super init]; if (self != nil) { + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + // initialize all member variables... - actionTable = nil; - addAction = nil; - addOutlet = nil; - classField = nil; - outletTable = nil; - removeAction = nil; - removeOutlet = nil; - tabView = nil; - currentClass = nil; - actionData = nil; - outletData = nil; - parentClassData = nil; + _actionTable = nil; + _addAction = nil; + _addOutlet = nil; + _classField = nil; + _outletTable = nil; + _removeAction = nil; + _removeOutlet = nil; + _tabView = nil; + _currentClass = nil; + _actionData = nil; + _outletData = nil; + _parentClassData = nil; // load the gui... - if (![NSBundle loadNibNamed: @"GormClassInspector" - owner: self]) + if (![bundle loadNibNamed: @"GormClassInspector" + owner: self + topLevelObjects: NULL]) { NSLog(@"Could not open gorm GormClassInspector"); return nil; @@ -276,52 +289,61 @@ objectValueForTableColumn: (NSTableColumn *)tc return self; } +- (void) dealloc +{ + RELEASE(_actionData); + RELEASE(_outletData); + RELEASE(_parentClassData); + + [super dealloc]; +} + - (void) awakeFromNib { // instantiate.. - actionData = [[GormActionDataSource alloc] init]; - outletData = [[GormOutletDataSource alloc] init]; - parentClassData = [[GormClassesDataSource alloc] init]; + _actionData = [[GormActionDataSource alloc] init]; + _outletData = [[GormOutletDataSource alloc] init]; + _parentClassData = [[GormClassesDataSource alloc] init]; // initialize.. - [actionData setInspector: self]; - [outletData setInspector: self]; - [parentClassData setInspector: self]; + [_actionData setInspector: self]; + [_outletData setInspector: self]; + [_parentClassData setInspector: self]; // use.. - [actionTable setDataSource: actionData]; - [outletTable setDataSource: outletData]; - [parentClass setDataSource: parentClassData]; - [parentClass setDoubleAction: @selector(selectClass:)]; - [parentClass setTarget: self]; + [_actionTable setDataSource: _actionData]; + [_outletTable setDataSource: _outletData]; + [_parentClass setDataSource: _parentClassData]; + [_parentClass setDoubleAction: @selector(selectClass:)]; + [_parentClass setTarget: self]; // delegate... - [actionTable setDelegate: self]; - [outletTable setDelegate: self]; - [parentClass setDelegate: self]; + [_actionTable setDelegate: self]; + [_outletTable setDelegate: self]; + [_parentClass setDelegate: self]; } - (void) _refreshView { - id addActionCell = [addAction cell]; - id removeActionCell = [removeAction cell]; - id addOutletCell = [addOutlet cell]; - id removeOutletCell = [removeOutlet cell]; - id selectClassCell = [selectClass cell]; - id searchCell = [search cell]; - BOOL isEditable = [classManager isCustomClass: [self _currentClass]]; + id addActionCell = [_addAction cell]; + id removeActionCell = [_removeAction cell]; + id addOutletCell = [_addOutlet cell]; + id removeOutletCell = [_removeOutlet cell]; + id selectClassCell = [_selectClass cell]; + id searchCell = [_search cell]; + BOOL isEditable = [_classManager isCustomClass: [self _currentClass]]; BOOL isFirstResponder = [[self _currentClass] isEqualToString: @"FirstResponder"]; - NSArray *list = [classManager allClassNames]; - NSString *superClass = [classManager parentOfClass: [self _currentClass]]; + NSArray *list = [_classManager allClassNames]; + NSString *superClass = [_classManager parentOfClass: [self _currentClass]]; NSUInteger index = [list indexOfObject: superClass]; - [classField setStringValue: [self _currentClass]]; - [outletTable reloadData]; - [actionTable reloadData]; - [parentClass reloadData]; - // [outletTable deselectAll: self]; - // [actionTable deselectAll: self]; + [_classField setStringValue: [self _currentClass]]; + [_outletTable reloadData]; + [_actionTable reloadData]; + [_parentClass reloadData]; + // [_outletTable deselectAll: self]; + // [_actionTable deselectAll: self]; // activate for actions... [addActionCell setEnabled: YES]; @@ -333,16 +355,16 @@ objectValueForTableColumn: (NSTableColumn *)tc // activate select class... [selectClassCell setEnabled: (isEditable && !isFirstResponder)]; - [parentClass setEnabled: (isEditable && !isFirstResponder)]; + [_parentClass setEnabled: (isEditable && !isFirstResponder)]; [searchCell setEnabled: (isEditable && !isFirstResponder)]; - [classField setEditable: (isEditable && !isFirstResponder)]; - [classField setBackgroundColor: ((isEditable && !isFirstResponder)?[NSColor whiteColor]:[NSColor lightGrayColor])]; + [_classField setEditable: (isEditable && !isFirstResponder)]; + [_classField setBackgroundColor: ((isEditable && !isFirstResponder)?[NSColor textBackgroundColor]:[NSColor selectedTextBackgroundColor])]; // select the parent class if(index != NSNotFound && list != nil) { - [parentClass selectRow: index byExtendingSelection: NO]; - [parentClass scrollRowToVisible: index]; + [_parentClass selectRow: index byExtendingSelection: NO]; + [_parentClass scrollRowToVisible: index]; } } @@ -350,21 +372,21 @@ objectValueForTableColumn: (NSTableColumn *)tc { NS_DURING { - GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; + GormDocument *document = (GormDocument *)[(id )[NSApp delegate] activeDocument]; if(document != nil) { NSString *className = [self _currentClass]; - NSString *newAction = [classManager addNewActionToClassNamed: className]; - NSArray *list = [classManager allActionsForClassNamed: className]; + NSString *newAction = [_classManager addNewActionToClassNamed: className]; + NSArray *list = [_classManager allActionsForClassNamed: className]; NSInteger row = [list indexOfObject: newAction]; [document collapseClass: className]; [document reloadClasses]; [nc postNotificationName: IBInspectorDidModifyObjectNotification - object: classManager]; - [actionTable reloadData]; - [actionTable scrollRowToVisible: row]; - [actionTable selectRow: row byExtendingSelection: NO]; + object: _classManager]; + [_actionTable reloadData]; + [_actionTable scrollRowToVisible: row]; + [_actionTable selectRow: row byExtendingSelection: NO]; [document selectClass: className]; [super ok: sender]; } @@ -380,21 +402,21 @@ objectValueForTableColumn: (NSTableColumn *)tc { NS_DURING { - GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; + GormDocument *document = (GormDocument *)[(id )[NSApp delegate] activeDocument]; if(document != nil) { NSString *className = [self _currentClass]; - NSString *newOutlet = [classManager addNewOutletToClassNamed: className]; - NSArray *list = [classManager allOutletsForClassNamed: className]; + NSString *newOutlet = [_classManager addNewOutletToClassNamed: className]; + NSArray *list = [_classManager allOutletsForClassNamed: className]; NSInteger row = [list indexOfObject: newOutlet]; [document collapseClass: className]; [document reloadClasses]; [nc postNotificationName: IBInspectorDidModifyObjectNotification - object: classManager]; - [outletTable reloadData]; - [outletTable scrollRowToVisible: row]; - [outletTable selectRow: row byExtendingSelection: NO]; + object: _classManager]; + [_outletTable reloadData]; + [_outletTable scrollRowToVisible: row]; + [_outletTable selectRow: row byExtendingSelection: NO]; [document selectClass: className]; [super ok: sender]; } @@ -410,28 +432,28 @@ objectValueForTableColumn: (NSTableColumn *)tc { NS_DURING { - NSInteger i = [actionTable selectedRow]; + NSInteger i = [_actionTable selectedRow]; NSString *className = [self _currentClass]; - NSArray *list = [classManager allActionsForClassNamed: className]; + NSArray *list = [_classManager allActionsForClassNamed: className]; BOOL removed = NO; - BOOL isCustom = [classManager isCustomClass: className]; + BOOL isCustom = [_classManager isCustomClass: className]; NSString *name = nil; - GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; + GormDocument *document = (GormDocument *)[(id )[NSApp delegate] activeDocument]; if(document != nil) { // check the count... - if(isCustom || [classManager isCategoryForClass: className]) + if(isCustom || [_classManager isCategoryForClass: className]) { if([list count] > 0 && i >= 0 && i < [list count]) { - [actionTable deselectAll: self]; + [_actionTable deselectAll: self]; name = [list objectAtIndex: i]; - if(isCustom || [classManager isAction: name onCategoryForClassNamed: className]) + if(isCustom || [_classManager isAction: name onCategoryForClassNamed: className]) { removed = [document removeConnectionsWithLabel: name - forClassNamed: currentClass + forClassNamed: _currentClass isAction: YES]; } } @@ -441,10 +463,10 @@ objectValueForTableColumn: (NSTableColumn *)tc [super ok: sender]; [document collapseClass: className]; [document reloadClasses]; - [classManager removeAction: name fromClassNamed: className]; + [_classManager removeAction: name fromClassNamed: className]; [nc postNotificationName: IBInspectorDidModifyObjectNotification - object: classManager]; - [actionTable reloadData]; + object: _classManager]; + [_actionTable reloadData]; [document selectClass: className]; } } @@ -461,23 +483,23 @@ objectValueForTableColumn: (NSTableColumn *)tc { NS_DURING { - NSInteger i = [outletTable selectedRow]; + NSInteger i = [_outletTable selectedRow]; NSString *className = [self _currentClass]; - NSArray *list = [classManager allOutletsForClassNamed: className]; + NSArray *list = [_classManager allOutletsForClassNamed: className]; BOOL removed = NO; NSString *name = nil; - GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; + GormDocument *document = (GormDocument *)[(id )[NSApp delegate] activeDocument]; if(document != nil) { // check the count... if([list count] > 0 && i >= 0 && i < [list count]) { - [outletTable deselectAll: self]; + [_outletTable deselectAll: self]; name = [list objectAtIndex: i]; removed = [document removeConnectionsWithLabel: name - forClassNamed: currentClass + forClassNamed: _currentClass isAction: NO]; } @@ -486,10 +508,10 @@ objectValueForTableColumn: (NSTableColumn *)tc [super ok: sender]; [document collapseClass: className]; [document reloadClasses]; - [classManager removeOutlet: name fromClassNamed: className]; + [_classManager removeOutlet: name fromClassNamed: className]; [nc postNotificationName: IBInspectorDidModifyObjectNotification - object: classManager]; - [outletTable reloadData]; + object: _classManager]; + [_outletTable reloadData]; [document selectClass: className]; } } @@ -508,24 +530,24 @@ objectValueForTableColumn: (NSTableColumn *)tc - (void) searchForClass: (id)sender { - NSArray *list = [classManager allClassNames]; - NSString *stringValue = [searchText stringValue]; + NSArray *list = [_classManager allClassNames]; + NSString *stringValue = [_searchText stringValue]; NSInteger index = [list indexOfObject: stringValue]; - NSLog(@"Search... %@",[searchText stringValue]); + NSLog(@"Search... %@",[_searchText stringValue]); if(index != NSNotFound && list != nil && [stringValue isEqualToString: @"FirstResponder"] == NO) { // select the parent class - [parentClass selectRow: index byExtendingSelection: NO]; - [parentClass scrollRowToVisible: index]; + [_parentClass selectRow: index byExtendingSelection: NO]; + [_parentClass scrollRowToVisible: index]; } } - (void) selectClass: (id)sender { - NSArray *list = [classManager allClassNames]; - NSInteger row = [parentClass selectedRow]; + NSArray *list = [_classManager allClassNames]; + NSInteger row = [_parentClass selectedRow]; NS_DURING { @@ -533,12 +555,12 @@ objectValueForTableColumn: (NSTableColumn *)tc { NSString *newParent = [list objectAtIndex: row]; NSString *name = [self _currentClass]; - GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; + GormDocument *document = (GormDocument *)[(id )[NSApp delegate] activeDocument]; // if it's a custom class, let it go, if not do nothing. if(document != nil) { - if([classManager isCustomClass: name]) + if([_classManager isCustomClass: name]) { NSString *title = _(@"Modifying/Reparenting Class"); NSString *msg = [NSString stringWithFormat: _(@"This action may break existing connections " @@ -563,12 +585,12 @@ objectValueForTableColumn: (NSTableColumn *)tc // if removed, move the class and notify... if(removed) { - NSString *oldSuper = [classManager superClassNameForClassNamed: name]; + NSString *oldSuper = [_classManager superClassNameForClassNamed: name]; - [classManager setSuperClassNamed: newParent forClassNamed: name]; + [_classManager setSuperClassNamed: newParent forClassNamed: name]; [document refreshConnectionsForClassNamed: name]; [nc postNotificationName: IBInspectorDidModifyObjectNotification - object: classManager]; + object: _classManager]; [document collapseClass: oldSuper]; [document collapseClass: name]; [document reloadClasses]; @@ -589,7 +611,7 @@ objectValueForTableColumn: (NSTableColumn *)tc { NSString *name = [self _currentClass]; NSString *newName = [sender stringValue]; - GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; + GormDocument *document = (GormDocument *)[(id )[NSApp delegate] activeDocument]; BOOL flag = NO; // check to see if the user wants to do this and rename the connections. @@ -599,10 +621,10 @@ objectValueForTableColumn: (NSTableColumn *)tc if(flag) { [document collapseClass: name]; - [classManager renameClassNamed: name + [_classManager renameClassNamed: name newName: newName]; [nc postNotificationName: IBInspectorDidModifyObjectNotification - object: classManager]; + object: _classManager]; [document reloadClasses]; [document selectClass: newName]; [super ok: sender]; @@ -612,14 +634,14 @@ objectValueForTableColumn: (NSTableColumn *)tc - (void) selectAction: (id)sender { NSInteger row = [sender selectedRow]; - NSArray *actions = [classManager allActionsForClassNamed: currentClass]; + NSArray *actions = [_classManager allActionsForClassNamed: _currentClass]; if(row <= [actions count]) { - BOOL isCustom = [classManager isCustomClass: currentClass]; - id cell = [removeAction cell]; + BOOL isCustom = [_classManager isCustomClass: _currentClass]; + id cell = [_removeAction cell]; NSString *action = [actions objectAtIndex: row]; - BOOL isAction = [classManager isAction: action ofClass: currentClass]; - BOOL isActionOnCategory = [classManager isAction: action onCategoryForClassNamed: currentClass]; + BOOL isAction = [_classManager isAction: action ofClass: _currentClass]; + BOOL isActionOnCategory = [_classManager isAction: action onCategoryForClassNamed: _currentClass]; [cell setEnabled: ((isCustom && isAction) || isActionOnCategory)]; } } @@ -627,14 +649,14 @@ objectValueForTableColumn: (NSTableColumn *)tc - (void) selectOutlet: (id)sender { NSInteger row = [sender selectedRow]; - NSArray *outlets = [classManager allOutletsForClassNamed: currentClass]; + NSArray *outlets = [_classManager allOutletsForClassNamed: _currentClass]; if(row <= [outlets count]) { - BOOL isCustom = [classManager isCustomClass: currentClass]; - BOOL isFirstResponder = [currentClass isEqualToString: @"FirstResponder"]; - id cell = [removeOutlet cell]; + BOOL isCustom = [_classManager isCustomClass: _currentClass]; + BOOL isFirstResponder = [_currentClass isEqualToString: @"FirstResponder"]; + id cell = [_removeOutlet cell]; NSString *outlet = [outlets objectAtIndex: row]; - BOOL isOutlet = [classManager isOutlet: outlet ofClass: currentClass]; + BOOL isOutlet = [_classManager isOutlet: outlet ofClass: _currentClass]; [cell setEnabled: (isOutlet && isCustom && !isFirstResponder)]; } } @@ -653,17 +675,17 @@ objectValueForTableColumn: (NSTableColumn *)tc if([anObject isKindOfClass: [GormClassProxy class]]) { [super setObject: anObject]; - ASSIGN(classManager, [(id)NSApp classManager]); - ASSIGN(currentClass, [object className]); + ASSIGN(_classManager, [(id)[NSApp delegate] classManager]); + ASSIGN(_currentClass, [object className]); - outletsCount = [[classManager allOutletsForClassNamed: currentClass] count]; - actionsCount = [[classManager allActionsForClassNamed: currentClass] count]; + outletsCount = [[_classManager allOutletsForClassNamed: _currentClass] count]; + actionsCount = [[_classManager allActionsForClassNamed: _currentClass] count]; - item = [tabView tabViewItemAtIndex: 1]; // actions; + item = [_tabView tabViewItemAtIndex: 1]; // actions; [item setLabel: [NSString stringWithFormat: @"Actions (%ld)",(long)actionsCount]]; - item = [tabView tabViewItemAtIndex: 0]; // outlets; + item = [_tabView tabViewItemAtIndex: 0]; // outlets; [item setLabel: [NSString stringWithFormat: @"Outlets (%ld)",(long)outletsCount]]; - [tabView setNeedsDisplay: YES]; + [_tabView setNeedsDisplay: YES]; [self _refreshView]; } @@ -680,8 +702,8 @@ objectValueForTableColumn: (NSTableColumn *)tc - (void) handleNotification: (NSNotification *)notification { - if([notification object] == classManager && - [(id)NSApp activeDocument] != nil) + if([notification object] == _classManager && + (id)[[NSApp delegate] activeDocument] != nil) { [self _refreshView]; } @@ -694,39 +716,39 @@ shouldEditTableColumn: (NSTableColumn *)aTableColumn { BOOL result = NO; - if(tableView != parentClass) + if(tableView != _parentClass) { NSArray *list = nil; NSString *name = nil; NSString *className = [self _currentClass]; - if(tableView == actionTable) + if(tableView == _actionTable) { - list = [classManager allActionsForClassNamed: className]; + list = [_classManager allActionsForClassNamed: className]; name = [list objectAtIndex: rowIndex]; } - else if(tableView == outletTable) + else if(tableView == _outletTable) { - list = [classManager allOutletsForClassNamed: className]; + list = [_classManager allOutletsForClassNamed: className]; name = [list objectAtIndex: rowIndex]; } - if([classManager isCustomClass: className]) + if([_classManager isCustomClass: className]) { - if(tableView == actionTable) + if(tableView == _actionTable) { - result = [classManager isAction: name + result = [_classManager isAction: name ofClass: className]; } - else if(tableView == outletTable) + else if(tableView == _outletTable) { - result = [classManager isOutlet: name + result = [_classManager isOutlet: name ofClass: className]; } } else { - result = [classManager isAction: name onCategoryForClassNamed: className]; + result = [_classManager isAction: name onCategoryForClassNamed: className]; } } @@ -738,36 +760,39 @@ shouldEditTableColumn: (NSTableColumn *)aTableColumn forTableColumn: (NSTableColumn *)aTableColumn row: (NSInteger)rowIndex { -/* NSString *name = [aCell stringValue]; NSString *className = [self _currentClass]; - if(tableView == actionTable) + if (tableView == _parentClass) { - if(([classManager isCustomClass: className] && - [classManager isAction: name ofClass: className]) || - [classManager isAction: name onCategoryForClassNamed: className]) + [aCell setTextColor: [NSColor textColor]]; + } + else if (tableView == _actionTable) + { + if(([_classManager isCustomClass: className] && + [_classManager isAction: name ofClass: className]) || + [_classManager isAction: name onCategoryForClassNamed: className]) { - [aCell setTextColor: [NSColor blackColor]]; + [aCell setTextColor: [NSColor textColor]]; } else { - [aCell setTextColor: [NSColor darkGrayColor]]; + [aCell setTextColor: [NSColor selectedTextColor]]; } } - else if(tableView == outletTable) + else if( tableView == _outletTable) { - if([classManager isCustomClass: className] && - [classManager isOutlet: name ofClass: className]) + if([_classManager isCustomClass: className] && + [_classManager isOutlet: name ofClass: className]) { - [aCell setTextColor: [NSColor blackColor]]; + [aCell setTextColor: [NSColor textColor]]; } else { - [aCell setTextColor: [NSColor darkGrayColor]]; + [aCell setTextColor: [NSColor selectedTextColor]]; } } -*/ + [(NSTextFieldCell *)aCell setScrollable: YES]; } @@ -775,14 +800,14 @@ shouldEditTableColumn: (NSTableColumn *)aTableColumn shouldSelectRow: (NSInteger)rowIndex { BOOL result = YES; - if(tv == parentClass) + if(tv == _parentClass) { - NSArray *list = [classManager allClassNames]; + NSArray *list = [_classManager allClassNames]; NSString *className = [list objectAtIndex: rowIndex]; NSString *name = [self _currentClass]; BOOL isFirstResponder = [className isEqualToString: @"FirstResponder"]; BOOL isCurrentClass = [className isEqualToString: name]; - BOOL isSubClass = [classManager isSuperclass: name linkedToClass: className]; + BOOL isSubClass = [_classManager isSuperclass: name linkedToClass: className]; if(isFirstResponder || isCurrentClass || isSubClass) { NSBeep(); diff --git a/GormCore/GormClassManager.h b/GormCore/GormClassManager.h index 53b6cec7..2b5bb41d 100644 --- a/GormCore/GormClassManager.h +++ b/GormCore/GormClassManager.h @@ -23,11 +23,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#include - #ifndef INCLUDED_GormClassManager_h #define INCLUDED_GormClassManager_h +#import + // The custom classes and category arrays will hold only those things which // will be persisted to the .classes file. Since the overall list of classes will // not change it seems that the only thing that we should save is the "delta" @@ -35,11 +35,11 @@ // list of base classes, in gui, to form the full list of classes. @interface GormClassManager : NSObject { - NSMutableDictionary *classInformation; - NSMutableArray *customClasses; - NSMutableDictionary *customClassMap; - NSMutableArray *categoryClasses; - id document; + NSMutableDictionary *_classInformation; + NSMutableArray *_customClasses; + NSMutableDictionary *_customClassMap; + NSMutableArray *_categoryClasses; + id _document; } - (id) initWithDocument: (id)aDocument; @@ -120,6 +120,8 @@ - (BOOL) isAction: (NSString *)actionName onCategoryForClassNamed: (NSString *)className; - (NSString *) classNameForObject: (id)object; - (NSString *) findClassByName: (NSString *)name; +- (NSDictionary *) classInformation; +- (NSDictionary *) customClassInformation; /* Parsing and creating classes */ - (BOOL) makeSourceAndHeaderFilesForClass: (NSString *)className @@ -137,6 +139,7 @@ - (BOOL) loadCustomClassesWithDict: (NSDictionary *)dict; - (BOOL) loadNibFormatCustomClassesWithData: (NSData *)data; - (BOOL) loadNibFormatCustomClassesWithDict: (NSDictionary *)dict; + @end #endif diff --git a/GormCore/GormClassManager.m b/GormCore/GormClassManager.m index 53af9325..66bfc813 100644 --- a/GormCore/GormClassManager.m +++ b/GormCore/GormClassManager.m @@ -23,16 +23,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#include +#import -#include -#include +#import +#import -#include "GormPrivate.h" -#include "GormCustomView.h" -#include "GormDocument.h" -#include "GormFilesOwner.h" -#include "GormPalettesManager.h" +#import "GormPrivate.h" +#import "GormCustomView.h" +#import "GormDocument.h" +#import "GormFilesOwner.h" +#import "GormPalettesManager.h" +#import "GormAbstractDelegate.h" /** * Just a few definitions to start things out. To increase efficiency, @@ -94,10 +95,10 @@ self = [super init]; if (self != nil) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path; - document = aDocument; // the document retains us, this is for convenience + _document = aDocument; // the _document retains us, this is for convenience path = [bundle pathForResource: @"ClassInformation" ofType: @"plist"]; if (path == nil) @@ -106,7 +107,7 @@ } else { - GormPalettesManager *palettesManager = [(id)NSApp palettesManager]; + GormPalettesManager *palettesManager = [(id)[NSApp delegate] palettesManager]; NSDictionary *importedClasses = [palettesManager importedClasses]; NSEnumerator *en = [importedClasses objectEnumerator]; NSDictionary *description = nil; @@ -114,15 +115,15 @@ // load the classes, initialize the custom class array and map.. if([self loadFromFile: path]) { - NSMutableDictionary *classDict = [classInformation objectForKey: @"FirstResponder"]; + NSMutableDictionary *classDict = [_classInformation objectForKey: @"FirstResponder"]; NSMutableArray *firstResponderActions = [classDict objectForKey: @"Actions"]; - customClasses = [[NSMutableArray alloc] initWithCapacity: 1]; - customClassMap = [[NSMutableDictionary alloc] initWithCapacity: 10]; - categoryClasses = [[NSMutableArray alloc] initWithCapacity: 1]; + _customClasses = [[NSMutableArray alloc] initWithCapacity: 1]; + _customClassMap = [[NSMutableDictionary alloc] initWithCapacity: 10]; + _categoryClasses = [[NSMutableArray alloc] initWithCapacity: 1]; // add the imported classes to the class information list... - [classInformation addEntriesFromDictionary: importedClasses]; + [_classInformation addEntriesFromDictionary: importedClasses]; // add all of the actions to the FirstResponder while((description = [en nextObject]) != nil) @@ -156,12 +157,12 @@ postNotificationName: GormDidModifyClassNotification object: self]; - [document touch]; + [_document touch]; } - (void) convertDictionary: (NSMutableDictionary *)dict { - [dict removeObjectsForKeys: [classInformation allKeys]]; + [dict removeObjectsForKeys: [_classInformation allKeys]]; } - (NSString *) uniqueClassNameFrom: (NSString *)name @@ -169,7 +170,7 @@ NSString *search = [NSString stringWithString: name]; NSInteger i = 1; - while([classInformation objectForKey: search]) + while([_classInformation objectForKey: search]) { search = [name stringByAppendingString: [NSString stringWithFormat: @"%ld",(long)i++]]; } @@ -179,7 +180,7 @@ - (NSString *) addClassWithSuperClassName: (NSString*)name { - if (([self isRootClass: name] || [classInformation objectForKey: name] != nil) + if (([self isRootClass: name] || [_classInformation objectForKey: name] != nil) && [name isEqual: @"FirstResponder"] == NO) { NSMutableDictionary *classInfo; @@ -195,8 +196,8 @@ [classInfo setObject: actions forKey: @"Actions"]; [classInfo setObject: name forKey: @"Super"]; - [classInformation setObject: classInfo forKey: className]; - [customClasses addObject: className]; + [_classInformation setObject: classInfo forKey: className]; + [_customClasses addObject: className]; [self touch]; @@ -272,12 +273,12 @@ // to the original objects from reflecting here. GJC if ([self isRootClass: superClassNameCopy] || - ([classInformation objectForKey: superClassNameCopy] != nil && + ([_classInformation objectForKey: superClassNameCopy] != nil && [superClassNameCopy isEqualToString: @"FirstResponder"] == NO)) { NSMutableDictionary *classInfo; - if (![classInformation objectForKey: classNameCopy]) + if (![_classInformation objectForKey: classNameCopy]) { NSEnumerator *e = [actionsCopy objectEnumerator]; id action = nil; @@ -298,12 +299,12 @@ { [classInfo setObject: superClassNameCopy forKey: @"Super"]; } - [classInformation setObject: classInfo forKey: classNameCopy]; + [_classInformation setObject: classInfo forKey: classNameCopy]; // if it's a custom class add it to the list. if(isCustom) { - [customClasses addObject: classNameCopy]; + [_customClasses addObject: classNameCopy]; } // copy all actions from the class imported to the first responder @@ -336,7 +337,7 @@ - (void) addAction: (NSString *)action forClassNamed: (NSString *)className { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; NSMutableArray *extraActions = [info objectForKey: @"ExtraActions"]; NSMutableArray *allActions = [info objectForKey: @"AllActions"]; NSString *anAction = [action copy]; @@ -344,6 +345,13 @@ NSEnumerator *en = [subClasses objectEnumerator]; NSString *subclassName = nil; + if (action == nil + || className == nil) + { + NSLog(@"Attempt to add nil action = %@ or className = %@ to class manager", action, className); + return; + } + // check all if ([allActions containsObject: anAction]) { @@ -352,9 +360,9 @@ if ([self isNonCustomClass: className]) { - if([categoryClasses containsObject: className] == NO) + if([_categoryClasses containsObject: className] == NO) { - [categoryClasses addObject: className]; + [_categoryClasses addObject: className]; } } @@ -374,7 +382,7 @@ while((subclassName = [en nextObject]) != nil) { - NSDictionary *subInfo = [classInformation objectForKey: subclassName]; + NSDictionary *subInfo = [_classInformation objectForKey: subclassName]; NSMutableArray *subAll = [subInfo objectForKey: @"AllActions"]; [subAll mergeObject: anAction]; } @@ -389,7 +397,7 @@ - (void) addOutlet: (NSString *)outlet forClassNamed: (NSString *)className { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; NSMutableArray *extraOutlets = [info objectForKey: @"ExtraOutlets"]; NSMutableArray *allOutlets = [info objectForKey: @"AllOutlets"]; NSString *anOutlet = [outlet copy]; @@ -414,7 +422,7 @@ while((subclassName = [en nextObject]) != nil) { - NSDictionary *subInfo = [classInformation objectForKey: subclassName]; + NSDictionary *subInfo = [_classInformation objectForKey: subclassName]; NSMutableArray *subAll = [subInfo objectForKey: @"AllOutlets"]; [subAll mergeObject: anOutlet]; } @@ -426,7 +434,7 @@ withAction: (NSString *)aNewAction forClassNamed: (NSString *)className { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; NSMutableArray *extraActions = [info objectForKey: @"ExtraActions"]; NSMutableArray *actions = [info objectForKey: @"Actions"]; NSMutableArray *allActions = [info objectForKey: @"AllActions"]; @@ -477,7 +485,7 @@ withOutlet: (NSString *)aNewOutlet forClassNamed: (NSString *)className { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; NSMutableArray *extraOutlets = [info objectForKey: @"ExtraOutlets"]; NSMutableArray *outlets = [info objectForKey: @"Outlets"]; NSMutableArray *allOutlets = [info objectForKey: @"AllOutlets"]; @@ -527,7 +535,7 @@ - (void) removeAction: (NSString *)anAction fromClassNamed: (NSString *)className { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; NSMutableArray *extraActions = [info objectForKey: @"ExtraActions"]; NSMutableArray *allActions = [info objectForKey: @"AllActions"]; NSEnumerator *en = [[self subClassesOf: className] objectEnumerator]; @@ -568,9 +576,9 @@ [self touch]; } - if([categoryClasses containsObject: className] && [extraActions count] == 0) + if([_categoryClasses containsObject: className] && [extraActions count] == 0) { - [categoryClasses removeObject: className]; + [_categoryClasses removeObject: className]; } if(![className isEqualToString: @"FirstResponder"]) @@ -591,7 +599,7 @@ - (void) removeOutlet: (NSString *)anOutlet fromClassNamed: (NSString *)className { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; NSMutableArray *extraOutlets = [info objectForKey: @"ExtraOutlets"]; NSMutableArray *allOutlets = [info objectForKey: @"AllOutlets"]; NSEnumerator *en = [[self subClassesOf: className] objectEnumerator]; @@ -699,7 +707,7 @@ - (NSArray *) allActionsForClassNamed: (NSString *)className { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; if (info != nil) { @@ -751,13 +759,13 @@ - (NSArray *) allCustomClassNames { - // return [customClassMap allKeys]; - return customClasses; + // return [_customClassMap allKeys]; + return _customClasses; } - (NSArray *) allClassNames { - return [[classInformation allKeys] sortedArrayUsingSelector: @selector(compare:)]; + return [[_classInformation allKeys] sortedArrayUsingSelector: @selector(compare:)]; } - (NSArray *) allOutletsForObject: (id)obj @@ -820,7 +828,7 @@ - (NSArray *) allOutletsForClassNamed: (NSString *)className; { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; if (info != nil) { @@ -874,7 +882,7 @@ { NSMutableDictionary *info; - info = [classInformation objectForKey: className]; + info = [_classInformation objectForKey: className]; if (info == nil) { Class theClass = NSClassFromString(className); @@ -899,7 +907,7 @@ [info setObject: o forKey: @"AllActions"]; o = [[self allOutletsForClassNamed: name] mutableCopy]; [info setObject: o forKey: @"AllOutlets"]; - [classInformation setObject: info forKey: className]; + [_classInformation setObject: info forKey: className]; } } } @@ -961,8 +969,8 @@ - (void) dealloc { - RELEASE(classInformation); - RELEASE(customClassMap); + RELEASE(_classInformation); + RELEASE(_customClassMap); [super dealloc]; } @@ -989,7 +997,7 @@ while ((object = [cen nextObject])) { - NSDictionary *dictForClass = [classInformation objectForKey: object]; + NSDictionary *dictForClass = [_classInformation objectForKey: object]; NSString *superClassName = [dictForClass objectForKey: @"Super"]; if ([superClassName isEqual: superclass] || (superClassName == nil && superclass == nil)) @@ -1007,7 +1015,7 @@ NSMutableArray *array = [NSMutableArray array]; [self allSubclassesOf: superClass - referenceClassList: [classInformation allKeys] + referenceClassList: [_classInformation allKeys] intoArray: array]; return [array sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)]; @@ -1018,7 +1026,7 @@ NSMutableArray *array = [NSMutableArray array]; [self allSubclassesOf: superClass - referenceClassList: customClasses + referenceClassList: _customClasses intoArray: array]; return [array sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)]; @@ -1026,13 +1034,13 @@ - (NSArray *) customSubClassesOf: (NSString *)superclass { - NSEnumerator *cen = [customClasses objectEnumerator]; + NSEnumerator *cen = [_customClasses objectEnumerator]; id object = nil; NSMutableArray *subclasses = [NSMutableArray array]; while ((object = [cen nextObject])) { - NSDictionary *dictForClass = [classInformation objectForKey: object]; + NSDictionary *dictForClass = [_classInformation objectForKey: object]; if ([[dictForClass objectForKey: @"Super"] isEqual: superclass]) { @@ -1045,14 +1053,14 @@ - (NSArray *) subClassesOf: (NSString *)superclass { - NSArray *allClasses = [classInformation allKeys]; + NSArray *allClasses = [_classInformation allKeys]; NSEnumerator *cen = [allClasses objectEnumerator]; id object = nil; NSMutableArray *subclasses = [NSMutableArray array]; while ((object = [cen nextObject])) { - NSDictionary *dictForClass = [classInformation objectForKey: object]; + NSDictionary *dictForClass = [_classInformation objectForKey: object]; NSString *superClassName = [dictForClass objectForKey: @"Super"]; if ([superClassName isEqual: superclass] || (superClassName == nil && superclass == nil)) @@ -1066,36 +1074,36 @@ - (void) removeClassNamed: (NSString *)className { - if ([customClasses containsObject: className]) + if ([_customClasses containsObject: className]) { - NSEnumerator *en = [customClassMap keyEnumerator]; + NSEnumerator *en = [_customClassMap keyEnumerator]; id object = nil; id owner = nil; - [customClasses removeObject: className]; + [_customClasses removeObject: className]; while((object = [en nextObject]) != nil) { - id customClassName = [customClassMap objectForKey: object]; + id customClassName = [_customClassMap objectForKey: object]; if(customClassName != nil) { if([className isEqualToString: customClassName]) { NSDebugLog(@"Deleting object -> customClass association %@ -> %@",object,customClassName); - [customClassMap removeObjectForKey: object]; + [_customClassMap removeObjectForKey: object]; } } } // get the owner and reset the class name to NSApplication. - owner = [document objectForName: @"NSOwner"]; + owner = [_document objectForName: @"NSOwner"]; if([className isEqual: [owner className]]) { [owner setClassName: @"NSApplication"]; } } - [classInformation removeObjectForKey: className]; + [_classInformation removeObjectForKey: className]; [self touch]; [[NSNotificationCenter defaultCenter] @@ -1105,48 +1113,48 @@ - (BOOL) renameClassNamed: (NSString *)oldName newName: (NSString *)newName { - id classInfo = [classInformation objectForKey: oldName]; + id classInfo = [_classInformation objectForKey: oldName]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSString *name = [newName copy]; NSDebugLog(@"Old name %@, new name %@",oldName,name); - if (classInfo != nil && [classInformation objectForKey: name] == nil) + if (classInfo != nil && [_classInformation objectForKey: name] == nil) { NSUInteger index = 0; NSArray *subclasses = [self subClassesOf: oldName]; RETAIN(classInfo); // prevent loss of the information... - [classInformation removeObjectForKey: oldName]; - [classInformation setObject: classInfo forKey: name]; + [_classInformation removeObjectForKey: oldName]; + [_classInformation setObject: classInfo forKey: name]; RELEASE(classInfo); // release our hold on it. - if ((index = [customClasses indexOfObject: oldName]) != NSNotFound) + if ((index = [_customClasses indexOfObject: oldName]) != NSNotFound) { - NSEnumerator *en = [customClassMap keyEnumerator]; + NSEnumerator *en = [_customClassMap keyEnumerator]; NSEnumerator *cen = [subclasses objectEnumerator]; id sc = nil; id object = nil; - NSDebugLog(@"replacing object with %@, %@",name, customClasses); - [customClasses replaceObjectAtIndex: index withObject: name]; - NSDebugLog(@"replaced object with %@, %@",name, customClasses); + NSDebugLog(@"replacing object with %@, %@",name, _customClasses); + [_customClasses replaceObjectAtIndex: index withObject: name]; + NSDebugLog(@"replaced object with %@, %@",name, _customClasses); // show the class map before... - NSDebugLog(@"customClassMap = %@",customClassMap); + NSDebugLog(@"_customClassMap = %@",_customClassMap); while((object = [en nextObject]) != nil) { - id customClassName = [customClassMap objectForKey: object]; + id customClassName = [_customClassMap objectForKey: object]; if(customClassName != nil) { if([oldName isEqualToString: customClassName]) { NSDebugLog(@"Replacing object -> customClass association %@ -> %@",object,customClassName); - [customClassMap setObject: name forKey: object]; + [_customClassMap setObject: name forKey: object]; } } } - NSDebugLog(@"New customClassMap = %@",customClassMap); // and after + NSDebugLog(@"New _customClassMap = %@",_customClassMap); // and after // Iterate over the list of subclasses and replace their referece with the new // name. @@ -1169,7 +1177,7 @@ - (NSString *)parentOfClass: (NSString *)aClass { - NSDictionary *dictForClass = [classInformation objectForKey: aClass]; + NSDictionary *dictForClass = [_classInformation objectForKey: aClass]; return [dictForClass objectForKey: @"Super"]; } @@ -1178,7 +1186,7 @@ NSMutableDictionary *dict = nil; NSMutableArray *classes = nil; NSEnumerator *enumerator = nil; - NSMutableArray *cats = [NSMutableArray arrayWithArray: categoryClasses]; + NSMutableArray *cats = [NSMutableArray arrayWithArray: _categoryClasses]; id name = nil; // save all custom classes.... @@ -1187,7 +1195,7 @@ classes = [NSMutableArray array]; // build IBClasses... - enumerator = [customClasses objectEnumerator]; + enumerator = [_customClasses objectEnumerator]; while ((name = [enumerator nextObject]) != nil) { NSDictionary *classInfo; @@ -1196,7 +1204,7 @@ id extraObj; // get the info... - classInfo = [classInformation objectForKey: name]; + classInfo = [_classInformation objectForKey: name]; newInfo = [[NSMutableDictionary alloc] init]; [newInfo setObject: name forKey: @"CLASS"]; @@ -1281,7 +1289,7 @@ id obj; // get the info... - classInfo = [classInformation objectForKey: name]; + classInfo = [_classInformation objectForKey: name]; newInfo = [NSMutableDictionary dictionary]; [newInfo setObject: name forKey: @"CLASS"]; @@ -1332,7 +1340,7 @@ // save all custom classes.... ci = [NSMutableDictionary dictionary]; - enumerator = [customClasses objectEnumerator]; + enumerator = [_customClasses objectEnumerator]; while ((key = [enumerator nextObject]) != nil) { NSDictionary *classInfo; @@ -1341,7 +1349,7 @@ id extraObj; // get the info... - classInfo = [classInformation objectForKey: key]; + classInfo = [_classInformation objectForKey: key]; newInfo = [[NSMutableDictionary alloc] init]; [ci setObject: newInfo forKey: key]; @@ -1386,7 +1394,7 @@ } // save all categories on existing, non-custom classes.... - enumerator = [categoryClasses objectEnumerator]; + enumerator = [_categoryClasses objectEnumerator]; while((key = [enumerator nextObject]) != nil) { NSDictionary *classInfo; @@ -1394,7 +1402,7 @@ id obj; // get the info... - classInfo = [classInformation objectForKey: key]; + classInfo = [_classInformation objectForKey: key]; newInfo = [NSMutableDictionary dictionary]; [ci setObject: newInfo forKey: key]; @@ -1445,7 +1453,7 @@ /* * Convert property-list data into a mutable structure. */ - ASSIGN(classInformation, [[NSMutableDictionary alloc] init]); + ASSIGN(_classInformation, [[NSMutableDictionary alloc] init]); // iterate over all entries.. enumerator = [dict keyEnumerator]; @@ -1457,7 +1465,7 @@ newInfo = [[NSMutableDictionary alloc] init]; - [classInformation setObject: newInfo forKey: key]; + [_classInformation setObject: newInfo forKey: key]; // superclass obj = [classInfo objectForKey: @"Super"]; @@ -1567,7 +1575,7 @@ return NO; } - if (classInformation == nil) + if (_classInformation == nil) { NSLog(@"Default classes file not loaded"); return NO; @@ -1596,7 +1604,7 @@ NSEnumerator *en = nil; id key = nil; - // Iterate over the set of classes, if it's in the classInformation + // Iterate over the set of classes, if it's in the _classInformation // list, it's a category, if it's not it's a custom class. en = [dict keyEnumerator]; while((key = [en nextObject]) != nil) @@ -1608,11 +1616,11 @@ if([class_dict isKindOfClass: [NSDictionary class]]) { NSMutableDictionary *classDict = (NSMutableDictionary *)class_dict; - NSMutableDictionary *info = [classInformation objectForKey: key]; + NSMutableDictionary *info = [_classInformation objectForKey: key]; if(info == nil) { - [customClasses addObject: key]; - [classInformation setObject: classDict forKey: key]; + [_customClasses addObject: key]; + [_classInformation setObject: classDict forKey: key]; } else { @@ -1634,7 +1642,7 @@ // add it, otherwise don't. if([actions count] > 0) { - [categoryClasses addObject: key]; + [_categoryClasses addObject: key]; [info setObject: actions forKey: @"ExtraActions"]; } } @@ -1646,7 +1654,7 @@ - (BOOL) isCustomClass: (NSString *)className { - return ([customClasses indexOfObject: className] != NSNotFound); + return ([_customClasses indexOfObject: className] != NSNotFound); } - (BOOL) isNonCustomClass: (NSString *)className @@ -1656,12 +1664,12 @@ - (BOOL) isCategoryForClass: (NSString *)className { - return ([categoryClasses indexOfObject: className] != NSNotFound); + return ([_categoryClasses indexOfObject: className] != NSNotFound); } - (BOOL) isAction: (NSString *)actionName onCategoryForClassNamed: (NSString *)className { - NSDictionary *info = [classInformation objectForKey: className]; + NSDictionary *info = [_classInformation objectForKey: className]; BOOL result = NO; if([self isCategoryForClass: className]) @@ -1681,7 +1689,7 @@ - (BOOL) isKnownClass: (NSString *)className { - return ([classInformation objectForKey: className] != nil); + return ([_classInformation objectForKey: className] != nil); } - (BOOL) setSuperClassNamed: (NSString *)superclass @@ -1697,7 +1705,7 @@ { NSMutableDictionary *info; - info = [classInformation objectForKey: subclass]; + info = [_classInformation objectForKey: subclass]; if (info != nil) { // remove actions/outlets inherited from superclasses... @@ -1725,7 +1733,7 @@ - (NSString *) superClassNameForClassNamed: (NSString *)className { - NSMutableDictionary *info = [classInformation objectForKey: className]; + NSMutableDictionary *info = [_classInformation objectForKey: className]; NSString *superName = nil; if (info != nil) @@ -1756,7 +1764,7 @@ - (NSDictionary *) dictionaryForClassNamed: (NSString *)className { - NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary: [classInformation objectForKey: className]]; + NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary: [_classInformation objectForKey: className]]; if(info != nil) { @@ -1784,7 +1792,7 @@ NSString *actionName; int i; int n; - NSDictionary *classInfo = [classInformation objectForKey: className]; + NSDictionary *classInfo = [_classInformation objectForKey: className]; headerFile = [NSMutableString stringWithCapacity: 200]; sourceFile = [NSMutableString stringWithCapacity: 200]; @@ -1798,8 +1806,9 @@ // header file comments... [headerFile appendString: @"/* All rights reserved */\n\n"]; [sourceFile appendString: @"/* All rights reserved */\n\n"]; + [headerFile appendString: [NSString stringWithFormat: @"#ifndef %@_H_INCLUDE\n", className]]; + [headerFile appendString: [NSString stringWithFormat: @"#define %@_H_INCLUDE\n\n", className]]; [headerFile appendString: @"#import \n\n"]; - [sourceFile appendString: @"#import \n"]; if ([[headerPath stringByDeletingLastPathComponent] isEqualToString: [sourcePath stringByDeletingLastPathComponent]]) { @@ -1812,7 +1821,7 @@ headerPath]; } [headerFile appendFormat: @"@interface %@ : %@\n{\n", className, - [self superClassNameForClassNamed: className]]; + [self superClassNameForClassNamed: className]]; [sourceFile appendFormat: @"@implementation %@\n\n", className]; n = [outlets count]; @@ -1820,7 +1829,7 @@ { [headerFile appendFormat: @" IBOutlet id %@;\n", [outlets objectAtIndex: i]]; } - [headerFile appendFormat: @"}\n"]; + [headerFile appendFormat: @"}\n\n"]; n = [actions count]; for (i = 0; i < n; i++) @@ -1828,14 +1837,14 @@ actionName = [actions objectAtIndex: i]; [headerFile appendFormat: @"- (IBAction) %@ (id)sender;\n", actionName]; [sourceFile appendFormat: - @"\n" @"- (IBAction) %@ (id)sender\n" @"{\n" @"}\n" @"\n" , [actions objectAtIndex: i]]; } - [headerFile appendFormat: @"\n@end\n"]; + [headerFile appendFormat: @"\n@end\n\n"]; + [headerFile appendString: [NSString stringWithFormat: @"#endif // %@_H_INCLUDE\n", className]]; [sourceFile appendFormat: @"@end\n"]; headerData = [headerFile dataUsingEncoding: @@ -1860,9 +1869,9 @@ - (BOOL) parseHeader: (NSString *)headerPath { - OCHeaderParser *ochp = AUTORELEASE([[OCHeaderParser alloc] initWithContentsOfFile: headerPath]); + OCHeaderParser *ochp = [[OCHeaderParser alloc] initWithContentsOfFile: headerPath]; BOOL result = NO; - + if(ochp != nil) { result = [ochp parse]; @@ -1876,12 +1885,15 @@ { NSArray *methods = [cls methods]; NSArray *ivars = [cls ivars]; - NSString *superClass = [cls superClassName]; + NSArray *properties = [cls properties]; + NSString *superClass = [cls superClassName]; // == nil) ? @"NSObject":[cls superClassName]; NSString *className = [cls className]; NSEnumerator *ien = [ivars objectEnumerator]; NSEnumerator *men = [methods objectEnumerator]; + NSEnumerator *pen = [properties objectEnumerator]; OCMethod *method = nil; OCIVar *ivar = nil; + OCProperty *property = nil; NSMutableArray *actions = [NSMutableArray array]; NSMutableArray *outlets = [NSMutableArray array]; @@ -1902,24 +1914,28 @@ } } + while((property = (OCProperty *)[pen nextObject]) != nil) + { + if([property isOutlet]) + { + [outlets addObject: [property name]]; + } + } + + NSLog(@"outlets = %@", outlets); + if(([self isKnownClass: superClass] || superClass == nil) && [cls isCategory] == NO) { if([self isKnownClass: className]) { - NSString *title = [NSString stringWithFormat: @"%@", - _(@"Reparsing Class")]; - NSString *messageFormat = _(@"This may break connections to " - @"actions/outlets to instances of class '%@' " - @"and it's subclasses. Continue?"); - NSString *msg = [NSString stringWithFormat: messageFormat, - className]; - NSInteger retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); - - if (retval == NSAlertDefaultReturn) + id delegate = (id)[NSApp delegate]; + BOOL result = [delegate shouldBreakConnectionsReparsingClass: className]; + + if (result == YES) { // get the owner and reset the class name to NSApplication. - GormFilesOwner *owner = [document objectForName: @"NSOwner"]; + GormFilesOwner *owner = [_document objectForName: @"NSOwner"]; NSString *ownerClassName = [owner className]; // Retain this, in case we're dealing with the NSOwner... @@ -1941,7 +1957,7 @@ } // refresh the connections. - [document refreshConnectionsForClassNamed: className]; + [_document refreshConnectionsForClassNamed: className]; // Release the owner classname... RELEASE(ownerClassName); @@ -1955,13 +1971,25 @@ withOutlets: outlets]; } } - else if([cls isCategory] && [self isKnownClass: className]) + else if([cls isCategory]) { - [self addActions: actions forClassNamed: className]; + if ([self isKnownClass: className]) + { + [self addActions: actions forClassNamed: className]; + [self addActions: outlets forClassNamed: className]; + } + else + { + [self addClassNamed: className + withSuperClassNamed: @"NSObject" + withActions: actions + withOutlets: outlets]; + } } else if(superClass != nil && [self isKnownClass: superClass] == NO) { result = NO; + RELEASE(ochp); [NSException raise: NSGenericException format: @"The superclass %@ of class %@ is not known, please parse it.", superClass, className]; @@ -1970,13 +1998,14 @@ } } + RELEASE(ochp); return result; } - (BOOL) isAction: (NSString *)name ofClass: (NSString *)className { BOOL result = NO; - NSDictionary *classInfo = [classInformation objectForKey: className]; + NSDictionary *classInfo = [_classInformation objectForKey: className]; if (classInfo != nil) { @@ -1995,7 +2024,7 @@ - (BOOL) isOutlet: (NSString *)name ofClass: (NSString *)className { BOOL result = NO; - NSDictionary *classInfo = [classInformation objectForKey: className]; + NSDictionary *classInfo = [_classInformation objectForKey: className]; if (classInfo != nil) { @@ -2014,16 +2043,16 @@ // custom class support... - (NSString *) customClassForName: (NSString *)name { - NSString *result = [customClassMap objectForKey: name]; + NSString *result = [_customClassMap objectForKey: name]; return result; } - (NSString *) customClassForObject: (id)object { - NSString *name = [document nameForObject: object]; + NSString *name = [_document nameForObject: object]; NSString *result = [self customClassForName: name]; - NSDebugLog(@"in customClassForObject: object = %@, name = %@, result = %@, customClassMap = %@", - object, name, result, customClassMap); + NSDebugLog(@"in customClassForObject: object = %@, name = %@, result = %@, _customClassMap = %@", + object, name, result, _customClassMap); return result; } @@ -2040,30 +2069,30 @@ - (void) setCustomClass: (NSString *)className forName: (NSString *)name { - [customClassMap setObject: className forKey: name]; + [_customClassMap setObject: className forKey: name]; } - (void) removeCustomClassForName: (NSString *)name { - [customClassMap removeObjectForKey: name]; + [_customClassMap removeObjectForKey: name]; } - (NSMutableDictionary *) customClassMap { - return customClassMap; + return _customClassMap; } - (void) setCustomClassMap: (NSMutableDictionary *)dict { // copy the dictionary.. NSDebugLog(@"dictionary = %@",dict); - ASSIGN(customClassMap, [dict mutableCopy]); - RETAIN(customClassMap); // released in dealloc + ASSIGN(_customClassMap, [dict mutableCopy]); + RETAIN(_customClassMap); // released in dealloc } - (BOOL) isCustomClassMapEmpty { - return ([customClassMap count] == 0); + return ([_customClassMap count] == 0); } - (BOOL) isRootClass: (NSString *)className @@ -2248,17 +2277,41 @@ return className; } +- (NSDictionary *) classInformation +{ + return _classInformation; +} + +- (NSDictionary *) customClassInformation +{ + NSEnumerator *en = [_customClasses objectEnumerator]; + NSMutableDictionary *result = [NSMutableDictionary dictionary]; + NSString *name = nil; + + while ((name = [en nextObject]) != nil) + { + NSDictionary *o = [_classInformation objectForKey: name]; + [result setObject: o forKey: name]; + } + + return result; +} + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" - (NSString *) description { return [NSString stringWithFormat: @"<%s: %lx> = %@", GSClassNameFromObject(self), (unsigned long)self, - customClassMap]; + _customClassMap]; } +#pragma GCC diagnostic pop /** Helpful for debugging */ - (NSString *) dumpClassInformation { - return [classInformation description]; + return [_classInformation description]; } + @end diff --git a/GormCore/GormClassPanelController.m b/GormCore/GormClassPanelController.m index 5249f0d1..acd1a452 100644 --- a/GormCore/GormClassPanelController.m +++ b/GormCore/GormClassPanelController.m @@ -36,7 +36,9 @@ self = [super init]; if(self != nil) { - if ( ![NSBundle loadNibNamed:@"GormClassPanel" owner:self] ) + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + + if ( ![bundle loadNibNamed:@"GormClassPanel" owner:self topLevelObjects: NULL] ) { NSLog(@"Can not load bundle GormClassPanel"); return nil; diff --git a/GormCore/GormConnectionInspector.m b/GormCore/GormConnectionInspector.m index 0ff01dda..978de645 100644 --- a/GormCore/GormConnectionInspector.m +++ b/GormCore/GormConnectionInspector.m @@ -89,8 +89,10 @@ - (id) init { if ((self = [super init]) != nil) - { - if([NSBundle loadNibNamed: @"GormConnectionInspector" owner: self] == NO) + { + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + + if([bundle loadNibNamed: @"GormConnectionInspector" owner: self topLevelObjects: NULL] == NO) { NSLog(@"Couldn't load GormConnectionInsector"); return nil; @@ -212,8 +214,10 @@ if ([con isKindOfClass: [NSNibControlConnector class]] == YES) { RELEASE(actions); - actions = RETAIN([[(id)NSApp classManager] - allActionsForObject: [con destination]]); + actions = [[(id)[NSApp delegate] classManager] + allActionsForObject: [con destination]]; + actions = [actions sortedArrayUsingSelector: @selector(compare:)]; + RETAIN(actions); break; } else @@ -225,13 +229,15 @@ if (con == nil) // && [actions containsObject: [currentConnector label]] == NO) { RELEASE(actions); - actions = RETAIN([[(id)NSApp classManager] - allActionsForObject: [NSApp connectDestination]]); + actions = [[(id)[NSApp delegate] classManager] + allActionsForObject: [[NSApp delegate] connectDestination]]; + actions = [actions sortedArrayUsingSelector: @selector(compare:)]; + RETAIN(actions); if ([actions count] > 0) { con = [[NSNibControlConnector alloc] init]; [con setSource: object]; - [con setDestination: [NSApp connectDestination]]; + [con setDestination: [[NSApp delegate] connectDestination]]; [con setLabel: [actions objectAtIndex: 0]]; AUTORELEASE(con); } @@ -275,7 +281,7 @@ RELEASE(currentConnector); currentConnector = [[NSNibOutletConnector alloc] init]; [currentConnector setSource: object]; - [currentConnector setDestination: [NSApp connectDestination]]; + [currentConnector setDestination: [[NSApp delegate] connectDestination]]; [currentConnector setLabel: title]; } } @@ -284,7 +290,7 @@ */ [oldBrowser loadColumnZero]; [oldBrowser selectRow: index inColumn: 0]; - [NSApp displayConnectionBetween: object + [[NSApp delegate] displayConnectionBetween: object and: [currentConnector destination]]; } else @@ -312,7 +318,7 @@ RELEASE(currentConnector); currentConnector = [[NSNibControlConnector alloc] init]; [currentConnector setSource: object]; - [currentConnector setDestination: [NSApp connectDestination]]; + [currentConnector setDestination: [[NSApp delegate] connectDestination]]; [currentConnector setLabel: title]; [oldBrowser loadColumnZero]; } @@ -329,10 +335,10 @@ if ([title hasPrefix: label] == YES) { NSString *name; - id dest = [NSApp connectDestination]; + id dest = [[NSApp delegate] connectDestination]; dest = [con destination]; - name = [[(id)NSApp activeDocument] nameForObject: dest]; + name = [[(id)[NSApp delegate] activeDocument] nameForObject: dest]; name = [label stringByAppendingFormat: @" (%@)", name]; if ([title isEqual: name] == YES) { @@ -348,7 +354,7 @@ path = [@"/target" stringByAppendingString: path]; } [newBrowser setPath: path]; - [NSApp displayConnectionBetween: object + [[NSApp delegate] displayConnectionBetween: object and: [con destination]]; break; } @@ -454,11 +460,11 @@ selectCellWithString: (NSString*)title { NSString *label; NSString *name; - id dest = [NSApp connectDestination]; + id dest = [[NSApp delegate] connectDestination]; label = [[connectors objectAtIndex: row] label]; dest = [[connectors objectAtIndex: row] destination]; - name = [[(id)NSApp activeDocument] nameForObject: dest]; + name = [[(id)[NSApp delegate] activeDocument] nameForObject: dest]; name = [label stringByAppendingFormat: @" (%@)", name]; [aCell setStringValue: name]; @@ -505,7 +511,7 @@ selectCellWithString: (NSString*)title { id con = currentConnector; - [[(id)NSApp activeDocument] removeConnector: con]; + [[(id)[NSApp delegate] activeDocument] removeConnector: con]; [connectors removeObject: con]; [oldBrowser loadColumnZero]; } @@ -527,7 +533,7 @@ selectCellWithString: (NSString*)title { if ([con isKindOfClass: [NSNibControlConnector class]]) { - [[(id)NSApp activeDocument] removeConnector: con]; + [[(id)[NSApp delegate] activeDocument] removeConnector: con]; [connectors removeObjectIdenticalTo: con]; break; } @@ -537,14 +543,14 @@ selectCellWithString: (NSString*)title [self _selectAction: [currentConnector label]]; } [connectors addObject: currentConnector]; - [[(id)NSApp activeDocument] addConnector: currentConnector]; + [[(id)[NSApp delegate] activeDocument] addConnector: currentConnector]; /* * When we establish a connection, we want to highlight it in * the browser so the user can see it has been done. */ dest = [currentConnector destination]; - path = [[(id)NSApp activeDocument] nameForObject: dest]; + path = [[(id)[NSApp delegate] activeDocument] nameForObject: dest]; path = [[currentConnector label] stringByAppendingFormat: @" (%@)", path]; path = [@"/" stringByAppendingString: path]; [oldBrowser loadColumnZero]; @@ -574,15 +580,17 @@ selectCellWithString: (NSString*)title * Create list of existing connections for selected object. */ connectors = [[NSMutableArray alloc] init]; - array = [[(id)NSApp activeDocument] connectorsForSource: object + array = [[(id)[NSApp delegate] activeDocument] connectorsForSource: object ofClass: [NSNibControlConnector class]]; [connectors addObjectsFromArray: array]; - array = [[(id)NSApp activeDocument] connectorsForSource: object + array = [[(id)[NSApp delegate] activeDocument] connectorsForSource: object ofClass: [NSNibOutletConnector class]]; [connectors addObjectsFromArray: array]; RELEASE(outlets); - outlets = RETAIN([[(id)NSApp classManager] allOutletsForObject: object]); + outlets = [[(id)[NSApp delegate] classManager] allOutletsForObject: object]; + outlets = [outlets sortedArrayUsingSelector: @selector(compare:)]; + RETAIN(outlets); DESTROY(actions); [oldBrowser loadColumnZero]; @@ -590,7 +598,7 @@ selectCellWithString: (NSString*)title /* * See if we can do initial selection based on pre-existing connections. */ - if ([NSApp isConnecting] == YES) + if ([[NSApp delegate] isConnecting] == YES) { id dest = [currentConnector destination]; unsigned row; @@ -624,7 +632,7 @@ selectCellWithString: (NSString*)title if ([currentConnector isKindOfClass: [NSNibControlConnector class]] == YES && - [NSApp isConnecting] == NO) + [[NSApp delegate] isConnecting] == NO) { [newBrowser setPath: @"/target"]; [newBrowser sendAction]; @@ -642,7 +650,7 @@ selectCellWithString: (NSString*)title } else { - GormDocument *active = (GormDocument *)[(id)NSApp activeDocument]; + GormDocument *active = (GormDocument *)[(id)[NSApp delegate] activeDocument]; id src = [currentConnector source]; id dest = [currentConnector destination]; diff --git a/GormCore/GormCore.h b/GormCore/GormCore.h index 4efedef4..7fbd1afc 100644 --- a/GormCore/GormCore.h +++ b/GormCore/GormCore.h @@ -34,71 +34,73 @@ FOUNDATION_EXPORT const unsigned char GormCoreVersionString[]; #ifndef INCLUDED_GORMCORE_H #define INCLUDED_GORMCORE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import #endif diff --git a/GormCore/GormCustomClassInspector.m b/GormCore/GormCustomClassInspector.m index af676a7e..51d24d8a 100644 --- a/GormCore/GormCustomClassInspector.m +++ b/GormCore/GormCustomClassInspector.m @@ -48,14 +48,17 @@ self = [super init]; if (self != nil) { + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + // initialize all member variables... _classManager = nil; _currentSelectionClassName = nil; _rowToSelect = 0; // load the gui... - if (![NSBundle loadNibNamed: @"GormCustomClassInspector" - owner: self]) + if (![bundle loadNibNamed: @"GormCustomClassInspector" + owner: self + topLevelObjects: NULL]) { NSLog(@"Could not open gorm GormCustomClassInspector"); return nil; @@ -130,8 +133,8 @@ NSMutableArray *classes = nil; [super setObject: anObject]; - _document = [(id)NSApp activeDocument]; - _classManager = [(id)NSApp classManager]; + _document = [(id)[NSApp delegate] activeDocument]; + _classManager = [(id)[NSApp delegate] classManager]; // get the information... NSDebugLog(@"Current selection %@", [self object]); diff --git a/GormCore/GormCustomView.m b/GormCore/GormCustomView.m index 9805a8f4..671df4e3 100644 --- a/GormCore/GormCustomView.m +++ b/GormCore/GormCustomView.m @@ -99,7 +99,7 @@ - (Class) bestPossibleSuperClass { Class cls = [NSView class]; - GormClassManager *classManager = [(id)NSApp classManager]; + GormClassManager *classManager = [(id)[NSApp delegate] classManager]; if([classManager isSuperclass: @"NSView" linkedToClass: className]) { @@ -127,7 +127,7 @@ { if([aCoder allowsKeyedCoding]) { - GormClassManager *classManager = [(id)NSApp classManager]; + GormClassManager *classManager = [(id)[NSApp delegate] classManager]; NSString *extension = nil; ASSIGNCOPY(extension,[classManager nonCustomSuperClassOf: className]); @@ -248,7 +248,7 @@ - (Class) bestPossibleSuperClass { Class cls = [NSView class]; - GormClassManager *classManager = [(id)NSApp classManager]; + GormClassManager *classManager = [(id)[NSApp delegate] classManager]; if([classManager isSuperclass: @"NSOpenGLView" linkedToClass: theClass] || [theClass isEqual: @"NSOpenGLView"]) @@ -279,7 +279,7 @@ id obj; Class cls; NSUInteger mask; - GormClassManager *classManager = [(id)NSApp classManager]; + GormClassManager *classManager = [(id)[NSApp delegate] classManager]; [aCoder decodeValueOfObjCType: @encode(id) at: &theClass]; theFrame = [aCoder decodeRect]; diff --git a/GormCore/GormDocument.h b/GormCore/GormDocument.h index 859acf43..a81181de 100644 --- a/GormCore/GormDocument.h +++ b/GormCore/GormDocument.h @@ -34,7 +34,7 @@ #include @class GormClassManager, GormClassEditor, GormObjectProxy, GormFilesOwner, - GormFilePrefsManager, GormDocumentWindow; + GormFilePrefsManager, GormDocumentWindow, GormObjectViewController; /* * Trivial classes for connections from objects to their editors, and from @@ -57,7 +57,7 @@ } @end -@interface GormDocument : NSDocument +@interface GormDocument : NSDocument { GormClassManager *classManager; GormFilesOwner *filesOwner; @@ -99,6 +99,9 @@ NSMutableSet *topLevelObjects; NSMutableSet *visibleWindows; NSMutableSet *deferredWindows; + + // Controllers... + GormObjectViewController *objectViewController; } /* Handle notifications */ @@ -212,19 +215,71 @@ withParentObject: (id)parentObj; /* Language translation */ -- (void) translate: (id)sender; -- (void) exportStrings: (id)sender; +/** + * Load a given file into the reciever using `filename'. + */ +- (void) importStringsFromFile: (NSString *)filename; + +/** + * Export the strings from receiver to the file indicated by 'filename'. + */ +- (void) exportStringsToFile: (NSString *)filename; /* Managing classes */ +/** + * Shared class manager + */ - (GormClassManager*) classManager; + +/** + * Create a subclass of the selected class + */ - (id) createSubclass: (id)sender; + +/** + * Instantiate the selected class + */ - (id) instantiateClass: (id)sender; + +/** + * Instantiate the class specified by the parameter className and + * returns the reference name within the document + */ +- (NSString *) instantiateClassNamed: (NSString *)className; + +/** + * Generate the class files for the selected class + */ - (id) createClassFiles: (id)sender; + +/** + * Add attribute to class + */ - (id) addAttributeToClass: (id)sender; + +/** + * Remove the selected class + */ - (id) remove: (id)sender; + +/** + * Select class named className + */ - (void) selectClass: (NSString *)className; + +/** + * Select class named className and edit it if flag is YES + */ - (void) selectClass: (NSString *)className editClass: (BOOL)flag; + +/** + * Returns YES if a class is selected in the view + */ - (BOOL) classIsSelected; + +/** + * Removes all instances of class named classNamed + */ - (void) removeAllInstancesOfClass: (NSString *)classNamed; /* Sound & Image support */ @@ -241,6 +296,11 @@ /* Connections */ +/** + * + */ +- (NSMutableArray *) connections; + /** * Build our reverse mapping information and other initialisation */ @@ -459,6 +519,17 @@ * Add aConnector to the set of connectors in this document. */ - (void) addConnector: (id)aConnector; + +/** + * Returns a set containing the top level objects for this document. + */ +- (NSMutableSet *) topLevelObjects; + +/** + * Returns an array of issues. If document is valid the array should be empty. + */ +- (NSArray *) validate; + @end @interface GormDocument (MenuValidation) @@ -481,6 +552,10 @@ * Returns YES if the document is editing classes. */ - (BOOL) isEditingClasses; + +@end + +@interface GormDocument (Metadata) @end #endif diff --git a/GormCore/GormDocument.m b/GormCore/GormDocument.m index 112311de..a1fc8f4f 100644 --- a/GormCore/GormDocument.m +++ b/GormCore/GormDocument.m @@ -4,7 +4,8 @@ * protocol plus additional methods which are useful for managing the * contents of the document. * - * Copyright (C) 1999,2002,2003,2004,2005,2020,2021 Free Software Foundation, Inc. + * Copyright (C) 1999,2002,2003,2004,2005,2020, + * 2021 Free Software Foundation, Inc. * * Author: Gregory John Casamento * Date: 2002,2003,2004,2005,2020,2021 @@ -28,32 +29,50 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#include -#include +#import +#import -#include +#import -#include +#import -#include "GormPrivate.h" -#include "GormClassManager.h" -#include "GormCustomView.h" -#include "GormOutlineView.h" -#include "GormFunctions.h" -#include "GormFilePrefsManager.h" -#include "GormViewWindow.h" -#include "NSView+GormExtensions.h" -#include "GormSound.h" -#include "GormImage.h" -#include "GormResourceManager.h" -#include "GormClassEditor.h" -#include "GormSoundEditor.h" -#include "GormImageEditor.h" -#include "GormObjectEditor.h" -#include "GormWrapperBuilder.h" -#include "GormWrapperLoader.h" -#include "GormDocumentWindow.h" -#include "GormDocumentController.h" +#import "GormPrivate.h" +#import "GormClassManager.h" +#import "GormCustomView.h" +#import "GormOutlineView.h" +#import "GormFunctions.h" +#import "GormFilePrefsManager.h" +#import "GormViewWindow.h" +#import "NSView+GormExtensions.h" +#import "GormSound.h" +#import "GormImage.h" +#import "GormResourceManager.h" +#import "GormClassEditor.h" +#import "GormSoundEditor.h" +#import "GormImageEditor.h" +#import "GormObjectEditor.h" +#import "GormWrapperBuilder.h" +#import "GormWrapperLoader.h" +#import "GormDocumentWindow.h" +#import "GormDocumentController.h" +#import "GormXLIFFDocument.h" +#import "GormObjectViewController.h" + +@interface NSObject (GormNSCoding) +@end + +@implementation NSObject (GormNSCoding) + +- (instancetype) initWithCoder: (NSCoder *)coder +{ + return [self init]; +} + +- (void) encodeWithCoder: (NSCoder *)coder +{ +} + +@end @interface GormDisplayCell : NSButtonCell @end @@ -83,35 +102,41 @@ @end @implementation GormFirstResponder + - (NSImage*) imageForViewer { static NSImage *image = nil; if (image == nil) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path = [bundle pathForImageResource: @"GormFirstResponder"]; image = [[NSImage alloc] initWithContentsOfFile: path]; } return image; } + - (NSString*) inspectorClassName { return @"GormNotApplicableInspector"; } + - (NSString*) connectInspectorClassName { return @"GormNotApplicableInspector"; } + - (NSString*) sizeInspectorClassName { return @"GormNotApplicableInspector"; } + - (NSString*) classInspectorClassName { return @"GormNotApplicableInspector"; } + - (NSString*) className { return @"FirstResponder"; @@ -146,7 +171,7 @@ static NSImage *fileImage = nil; NSBundle *bundle; NSString *path; - bundle = [NSBundle mainBundle]; + bundle = [NSBundle bundleForClass: [self class]]; path = [bundle pathForImageResource: @"GormObject"]; if (path != nil) { @@ -167,7 +192,7 @@ static NSImage *fileImage = nil; { classesImage = [[NSImage alloc] initWithContentsOfFile: path]; } - path = [bundle pathForImageResource: @"Gorm"]; + path = [bundle pathForImageResource: @"GormFile"]; if (path != nil) { fileImage = [[NSImage alloc] initWithContentsOfFile: path]; @@ -192,6 +217,7 @@ static NSImage *fileImage = nil; { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + id delegate = [NSApp delegate]; // initialize... openEditors = [[NSMutableArray alloc] init]; @@ -270,20 +296,12 @@ static NSImage *fileImage = nil; { if(![classManager parseHeader: header]) { - NSString *file = [header lastPathComponent]; - NSString *message = [NSString stringWithFormat: - _(@"Unable to parse class in %@"),file]; - NSRunAlertPanel(_(@"Problem parsing class"), - message, - nil, nil, nil); + [delegate couldNotParseClassAtPath: header]; } } NS_HANDLER { - NSString *message = [localException reason]; - NSRunAlertPanel(_(@"Problem parsing class"), - message, - nil, nil, nil); + [delegate exceptionWhileParsingClass: localException]; } NS_ENDHANDLER; } @@ -309,7 +327,8 @@ static NSImage *fileImage = nil; NSMenu *mainMenu = nil; NSEnumerator *en = nil; id o = nil; - + NSOutlineView *outlineView = [[NSOutlineView alloc] init]; + // get the window and cache it... window = (GormDocumentWindow *)[self _docWindow]; [IBResourceManager registerForAllPboardTypes:window @@ -344,6 +363,35 @@ static NSImage *fileImage = nil; object: window]; // objects... + NSScrollView *outlineScrollView = [[NSScrollView alloc] initWithFrame: scrollRect]; + NSTableColumn *tbo = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"objects"]); + NSTableColumn *tbc = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"destination"]); + NSTableColumn *tbs = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"source"]); + NSTableColumn *tbcl = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"class"]); + NSTableColumn *tbv = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"version"]); + + // Titles + [tbo setTitle: @"Objects"]; + [tbc setTitle: @"Destination"]; + [tbs setTitle: @"Source"]; + [tbcl setTitle: @"Class"]; + [tbv setTitle: @"Version"]; + + // Set up the outline view... + [outlineView setDrawsGrid: NO]; + [outlineView setOutlineTableColumn: tbo]; + [outlineView addTableColumn: tbo]; + [outlineView addTableColumn: tbcl]; + [outlineView addTableColumn: tbv]; + [outlineView addTableColumn: tbc]; + [outlineView addTableColumn: tbs]; + [outlineScrollView setHasVerticalScroller: YES]; + [outlineScrollView setHasHorizontalScroller: YES]; + [outlineScrollView setAutoresizingMask: + NSViewHeightSizable|NSViewWidthSizable]; + [outlineScrollView setBorderType: NSBezelBorder]; + + // Configure the scrollview... mainRect.origin = NSMakePoint(0,0); scrollView = [[NSScrollView alloc] initWithFrame: scrollRect]; [scrollView setHasVerticalScroller: YES]; @@ -351,6 +399,11 @@ static NSImage *fileImage = nil; [scrollView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable]; [scrollView setBorderType: NSBezelBorder]; + + objectViewController = [[GormObjectViewController alloc] initWithNibName: @"GormObjectOutlineView" + bundle: [NSBundle bundleForClass: [self class]]]; + [objectViewController setDocument: self]; + NSDebugLog(@"objectViewController = %@, view = %@", objectViewController, [objectViewController view]); objectsView = [[GormObjectEditor alloc] initWithObject: nil inDocument: self]; @@ -358,8 +411,22 @@ static NSImage *fileImage = nil; [objectsView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable]; [scrollView setDocumentView: objectsView]; - RELEASE(objectsView); + RELEASE(objectsView); + [objectViewController setIconView: scrollView]; + RELEASE(scrollView); + + [outlineScrollView setDocumentView: outlineView]; + [objectViewController setOutlineView: outlineScrollView]; + [outlineView setDataSource: self]; + [objectViewController reloadOutlineView]; + + RELEASE(outlineView); + + [[objectViewController view] setAutoresizingMask: + NSViewHeightSizable|NSViewWidthSizable]; + [objectViewController resetDisplayView: scrollView]; + // images... mainRect.origin = NSMakePoint(0,0); imagesScrollView = [[NSScrollView alloc] initWithFrame: scrollRect]; @@ -400,7 +467,7 @@ static NSImage *fileImage = nil; /* * Set the objects view as the initial view the user's see on startup. */ - [selectionBox setContentView: scrollView]; + [selectionBox setContentView: [objectViewController view]]; //scrollView]; // add to the objects view... [objectsView addObject: filesOwner]; @@ -434,20 +501,15 @@ static NSImage *fileImage = nil; { NSInteger version = [filePrefsManager version]; NSInteger currentVersion = [GormFilePrefsManager currentVersion]; + id delegate = [NSApp delegate]; if(version > currentVersion) { - NSInteger retval = NSRunAlertPanel(_(@"Gorm Build Mismatch"), - _(@"The file being loaded was created with a newer build, continue?"), - _(@"OK"), - _(@"Cancel"), - nil, - nil); - if(retval != NSAlertDefaultReturn) + BOOL result = [delegate shouldLoadNewerArchive]; + if (result == NO) { - // close the document, if the user says "NO." [self close]; - } + } } DESTROY(infoData); } @@ -504,6 +566,7 @@ static NSImage *fileImage = nil; object: aConnector]; [connections addObject: aConnector]; + [self touch]; // make sure the doc is marked as modified... [nc postNotificationName: IBDidAddConnectorNotification object: aConnector]; @@ -523,28 +586,35 @@ static NSImage *fileImage = nil; */ - (void) _instantiateFontManager { - GSNibItem *item = nil; - NSMenu *fontMenu = nil; - - item = [[GormObjectProxy alloc] initWithClassName: @"NSFontManager"]; - - [self setName: @"NSFont" forObject: item]; - [self attachObject: item toParent: nil]; - RELEASE(item); - - // set the holder in the document. - fontManager = (GormObjectProxy *)item; - [self changeToViewWithTag: 0]; - - // Add the connection to the menu from the font manager, if the NSFontMenu exists... - fontMenu = [self fontMenu]; - if (fontMenu != nil) + if (fontManager != nil) { - NSNibOutletConnector *con = [[NSNibOutletConnector alloc] init]; - [con setSource: item]; - [con setDestination: fontMenu]; - [con setLabel: @"menu"]; - [self addConnector: con]; + return; + } + else + { + GSNibItem *item = nil; + NSMenu *fontMenu = nil; + + item = [[GormObjectProxy alloc] initWithClassName: @"NSFontManager"]; + + [self setName: @"NSFont" forObject: item]; + [self attachObject: item toParent: nil]; + RELEASE(item); + + // set the holder in the document. + fontManager = (GormObjectProxy *)item; + [self changeToViewWithTag: 0]; + + // Add the connection to the menu from the font manager, if the NSFontMenu exists... + fontMenu = [self fontMenu]; + if (fontMenu != nil) + { + NSNibOutletConnector *con = [[NSNibOutletConnector alloc] init]; + [con setSource: item]; + [con setDestination: fontMenu]; + [con setLabel: @"menu"]; + [self addConnector: con]; + } } } @@ -932,9 +1002,9 @@ static NSImage *fileImage = nil; { case 0: // objects { - [selectionBox setContentView: scrollView]; + [selectionBox setContentView: [objectViewController view]]; //scrollView]; [toolbar setSelectedItemIdentifier: @"ObjectsItem"]; - if (![NSApp isConnecting]) + if (![[NSApp delegate] isConnecting]) [self setSelectionFromEditor: objectsView]; } break; @@ -954,7 +1024,7 @@ static NSImage *fileImage = nil; break; case 3: // classes { - NSArray *selection = [[(id)NSApp selectionOwner] selection]; + NSArray *selection = [[(id)[NSApp delegate] selectionOwner] selection]; [selectionBox setContentView: classesView]; // if something is selected, in the object view. @@ -1441,7 +1511,7 @@ static NSImage *fileImage = nil; /** * Detach every object in anArray from the document. Optionally closing editors. */ -- (void) detachObjects: (NSArray*)anArray closeEditors: (BOOL)close_editors +- (void) detachObjects: (/* NSArray* */ id)anArray closeEditors: (BOOL)close_editors { NSEnumerator *enumerator = [anArray objectEnumerator]; NSObject *obj; @@ -1493,6 +1563,84 @@ static NSImage *fileImage = nil; return [classesView instantiateClass: sender]; } +/** + * Instantiate the class specified by the parameter className + */ +- (NSString *) instantiateClassNamed: (NSString *)className +{ + NSString *theName = nil; + GSNibItem *item = nil; + + if([className isEqualToString: @"FirstResponder"]) + { + return nil; + } + + if([classManager canInstantiateClassNamed: className] == NO) + { + return nil; + } + + if([classManager isSuperclass: @"NSView" linkedToClass: className] || + [className isEqualToString: @"NSView"]) + { + Class cls; + BOOL isCustom = [classManager isCustomClass: className]; + id instance; + + // Replace with NON custom class, since we don't have the compiled version + // of the custom class available to us in Gorm. + if(isCustom) + { + className = [classManager nonCustomSuperClassOf: className]; + } + + // instantiate the object or it's substitute... + cls = NSClassFromString(className); + if([cls respondsToSelector: @selector(allocSubstitute)]) + { + instance = [cls allocSubstitute]; + } + else + { + instance = [cls alloc]; + } + + // give it some initial dimensions... + if([instance respondsToSelector: @selector(initWithFrame:)]) + { + instance = [instance initWithFrame: NSMakeRect(10,10,380,280)]; + } + else + { + instance = [instance init]; + } + + // add it to the top level objects... + [self attachObject: instance toParent: nil]; + + // we want to record if it's custom or not and act appropriately... + if(isCustom) + { + theName = [self nameForObject: instance]; + [classManager setCustomClass: className + forName: theName]; + } + + [self changeToViewWithTag: 0]; + NSDebugLog(@"Instantiate NSView subclass %@",className); + } + else + { + item = [[GormObjectProxy alloc] initWithClassName: className]; + [self attachObject: item toParent: nil]; + [self changeToViewWithTag: 0]; + theName = [self nameForObject: item]; + } + + return theName; +} + /** * Remove a class from the classes view */ @@ -1554,7 +1702,7 @@ static NSImage *fileImage = nil; /* * Make sure that this editor is not the selection owner. */ - if ([(id)NSApp selectionOwner] == + if ([(id)[NSApp delegate] selectionOwner] == (id)anEditor) { [self resignSelectionForEditor: anEditor]; @@ -1740,7 +1888,8 @@ static void _real_close(GormDocument *self, } else if ([name isEqual: IBWillBeginTestingInterfaceNotification] && isDocumentOpen) { - if ([(id)NSApp activeDocument] == self) + id delegate = [NSApp delegate]; + if ([delegate activeDocument] == self && [delegate isInTool] == NO) { NSEnumerator *enumerator; id obj; @@ -1752,8 +1901,11 @@ static void _real_close(GormDocument *self, [[self window] orderOut: self]; } - [[NSApp mainMenu] close]; // close the menu during test... - + if ([delegate respondsToSelector: @selector(mainMenu)]) + { + [[delegate mainMenu] close]; // close the menu during test... + } + enumerator = [nameTable objectEnumerator]; while ((obj = [enumerator nextObject]) != nil) { @@ -1783,7 +1935,7 @@ static void _real_close(GormDocument *self, NSEnumerator *enumerator; id obj; - [[NSApp mainMenu] display]; // bring the menu back... + [[[NSApp delegate] mainMenu] display]; // bring the menu back... enumerator = [hidden objectEnumerator]; while ((obj = [enumerator nextObject]) != nil) @@ -2427,12 +2579,12 @@ static void _real_close(GormDocument *self, id obj; // stop all connection activities. - [(id)NSApp stopConnecting]; + [(id)[NSApp delegate] stopConnecting]; enumerator = [nameTable objectEnumerator]; if (flag) { - GormDocument *document = (GormDocument*)[(id)NSApp activeDocument]; + GormDocument *document = (GormDocument*)[(id)[NSApp delegate] activeDocument]; // set the current document active and unset the old one. [document setDocumentActive: NO]; @@ -2491,7 +2643,7 @@ static void _real_close(GormDocument *self, NSDebugLog(@"setSelectionFromEditor %@", anEditor); ASSIGN(lastEditor, anEditor); - [(id)NSApp stopConnecting]; // cease any connection + [(id)[NSApp delegate] stopConnecting]; // cease any connection if ([(NSObject *)anEditor respondsToSelector: @selector(window)]) { [[anEditor window] makeKeyWindow]; @@ -2506,6 +2658,7 @@ static void _real_close(GormDocument *self, */ - (void) touch { + [objectViewController reloadOutlineView]; [self updateChangeCount: NSChangeDone]; } @@ -2639,7 +2792,8 @@ static void _real_close(GormDocument *self, id c = nil; BOOL removed = YES; BOOL prompted = NO; - + id delegate = [NSApp delegate]; + // find connectors to be removed. while ((c = [en nextObject]) != nil) { @@ -2677,33 +2831,12 @@ static void _real_close(GormDocument *self, if ([label isEqualToString: name] && ([proxyClass isEqualToString: className] || [classManager isSuperclass: className linkedToClass: proxyClass])) { - NSString *title; - NSString *msg; - NSInteger retval; - - if(prompted == NO) + removed = [delegate shouldBreakConnectionsModifyingLabel: name + isAction: action + prompted: prompted]; + if (removed) { - title = [NSString stringWithFormat: - @"Modifying %@",(action==YES?@"Action":@"Outlet")]; - msg = [NSString stringWithFormat: - _(@"This will break all connections to '%@'. Continue?"), name]; - retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); - prompted = YES; - } - else - { - removed = NO; - break; - } - - if (retval == NSAlertDefaultReturn) - { - removed = YES; [removedConnections addObject: c]; - } - else - { - removed = NO; break; } } @@ -2731,26 +2864,9 @@ static void _real_close(GormDocument *self, { NSEnumerator *en = nil; id c = nil; - BOOL removed = YES; - NSInteger retval = -1; - NSString *title = [NSString stringWithFormat: @"%@",_(@"Modifying Class")]; - NSString *msg; - NSString *msgFormat = _(@"This will break all connections to " - @"actions/outlets to instances of class '%@' and it's subclasses. Continue?"); - - msg = [NSString stringWithFormat: msgFormat, className]; - - // ask the user if he/she wants to continue... - retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); - if (retval == NSAlertDefaultReturn) - { - removed = YES; - } - else - { - removed = NO; - } - + id delegate = [NSApp delegate]; + BOOL removed = [delegate shouldBreakConnectionsForClassNamed: className]; + // remove all. if(removed) { @@ -2845,24 +2961,9 @@ static void _real_close(GormDocument *self, { NSEnumerator *en = [connections objectEnumerator]; id c = nil; - BOOL renamed = YES; - NSInteger retval = -1; - NSString *title = [NSString stringWithFormat: @"%@", _(@"Modifying Class")]; - NSString *msgFormat = _(@"Change class name '%@' to '%@'. Continue?"); - NSString *msg = [NSString stringWithFormat: - msgFormat, - className, newName]; - - // ask the user if he/she wants to continue... - retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); - if (retval == NSAlertDefaultReturn) - { - renamed = YES; - } - else - { - renamed = NO; - } + id delegate = [NSApp delegate]; + BOOL renamed = [delegate shouldRenameConnectionsForClassNamed: className + toClassName: newName]; // remove all. if(renamed) @@ -2981,6 +3082,8 @@ static void _real_close(GormDocument *self, /** * Return a text description of the document. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" - (NSString *) description { return [NSString stringWithFormat: @"<%s: %lx> = <>", @@ -2988,6 +3091,7 @@ static void _real_close(GormDocument *self, (unsigned long)self, nameTable, connections]; } +#pragma GCC diagnostic pop /** * Returns YES, if obj is a top level object. @@ -3141,164 +3245,96 @@ static void _real_close(GormDocument *self, return allObjects; } -/** - * This method is used to translate all of the strings in the file from one language - * into another. This is helpful when attempting to translate an application for use - * in different locales. - */ -- (void) translate: (id)sender +- (void) importStringsFromFile: (NSString *)filename { - NSArray *fileTypes = [NSArray arrayWithObjects: @"strings", nil]; - NSOpenPanel *oPanel = [NSOpenPanel openPanel]; - int result; - - [oPanel setAllowsMultipleSelection: NO]; - [oPanel setCanChooseFiles: YES]; - [oPanel setCanChooseDirectories: NO]; - result = [oPanel runModalForDirectory: nil - file: nil - types: fileTypes]; - if (result == NSOKButton) + NSMutableArray *allObjects = [self _collectAllObjects]; + NSDictionary *dictionary = nil; + NSEnumerator *en = nil; + id obj = nil; + + dictionary = [[NSString stringWithContentsOfFile: filename] propertyListFromStringsFileFormat]; + + // change to translated values. + en = [allObjects objectEnumerator]; + while((obj = [en nextObject]) != nil) { - NSMutableArray *allObjects = [self _collectAllObjects]; - NSString *filename = [oPanel filename]; - NSDictionary *dictionary = nil; - NSEnumerator *en = nil; - id obj = nil; - - NS_DURING + NSString *translation = nil; + + if([obj respondsToSelector: @selector(setTitle:)] && + [obj respondsToSelector: @selector(title)]) { - dictionary = [[NSString stringWithContentsOfFile: filename] propertyListFromStringsFileFormat]; - } - NS_HANDLER - { - NSString *message = [localException reason]; - NSRunAlertPanel(_(@"Problem loading strings"), - message, nil, nil, nil); - } - NS_ENDHANDLER - - // change to translated values. - en = [allObjects objectEnumerator]; - while((obj = [en nextObject]) != nil) - { - NSString *translation = nil; - - if([obj respondsToSelector: @selector(setTitle:)] && - [obj respondsToSelector: @selector(title)]) - { - translation = [dictionary objectForKey: [obj title]]; - if(translation != nil) - { - [obj setTitle: translation]; - } - } - else if([obj respondsToSelector: @selector(setStringValue:)] && - [obj respondsToSelector: @selector(stringValue)]) - { - translation = [dictionary objectForKey: [obj stringValue]]; - if(translation != nil) - { - [obj setStringValue: translation]; - } - } - else if([obj respondsToSelector: @selector(setLabel:)] && - [obj respondsToSelector: @selector(label)]) - { - translation = [dictionary objectForKey: [obj label]]; - if(translation != nil) - { - [obj setLabel: translation]; - } - } - + translation = [dictionary objectForKey: [obj title]]; if(translation != nil) { - if([obj isKindOfClass: [NSView class]]) - { - [obj setNeedsDisplay: YES]; - } - - [self touch]; + [obj setTitle: translation]; } - - // redisplay/flush, if the object is a window. - if([obj isKindOfClass: [NSWindow class]]) - { - NSWindow *w = (NSWindow *)obj; - [w setViewsNeedDisplay: YES]; - [w disableFlushWindow]; - [[w contentView] setNeedsDisplay: YES]; - [[w contentView] displayIfNeeded]; - [w enableFlushWindow]; - [w flushWindowIfNeeded]; - } - } - } + else if([obj respondsToSelector: @selector(setStringValue:)] && + [obj respondsToSelector: @selector(stringValue)]) + { + translation = [dictionary objectForKey: [obj stringValue]]; + if(translation != nil) + { + [obj setStringValue: translation]; + } + } + else if([obj respondsToSelector: @selector(setLabel:)] && + [obj respondsToSelector: @selector(label)]) + { + translation = [dictionary objectForKey: [obj label]]; + if(translation != nil) + { + [obj setLabel: translation]; + } + } + } } -/** - * This method is used to export all strings in a document to a file for Language - * translation. This allows the user to see all of the strings which can be translated - * and allows the user to provide a translateion for each of them. - */ -- (void) exportStrings: (id)sender +- (void) exportStringsToFile: (NSString *)filename { - NSSavePanel *sp = [NSSavePanel savePanel]; - int result; - - [sp setRequiredFileType: @"strings"]; - [sp setTitle: _(@"Save strings file as...")]; - result = [sp runModalForDirectory: NSHomeDirectory() - file: nil]; - if (result == NSOKButton) + NSMutableArray *allObjects = [self _collectAllObjects]; + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + NSEnumerator *en = [allObjects objectEnumerator]; + id obj = nil; + BOOL touched = NO; + + // change to translated values. + while((obj = [en nextObject]) != nil) { - NSMutableArray *allObjects = [self _collectAllObjects]; - NSString *filename = [sp filename]; - NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; - NSEnumerator *en = [allObjects objectEnumerator]; - id obj = nil; - BOOL touched = NO; - - // change to translated values. - while((obj = [en nextObject]) != nil) + NSString *string = nil; + if([obj respondsToSelector: @selector(setTitle:)] && + [obj respondsToSelector: @selector(title)]) { - NSString *string = nil; - if([obj respondsToSelector: @selector(setTitle:)] && - [obj respondsToSelector: @selector(title)]) - { - string = [obj title]; - } - else if([obj respondsToSelector: @selector(setStringValue:)] && - [obj respondsToSelector: @selector(stringValue)]) - { - string = [obj stringValue]; - } - else if([obj respondsToSelector: @selector(setLabel:)] && - [obj respondsToSelector: @selector(label)]) - { - string = [obj label]; - } - - if(string != nil) - { - [dictionary setObject: string forKey: string]; - touched = YES; - } + string = [obj title]; } - - if(touched) + else if([obj respondsToSelector: @selector(setStringValue:)] && + [obj respondsToSelector: @selector(stringValue)]) { - NSString *stringToWrite = - @"/* TRANSLATORS: Make sure to quote all translated strings if\n" - @" they contain spaces or non-ASCII characters. */\n\n"; - - stringToWrite = [stringToWrite stringByAppendingString: - [dictionary descriptionInStringsFileFormat]]; - [stringToWrite writeToFile: filename atomically: YES]; + string = [obj stringValue]; } - } + else if([obj respondsToSelector: @selector(setLabel:)] && + [obj respondsToSelector: @selector(label)]) + { + string = [obj label]; + } + + if(string != nil) + { + [dictionary setObject: string forKey: string]; + touched = YES; + } + } + + if(touched) + { + NSString *stringToWrite = + @"/* TRANSLATORS: Make sure to quote all translated strings if\n" + @" they contain spaces or non-ASCII characters. */\n\n"; + + stringToWrite = [stringToWrite stringByAppendingString: + [dictionary descriptionInStringsFileFormat]]; + [stringToWrite writeToFile: filename atomically: YES]; + } } /** @@ -3306,7 +3342,7 @@ static void _real_close(GormDocument *self, */ - (void) arrangeSelectedObjects: (id)sender { - NSArray *selection = [[(id)NSApp selectionOwner] selection]; + NSArray *selection = [[(id)[NSApp delegate] selectionOwner] selection]; NSInteger tag = [sender tag]; NSEnumerator *en = [selection objectEnumerator]; id v = nil; @@ -3338,7 +3374,7 @@ static void _real_close(GormDocument *self, */ - (void) alignSelectedObjects: (id)sender { - NSArray *selection = [[(id)NSApp selectionOwner] selection]; + NSArray *selection = [[(id)[NSApp delegate] selectionOwner] selection]; NSInteger tag = [sender tag]; NSEnumerator *en = [selection objectEnumerator]; id v = nil; @@ -3410,27 +3446,24 @@ static void _real_close(GormDocument *self, id builder = [[GormWrapperBuilderFactory sharedWrapperBuilderFactory] wrapperBuilderForType: type]; NSFileWrapper *result = nil; + id delegate = [NSApp delegate]; /* * Warn the user, if we are about to upgrade the package. */ if(isOlderArchive && [filePrefsManager isLatest]) { - NSInteger retval = NSRunAlertPanel(_(@"Compatibility Warning"), - _(@"Saving will update this gorm to the latest version \n" - @"which may not be compatible with some previous versions \n" - @"of GNUstep."), - _(@"Save"), - _(@"Don't Save"), nil, nil); - if (retval != NSAlertDefaultReturn) - { - return nil; - } - else + BOOL result = [delegate shouldUpgradeOlderArchive]; + + if (result == YES) { // we're saving anyway... set to new value. isOlderArchive = NO; } + else + { + return nil; + } } /* @@ -3769,6 +3802,38 @@ static void _real_close(GormDocument *self, { return [classManager allOutletsForClassNamed: className]; } + +//// Document Validation + +- (NSArray *) validate +{ + NSMutableArray *results = [NSMutableArray array]; + NSEnumerator *en = [topLevelObjects objectEnumerator]; + id o = nil; + + NSLog(@"Validating topLevelObjects: %@", topLevelObjects); + while ((o = [en nextObject]) != nil) + { + // check the type of o... + if ([o isKindOfClass: [NSWindow class]] + || [o isKindOfClass: [NSMenu class]] + || [o isKindOfClass: [NSView class]] + || [o isKindOfClass: [GormObjectProxy class]]) + { + continue; + } + else + { + NSString *className = NSStringFromClass([o class]); + NSString *error = [NSString stringWithFormat: @"%@ has an invalid class of type %@", o, className]; + + [results addObject: error]; + } + } + + return results; +} + @end @implementation GormDocument (MenuValidation) @@ -3877,3 +3942,219 @@ willBeInsertedIntoToolbar: (BOOL)flag } @end +@implementation GormDocument (Metadata) + +// Core methods.. + +- (id) outlineView: (NSOutlineView *)ov + child: (NSInteger)index + ofItem: (id)item +{ + id result = nil; + + if ([objectViewController editor] == NO) + [self deactivateEditors]; + + NSDebugLog(@"index = %ld, item = %@", index, item); + if (item == nil) + { + result = [[topLevelObjects allObjects] objectAtIndex: index]; + } + else if ([item isKindOfClass: [NSWindow class]]) + { + result = [item contentView]; + } + else if ([item isKindOfClass: [NSView class]]) + { + result = [[item subviews] objectAtIndex: index]; + } + else if ([item isKindOfClass: [NSMenu class]]) + { + result = [item itemAtIndex: index]; + } + else if ([item isKindOfClass: [NSMenuItem class]]) + { + result = [item submenu]; + } + NSDebugLog(@"result = %@", result); + if ([objectViewController editor] == NO) + [self reactivateEditors]; + + return result; +} + +- (BOOL) outlineView: (NSOutlineView *)ov + isItemExpandable: (id)item +{ + BOOL f = NO; + + if ([objectViewController editor] == NO) + [self deactivateEditors]; + if (item == nil) + { + f = [topLevelObjects count] > 0; + } + else if ([item isKindOfClass: [NSWindow class]]) + { + f = [item contentView] != nil; + } + else if ([item isKindOfClass: [NSView class]]) + { + f = [[item subviews] count] > 0; + } + else if ([item isKindOfClass: [NSMenu class]]) + { + f = [item numberOfItems] > 0; + } + else if ([item isKindOfClass: [NSMenuItem class]]) + { + f = [item hasSubmenu]; + } + if ([objectViewController editor] == NO) + [self reactivateEditors]; + + NSDebugLog(@"f = %d",f); + return f; +} + +- (NSInteger) outlineView: (NSOutlineView *)ov + numberOfChildrenOfItem: (id)item +{ + NSInteger c = 0; + + if ([objectViewController editor] == NO) + [self deactivateEditors]; + if (item == nil) + { + c = [topLevelObjects count]; + } + else if ([item isKindOfClass: [NSWindow class]]) + { + c = 1; // We are only counting the contentView... + } + else if ([item isKindOfClass: [NSView class]]) + { + c = [[item subviews] count]; + } + else if ([item isKindOfClass: [NSMenu class]]) + { + c = [item numberOfItems]; + } + else if ([item isKindOfClass: [NSMenuItem class]]) + { + c = 1; // one submenu... + } + if ([objectViewController editor] == NO) + [self reactivateEditors]; + + NSDebugLog(@"c = %ld", c); + return c; +} + +- (id) outlineView: (NSOutlineView *)ov + objectValueForTableColumn: (NSTableColumn *)tableColumn + byItem: (id)item +{ + id value = nil; + NSString *className = [classManager classNameForObject: item]; + NSString *name = [self nameForObject: item]; + NSUInteger version = 0; + + if ([objectViewController editor] == NO) + [self deactivateEditors]; + if ([[tableColumn identifier] isEqualToString: @"objects"]) + { + NSString *title = @""; + + if ([item respondsToSelector: @selector(title)]) + { + title = [item title]; + value = [NSString stringWithFormat: @"%@ : %@", + (title != nil && ![title isEqualToString: @""]) ? title : @"*Untitled*", + (name != nil) ? name : @"*Unnamed*"]; + } + else + { + value = [NSString stringWithFormat: @"%@", (name != nil)?name:@"*Unnamed*"]; + } + } + else if ([[tableColumn identifier] isEqualToString: @"class"]) + { + value = className; + } + else if ([[tableColumn identifier] isEqualToString: @"version"]) + { + value = [NSNumber numberWithInteger: version]; + } + else if ([[tableColumn identifier] isEqualToString: @"destination"]) + { + NSArray *c = [self connectorsForDestination: item]; + value = [NSNumber numberWithInteger: [c count]]; + } + else if ([[tableColumn identifier] isEqualToString: @"source"]) + { + NSArray *c = [self connectorsForSource: item]; + value = [NSNumber numberWithInteger: [c count]]; + } + if ([objectViewController editor] == NO) + [self reactivateEditors]; + + return value; +} + +// Other methods... + +- (BOOL) outlineView: (NSOutlineView *)ov + acceptDrop: (id)info + item: (id)item + childIndex: (NSInteger)index +{ + return NO; +} + +- (id) outlineView: (NSOutlineView *)ov + itemForPersistentObject: (id)obj +{ + return nil; +} + +- (id) outlineView: (NSOutlineView *)ov + persistentObjectForItem: (id)item +{ + return nil; +} + +- (NSArray *) outlineView: (NSOutlineView *)ov + namesOfPromisedFilesDroppedAtDestination: (NSURL *)dropDestination + forDraggedItems: (NSArray *)items +{ + return nil; +} + +- (void) outlineView: (NSOutlineView *)ov + setObjectValue: (id)value + forTableColumn: (NSTableColumn *)tc + byItem: (id)item +{ +} + +- (void) outlineView: (NSOutlineView *)ov + sortDescriptorsDidChange: (NSArray *)oldDescriptors +{ +} + +- (void) outlineView: (NSOutlineView *)ov + writeItems: (NSArray *)items + toPasteboard: (NSPasteboard *)pb +{ +} + +- (NSDragOperation) outlineView: (NSOutlineView *)ov + validateDrop: (id)info + proposedItem: (id)item + proposedChildIndex: (NSInteger)index +{ + return 0; +} + +@end diff --git a/GormCore/GormDocumentController.m b/GormCore/GormDocumentController.m index 967bf442..431d1ce7 100644 --- a/GormCore/GormDocumentController.m +++ b/GormCore/GormDocumentController.m @@ -24,10 +24,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#include "GormPrivate.h" #include #include +#include "GormPrivate.h" + @implementation GormDocumentController - (id) currentDocument diff --git a/GormCore/GormFilePrefsManager.h b/GormCore/GormFilePrefsManager.h index cf8695dd..39eb9a2c 100644 --- a/GormCore/GormFilePrefsManager.h +++ b/GormCore/GormFilePrefsManager.h @@ -119,4 +119,15 @@ * The current Gorm version. */ + (int) currentVersion; + +/** + * Current profile for the current model file. + */ +- (NSDictionary *) currentProfile; + +/** + * Version information for the model file. + */ +- (NSDictionary *) versionProfiles; + @end diff --git a/GormCore/GormFilePrefsManager.m b/GormCore/GormFilePrefsManager.m index d07d9adf..c2cf5423 100644 --- a/GormCore/GormFilePrefsManager.m +++ b/GormCore/GormFilePrefsManager.m @@ -69,7 +69,7 @@ NSString *formatVersion(NSInteger version) { if((self = [super init]) != nil) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path = [bundle pathForResource: @"VersionProfiles" ofType: @"plist"]; versionProfiles = RETAIN([[NSString stringWithContentsOfFile: path] propertyList]); } @@ -87,7 +87,7 @@ NSString *formatVersion(NSInteger version) + (int) currentVersion { - return appVersion(1,3,1); + return appVersion(1, 5, 0); } - (void) awakeFromNib @@ -184,7 +184,7 @@ NSString *formatVersion(NSInteger version) NSMutableDictionary *dict = [NSMutableDictionary dictionary]; NSRect docLocation = - [[(GormDocument *)[(id)NSApp activeDocument] window] frame]; + [[(GormDocument *)[(id)[NSApp delegate] activeDocument] window] frame]; NSRect screenRect = [[NSScreen mainScreen] frame]; NSString *stringRect = [NSString stringWithFormat: @"%d %d %d %d %d %d %d %d", (int)docLocation.origin.x, (int)docLocation.origin.y, @@ -226,6 +226,22 @@ NSString *formatVersion(NSInteger version) } +/** + * Current profile for the current model file. + */ +- (NSDictionary *) currentProfile; +{ + return currentProfile; +} + +/** + * Version information for the model file. + */ +- (NSDictionary *) versionProfiles; +{ + return versionProfiles; +} + - (BOOL) loadFromFile: (NSString *)path { return [self loadFromData: [NSData dataWithContentsOfFile: path]]; diff --git a/GormCore/GormFilesOwner.m b/GormCore/GormFilesOwner.m index f8f6ec17..afcc1a77 100644 --- a/GormCore/GormFilesOwner.m +++ b/GormCore/GormFilesOwner.m @@ -49,7 +49,7 @@ if (image == nil) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path = [bundle pathForImageResource: @"GormFilesOwner"]; image = [[NSImage alloc] initWithContentsOfFile: path]; @@ -177,13 +177,13 @@ addObserver: self selector: @selector(_classAdded:) name: GormDidAddClassNotification - object: [(id)NSApp classManager]]; + object: [(id)[NSApp delegate] classManager]]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_classDeleted:) name: GormDidDeleteClassNotification - object: [(id)NSApp classManager]]; + object: [(id)[NSApp delegate] classManager]]; } return self; } @@ -193,11 +193,11 @@ // filter the classes to view only when a custom view is selected. if([anObject isKindOfClass: [GormCustomView class]]) { - ASSIGN(classes, AUTORELEASE([[[(id)NSApp classManager] allSubclassesOf: @"NSView"] mutableCopy])); + ASSIGN(classes, AUTORELEASE([[[(id)[NSApp delegate] classManager] allSubclassesOf: @"NSView"] mutableCopy])); } else { - ASSIGN(classes, AUTORELEASE([[[(id)NSApp classManager] allClassNames] mutableCopy])); + ASSIGN(classes, AUTORELEASE([[[(id)[NSApp delegate] classManager] allClassNames] mutableCopy])); } // remove the first responder, since we don't want the user to choose this. @@ -214,11 +214,11 @@ /* * Create list of existing connections for selected object. */ - array = [[(id)NSApp activeDocument] connectorsForSource: object + array = [[(id)[NSApp delegate] activeDocument] connectorsForSource: object ofClass: [NSNibOutletConnector class]]; if ([array count] > 0) hasConnections = YES; - array = [[(id)NSApp activeDocument] connectorsForDestination: object + array = [[(id)[NSApp delegate] activeDocument] connectorsForDestination: object ofClass: [NSNibControlConnector class]]; if ([array count] > 0) hasConnections = YES; @@ -250,7 +250,7 @@ else { NSArray *array; - id doc = [(id)NSApp activeDocument]; + id doc = [(id)[NSApp delegate] activeDocument]; unsigned i; array = [doc connectorsForSource: object diff --git a/GormCore/GormFontViewController.m b/GormCore/GormFontViewController.m index aaadc604..32bc83d3 100644 --- a/GormCore/GormFontViewController.m +++ b/GormCore/GormFontViewController.m @@ -22,9 +22,12 @@ static GormFontViewController *gorm_font_cont = nil; self = [super init]; if (self != nil) { + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + // load the gui... - if (![NSBundle loadNibNamed: @"GormFontView" - owner: self]) + if (![bundle loadNibNamed: @"GormFontView" + owner: self + topLevelObjects: NULL]) { NSLog(@"Could not open gorm GormFontView"); return nil; diff --git a/GormCore/GormFunctions.h b/GormCore/GormFunctions.h index 11f20912..27aeabe8 100644 --- a/GormCore/GormFunctions.h +++ b/GormCore/GormFunctions.h @@ -25,8 +25,8 @@ #ifndef INCLUDED_GormFunctions_h #define INCLUDED_GormFunctions_h -#include -#include +#import +#import // find all subitems for the given items... void findAllWithArray(id item, NSMutableArray *array); diff --git a/GormPrefs/GormGeneralPref.h b/GormCore/GormGeneralPref.h similarity index 100% rename from GormPrefs/GormGeneralPref.h rename to GormCore/GormGeneralPref.h diff --git a/GormPrefs/GormGeneralPref.m b/GormCore/GormGeneralPref.m similarity index 100% rename from GormPrefs/GormGeneralPref.m rename to GormCore/GormGeneralPref.m diff --git a/GormCore/GormGenericEditor.h b/GormCore/GormGenericEditor.h index 8e7a5bfa..4b3b9d45 100644 --- a/GormCore/GormGenericEditor.h +++ b/GormCore/GormGenericEditor.h @@ -31,7 +31,7 @@ #include -@interface GormGenericEditor : NSMatrix +@interface GormGenericEditor : NSMatrix { NSMutableArray *objects; id document; diff --git a/GormPrefs/GormGuidelinePref.h b/GormCore/GormGuidelinePref.h similarity index 100% rename from GormPrefs/GormGuidelinePref.h rename to GormCore/GormGuidelinePref.h diff --git a/GormPrefs/GormGuidelinePref.m b/GormCore/GormGuidelinePref.m similarity index 100% rename from GormPrefs/GormGuidelinePref.m rename to GormCore/GormGuidelinePref.m diff --git a/GormPrefs/GormHeadersPref.h b/GormCore/GormHeadersPref.h similarity index 100% rename from GormPrefs/GormHeadersPref.h rename to GormCore/GormHeadersPref.h diff --git a/GormPrefs/GormHeadersPref.m b/GormCore/GormHeadersPref.m similarity index 100% rename from GormPrefs/GormHeadersPref.m rename to GormCore/GormHeadersPref.m diff --git a/GormCore/GormHelpInspector.m b/GormCore/GormHelpInspector.m index a3654cff..e0316cb9 100644 --- a/GormCore/GormHelpInspector.m +++ b/GormCore/GormHelpInspector.m @@ -9,12 +9,14 @@ @implementation GormHelpInspector - (id) init { + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + if ([super init] == nil) { return nil; } - if ([NSBundle loadNibNamed: @"GormHelpInspector" owner: self] == NO) + if ([bundle loadNibNamed: @"GormHelpInspector" owner: self topLevelObjects: NULL] == NO) { NSLog(@"Could not gorm GormHelpInspector"); return nil; @@ -25,7 +27,7 @@ - (void) ok: (id)sender { - id document = [(id)NSApp activeDocument]; + id document = [(id)[NSApp delegate] activeDocument]; NSArray *cons = [document connectorsForDestination: object ofClass: [NSIBHelpConnector class]]; NSIBHelpConnector *con = nil; @@ -65,7 +67,7 @@ - (void) revert: (id)sender { - id document = [(id)NSApp activeDocument]; + id document = [(id)[NSApp delegate] activeDocument]; NSArray *cons = [document connectorsForDestination: object ofClass: [NSIBHelpConnector class]]; diff --git a/GormCore/GormImageEditor.m b/GormCore/GormImageEditor.m index ad99dcc7..e363d63c 100644 --- a/GormCore/GormImageEditor.m +++ b/GormCore/GormImageEditor.m @@ -80,7 +80,7 @@ static NSMapTable *docMap = 0; NSMutableArray *list = [NSMutableArray array]; NSEnumerator *en; id obj; - GormPalettesManager *palettesManager = [(id)NSApp palettesManager]; + GormPalettesManager *palettesManager = [(id)[NSApp delegate] palettesManager]; // add all of the system objects... [list addObjectsFromArray: systemImagesList()]; diff --git a/GormCore/GormImageInspector.m b/GormCore/GormImageInspector.m index 08672528..6f17111e 100644 --- a/GormCore/GormImageInspector.m +++ b/GormCore/GormImageInspector.m @@ -19,9 +19,12 @@ self = [super init]; if (self != nil) { + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + // load the gui... - if (![NSBundle loadNibNamed: @"GormImageInspector" - owner: self]) + if (![bundle loadNibNamed: @"GormImageInspector" + owner: self + topLevelObjects: NULL]) { NSLog(@"Could not open gorm GormImageInspector"); return nil; diff --git a/GormCore/GormInspectorsManager.m b/GormCore/GormInspectorsManager.m index c96ae685..b018fba7 100644 --- a/GormCore/GormInspectorsManager.m +++ b/GormCore/GormInspectorsManager.m @@ -48,7 +48,9 @@ self = [super init]; if (self != nil) { - if([NSBundle loadNibNamed: @"GormDummyInspector" owner: self]) + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + + if([bundle loadNibNamed: @"GormDummyInspector" owner: self topLevelObjects: NULL]) { [button setStringValue: [self title]]; } @@ -182,7 +184,7 @@ - (void) updateSelection { - if ([NSApp isConnecting] == YES) + if ([[NSApp delegate] isConnecting] == YES) { [popup selectItemAtIndex: 1]; [popup setNeedsDisplay: YES]; @@ -271,10 +273,10 @@ - (void) setCurrentInspector: (id)anObj { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - NSArray *selection = [[(id)NSApp selectionOwner] selection]; + NSArray *selection = [[(id)[NSApp delegate] selectionOwner] selection]; unsigned count = [selection count]; id obj = [selection lastObject]; - id document = [(id)NSApp activeDocument]; + id document = [(id)[NSApp delegate] activeDocument]; NSView *newView = nil; NSView *oldView = nil; NSString *newInspector = nil; diff --git a/GormCore/GormInternalViewEditor.m b/GormCore/GormInternalViewEditor.m index c4fdcfcc..21e65c4a 100644 --- a/GormCore/GormInternalViewEditor.m +++ b/GormCore/GormInternalViewEditor.m @@ -65,7 +65,7 @@ static NSImage *horizontalImage; if (image == nil) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path = [bundle pathForImageResource: @"GormView"]; image = [[NSImage alloc] initWithContentsOfFile: path]; } diff --git a/GormCore/GormMatrixEditor.m b/GormCore/GormMatrixEditor.m index 8877b7ad..dbb91a0a 100644 --- a/GormCore/GormMatrixEditor.m +++ b/GormCore/GormMatrixEditor.m @@ -734,6 +734,7 @@ static BOOL done_editing; { NSPasteboard *dragPb; NSArray *types; + id delegate = [NSApp delegate]; dragPb = [sender draggingPasteboard]; types = [dragPb types]; @@ -742,8 +743,8 @@ static BOOL done_editing; NSPoint loc = [sender draggingLocation]; NSPoint mouseDownPoint = [_EO convertPoint: loc fromView: nil]; - [NSApp displayConnectionBetween: [NSApp connectSource] - and: [self connectTargetAtPoint: mouseDownPoint]]; + [delegate displayConnectionBetween: [delegate connectSource] + and: [self connectTargetAtPoint: mouseDownPoint]]; return NSDragOperationLink; } return [super draggingEntered: sender]; @@ -755,15 +756,16 @@ static BOOL done_editing; NSArray *types; NSPoint dropPoint = [sender draggedImageLocation]; NSPoint mouseDownPoint = [_EO convertPoint: dropPoint fromView: nil]; + id delegate = [NSApp delegate]; dragPb = [sender draggingPasteboard]; types = [dragPb types]; if ([types containsObject: GormLinkPboardType]) { - [NSApp displayConnectionBetween: [NSApp connectSource] - and: [self connectTargetAtPoint: mouseDownPoint]]; - [NSApp startConnecting]; + [delegate displayConnectionBetween: [delegate connectSource] + and: [self connectTargetAtPoint: mouseDownPoint]]; + [delegate startConnecting]; } else if ([types containsObject: GormImagePboardType] == YES || [types containsObject: GormSoundPboardType] == YES) diff --git a/GormCore/GormNSPanel.m b/GormCore/GormNSPanel.m index b64b2f2e..b3e91ed7 100644 --- a/GormCore/GormNSPanel.m +++ b/GormCore/GormNSPanel.m @@ -129,9 +129,9 @@ static NSUInteger defaultStyleMask = NSTitledWindowMask | NSClosableWindowMask - (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (NSInteger)otherWin { - id document = [(id)NSApp documentForObject: self]; + id document = [(id)[NSApp delegate] documentForObject: self]; [super orderWindow: place relativeTo: otherWin]; - if([NSApp isConnecting] == NO) + if([[NSApp delegate] isConnecting] == NO) { id editor = [document editorForObject: self create: NO]; diff --git a/GormCore/GormNSSplitViewInspector.m b/GormCore/GormNSSplitViewInspector.m index fd6117af..01fb15c3 100644 --- a/GormCore/GormNSSplitViewInspector.m +++ b/GormCore/GormNSSplitViewInspector.m @@ -23,25 +23,15 @@ self = [super init]; if (self != nil) { - if ([NSBundle loadNibNamed: @"GormNSSplitViewInspector" - owner: self] == NO) - { - NSDictionary *table = nil; - NSBundle *bundle = nil; - BOOL loaded = NO; - - table = [NSDictionary dictionaryWithObject: self forKey: @"NSOwner"]; - bundle = [NSBundle mainBundle]; - loaded = [bundle loadNibFile: @"GormNSSplitViewInspector" - externalNameTable: table - withZone: [self zone]]; - - if (!loaded) - { - NSLog(@"Could not open gorm GormNSSplitViewInspector"); - NSLog(@"self %@", self); - return nil; - } + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + + if ([bundle loadNibNamed: @"GormNSSplitViewInspector" + owner: self + topLevelObjects: NULL] == NO) + { + NSLog(@"Could not open gorm GormNSSplitViewInspector"); + NSLog(@"self %@", self); + return nil; } } diff --git a/GormCore/GormNSWindow.m b/GormCore/GormNSWindow.m index 489c17aa..deac66d6 100644 --- a/GormCore/GormNSWindow.m +++ b/GormCore/GormNSWindow.m @@ -138,9 +138,9 @@ static NSUInteger defaultStyleMask = NSTitledWindowMask | NSClosableWindowMask - (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (NSInteger)otherWin { - id document = [(id)NSApp documentForObject: self]; + id document = [(id)[NSApp delegate] documentForObject: self]; [super orderWindow: place relativeTo: otherWin]; - if([NSApp isConnecting] == NO) + if([[NSApp delegate] isConnecting] == NO) { id editor = [document editorForObject: self create: NO]; diff --git a/GormCore/GormObjectEditor.h b/GormCore/GormObjectEditor.h index 80358a94..656810f9 100644 --- a/GormCore/GormObjectEditor.h +++ b/GormCore/GormObjectEditor.h @@ -3,8 +3,8 @@ * Copyright (C) 1999, 2003 Free Software Foundation, Inc. * * Author: Richard Frith-Macdonald - * Author: Gregory John Casamento - * Date: 1999, 2003, 2004 + * Author: Gregory John Casamento + * Date: 1999, 2003, 2004, 2024 * * This file is part of GNUstep. * @@ -26,17 +26,29 @@ #ifndef INCLUDED_GormObjectEditor_h #define INCLUDED_GormObjectEditor_h -#include "GormGenericEditor.h" +#import "GormGenericEditor.h" + +@interface NSObject (GormObjectAdditions) + +- (NSImage *) imageForViewer; +- (NSString *) inspectorClassName; +- (NSString *) connectInspectorClassName; +- (NSString *) sizeInspectorClassName; +- (NSString *) helpInspectorClassName; +- (NSString *) classInspectorClassName; +- (NSString *) editorClassName; + +@end @interface GormObjectEditor : GormGenericEditor -{ -} + + (void) setEditor: (id)editor forDocument: (id)aDocument; -- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f; +- (void) draggedImage: (NSImage *)i endedAt: (NSPoint)p deposited: (BOOL)f; - (NSDragOperation) draggingSourceOperationMaskForLocal: (BOOL)flag; -- (BOOL) acceptsTypeFromArray: (NSArray*)types; +- (BOOL) acceptsTypeFromArray: (NSArray *)types; - (void) makeSelectionVisible: (BOOL)flag; - (void) resetObject: (id)anObject; + @end #endif diff --git a/GormCore/GormObjectEditor.m b/GormCore/GormObjectEditor.m index 4f4c5466..2a974f4b 100644 --- a/GormCore/GormObjectEditor.m +++ b/GormCore/GormObjectEditor.m @@ -24,31 +24,29 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#include +#import +#import -#include - -#include "GormPrivate.h" -#include "GormObjectEditor.h" -#include "GormFunctions.h" -#include "GormDocument.h" -#include "GormClassManager.h" +#import "GormPrivate.h" +#import "GormObjectEditor.h" +#import "GormFunctions.h" +#import "GormDocument.h" +#import "GormClassManager.h" +#import "GormAbstractDelegate.h" +@implementation NSObject (GormObjectAdditions) /* * Method to return the image that should be used to display objects within * the matrix containing the objects in a document. */ -@interface NSObject (GormObjectAdditions) -@end - -@implementation NSObject (GormObjectAdditions) - (NSImage*) imageForViewer { - static NSImage *image = nil; + static NSImage *image = nil; + GormAbstractDelegate *delegate = (GormAbstractDelegate *)[NSApp delegate]; - if (image == nil) + if (image == nil && [delegate isInTool] == NO) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path = [bundle pathForImageResource: @"GormUnknown"]; image = [[NSImage alloc] initWithContentsOfFile: path]; } @@ -85,6 +83,7 @@ { return @"GormObjectEditor"; } + @end @implementation NSView (GormObjectAdditions) @@ -104,7 +103,7 @@ static NSMapTable *docMap = 0; { docMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks, NSNonRetainedObjectMapValueCallBacks, - 2); + 2); } } @@ -126,7 +125,6 @@ static NSMapTable *docMap = 0; NSMapInsert(docMap, (void*)aDocument, (void*)editor); } - - (BOOL) acceptsTypeFromArray: (NSArray*)types { return ([[(GormDocument *)document allManagedPboardTypes] firstObjectCommonWithArray: types] != nil); @@ -252,7 +250,8 @@ static NSMapTable *docMap = 0; NSInteger r, c; int pos; id obj = nil; - + id delegate = [NSApp delegate]; + loc = [self convertPoint: loc fromView: nil]; [self getRow: &r column: &c forPoint: loc]; pos = r * [self numberOfColumns] + c; @@ -260,12 +259,12 @@ static NSMapTable *docMap = 0; { obj = [objects objectAtIndex: pos]; } - if (obj == [NSApp connectSource]) + if (obj == [delegate connectSource]) { return NSDragOperationNone; /* Can't drag an object onto itsself */ } - [NSApp displayConnectionBetween: [NSApp connectSource] and: obj]; + [delegate displayConnectionBetween: [delegate connectSource] and: obj]; if (obj != nil) { return NSDragOperationLink; @@ -467,10 +466,10 @@ static NSMapTable *docMap = 0; [pb declareTypes: [NSArray arrayWithObject: GormLinkPboardType] owner: self]; [pb setString: name forType: GormLinkPboardType]; - [NSApp displayConnectionBetween: obj and: nil]; - [NSApp startConnecting]; + [[NSApp delegate] displayConnectionBetween: obj and: nil]; + [[NSApp delegate] startConnecting]; - [self dragImage: [NSApp linkImage] + [self dragImage: [[NSApp delegate] linkImage] at: loc offset: NSZeroSize event: theEvent @@ -507,8 +506,8 @@ static NSMapTable *docMap = 0; } else { - [NSApp displayConnectionBetween: [NSApp connectSource] and: obj]; - [NSApp startConnecting]; + [[NSApp delegate] displayConnectionBetween: [NSApp connectSource] and: obj]; + [[NSApp delegate] startConnecting]; return YES; } } @@ -564,7 +563,7 @@ static NSMapTable *docMap = 0; - (void) resetObject: (id)anObject { NSString *name = [document nameForObject: anObject]; - GormInspectorsManager *mgr = [(id)NSApp inspectorsManager]; + GormInspectorsManager *mgr = [(id)[NSApp delegate] inspectorsManager]; if ([name isEqual: @"NSOwner"] == YES) { diff --git a/GormCore/GormObjectInspector.h b/GormCore/GormObjectInspector.h index 67325604..6e36ae55 100644 --- a/GormCore/GormObjectInspector.h +++ b/GormCore/GormObjectInspector.h @@ -27,6 +27,8 @@ #include "GormPrivate.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" static NSString *typeId = @"Object"; static NSString *typeChar = @"Character or Boolean"; static NSString *typeUChar = @"Unsigned character/bool"; @@ -34,7 +36,7 @@ static NSString *typeInt = @"Integer"; static NSString *typeUInt = @"Unsigned integer"; static NSString *typeFloat = @"Float"; static NSString *typeDouble = @"Double"; - +#pragma GCC diagnostic pop @interface GormObjectInspector : IBInspector { diff --git a/GormCore/GormObjectInspector.m b/GormCore/GormObjectInspector.m index 4d402b05..452e66af 100644 --- a/GormCore/GormObjectInspector.m +++ b/GormCore/GormObjectInspector.m @@ -31,26 +31,21 @@ self = [super init]; if (self != nil) { - if([NSBundle loadNibNamed: @"GormObjectInspector" owner: self] == NO) + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + + if([bundle loadNibNamed: @"GormObjectInspector" owner: self topLevelObjects: NULL] == NO) { NSLog(@"Couldn't load GormObjectInsector"); return nil; } - else - { - sets = [[NSMutableArray alloc] init]; - gets = [[NSMutableDictionary alloc] init]; - types = [[NSMutableDictionary alloc] init]; - okButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,90,20)]; - [okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin]; - [okButton setAction: @selector(ok:)]; - [okButton setTarget: self]; - [okButton setTitle: _(@"OK")]; - [okButton setEnabled: NO]; - - revertButton = nil; - } + sets = [[NSMutableArray alloc] init]; + gets = [[NSMutableDictionary alloc] init]; + types = [[NSMutableDictionary alloc] init]; + + [okButton setEnabled: NO]; + + revertButton = nil; } return self; } @@ -96,7 +91,6 @@ selectCellWithString: (NSString*)title RELEASE(gets); RELEASE(sets); RELEASE(types); - RELEASE(okButton); [super dealloc]; } @@ -197,7 +191,7 @@ selectCellWithString: (NSString*)title } else { - id o = [[(id)NSApp activeDocument] objectForName: v]; + id o = [[(id)[NSApp delegate] activeDocument] objectForName: v]; if (o != nil) { diff --git a/GormCore/GormObjectViewController.h b/GormCore/GormObjectViewController.h new file mode 100644 index 00000000..143e8d57 --- /dev/null +++ b/GormCore/GormObjectViewController.h @@ -0,0 +1,47 @@ +/* All rights reserved */ + +#ifndef GormObjectViewController_H_INCLUDE +#define GormObjectViewController_H_INCLUDE + +#import + +@class GormDocument; + +@interface GormObjectViewController : NSViewController +{ + IBOutlet id displayView; + IBOutlet id iconButton; + IBOutlet id outlineButton; + IBOutlet id editorButton; + + // Document + GormDocument *_document; + id _iconView; + id _outlineView; + + // Editor flag + BOOL _editor; +} + +- (GormDocument *) document; +- (void) setDocument: (GormDocument *)document; + +- (id) iconView; +- (void) setIconView: (id)iconView; + +- (id) outlineView; +- (void) setOutlineView: (id)outlineView; + +- (BOOL) editor; +- (void) setEditor: (BOOL)f; + +- (void) resetDisplayView: (NSView *)view; +- (void) reloadOutlineView; + +- (IBAction) iconView: (id)sender; +- (IBAction) outlineView: (id)sender; +- (IBAction) editorButton: (id)sender; + +@end + +#endif // GormObjectViewController_H_INCLUDE diff --git a/GormCore/GormObjectViewController.m b/GormCore/GormObjectViewController.m new file mode 100644 index 00000000..544bd397 --- /dev/null +++ b/GormCore/GormObjectViewController.m @@ -0,0 +1,113 @@ +/* All rights reserved */ + +#import "GormObjectViewController.h" +#import "GormDocument.h" +#import "GormObjectEditor.h" + +@implementation GormObjectViewController + +- (instancetype) init +{ + self = [super init]; + if (self != nil) + { + _document = nil; + _iconView = nil; + _outlineView = nil; + _editor = NO; + } + return self; +} + +- (void) dealloc +{ + RELEASE(_document); + RELEASE(_iconView); + RELEASE(_outlineView); + + [super dealloc]; +} + +- (GormDocument *) document +{ + return _document; +} + +- (void) setDocument: (GormDocument *)document +{ + ASSIGN(_document, document); +} + +- (id) iconView +{ + return _iconView; +} + +- (void) setIconView: (id)iconView +{ + ASSIGN(_iconView, iconView); +} + +- (id) outlineView +{ + return _outlineView; +} + +- (void) setOutlineView: (id)outlineView +{ + ASSIGN(_outlineView, outlineView); +} + +- (BOOL) editor +{ + return _editor; +} + +- (void) setEditor: (BOOL)f +{ + _editor = f; +} + +- (IBAction) iconView: (id)sender +{ + NSDebugLog(@"Called %@", NSStringFromSelector(_cmd)); + [self resetDisplayView: _iconView]; +} + +- (IBAction) outlineView: (id)sender +{ + NSDebugLog(@"Called %@", NSStringFromSelector(_cmd)); + [_document deactivateEditors]; + [[_outlineView documentView] reloadData]; + [_document reactivateEditors]; + [self resetDisplayView: _outlineView]; +} + +- (IBAction) editorButton: (id)sender +{ + _editor = !_editor; + [[_outlineView documentView] reloadData]; +} + +- (void) resetDisplayView: (NSView *)view +{ + [displayView setContentView: view]; + NSDebugLog(@"displayView = %@", view); +} + +- (void) reloadOutlineView +{ + if (_editor == NO) + { + [_document deactivateEditors]; + } + + [[_outlineView documentView] reloadData]; + + if (_editor == NO) + { + [_document reactivateEditors]; + } +} + +@end diff --git a/GormCore/GormOutlineView.m b/GormCore/GormOutlineView.m index 413e60d8..ef260cfd 100644 --- a/GormCore/GormOutlineView.m +++ b/GormCore/GormOutlineView.m @@ -81,16 +81,23 @@ static NSColor *darkGreyBlueColor = nil; { if (self == [GormOutlineView class]) { + NSBundle *bundle = [NSBundle bundleForClass: self]; + NSString *path = nil; + // initialize images [self setVersion: current_version]; nc = [NSNotificationCenter defaultCenter]; collapsed = [NSImage imageNamed: @"common_outlineCollapsed"]; expanded = [NSImage imageNamed: @"common_outlineExpanded"]; unexpandable = [NSImage imageNamed: @"common_outlineUnexpandable"]; - action = [NSImage imageNamed: @"GormAction"]; - outlet = [NSImage imageNamed: @"GormOutlet"]; - actionSelected = [NSImage imageNamed: @"GormActionSelected"]; - outletSelected = [NSImage imageNamed: @"GormOutletSelected"]; + path = [bundle pathForImageResource: @"GormAction"]; + action = [[NSImage alloc] initWithContentsOfFile: path]; + path = [bundle pathForImageResource: @"GormOutlet"]; + outlet = [[NSImage alloc] initWithContentsOfFile: path]; + path = [bundle pathForImageResource: @"GormActionSelected"]; + actionSelected = [[NSImage alloc] initWithContentsOfFile: path]; + path = [bundle pathForImageResource: @"GormOutletSelected"]; + outletSelected = [[NSImage alloc] initWithContentsOfFile: path]; // initialize colors salmonColor = diff --git a/GormCore/GormPalettesManager.m b/GormCore/GormPalettesManager.m index 326733d3..1bad7f6d 100644 --- a/GormCore/GormPalettesManager.m +++ b/GormCore/GormPalettesManager.m @@ -124,7 +124,7 @@ static NSImage *dragImage = nil; if (f == NO && ([type isEqual: IBWindowPboardType] == YES || [type isEqual: IBMenuPboardType] == YES)) { - id active = [(id)NSApp activeDocument]; + id active = [(id)[NSApp delegate] activeDocument]; if (active != nil) { @@ -185,7 +185,7 @@ static NSImage *dragImage = nil; NSPoint dragPoint = [theEvent locationInWindow]; NSWindow *w = [self window]; NSView *view; - GormDocument *active = (GormDocument *)[(id)NSApp activeDocument]; + GormDocument *active = (GormDocument *)[(id)[NSApp delegate] activeDocument]; NSRect rect; NSString *type; id obj; @@ -680,7 +680,7 @@ static NSImage *dragImage = nil; } else { - NSLog(@"Bad palette selection - %d", (int)[anObj selectedColumn]); + NSDebugLog(@"Bad palette selection - %d", (int)[anObj selectedColumn]); current = -1; } [dragView setNeedsDisplay: YES]; diff --git a/GormPrefs/GormPalettesPref.h b/GormCore/GormPalettesPref.h similarity index 100% rename from GormPrefs/GormPalettesPref.h rename to GormCore/GormPalettesPref.h diff --git a/GormPrefs/GormPalettesPref.m b/GormCore/GormPalettesPref.m similarity index 97% rename from GormPrefs/GormPalettesPref.m rename to GormCore/GormPalettesPref.m index 09dd9000..39b4a629 100644 --- a/GormPrefs/GormPalettesPref.m +++ b/GormCore/GormPalettesPref.m @@ -90,7 +90,7 @@ objectValueForTableColumn: (NSTableColumn *)tc - (void) addAction: (id)sender { - [[(id)NSApp palettesManager] openPalette: self]; + [[(id)[NSApp delegate] palettesManager] openPalette: self]; [table reloadData]; } diff --git a/GormCore/GormPlugin.m b/GormCore/GormPlugin.m index b83ba085..d89f0cd6 100644 --- a/GormCore/GormPlugin.m +++ b/GormCore/GormPlugin.m @@ -25,6 +25,7 @@ #include #include +#include @interface NSDocumentController (GormPrivate) - (NSArray *) types; @@ -78,7 +79,7 @@ static Ivar types_ivar(void) humanReadableName: (NSString *)hrName forExtensions: (NSArray *)extensions { - NSDocumentController *controller = [NSDocumentController sharedDocumentController]; + NSDocumentController *controller = [GormDocumentController sharedDocumentController]; NSMutableArray *types = [[controller types] mutableCopy]; if([controller containsDocumentTypeName: name] == NO) diff --git a/GormCore/GormPluginManager.m b/GormCore/GormPluginManager.m index aa9530ae..f8f62ee3 100644 --- a/GormCore/GormPluginManager.m +++ b/GormCore/GormPluginManager.m @@ -51,6 +51,7 @@ NSArray *array; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSArray *userPlugins = [defaults arrayForKey: USER_PLUGINS]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; self = [super init]; if (self == nil) @@ -65,8 +66,8 @@ plugins = [[NSMutableArray alloc] init]; pluginNames = [[NSMutableArray alloc] init]; - array = [[NSBundle mainBundle] pathsForResourcesOfType: @"plugin" - inDirectory: nil]; + array = [bundle pathsForResourcesOfType: @"plugin" + inDirectory: nil]; if ([array count] > 0) { unsigned index; diff --git a/GormPrefs/GormPluginsPref.h b/GormCore/GormPluginsPref.h similarity index 100% rename from GormPrefs/GormPluginsPref.h rename to GormCore/GormPluginsPref.h diff --git a/GormPrefs/GormPluginsPref.m b/GormCore/GormPluginsPref.m similarity index 97% rename from GormPrefs/GormPluginsPref.m rename to GormCore/GormPluginsPref.m index d63085c8..cea0146f 100644 --- a/GormPrefs/GormPluginsPref.m +++ b/GormCore/GormPluginsPref.m @@ -90,7 +90,7 @@ objectValueForTableColumn: (NSTableColumn *)tc - (void) addAction: (id)sender { - [[(id)NSApp pluginManager] openPlugin: self]; + [[(id)[NSApp delegate] pluginManager] openPlugin: self]; [table reloadData]; } diff --git a/GormPrefs/GormPrefController.h b/GormCore/GormPrefController.h similarity index 100% rename from GormPrefs/GormPrefController.h rename to GormCore/GormPrefController.h diff --git a/GormPrefs/GormPrefController.m b/GormCore/GormPrefController.m similarity index 100% rename from GormPrefs/GormPrefController.m rename to GormCore/GormPrefController.m diff --git a/GormPrefs/GormPrefs.h b/GormCore/GormPrefs.h similarity index 81% rename from GormPrefs/GormPrefs.h rename to GormCore/GormPrefs.h index f522d8c0..a4a95008 100644 --- a/GormPrefs/GormPrefs.h +++ b/GormCore/GormPrefs.h @@ -35,12 +35,12 @@ FOUNDATION_EXPORT const unsigned char GormPrefsVersionString[]; #ifndef INCLUDED_GORMPREFS_H #define INCLUDED_GORMPREFS_H -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #endif diff --git a/GormCore/GormPrivate.h b/GormCore/GormPrivate.h index 651996ba..f8a08bd4 100644 --- a/GormCore/GormPrivate.h +++ b/GormCore/GormPrivate.h @@ -39,6 +39,8 @@ #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattributes" extern NSString *GormLinkPboardType; extern NSString *GormToggleGuidelineNotification; extern NSString *GormDidModifyClassNotification; @@ -47,6 +49,7 @@ extern NSString *GormDidDeleteClassNotification; extern NSString *GormWillDetachObjectFromDocumentNotification; extern NSString *GormDidDetachObjectFromDocumentNotification; extern NSString *GormResizeCellNotification; +#pragma GCC diagnostic pop @class GormDocument; @class GormInspectorsManager; diff --git a/GormCore/GormPrivate.m b/GormCore/GormPrivate.m index e7532b41..bdd3b494 100644 --- a/GormCore/GormPrivate.m +++ b/GormCore/GormPrivate.m @@ -76,19 +76,10 @@ static BOOL _isInInterfaceBuilder = NO; @end @interface NSObject (GormPrivate) -// + (void) poseAsClass: (Class)aClassObject; + (BOOL) canSubstituteForClass: (Class)origClass; @end @implementation NSObject (GormPrivate) -/* -+ (void) poseAsClass: (Class)aClassObject -{ - // disable poseAs: while in Gorm. - class_pose_as(self, aClassObject); - NSLog(@"WARNING: poseAs: called in Gorm."); -} -*/ + (BOOL) canSubstituteForClass: (Class)origClass { @@ -113,6 +104,7 @@ static BOOL _isInInterfaceBuilder = NO; return NO; } + @end @implementation GormObjectProxy @@ -214,7 +206,7 @@ static BOOL _isInInterfaceBuilder = NO; NSImage *image = [super imageForViewer]; if([theClass isEqual: @"NSFontManager"]) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *path = [bundle pathForImageResource: @"GormFontManager"]; image = [[NSImage alloc] initWithContentsOfFile: path]; } diff --git a/GormCore/GormProtocol.h b/GormCore/GormProtocol.h index 1dac7e7f..7df925dd 100644 --- a/GormCore/GormProtocol.h +++ b/GormCore/GormProtocol.h @@ -27,9 +27,16 @@ #include -@class GormClassManager, GormPalettesManager, GormInspectorsManager, NSString, NSMenu, GormPluginManager; +@class GormClassManager; +@class GormInspectorsManager; +@class GormPalettesManager; +@class GormPluginManager; + +@class NSMenu; +@class NSString; + +@protocol GormAppDelegate -@protocol Gorm // Connections - (id) connectSource; - (id) connectDestination; @@ -37,43 +44,28 @@ - (BOOL) isConnecting; - (void) stopConnecting; -// preferences -- (void) preferencesPanel: (id) sender; - -// Cut/Paste operations -- (void) copy: (id)sender; -- (void) cut: (id)sender; -- (void) paste: (id)sender; -- (void) delete: (id)sender; -- (void) selectAllItems: (id)sender; -- (void) setName: (id)sender; - -// palettes/inspectors. -- (void) inspector: (id) sender; -- (void) palettes: (id) sender; -- (void) loadPalette: (id) sender; - (GormPalettesManager*) palettesManager; - (GormInspectorsManager*) inspectorsManager; - (GormPluginManager*) pluginManager; -// testing the interface -- (void) testInterface: (id)sender; -- (id) endTesting: (id)sender; - -// sound & images -- (void) loadSound: (id) sender; -- (void) loadImage: (id) sender; - -// grouping/layout -- (void) groupSelectionInSplitView: (id)sender; -- (void) groupSelectionInBox: (id)sender; -- (void) groupSelectionInScrollView: (id)sender; -- (void) ungroup: (id)sender; - // added for classes support - (GormClassManager*) classManager; - (NSMenu*) classMenu; +// Check if we are in the app or the tool +- (BOOL) isInTool; + +// Delegate methods to handle issues that may occur +- (BOOL) shouldUpgradeOlderArchive; +- (BOOL) shouldLoadNewerArchive; +- (BOOL) shouldBreakConnectionsForClassNamed: (NSString *)className; +- (BOOL) shouldRenameConnectionsForClassNamed: (NSString *)className toClassName: (NSString *)newName; +- (BOOL) shouldBreakConnectionsModifyingLabel: (NSString *)name isAction: (BOOL)action prompted: (BOOL)prompted; +- (void) couldNotParseClassAtPath: (NSString *)path; +- (void) exceptionWhileParsingClass: (NSException *)localException; +- (BOOL) shouldBreakConnectionsReparsingClass: (NSString *)className; +- (void) exceptionWhileLoadingModel: (NSString *)errorMessage; + @end #endif diff --git a/GormCore/GormResource.m b/GormCore/GormResource.m index d20ae132..dd8977ad 100644 --- a/GormCore/GormResource.m +++ b/GormCore/GormResource.m @@ -53,7 +53,7 @@ { if((self = [self init])) { - ASSIGN(path, nil); + path = nil; ASSIGN(fileName, aFileName); ASSIGN(name, [fileName stringByDeletingPathExtension]); ASSIGN(fileType, [fileName pathExtension]); diff --git a/GormCore/GormResourceEditor.m b/GormCore/GormResourceEditor.m index a70f3938..6fdc63cd 100644 --- a/GormCore/GormResourceEditor.m +++ b/GormCore/GormResourceEditor.m @@ -31,6 +31,29 @@ #include "GormPalettesManager.h" #include "GormResource.h" +@interface NSMatrix (GormResourceEditorPrivate) +- (BOOL **) _selectedCells; +- (id **) _cells; +- (void) _setSelectedCell: (id)c; +@end + +@implementation NSMatrix (GormResourceEditorPrivate) +- (BOOL **) _selectedCells +{ + return _selectedCells; +} + +- (id **) _cells +{ + return _cells; +} + +- (void) _setSelectedCell: (id)c +{ + _selectedCell = c; +} +@end + @implementation GormResourceEditor - (BOOL) acceptsTypeFromArray: (NSArray*)types @@ -197,7 +220,9 @@ NSPoint lastLocation = [theEvent locationInWindow]; NSEvent* lastEvent = theEvent; NSPoint initialLocation; - + BOOL **selectedCells = [self _selectedCells]; + id selectedCell = [self selectedCell]; + /* * Pathological case -- ignore mouse down */ @@ -219,17 +244,17 @@ { if ((_mode == NSRadioModeMatrix) && _selectedCell != nil) { - [_selectedCell setState: NSOffState]; + [selectedCell setState: NSOffState]; [self drawCellAtRow: _selectedRow column: _selectedColumn]; - _selectedCells[_selectedRow][_selectedColumn] = NO; - _selectedCell = nil; + selectedCells[_selectedRow][_selectedColumn] = NO; + selectedCell = nil; _selectedRow = _selectedColumn = -1; } [_cells[row][column] setState: NSOnState]; [self drawCellAtRow: row column: column]; [_window flushWindow]; - _selectedCells[row][column] = YES; - _selectedCell = _cells[row][column]; + selectedCells[row][column] = YES; + [self _setSelectedCell: _cells[row][column]]; _selectedRow = row; _selectedColumn = column; } diff --git a/GormCore/GormScrollViewAttributesInspector.m b/GormCore/GormScrollViewAttributesInspector.m index 0415b36a..cb647357 100644 --- a/GormCore/GormScrollViewAttributesInspector.m +++ b/GormCore/GormScrollViewAttributesInspector.m @@ -36,22 +36,15 @@ self = [super init]; if (self != nil) { - if ([NSBundle loadNibNamed: @"GormScrollViewAttributesInspector" - owner: self] == NO) + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + + if ([bundle loadNibNamed: @"GormScrollViewAttributesInspector" + owner: self + topLevelObjects: NULL] == NO) { - - NSDictionary *table; - NSBundle *bundle; - table = [NSDictionary dictionaryWithObject: self forKey: @"NSOwner"]; - bundle = [NSBundle mainBundle]; - if ([bundle loadNibFile: @"GormScrollViewAttributesInspector" - externalNameTable: table - withZone: [self zone]] == NO) - { - NSLog(@"Could not open gorm GormScrollViewAttributesInspector"); - NSLog(@"self %@", self); - return nil; - } + NSLog(@"Could not open gorm GormScrollViewAttributesInspector"); + NSLog(@"self %@", self); + return nil; } } diff --git a/GormCore/GormSetNameController.m b/GormCore/GormSetNameController.m index 2adece0a..58b87e51 100644 --- a/GormCore/GormSetNameController.m +++ b/GormCore/GormSetNameController.m @@ -12,7 +12,9 @@ if (!window) { - if (![NSBundle loadNibNamed: @"GormSetName" owner: self]) + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + + if (![bundle loadNibNamed: @"GormSetName" owner: self topLevelObjects: NULL]) { return NSAlertAlternateReturn; } diff --git a/GormPrefs/GormShelfPref.h b/GormCore/GormShelfPref.h similarity index 100% rename from GormPrefs/GormShelfPref.h rename to GormCore/GormShelfPref.h diff --git a/GormPrefs/GormShelfPref.m b/GormCore/GormShelfPref.m similarity index 100% rename from GormPrefs/GormShelfPref.m rename to GormCore/GormShelfPref.m diff --git a/GormCore/GormSound.m b/GormCore/GormSound.m index f988fb50..0a371a00 100644 --- a/GormCore/GormSound.m +++ b/GormCore/GormSound.m @@ -97,7 +97,7 @@ if (image == nil) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; NSString *bpath = [bundle pathForImageResource: @"GormSound"]; image = [[NSImage alloc] initWithContentsOfFile: bpath]; diff --git a/GormCore/GormSoundEditor.m b/GormCore/GormSoundEditor.m index 73648d0a..bcfe5981 100644 --- a/GormCore/GormSoundEditor.m +++ b/GormCore/GormSoundEditor.m @@ -80,7 +80,7 @@ static NSMapTable *docMap = 0; NSMutableArray *list = [NSMutableArray array]; NSEnumerator *en; id obj; - GormPalettesManager *palettesManager = [(id)NSApp palettesManager]; + GormPalettesManager *palettesManager = [(id)[NSApp delegate] palettesManager]; // add all of the system objects... [list addObjectsFromArray: systemSoundsList()]; diff --git a/GormCore/GormSoundInspector.m b/GormCore/GormSoundInspector.m index 3e2610cc..4aa9df47 100644 --- a/GormCore/GormSoundInspector.m +++ b/GormCore/GormSoundInspector.m @@ -50,9 +50,12 @@ self = [super init]; if (self != nil) { + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + // load the gui... - if (![NSBundle loadNibNamed: @"GormSoundInspector" - owner: self]) + if (![bundle loadNibNamed: @"GormSoundInspector" + owner: self + topLevelObjects: NULL]) { NSLog(@"Could not open gorm GormSoundInspector"); return nil; diff --git a/GormCore/GormSplitViewEditor.m b/GormCore/GormSplitViewEditor.m index 02b084a8..60efe908 100644 --- a/GormCore/GormSplitViewEditor.m +++ b/GormCore/GormSplitViewEditor.m @@ -126,12 +126,13 @@ { NSPasteboard *dragPb; NSArray *types; + id delegate = [NSApp delegate]; dragPb = [sender draggingPasteboard]; types = [dragPb types]; if ([types containsObject: GormLinkPboardType] == YES) { - [NSApp displayConnectionBetween: [NSApp connectSource] + [delegate displayConnectionBetween: [delegate connectSource] and: _EO]; return NSDragOperationLink; } @@ -170,12 +171,13 @@ { NSPasteboard *dragPb; NSArray *types; + id delegate = [NSApp delegate]; dragPb = [sender draggingPasteboard]; types = [dragPb types]; if ([types containsObject: GormLinkPboardType] == YES) { - [NSApp displayConnectionBetween: [NSApp connectSource] + [delegate displayConnectionBetween: [delegate connectSource] and: _EO]; return NSDragOperationLink; } @@ -193,15 +195,16 @@ { NSPasteboard *dragPb; NSArray *types; + id delegate = [NSApp delegate]; dragPb = [sender draggingPasteboard]; types = [dragPb types]; if ([types containsObject: GormLinkPboardType]) { - [NSApp displayConnectionBetween: [NSApp connectSource] + [delegate displayConnectionBetween: [delegate connectSource] and: _EO]; - [NSApp startConnecting]; + [delegate startConnecting]; } else if ([types containsObject: IBViewPboardType] == YES) { diff --git a/GormCore/GormViewEditor.m b/GormCore/GormViewEditor.m index a86c3b8e..749e2f37 100644 --- a/GormCore/GormViewEditor.m +++ b/GormCore/GormViewEditor.m @@ -1205,6 +1205,7 @@ static BOOL currently_displaying = NO; NSPasteboard *pb; NSString *name = [document nameForObject: anObject]; NSPoint dragPoint = [theEvent locationInWindow]; + id delegate = [NSApp delegate]; if(name != nil) { @@ -1212,10 +1213,10 @@ static BOOL currently_displaying = NO; [pb declareTypes: [NSArray arrayWithObject: GormLinkPboardType] owner: self]; [pb setString: name forType: GormLinkPboardType]; - [NSApp displayConnectionBetween: anObject and: nil]; - [NSApp startConnecting]; + [delegate displayConnectionBetween: anObject and: nil]; + [delegate startConnecting]; - [self dragImage: [NSApp linkImage] + [self dragImage: [delegate linkImage] at: dragPoint offset: NSZeroSize event: theEvent @@ -1229,13 +1230,14 @@ static BOOL currently_displaying = NO; { NSPasteboard *dragPb; NSArray *types; + id delegate = [NSApp delegate]; dragPb = [sender draggingPasteboard]; types = [dragPb types]; if ([types containsObject: GormLinkPboardType] == YES) { - [NSApp displayConnectionBetween: [NSApp connectSource] - and: _editedObject]; + [delegate displayConnectionBetween: [delegate connectSource] + and: _editedObject]; return NSDragOperationLink; } else if ([types firstObjectCommonWithArray: [NSView acceptedViewResourcePasteboardTypes]] != nil) @@ -1258,13 +1260,14 @@ static BOOL currently_displaying = NO; { NSPasteboard *dragPb; NSArray *types; - + id delegate = [NSApp delegate]; + dragPb = [sender draggingPasteboard]; types = [dragPb types]; if ([types containsObject: GormLinkPboardType] == YES) { - [NSApp displayConnectionBetween: [NSApp connectSource] - and: nil]; + [delegate displayConnectionBetween: [delegate connectSource] + and: nil]; } } @@ -1359,32 +1362,34 @@ static BOOL currently_displaying = NO; { NSPasteboard *dragPb; NSArray *types; - id delegate = nil; NSPoint point = [sender draggingLocation]; - + id delegate = [NSApp delegate]; + id viewDelegate = nil; + dragPb = [sender draggingPasteboard]; types = [dragPb types]; if ([types containsObject: GormLinkPboardType]) { - [NSApp displayConnectionBetween: [NSApp connectSource] - and: _editedObject]; - [NSApp startConnecting]; + [delegate displayConnectionBetween: [delegate connectSource] + and: _editedObject]; + [delegate startConnecting]; } - else if ((delegate = [self _selectDelegate: sender]) != nil) + else if ((viewDelegate = [self _selectDelegate: sender]) != nil) { - if([delegate respondsToSelector: @selector(shouldDrawConnectionFrame)]) + if([viewDelegate respondsToSelector: @selector(shouldDrawConnectionFrame)]) { - if([delegate shouldDrawConnectionFrame]) + if([viewDelegate shouldDrawConnectionFrame]) { - [NSApp displayConnectionBetween: [NSApp connectSource] - and: _editedObject]; + [delegate displayConnectionBetween: [delegate connectSource] + and: _editedObject]; } } - if([delegate respondsToSelector: @selector(depositViewResourceFromPasteboard:onObject:atPoint:)]) + if([viewDelegate respondsToSelector: + @selector(depositViewResourceFromPasteboard:onObject:atPoint:)]) { - [delegate depositViewResourceFromPasteboard: dragPb + [viewDelegate depositViewResourceFromPasteboard: dragPb onObject: _editedObject atPoint: point]; @@ -1442,9 +1447,14 @@ static BOOL currently_displaying = NO; - (void) postDraw: (NSRect) rect { - if ([parent respondsToSelector: @selector(postDrawForView:)]) - [parent performSelector: @selector(postDrawForView:) - withObject: self]; + if (parent != nil) + { + if ([parent respondsToSelector: @selector(postDrawForView:)]) + { + [parent performSelector: @selector(postDrawForView:) + withObject: self]; + } + } } - (void) drawRect: (NSRect) rect diff --git a/GormCore/GormViewSizeInspector.m b/GormCore/GormViewSizeInspector.m index 9d60d4dd..253c8672 100644 --- a/GormCore/GormViewSizeInspector.m +++ b/GormCore/GormViewSizeInspector.m @@ -44,7 +44,7 @@ NSImage *mVLine = nil; { if (self == [GormViewSizeInspector class]) { - NSBundle *bundle = [NSBundle mainBundle]; + NSBundle *bundle = [NSBundle bundleForClass: self]; NSString *path; path = [bundle pathForImageResource: @"GormEHCoil"]; @@ -78,25 +78,14 @@ NSImage *mVLine = nil; self = [super init]; if (self != nil) { - if ([NSBundle loadNibNamed: @"GormViewSizeInspector" - owner: self] == NO) + NSBundle *bundle = [NSBundle bundleForClass: [self class]]; + if ([bundle loadNibNamed: @"GormViewSizeInspector" + owner: self + topLevelObjects: NULL] == NO) { - - NSDictionary *table; - NSBundle *bundle; - - table = [NSDictionary dictionaryWithObject: self - forKey: @"NSOwner"]; - bundle = [NSBundle mainBundle]; - - if ( [bundle loadNibFile: @"GormViewSizeInspector" - externalNameTable: table - withZone: [self zone]] == NO) - { - NSLog(@"Could not open gorm GormViewSizeInspector"); - NSLog(@"self %@", self); - return nil; - } + NSLog(@"Could not open gorm GormViewSizeInspector"); + NSLog(@"self %@", self); + return nil; } // set the tags... @@ -126,7 +115,7 @@ NSImage *mVLine = nil; { if (control == sizeForm) { - id document = [(id)NSApp activeDocument]; + id document = [(id)[NSApp delegate] activeDocument]; NSRect rect; // Update the document as edited... @@ -163,16 +152,7 @@ NSImage *mVLine = nil; if (anObject != object) return; - /* - if([[anObject window] isKindOfClass: [GormViewWindow class]]) - { - [sizeForm setEnabled: NO]; - } - else - */ - { - [sizeForm setEnabled: YES]; - } + [sizeForm setEnabled: YES]; // stop editing so that the new values can be populated. [sizeForm abortEditing]; @@ -201,7 +181,7 @@ NSImage *mVLine = nil; - (void) setAutosize: (id)sender { unsigned mask = [sender tag]; - id document = [(id)NSApp activeDocument]; + id document = [(id)[NSApp delegate] activeDocument]; [document touch]; if ([sender state] == NSOnState) { diff --git a/GormCore/GormViewWindow.m b/GormCore/GormViewWindow.m index 715f7355..00cb1dee 100644 --- a/GormCore/GormViewWindow.m +++ b/GormCore/GormViewWindow.m @@ -138,7 +138,7 @@ if((self = [super init]) != nil) { NSString *className = NSStringFromClass([view class]); - NSString *objectName = [[(id)NSApp activeDocument] nameForObject: view]; + NSString *objectName = [[(id)[NSApp delegate] activeDocument] nameForObject: view]; NSString *title = [NSString stringWithFormat: @"Standalone View Window: (%@, %@)", className, objectName]; NSColor *color = [NSColor lightGrayColor]; @@ -173,7 +173,7 @@ - (void) activateEditorForView { - id editor = [[(id)NSApp activeDocument] editorForObject: _view create: YES]; + id editor = [[(id)[NSApp delegate] activeDocument] editorForObject: _view create: YES]; // NSArray *subviews = [_view subviews]; // NSEnumerator *en = [subviews objectEnumerator]; // id sub = nil; @@ -183,7 +183,7 @@ /* while((sub = [en nextObject]) != nil) { - editor = [[(id)NSApp activeDocument] editorForObject: sub create: YES]; + editor = [[(id)[NSApp delegate] activeDocument] editorForObject: sub create: YES]; [editor activate]; } */ diff --git a/GormCore/GormWindowEditor.m b/GormCore/GormWindowEditor.m index 5c708bcd..9ee4004d 100644 --- a/GormCore/GormWindowEditor.m +++ b/GormCore/GormWindowEditor.m @@ -211,7 +211,7 @@ [[NSNotificationCenter defaultCenter] removeObserver: self]; [self makeSelectionVisible: NO]; - if ([(id)NSApp selectionOwner] == self) + if ([(id)[NSApp delegate] selectionOwner] == self) { [document resignSelectionForEditor: self]; } diff --git a/GormCore/GormXLIFFDocument.h b/GormCore/GormXLIFFDocument.h new file mode 100644 index 00000000..1d01a6f4 --- /dev/null +++ b/GormCore/GormXLIFFDocument.h @@ -0,0 +1,75 @@ +/* GormXLIFFDocument.h + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + */ + +#ifndef GormXLIFFDocument_H_INCLUDE +#define GormXLIFFDocument_H_INCLUDE + +#import + +@class NSMutableDictionary; +@class NSString; +@class NSXMLDocument; +@class GormDocument; + +@interface GormXLIFFDocument : NSObject +{ + GormDocument *_gormDocument; + + NSString *_objectId; + NSString *_targetString; + NSString *_sourceString; + NSMutableDictionary *_translationDictionary; + + BOOL _source; + BOOL _target; + +} + +/** + * Returns an autoreleased GormXLIFFDocument object; + */ ++ (instancetype) xliffWithGormDocument: (GormDocument *)doc; + +/** + * Initialize with GormDocument object to parse the XML from or into. + */ +- (instancetype) initWithGormDocument: (GormDocument *)doc; + +/** + * Exports XLIFF file for CAT. This method starts the process and calls + * another method that recurses through the objects in the model and pulls + * any translatable elements. + */ +- (BOOL) exportXLIFFDocumentWithName: (NSString *)name + withSourceLanguage: (NSString *)slang + andTargetLanguage: (NSString *)tlang; + +/** + * Import XLIFF Document withthe name filename + */ +- (BOOL) importXLIFFDocumentWithName: (NSString *)filename; + +@end + +#endif // GormXLIFFDocument_H_INCLUDE diff --git a/GormCore/GormXLIFFDocument.m b/GormCore/GormXLIFFDocument.m new file mode 100644 index 00000000..9b80314a --- /dev/null +++ b/GormCore/GormXLIFFDocument.m @@ -0,0 +1,427 @@ +/* GormXLIFFDocument.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + */ + +#import +#import +#import +#import +#import +#import +#import + +#import +#import +#import + +#import "GormDocument.h" +#import "GormDocumentController.h" +#import "GormFilePrefsManager.h" +#import "GormProtocol.h" +#import "GormPrivate.h" +#import "GormXLIFFDocument.h" + +@implementation GormXLIFFDocument + +/** + * Returns an autoreleast GormXLIFFDocument object; + */ ++ (instancetype) xliffWithGormDocument: (GormDocument *)doc +{ + return AUTORELEASE([[self alloc] initWithGormDocument: doc]); +} + +/** + * Initialize with GormDocument object to parse the XML from or into. + */ +- (instancetype) initWithGormDocument: (GormDocument *)doc +{ + self = [super init]; + if (self != nil) + { + ASSIGN(_gormDocument, doc); + + _objectId = nil; + _source = NO; + _target = NO; + _sourceString = nil; + _targetString = nil; + _translationDictionary = [[NSMutableDictionary alloc] init]; + } + return self; +} + +- (void) dealloc +{ + DESTROY(_gormDocument); + _objectId = nil; + _sourceString = nil; + _targetString = nil; + DESTROY(_translationDictionary); + + [super dealloc]; +} + +- (void) _collectObjectsFromObject: (id)obj + withNode: (NSXMLElement *)node +{ + NSString *name = [_gormDocument nameForObject: obj]; + + if (name != nil) + { + NSString *className = NSStringFromClass([obj class]); + NSXMLElement *group = [NSXMLNode elementWithName: @"group"]; + NSXMLNode *attr = [NSXMLNode attributeWithName: @"ib:object-id" stringValue: name]; + + [group addAttribute: attr]; + if ([obj isKindOfClass: [GormObjectProxy class]] || + [obj respondsToSelector: @selector(className)]) + { + className = [obj className]; + } + + attr = [NSXMLNode attributeWithName: @"ib:class" stringValue: className]; + [group addAttribute: attr]; + [node addChild: group]; + + // If the object responds to "title" get that and add it to the XML + if ([obj respondsToSelector: @selector(title)]) + { + NSString *title = [obj title]; + if (title != nil) + { + NSXMLElement *transunit = [NSXMLNode elementWithName: @"trans-unit"]; + NSString *objId = [NSString stringWithFormat: @"%@.title", name]; + + attr = [NSXMLNode attributeWithName: @"ib:key-path-category" + stringValue: @"string"]; + [transunit addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"ib:key-path" stringValue: @"title"]; + [transunit addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"id" stringValue: objId]; + [transunit addAttribute: attr]; + [group addChild: transunit]; + + NSXMLElement *source = [NSXMLNode elementWithName: @"source"]; + [source setStringValue: title]; + [transunit addChild: source]; + } + } + + // For each different class, recurse through the structure as needed. + if ([obj isKindOfClass: [NSMenu class]] || + [obj isKindOfClass: [NSPopUpButton class]]) + { + NSArray *items = [obj itemArray]; + NSEnumerator *en = [items objectEnumerator]; + id item = nil; + while ((item = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: item + withNode: group]; + } + } + else if ([obj isKindOfClass: [NSMenuItem class]]) + { + NSMenu *sm = [obj submenu]; + if (sm != nil) + { + [self _collectObjectsFromObject: sm + withNode: group]; + } + } + else if ([obj isKindOfClass: [NSWindow class]]) + { + [self _collectObjectsFromObject: [obj contentView] + withNode: group]; + } + else if ([obj isKindOfClass: [NSView class]]) + { + NSArray *subviews = [obj subviews]; + NSEnumerator *en = [subviews objectEnumerator]; + id v = nil; + + while ((v = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: v + withNode: group]; + } + } + } +} + +- (void) _buildXLIFFDocumentWithParentNode: (NSXMLElement *)parentNode +{ + NSEnumerator *en = [[_gormDocument topLevelObjects] objectEnumerator]; + id o = nil; + + [_gormDocument deactivateEditors]; + while ((o = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: o + withNode: parentNode]; + } + [_gormDocument reactivateEditors]; +} + +/** + * Exports XLIFF file for CAT. This method starts the process and calls + * another method that recurses through the objects in the model and pulls + * any translatable elements. + */ +- (BOOL) exportXLIFFDocumentWithName: (NSString *)name + withSourceLanguage: (NSString *)slang + andTargetLanguage: (NSString *)tlang +{ + BOOL result = NO; + id delegate = [NSApp delegate]; + + if (slang != nil) + { + NSString *toolId = @"gnu.gnustep.Gorm"; + NSString *toolName = @"Gorm"; + NSString *toolVersion = [NSString stringWithFormat: @"%d", [GormFilePrefsManager currentVersion]]; + + if ([delegate isInTool]) + { + toolName = @"gormtool"; + toolId = @"gnu.gnustep.gormtool"; + } + + // Build root element... + NSXMLElement *rootElement = [NSXMLNode elementWithName: @"xliff"]; + NSXMLNode *attr = [NSXMLNode attributeWithName: @"xmlns" + stringValue: @"urn:oasis:names:tc:xliff:document:1.2"]; + [rootElement addAttribute: attr]; + NSXMLNode *xsi_ns = [NSXMLNode namespaceWithName: @"xsi" + stringValue: @"http://www.w3.org/2001/XMLSchema-instance"]; + [rootElement addNamespace: xsi_ns]; + NSXMLNode *ib_ns = [NSXMLNode namespaceWithName: @"ib" + stringValue: @"com.apple.InterfaceBuilder3"]; + [rootElement addNamespace: ib_ns]; + + attr = [NSXMLNode attributeWithName: @"version" stringValue: @"1.2"]; + [rootElement addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"xsi:schemaLocation" + stringValue: @"urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd"]; + [rootElement addAttribute: attr]; + + // Build header... + NSXMLElement *header = [NSXMLNode elementWithName: @"header"]; + NSXMLElement *tool = [NSXMLNode elementWithName: @"tool"]; + attr = [NSXMLNode attributeWithName: @"tool-id" stringValue: toolId]; + [tool addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"tool-name" stringValue: toolName]; + [tool addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"tool-version" stringValue: toolVersion]; + [tool addAttribute: attr]; + [header addChild: tool]; + + // Build "file" element... + NSString *filename = [[_gormDocument fileName] lastPathComponent]; + NSXMLElement *file = [NSXMLNode elementWithName: @"file"]; + GormDocumentController *dc = [GormDocumentController sharedDocumentController]; + NSString *type = [dc typeFromFileExtension: [filename pathExtension]]; + + attr = [NSXMLNode attributeWithName: @"original" stringValue: filename]; + [file addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"datatype" stringValue: type]; // we will have the plugin return a datatype... + [file addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"tool-id" stringValue: toolId]; + [file addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"source-language" stringValue: slang]; + [file addAttribute: attr]; + if (tlang != nil) + { + attr = [NSXMLNode attributeWithName: @"target-language" stringValue: tlang]; + [file addAttribute: attr]; + } + [rootElement addChild: file]; + + // Set up document... + NSXMLDocument *xliffDocument = [NSXMLNode documentWithRootElement: rootElement]; + [file addChild: header]; + + NSXMLElement *body = [NSXMLNode elementWithName: @"body"]; + NSXMLElement *group = [NSXMLNode elementWithName: @"group"]; + attr = [NSXMLNode attributeWithName: @"ib_member-type" stringValue: @"objects"]; // not sure why generates ib_1 when using a colon + [group addAttribute: attr]; + [body addChild: group]; + + // add body to document... + [file addChild: body]; + + // Recursively build the XLIFF document from the GormDocument... + [self _buildXLIFFDocumentWithParentNode: group]; + + NSData *data = [xliffDocument XMLDataWithOptions: NSXMLNodePrettyPrint | NSXMLNodeCompactEmptyElement ]; + NSString *xmlString = [[NSString alloc] initWithBytes: [data bytes] length: [data length] encoding: NSUTF8StringEncoding]; + NSString *fixedString = [xmlString stringByReplacingOccurrencesOfString: @"ib_member-type" + withString: @"ib:member-type"]; + + // "fixedString" corrects a rather confusing problem where adding the + // ib:member-type attribute, for some reason causes the NSXMLNode to + // create a repeated declaration of the "ib" namespace. I don't understand + // why this is happening, but this fixes it in the output for now. + + AUTORELEASE(xmlString); + result = [fixedString writeToFile: name atomically: YES]; + } + else + { + NSLog(@"Source language not specified"); + } + + return result; +} + +- (void) parserDidStartDocument: (NSXMLParser *)parser +{ + NSDebugLog(@"start of document"); +} + +- (void) parser: (NSXMLParser *)parser +didStartElement: (NSString *)elementName + namespaceURI: (NSString *)namespaceURI + qualifiedName: (NSString *)qName + attributes: (NSDictionary *)attrs +{ + NSDebugLog(@"start element %@", elementName); + if ([elementName isEqualToString: @"trans-unit"]) + { + NSString *objId = [attrs objectForKey: @"id"]; + _objectId = objId; + } + else if ([elementName isEqualToString: @"source"]) + { + _source = YES; + } + else if ([elementName isEqualToString: @"target"]) + { + _target = YES; + } +} + +- (void) parser: (NSXMLParser *)parser +foundCharacters: (NSString *)string +{ + if (_objectId != nil) + { + if (_source) + { + NSDebugLog(@"Found source string %@, current id = %@", string, _objectId); + } + + if (_target) + { + [_translationDictionary setObject: string forKey: _objectId]; + + NSDebugLog(@"Found target string %@, current id = %@", string, _objectId); + } + } +} + +- (void) parser: (NSXMLParser *)parser + didEndElement: (NSString *)elementName + namespaceURI: (NSString *)namespaceURI + qualifiedName: (NSString *)qName +{ + NSDebugLog(@"end element %@", elementName); + if ([elementName isEqualToString: @"trans-unit"]) + { + _objectId = nil; + } + else if ([elementName isEqualToString: @"source"]) + { + _source = NO; + } + else if ([elementName isEqualToString: @"target"]) + { + _target = NO; + } +} + +- (void) parserDidEndDocument: (NSXMLParser *)parser +{ + NSDebugLog(@"end of document"); +} + +/** + * Import XLIFF Document withthe name filename + */ +- (BOOL) importXLIFFDocumentWithName: (NSString *)filename +{ + NSData *xmlData = [NSData dataWithContentsOfFile: filename]; + NSXMLParser *xmlParser = + [[NSXMLParser alloc] initWithData: xmlData]; + BOOL result = NO; + + [xmlParser setDelegate: self]; + [xmlParser parse]; + + if ([_translationDictionary count] > 0) + { + NSEnumerator *en = [_translationDictionary keyEnumerator]; + NSString *oid = nil; + + while ((oid = [en nextObject]) != nil) + { + NSString *target = [_translationDictionary objectForKey: oid]; + NSArray *c = [oid componentsSeparatedByString: @"."]; + + if ([c count] == 2) + { + NSString *nm = [c objectAtIndex: 0]; + NSString *kp = [c objectAtIndex: 1]; + id o = nil; + NSString *capName = [kp capitalizedString]; + NSString *selName = [NSString stringWithFormat: @"set%@:", capName]; + SEL _sel = NSSelectorFromString(selName); + + NSDebugLog(@"computed selector name = %@", selName); + + // Pull the object that we want to translate and apply the target translation... + o = [_gormDocument objectForName: nm]; + if ([o respondsToSelector: _sel]) + { + NSDebugLog(@"performing %@, with object: %@", selName, target); + [o performSelector: _sel withObject: target]; + } + } + NSDebugLog(@"target = %@, oid = %@", target, oid); + } + + result = YES; + } + else + { + NSLog(@"Document contains no target translation elements"); + } + + + RELEASE(xmlParser); + + return result; +} + +@end diff --git a/Images/GormAction.tiff b/GormCore/Images/GormAction.tiff similarity index 100% rename from Images/GormAction.tiff rename to GormCore/Images/GormAction.tiff diff --git a/Images/GormActionSelected.tiff b/GormCore/Images/GormActionSelected.tiff similarity index 100% rename from Images/GormActionSelected.tiff rename to GormCore/Images/GormActionSelected.tiff diff --git a/Images/GormClass.tiff b/GormCore/Images/GormClass.tiff similarity index 100% rename from Images/GormClass.tiff rename to GormCore/Images/GormClass.tiff diff --git a/Images/GormCopyImage.tiff b/GormCore/Images/GormCopyImage.tiff similarity index 100% rename from Images/GormCopyImage.tiff rename to GormCore/Images/GormCopyImage.tiff diff --git a/GormCore/Images/GormEHCoil.tiff b/GormCore/Images/GormEHCoil.tiff new file mode 100644 index 00000000..79095028 Binary files /dev/null and b/GormCore/Images/GormEHCoil.tiff differ diff --git a/GormCore/Images/GormEHLine.tiff b/GormCore/Images/GormEHLine.tiff new file mode 100644 index 00000000..ee173948 Binary files /dev/null and b/GormCore/Images/GormEHLine.tiff differ diff --git a/GormCore/Images/GormEVCoil.tiff b/GormCore/Images/GormEVCoil.tiff new file mode 100644 index 00000000..6e11a284 Binary files /dev/null and b/GormCore/Images/GormEVCoil.tiff differ diff --git a/GormCore/Images/GormEVLine.tiff b/GormCore/Images/GormEVLine.tiff new file mode 100644 index 00000000..87091173 Binary files /dev/null and b/GormCore/Images/GormEVLine.tiff differ diff --git a/GormCore/Images/GormFile.tiff b/GormCore/Images/GormFile.tiff new file mode 100644 index 00000000..a4904a6b Binary files /dev/null and b/GormCore/Images/GormFile.tiff differ diff --git a/Images/GormFilesOwner.tiff b/GormCore/Images/GormFilesOwner.tiff similarity index 100% rename from Images/GormFilesOwner.tiff rename to GormCore/Images/GormFilesOwner.tiff diff --git a/Images/GormFirstResponder.tiff b/GormCore/Images/GormFirstResponder.tiff similarity index 100% rename from Images/GormFirstResponder.tiff rename to GormCore/Images/GormFirstResponder.tiff diff --git a/Images/GormFontManager.tiff b/GormCore/Images/GormFontManager.tiff similarity index 100% rename from Images/GormFontManager.tiff rename to GormCore/Images/GormFontManager.tiff diff --git a/Images/GormImage.tiff b/GormCore/Images/GormImage.tiff similarity index 100% rename from Images/GormImage.tiff rename to GormCore/Images/GormImage.tiff diff --git a/GormCore/Images/GormMHCoil.tiff b/GormCore/Images/GormMHCoil.tiff new file mode 100644 index 00000000..6e7d0347 Binary files /dev/null and b/GormCore/Images/GormMHCoil.tiff differ diff --git a/GormCore/Images/GormMHLine.tiff b/GormCore/Images/GormMHLine.tiff new file mode 100644 index 00000000..4f80b94a Binary files /dev/null and b/GormCore/Images/GormMHLine.tiff differ diff --git a/GormCore/Images/GormMVCoil.tiff b/GormCore/Images/GormMVCoil.tiff new file mode 100644 index 00000000..641e32c9 Binary files /dev/null and b/GormCore/Images/GormMVCoil.tiff differ diff --git a/GormCore/Images/GormMVLine.tiff b/GormCore/Images/GormMVLine.tiff new file mode 100644 index 00000000..953ff98d Binary files /dev/null and b/GormCore/Images/GormMVLine.tiff differ diff --git a/GormCore/Images/GormMenu.tiff b/GormCore/Images/GormMenu.tiff new file mode 100644 index 00000000..900523a5 Binary files /dev/null and b/GormCore/Images/GormMenu.tiff differ diff --git a/Images/GormObject.tiff b/GormCore/Images/GormObject.tiff similarity index 100% rename from Images/GormObject.tiff rename to GormCore/Images/GormObject.tiff diff --git a/Images/GormOutlet.tiff b/GormCore/Images/GormOutlet.tiff similarity index 100% rename from Images/GormOutlet.tiff rename to GormCore/Images/GormOutlet.tiff diff --git a/Images/GormOutletSelected.tiff b/GormCore/Images/GormOutletSelected.tiff similarity index 100% rename from Images/GormOutletSelected.tiff rename to GormCore/Images/GormOutletSelected.tiff diff --git a/Images/GormSound.tiff b/GormCore/Images/GormSound.tiff similarity index 100% rename from Images/GormSound.tiff rename to GormCore/Images/GormSound.tiff diff --git a/Images/GormUnknown.tiff b/GormCore/Images/GormUnknown.tiff similarity index 100% rename from Images/GormUnknown.tiff rename to GormCore/Images/GormUnknown.tiff diff --git a/Images/GormView.tiff b/GormCore/Images/GormView.tiff similarity index 100% rename from Images/GormView.tiff rename to GormCore/Images/GormView.tiff diff --git a/Images/GormWindow.tiff b/GormCore/Images/GormWindow.tiff similarity index 100% rename from Images/GormWindow.tiff rename to GormCore/Images/GormWindow.tiff diff --git a/Images/browserView.tiff b/GormCore/Images/browserView.tiff similarity index 100% rename from Images/browserView.tiff rename to GormCore/Images/browserView.tiff diff --git a/GormCore/Images/editor.tiff b/GormCore/Images/editor.tiff new file mode 100644 index 00000000..d099cb0f Binary files /dev/null and b/GormCore/Images/editor.tiff differ diff --git a/GormCore/Images/iconView.tiff b/GormCore/Images/iconView.tiff new file mode 100644 index 00000000..940ed4c3 Binary files /dev/null and b/GormCore/Images/iconView.tiff differ diff --git a/GormCore/Images/outlineView.tiff b/GormCore/Images/outlineView.tiff new file mode 100644 index 00000000..eceb4cb0 Binary files /dev/null and b/GormCore/Images/outlineView.tiff differ diff --git a/GormCore/NSFontManager+GormExtensions.m b/GormCore/NSFontManager+GormExtensions.m index 86ef26a3..2fd86172 100644 --- a/GormCore/NSFontManager+GormExtensions.m +++ b/GormCore/NSFontManager+GormExtensions.m @@ -62,7 +62,7 @@ if(result == NO) { - id object = [(GormDocument *)[(id)NSApp activeDocument] lastEditor]; + id object = [(GormDocument *)[(id)[NSApp delegate] activeDocument] lastEditor]; NS_DURING { if(object != nil) diff --git a/GormCore/README.md b/GormCore/README.md new file mode 100644 index 00000000..2624fd51 --- /dev/null +++ b/GormCore/README.md @@ -0,0 +1,7 @@ +# GormCore framework + +This framework is the heart of the Gorm application. It contains all of the classes needed to interact with a Gorm file. +The Gorm application uses it, obviously, and it is also used by gormtool to provide access to certain features from the +command line. + +This framework allows Gorm features to be used in other applications either directly or through the use of Plugins. diff --git a/Resources/ClassInformation.plist b/GormCore/Resources/ClassInformation.plist similarity index 98% rename from Resources/ClassInformation.plist rename to GormCore/Resources/ClassInformation.plist index 2d71f1e4..36935c19 100644 --- a/Resources/ClassInformation.plist +++ b/GormCore/Resources/ClassInformation.plist @@ -149,7 +149,7 @@ }; IBInspector = { Actions = ("ok:", "revert:", "touch:"); - Outlets = (window); + Outlets = (window, okButton, revertButton); Super = NSObject; }; IBPalette = {Actions = (); Outlets = (originalWindow); Super = NSObject; }; @@ -367,6 +367,11 @@ Super = NSText; }; NSView = {Actions = ("fax:", "print:"); Outlets = (nextKeyView); Super = NSResponder; }; + NSViewController = { + Actions = (); + Outlets = (view); + Super = NSResponder; + }; NSWindow = { Actions = ( "deminiaturize:", diff --git a/Resources/VersionProfiles.plist b/GormCore/Resources/VersionProfiles.plist similarity index 100% rename from Resources/VersionProfiles.plist rename to GormCore/Resources/VersionProfiles.plist diff --git a/GormLib/README b/GormLib/README deleted file mode 100644 index 7c1fcdfb..00000000 --- a/GormLib/README +++ /dev/null @@ -1,11 +0,0 @@ -GormLib is a clone of the InterfaceBuilder framework. - -GormLib's primary purpose is to allow the creation of custom palettes and -inspectors outside of Gorm. This will also facilitate extension of Gorm -since it will allow outside applications to have an interface with which they -can interact with the running Gorm application. - -You must install this library before you can build Gorm. - -Thanks, Gregory John Casamento - \ No newline at end of file diff --git a/GormObjCHeaderParser/GNUmakefile b/GormObjCHeaderParser/GNUmakefile index 8d63ad2d..bfab7558 100644 --- a/GormObjCHeaderParser/GNUmakefile +++ b/GormObjCHeaderParser/GNUmakefile @@ -5,37 +5,29 @@ PACKAGE_NAME = gorm include $(GNUSTEP_MAKEFILES)/common.make - # # Subprojects # - - +SUBPROJECTS = \ +Tests # # Library # - LIBRARY_VAR=GMOBJCHEADERPARSER -LIBRARY_NAME=libGormObjCHeaderParser -libGormObjCHeaderParser_HEADER_FILES_DIR=. -libGormObjCHeaderParser_HEADER_FILES_INSTALL_DIR=/GormObjCHeaderParser +LIBRARY_NAME=GormObjCHeaderParser +GormObjCHeaderParser_HEADER_FILES_DIR=. ADDITIONAL_INCLUDE_DIRS = -I.. -srcdir = . - -include ./Version # # Additional libraries # - -libGormObjCHeaderParser_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LIBRARY_NAME) +GormObjCHeaderParser_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LIBRARY_NAME) # # Header files # - -libGormObjCHeaderParser_HEADER_FILES= \ +GormObjCHeaderParser_HEADER_FILES= \ GormObjCHeaderParser.h \ NSScanner+OCHeaderParser.h \ OCClass.h \ @@ -43,29 +35,28 @@ OCHeaderParser.h \ OCIVar.h \ OCIVarDecl.h \ OCMethod.h \ +OCProperty.h \ ParserFunctions.h - # # Class files # - -libGormObjCHeaderParser_OBJC_FILES= \ +GormObjCHeaderParser_OBJC_FILES= \ NSScanner+OCHeaderParser.m \ OCClass.m \ OCHeaderParser.m \ OCIVar.m \ OCIVarDecl.m \ OCMethod.m \ +OCProperty.m \ ParserFunctions.m # # C files # +GormObjCHeaderParser_C_FILES= -libGormObjCHeaderParser_C_FILES= - -HEADERS_INSTALL = $(libGormObjCHeaderParser_HEADER_FILES) +HEADERS_INSTALL = $(GormObjCHeaderParser_HEADER_FILES) -include GNUmakefile.preamble -include GNUmakefile.local diff --git a/GormObjCHeaderParser/GormObjCHeaderParser.h b/GormObjCHeaderParser/GormObjCHeaderParser.h index e68c7632..fc547311 100644 --- a/GormObjCHeaderParser/GormObjCHeaderParser.h +++ b/GormObjCHeaderParser/GormObjCHeaderParser.h @@ -41,6 +41,7 @@ FOUNDATION_EXPORT const unsigned char GormObjCHeaderParserVersionString[]; #include #include #include +#include #include #endif diff --git a/GormObjCHeaderParser/OCClass.h b/GormObjCHeaderParser/OCClass.h index 2dfecb11..f6f67301 100644 --- a/GormObjCHeaderParser/OCClass.h +++ b/GormObjCHeaderParser/OCClass.h @@ -31,26 +31,31 @@ @interface OCClass : NSObject { - NSMutableArray *ivars; - NSMutableArray *methods; - NSMutableArray *protocols; - NSString *className; - NSString *superClassName; - NSString *classString; - BOOL isCategory; + NSMutableArray *_ivars; + NSMutableArray *_methods; + NSMutableArray *_protocols; + NSMutableArray *_properties; + NSString *_className; + NSString *_superClassName; + NSString *_classString; + BOOL _isCategory; } + - (id) initWithString: (NSString *)string; - (NSArray *) methods; -- (void) addMethod: (NSString *)name isAction: (BOOL) flag; +- (void) addMethod: (NSString *)name isAction: (BOOL)flag; - (NSArray *) ivars; -- (void) addIVar: (NSString *)name isOutlet: (BOOL) flag; +- (void) addIVar: (NSString *)name isOutlet: (BOOL)flag; - (NSString *) className; - (void) setClassName: (NSString *)name; - (NSString *) superClassName; - (void) setSuperClassName: (NSString *)name; - (BOOL) isCategory; - (void) setIsCategory: (BOOL)flag; +- (NSArray *) properties; + - (void) parse; + @end #endif diff --git a/GormObjCHeaderParser/OCClass.m b/GormObjCHeaderParser/OCClass.m index 7933accf..738f248b 100644 --- a/GormObjCHeaderParser/OCClass.m +++ b/GormObjCHeaderParser/OCClass.m @@ -24,38 +24,44 @@ #include -#include -#include -#include -#include -#include -#include +#include "GormObjCHeaderParser/OCClass.h" +#include "GormObjCHeaderParser/OCMethod.h" +#include "GormObjCHeaderParser/OCProperty.h" +#include "GormObjCHeaderParser/OCIVar.h" +#include "GormObjCHeaderParser/OCIVarDecl.h" +#include "GormObjCHeaderParser/NSScanner+OCHeaderParser.h" +#include "GormObjCHeaderParser/ParserFunctions.h" @implementation OCClass - (id) initWithString: (NSString *)string { - if((self = [super init]) != nil) + if ((self = [super init]) != nil) { - methods = [[NSMutableArray alloc] init]; - ivars = [[NSMutableArray alloc] init]; - ASSIGN(classString, string); + _methods = [[NSMutableArray alloc] init]; + _ivars = [[NSMutableArray alloc] init]; + _properties = [[NSMutableArray alloc] init]; + _protocols = [[NSMutableArray alloc] init]; + _superClassName = nil; + ASSIGN(_classString, string); } return self; } - (void) dealloc { - RELEASE(methods); - RELEASE(ivars); - RELEASE(classString); - RELEASE(className); - RELEASE(superClassName); + RELEASE(_methods); + RELEASE(_ivars); + RELEASE(_properties); + RELEASE(_protocols); + RELEASE(_classString); + RELEASE(_className); + RELEASE(_superClassName); [super dealloc]; } - (NSArray *) methods { - return methods; + return _methods; } - (void) addMethod: (NSString *)name isAction: (BOOL) flag @@ -63,12 +69,12 @@ OCMethod *method = AUTORELEASE([[OCMethod alloc] init]); [method setName: name]; [method setIsAction: flag]; - [methods addObject: method]; + [_methods addObject: method]; } - (NSArray *) ivars { - return ivars; + return _ivars; } - (void) addIVar: (NSString *)name isOutlet: (BOOL) flag @@ -76,42 +82,47 @@ OCIVar *ivar = AUTORELEASE([[OCIVar alloc] init]); [ivar setName: name]; [ivar setIsOutlet: flag]; - [ivars addObject: ivar]; + [_ivars addObject: ivar]; } - (NSString *) className { - return className; + return _className; } - (void) setClassName: (NSString *)name { - ASSIGN(className, name); + ASSIGN(_className, name); } - (NSString *) superClassName { - return superClassName; + return _superClassName; } - (void) setSuperClassName: (NSString *)name { - ASSIGN(superClassName,name); + ASSIGN(_superClassName,name); } - (BOOL) isCategory { - return isCategory; + return _isCategory; } - (void) setIsCategory: (BOOL)flag { - isCategory = flag; + _isCategory = flag; +} + +- (NSArray *) properties +{ + return _properties; } - (void) _strip { - NSScanner *stripScanner = [NSScanner scannerWithString: classString]; + NSScanner *stripScanner = [NSScanner scannerWithString: _classString]; NSString *resultString = @""; NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet]; @@ -120,13 +131,13 @@ NSString *string = nil; [stripScanner scanUpToCharactersFromSet: wsnl intoString: &string]; resultString = [resultString stringByAppendingString: string]; - if(![stripScanner isAtEnd]) + if (![stripScanner isAtEnd]) { resultString = [resultString stringByAppendingString: @" "]; } } - ASSIGN(classString, resultString); + ASSIGN(_classString, resultString); } - (void) parse @@ -141,94 +152,134 @@ // get the interface line... look ahead... [self _strip]; - scanner = [NSScanner scannerWithString: classString]; - if(lookAhead(classString, @"{")) - { - [scanner scanUpToString: @"@interface" intoString: NULL]; - [scanner scanUpToString: @"{" intoString: &interfaceLine]; - iscan = [NSScanner scannerWithString: interfaceLine]; // reset scanner... - } - else // if there is no "{", then there are no ivars... - { - [scanner scanUpToString: @"@interface" intoString: NULL]; - [scanner scanUpToCharactersFromSet: pmcs intoString: &interfaceLine]; - iscan = [NSScanner scannerWithString: interfaceLine]; // reset scanner... - } - - // look ahead... - if(lookAhead(interfaceLine, @":")) - { - NSString *cn = nil, *scn = nil; - - [iscan scanUpToAndIncludingString: @"@interface" intoString: NULL]; - [iscan scanUpToString: @":" intoString: &cn]; - className = [cn stringByTrimmingCharactersInSet: wsnl]; - RETAIN(className); - [iscan scanString: @":" intoString: NULL]; - [iscan scanUpToCharactersFromSet: wsnl intoString: &scn]; - superClassName = [scn stringByTrimmingCharactersInSet: wsnl]; - RETAIN(superClassName); - } - else // category... + NSDebugLog(@"_classString = %@", _classString); + scanner = [NSScanner scannerWithString: _classString]; + if (lookAhead(_classString, @"@implementation")) { NSString *cn = nil; - - [iscan scanUpToAndIncludingString: @"@interface" intoString: NULL]; - [iscan scanUpToCharactersFromSet: wsnl intoString: &cn]; - className = [cn stringByTrimmingCharactersInSet: wsnl]; - RETAIN(className); - // check to see if it's a category on an existing interface... - if(lookAhead(interfaceLine,@"(")) + [scanner scanUpToAndIncludingString: @"@implementation" intoString: NULL]; + [scanner scanUpToCharactersFromSet: wsnl intoString: &cn]; + _className = [cn stringByTrimmingCharactersInSet: wsnl]; + RETAIN(_className); + NSDebugLog(@"_className = %@", _className); + } + else + { + if (lookAhead(_classString, @"{")) { - isCategory = YES; + [scanner scanUpToString: @"@interface" intoString: NULL]; + [scanner scanUpToString: @"{" intoString: &interfaceLine]; + iscan = [NSScanner scannerWithString: interfaceLine]; // reset scanner... + } + else // if there is no "{", then there are no ivars... + { + [scanner scanUpToString: @"@interface" intoString: NULL]; + [scanner scanUpToCharactersFromSet: pmcs intoString: &interfaceLine]; + iscan = [NSScanner scannerWithString: interfaceLine]; // reset scanner... + } + + // look ahead... + if (lookAhead(interfaceLine, @":")) + { + NSString *cn = nil, *scn = nil; + + [iscan scanUpToAndIncludingString: @"@interface" intoString: NULL]; + [iscan scanUpToString: @":" intoString: &cn]; + _className = [cn stringByTrimmingCharactersInSet: wsnl]; + RETAIN(_className); + [iscan scanString: @":" intoString: NULL]; + [iscan scanUpToCharactersFromSet: wsnl intoString: &scn]; + [self setSuperClassName: [scn stringByTrimmingCharactersInSet: wsnl]]; + } + else // category... + { + NSString *cn = nil; + + [iscan scanUpToAndIncludingString: @"@interface" intoString: NULL]; + [iscan scanUpToCharactersFromSet: wsnl intoString: &cn]; + _className = [cn stringByTrimmingCharactersInSet: wsnl]; + RETAIN(_className); + + // check to see if it's a category on an existing interface... + if (lookAhead(interfaceLine,@"(")) + { + _isCategory = YES; + } + } + + if (_isCategory == NO) + { + NSScanner *ivarScan = nil; + + // put the ivars into a a string... + [scanner scanUpToAndIncludingString: @"{" intoString: NULL]; + [scanner scanUpToString: @"}" intoString: &ivarsString]; + [scanner scanString: @"}" intoString: NULL]; + + if (ivarsString != nil) + { + // scan each ivar... + ivarScan = [NSScanner scannerWithString: ivarsString]; + while(![ivarScan isAtEnd]) + { + NSString *ivarLine = nil; + OCIVarDecl *ivarDecl = nil; + + [ivarScan scanUpToString: @";" intoString: &ivarLine]; + [ivarScan scanString: @";" intoString: NULL]; + ivarDecl = AUTORELEASE([[OCIVarDecl alloc] initWithString: ivarLine]); + [ivarDecl parse]; + [_ivars addObjectsFromArray: [ivarDecl ivars]]; + } + } + } + else + { + NSString *cn = nil; + NSScanner *cs = [NSScanner scannerWithString: _classString]; + + [cs scanUpToAndIncludingString: @"@interface" intoString: NULL]; + [cs scanUpToCharactersFromSet: wsnl intoString: &cn]; + _className = [cn stringByTrimmingCharactersInSet: wsnl]; + RETAIN(_className); + NSDebugLog(@"_className = %@", _className); + } + + // put the methods into a string... + if (ivarsString != nil) + { + [scanner scanUpToString: @"@end" intoString: &methodsString]; + } + else // + { + scanner = [NSScanner scannerWithString: _classString]; + [scanner scanUpToAndIncludingString: interfaceLine intoString: NULL]; + [scanner scanUpToString: @"@end" intoString: &methodsString]; } } - if(isCategory == NO) - { - NSScanner *ivarScan = nil; - - // put the ivars into a a string... - [scanner scanUpToAndIncludingString: @"{" intoString: NULL]; - [scanner scanUpToString: @"}" intoString: &ivarsString]; - [scanner scanString: @"}" intoString: NULL]; - - if(ivarsString != nil) + if (_classString != nil) + { + NSScanner *propertiesScan = [NSScanner scannerWithString: _classString]; + while ([propertiesScan isAtEnd] == NO) { - // scan each ivar... - ivarScan = [NSScanner scannerWithString: ivarsString]; - while(![ivarScan isAtEnd]) - { - NSString *ivarLine = nil; - OCIVarDecl *ivarDecl = nil; - - [ivarScan scanUpToString: @";" intoString: &ivarLine]; - [ivarScan scanString: @";" intoString: NULL]; - ivarDecl = AUTORELEASE([[OCIVarDecl alloc] initWithString: ivarLine]); - [ivarDecl parse]; - [ivars addObjectsFromArray: [ivarDecl ivars]]; - } - } - } + NSString *propertiesLine = nil; + OCProperty *property = nil; - // put the methods into a string... - if(ivarsString != nil) - { - [scanner scanUpToString: @"@end" intoString: &methodsString]; - } - else // - { - scanner = [NSScanner scannerWithString: classString]; - [scanner scanUpToAndIncludingString: interfaceLine intoString: NULL]; - [scanner scanUpToString: @"@end" intoString: &methodsString]; + [propertiesScan scanUpToString: @";" intoString: &propertiesLine]; + [propertiesScan scanString: @";" intoString: NULL]; + property = AUTORELEASE([[OCProperty alloc] initWithString: propertiesLine]); + [property parse]; + [_properties addObject: property]; + } } // scan each method... - if(methodsString != nil) + if (methodsString != nil) { NSScanner *methodScan = [NSScanner scannerWithString: methodsString]; - while(![methodScan isAtEnd]) + while ([methodScan isAtEnd] == NO) { NSString *methodLine = nil; OCMethod *method = nil; @@ -237,8 +288,8 @@ [methodScan scanString: @";" intoString: NULL]; method = AUTORELEASE([[OCMethod alloc] initWithString: methodLine]); [method parse]; - [methods addObject: method]; - } + [_methods addObject: method]; + } } } @end diff --git a/GormObjCHeaderParser/OCHeaderParser.m b/GormObjCHeaderParser/OCHeaderParser.m index ecd7238a..6f9f2f83 100644 --- a/GormObjCHeaderParser/OCHeaderParser.m +++ b/GormObjCHeaderParser/OCHeaderParser.m @@ -166,9 +166,10 @@ if(classString != nil && [classString length] != 0) { - cls = AUTORELEASE([[OCClass alloc] initWithString: classString]); + cls = [[OCClass alloc] initWithString: classString]; [cls parse]; [classes addObject: cls]; + RELEASE(cls); } } diff --git a/GormObjCHeaderParser/OCIVarDecl.m b/GormObjCHeaderParser/OCIVarDecl.m index ea2091da..442ef931 100644 --- a/GormObjCHeaderParser/OCIVarDecl.m +++ b/GormObjCHeaderParser/OCIVarDecl.m @@ -159,6 +159,5 @@ [ivar parse]; [ivars addObject: ivar]; } - } @end diff --git a/GormObjCHeaderParser/OCProperty.h b/GormObjCHeaderParser/OCProperty.h new file mode 100644 index 00000000..b748a3de --- /dev/null +++ b/GormObjCHeaderParser/OCProperty.h @@ -0,0 +1,45 @@ +/* Definition of class OCProperty + Copyright (C) 2024 Free Software Foundation, Inc. + + By: Gregory John Casamento + Date: 27-12-2024 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110 USA. +*/ + +#ifndef _OCProperty_h_INCLUDE +#define _OCProperty_h_INCLUDE + +#import "OCIVar.h" +#import + +#if defined(__cplusplus) +extern "C" { +#endif + +GS_EXPORT_CLASS +@interface OCProperty : OCIVar + +@end + +#if defined(__cplusplus) +} +#endif + +#endif /* _OCProperty_h_INCLUDE */ + diff --git a/GormObjCHeaderParser/OCProperty.m b/GormObjCHeaderParser/OCProperty.m new file mode 100644 index 00000000..58c6d73c --- /dev/null +++ b/GormObjCHeaderParser/OCProperty.m @@ -0,0 +1,30 @@ +/* Implementation of class OCProperty + Copyright (C) 2024 Free Software Foundation, Inc. + + By: Gregory John Casamento + Date: 27-12-2024 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110 USA. +*/ + +#import "OCProperty.h" + +@implementation OCProperty + +@end + diff --git a/GormObjCHeaderParser/ParserFunctions.m b/GormObjCHeaderParser/ParserFunctions.m index d828d119..28356011 100644 --- a/GormObjCHeaderParser/ParserFunctions.m +++ b/GormObjCHeaderParser/ParserFunctions.m @@ -23,7 +23,6 @@ */ #include - #include "ParserFunctions.h" BOOL lookAhead(NSString *stringToScan, NSString *stringToFind) @@ -36,13 +35,13 @@ BOOL lookAhead(NSString *stringToScan, NSString *stringToFind) BOOL lookAheadForToken(NSString *stringToScan, NSString *stringToFind) { NSScanner *scanner = [NSScanner scannerWithString: stringToScan]; - NSString *resultString = @""; // [NSString stringWithString: @""]; + NSString *resultString = @""; [scanner setCharactersToBeSkipped: nil]; [scanner scanString: stringToFind intoString: &resultString]; if([resultString isEqualToString: stringToFind]) { - NSString *postTokenString = @""; // [NSString stringWithString: @""]; + NSString *postTokenString = @""; NSCharacterSet *wsnl = [NSCharacterSet whitespaceAndNewlineCharacterSet]; [scanner scanCharactersFromSet: wsnl intoString: &postTokenString]; diff --git a/GormObjCHeaderParser/README.md b/GormObjCHeaderParser/README.md new file mode 100644 index 00000000..b847e1b9 --- /dev/null +++ b/GormObjCHeaderParser/README.md @@ -0,0 +1,4 @@ +# GormObjCHeaderParser library + +This library is a basic recursive descent parser that handles ObjC syntax to allow Gorm to pull in information about a class from it's header file. +It is separated out into a library so that other applications or tools can make use of it. diff --git a/GormObjCHeaderParser/Tests/GNUmakefile b/GormObjCHeaderParser/Tests/GNUmakefile index 244ea63f..8fa0e007 100644 --- a/GormObjCHeaderParser/Tests/GNUmakefile +++ b/GormObjCHeaderParser/Tests/GNUmakefile @@ -1,5 +1,5 @@ # -# Tests Makefile for Gorm ObjC Parser Library. +# Tests Makefile for GNUstep GUI Library. # # Copyright (C) 2011 Free Software Foundation, Inc. # @@ -45,21 +45,24 @@ include $(GNUSTEP_MAKEFILES)/common.make TOP_DIR := $(shell dirname $(CURDIR)) all:: - @(echo If you want to run the gnustep-gui testsuite, please type \'make check\') + @(echo If you want to run the gorm-objcheaderparser testsuite, please type \'make check\') check:: (\ - ADDITIONAL_INCLUDE_DIRS="-I$(TOP_DIR)/." - ADDITIONAL_LIB_DIRS="-L$(TOP_DIR)/$(GNUSTEP_OBJ_DIR)";\ - LD_LIBRARY_PATH="$(TOP_DIR)/$(GNUSTEP_OBJ_DIR):${LD_LIBRARY_PATH}";\ + ADDITIONAL_INCLUDE_DIRS="-I$(TOP_DIR)/Headers -I$(TOP_DIR)/Source/$(GNUSTEP_TARGET_DIR) -I$(TOP_DIR)/Headers/Additions";\ + ADDITIONAL_LIB_DIRS="-L$(TOP_DIR)/Source/$(GNUSTEP_OBJ_DIR)";\ + LD_LIBRARY_PATH="$(TOP_DIR)/Source/$(GNUSTEP_OBJ_DIR):${LD_LIBRARY_PATH}";\ + PATH="$(TOP_DIR)/Tools/$(GNUSTEP_OBJ_DIR):${PATH}";\ + export GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES;\ export ADDITIONAL_INCLUDE_DIRS;\ export ADDITIONAL_LIB_DIRS;\ export LD_LIBRARY_PATH;\ export PATH;\ + env;\ if [ "$(DEBUG)" = "" ]; then \ - gnustep-tests GormObjCHeaderParser;\ + gnustep-tests parser;\ else \ - gnustep-tests --debug GormObjCHeaderParser;\ + gnustep-tests --debug parser;\ fi; \ ) diff --git a/GormObjCHeaderParser/Tests/GormObjCHeaderParser/README.md b/GormObjCHeaderParser/Tests/parser/README.md similarity index 100% rename from GormObjCHeaderParser/Tests/GormObjCHeaderParser/README.md rename to GormObjCHeaderParser/Tests/parser/README.md diff --git a/GormPrefs/GNUmakefile b/GormPrefs/GNUmakefile deleted file mode 100644 index 0e9feac9..00000000 --- a/GormPrefs/GNUmakefile +++ /dev/null @@ -1,94 +0,0 @@ -# -# GNUmakefile -# Written by Gregory John Casamento -# -PACKAGE_NAME = gorm -include $(GNUSTEP_MAKEFILES)/common.make - - -# -# Subprojects -# - - - -# -# Framework -# - -PACKAGE_NAME=GormPrefs -LIBRARY_VAR=GORMPREFS -LIBRARY_NAME=GormPrefs - -GormPrefs_HEADER_FILES_DIR=. -GormPrefs_HEADER_FILES_INSTALL_DIR=/GormPrefs -ADDITIONAL_INCLUDE_DIRS = -I.. -srcdir = . - -include ../Version - -# -# Additional libraries -# - -GormPrefs_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LIBRARY_NAME) - -# -# Header files -# - -GormPrefs_HEADER_FILES= \ -GormPrefs.h \ -GormGeneralPref.h \ -GormGuidelinePref.h \ -GormHeadersPref.h \ -GormPalettesPref.h \ -GormPluginsPref.h \ -GormPrefController.h \ -GormShelfPref.h - -# -# Class files -# - -GormPrefs_OBJC_FILES= \ -GormGeneralPref.m \ -GormGuidelinePref.m \ -GormHeadersPref.m \ -GormPalettesPref.m \ -GormPluginsPref.m \ -GormPrefController.m \ -GormShelfPref.m - -# -# Resources -# -#GormPrefs_LOCALIZED_RESOURCE_FILES= \ -#GormPrefColors.gorm \ -#GormPreferences.gorm \ -#GormPrefGeneral.gorm \ -#GormPrefGuideline.gorm \ -#GormPrefHeaders.gorm \ -#GormPrefPalettes.gorm \ -#GormShelfPref.gorm - -# -# Languages -# -#GormPrefs_LANGUAGES= \ -#English - -# -# C files -# - -GormPrefs_C_FILES= - -HEADERS_INSTALL = $(GormPrefs_HEADER_FILES) - --include GNUmakefile.preamble --include GNUmakefile.local - -include $(GNUSTEP_MAKEFILES)/library.make - --include GNUmakefile.postamble diff --git a/GormLib/COPYING.LIB b/InterfaceBuilder/COPYING.LIB similarity index 100% rename from GormLib/COPYING.LIB rename to InterfaceBuilder/COPYING.LIB diff --git a/GormLib/GNUmakefile b/InterfaceBuilder/GNUmakefile similarity index 70% rename from GormLib/GNUmakefile rename to InterfaceBuilder/GNUmakefile index bdeed432..24833f6e 100644 --- a/GormLib/GNUmakefile +++ b/InterfaceBuilder/GNUmakefile @@ -3,7 +3,7 @@ # Written by Gregory John Casamento # -PACKAGE_NAME = gorm +PACKAGE_NAME = InterfaceBuilder include $(GNUSTEP_MAKEFILES)/common.make @@ -17,11 +17,11 @@ include $(GNUSTEP_MAKEFILES)/common.make # Library # -PACKAGE_NAME=Gorm -LIBRARY_VAR=GORM -LIBRARY_NAME=libGorm -libGorm_HEADER_FILES_DIR=. -libGorm_HEADER_FILES_INSTALL_DIR=/InterfaceBuilder +PACKAGE_NAME=InterfaceBuilder +LIBRARY_VAR=INTERFACEBUILDER +LIBRARY_NAME=InterfaceBuilder +InterfaceBuilder_HEADER_FILES_DIR=. +InterfaceBuilder_HEADER_FILES_INSTALL_DIR=/InterfaceBuilder ADDITIONAL_INCLUDE_DIRS = -I.. srcdir = . @@ -31,13 +31,13 @@ include ./Version # Additional libraries # -libGorm_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LIBRARY_NAME) +InterfaceBuilder_LIBRARIES_DEPEND_UPON += -lgnustep-gui -l$(FOUNDATION_LIBRARY_NAME) # # Header files # -libGorm_HEADER_FILES= \ +InterfaceBuilder_HEADER_FILES= \ IBApplicationAdditions.h \ IBCellAdditions.h \ IBCellProtocol.h \ @@ -65,7 +65,7 @@ InterfaceBuilder.h # Class files # -libGorm_OBJC_FILES= \ +InterfaceBuilder_OBJC_FILES= \ IBApplicationAdditions.m \ IBConnectors.m \ IBDocuments.m \ @@ -82,9 +82,9 @@ IBResourceManager.m # C files # -libGorm_C_FILES= +InterfaceBuilder_C_FILES= -HEADERS_INSTALL = $(libGorm_HEADER_FILES) +HEADERS_INSTALL = $(InterfaceBuilder_HEADER_FILES) -include GNUmakefile.preamble -include GNUmakefile.local diff --git a/GormLib/GNUmakefile.postamble b/InterfaceBuilder/GNUmakefile.postamble similarity index 94% rename from GormLib/GNUmakefile.postamble rename to InterfaceBuilder/GNUmakefile.postamble index b1491e67..a23936d6 100644 --- a/GormLib/GNUmakefile.postamble +++ b/InterfaceBuilder/GNUmakefile.postamble @@ -25,5 +25,3 @@ before-all:: after-clean:: - rm -rf ../InterfaceBuilder - rm -rf ./InterfaceBuilder diff --git a/GormLib/GNUmakefile.preamble b/InterfaceBuilder/GNUmakefile.preamble similarity index 91% rename from GormLib/GNUmakefile.preamble rename to InterfaceBuilder/GNUmakefile.preamble index b6c82473..e34e8ece 100644 --- a/GormLib/GNUmakefile.preamble +++ b/InterfaceBuilder/GNUmakefile.preamble @@ -47,8 +47,7 @@ # ADDITIONAL_CFLAGS += -Wall -Werror # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../InterfaceBuilder -# INCLUDE_DIRS = -I../InterfaceBuilder $(INCLUDE_DIRS) +ADDITIONAL_INCLUDE_DIRS += # Additional LDFLAGS to pass to the linker #ADDITIONAL_LDFLAGS += @@ -68,9 +67,3 @@ ADDITIONAL_INSTALL_DIRS += # # Local configuration # - -ifeq ($(GNUSTEP_TARGET_OS),cygwin) -libGorm_LIBRARIES_DEPEND_UPON += -lobjc -endif - - diff --git a/GormLib/IBApplicationAdditions.h b/InterfaceBuilder/IBApplicationAdditions.h similarity index 100% rename from GormLib/IBApplicationAdditions.h rename to InterfaceBuilder/IBApplicationAdditions.h diff --git a/GormLib/IBApplicationAdditions.m b/InterfaceBuilder/IBApplicationAdditions.m similarity index 100% rename from GormLib/IBApplicationAdditions.m rename to InterfaceBuilder/IBApplicationAdditions.m diff --git a/GormLib/IBCellAdditions.h b/InterfaceBuilder/IBCellAdditions.h similarity index 100% rename from GormLib/IBCellAdditions.h rename to InterfaceBuilder/IBCellAdditions.h diff --git a/GormLib/IBCellProtocol.h b/InterfaceBuilder/IBCellProtocol.h similarity index 100% rename from GormLib/IBCellProtocol.h rename to InterfaceBuilder/IBCellProtocol.h diff --git a/GormLib/IBConnectors.h b/InterfaceBuilder/IBConnectors.h similarity index 100% rename from GormLib/IBConnectors.h rename to InterfaceBuilder/IBConnectors.h diff --git a/GormLib/IBConnectors.m b/InterfaceBuilder/IBConnectors.m similarity index 100% rename from GormLib/IBConnectors.m rename to InterfaceBuilder/IBConnectors.m diff --git a/GormLib/IBDefines.h b/InterfaceBuilder/IBDefines.h similarity index 100% rename from GormLib/IBDefines.h rename to InterfaceBuilder/IBDefines.h diff --git a/GormLib/IBDocuments.h b/InterfaceBuilder/IBDocuments.h similarity index 100% rename from GormLib/IBDocuments.h rename to InterfaceBuilder/IBDocuments.h diff --git a/GormLib/IBDocuments.m b/InterfaceBuilder/IBDocuments.m similarity index 94% rename from GormLib/IBDocuments.m rename to InterfaceBuilder/IBDocuments.m index cdd64dce..4e9ddd35 100644 --- a/GormLib/IBDocuments.m +++ b/InterfaceBuilder/IBDocuments.m @@ -22,9 +22,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. */ -#include +#include -#include +#include "IBDocuments.h" NSString *IBDidOpenDocumentNotification = @"IBDidOpenDocumentNotification"; NSString *IBWillSaveDocumentNotification = @"IBWillSaveDocumentNotification"; diff --git a/GormLib/IBEditors.h b/InterfaceBuilder/IBEditors.h similarity index 100% rename from GormLib/IBEditors.h rename to InterfaceBuilder/IBEditors.h diff --git a/GormLib/IBEditors.m b/InterfaceBuilder/IBEditors.m similarity index 100% rename from GormLib/IBEditors.m rename to InterfaceBuilder/IBEditors.m diff --git a/GormLib/IBInspector.h b/InterfaceBuilder/IBInspector.h similarity index 100% rename from GormLib/IBInspector.h rename to InterfaceBuilder/IBInspector.h diff --git a/GormLib/IBInspector.m b/InterfaceBuilder/IBInspector.m similarity index 85% rename from GormLib/IBInspector.m rename to InterfaceBuilder/IBInspector.m index 2a22dd47..430e2c86 100644 --- a/GormLib/IBInspector.m +++ b/InterfaceBuilder/IBInspector.m @@ -25,9 +25,9 @@ #include #include -#include -#include -#include +#include "IBApplicationAdditions.h" +#include "IBInspector.h" +#include "IBDocuments.h" static NSNotificationCenter *nc = nil; @@ -112,7 +112,18 @@ static NSNotificationCenter *nc = nil; - (void) touch: (id)sender { - id doc = [(id)NSApp activeDocument]; + id delegate = [NSApp delegate]; + id doc = nil; + + if ([NSApp respondsToSelector: @selector(activeDocument)]) + { + doc = [(id)NSApp activeDocument]; + } + else if ([delegate respondsToSelector: @selector(activeDocument)]) + { + doc = [delegate activeDocument]; + } + [doc touch]; } diff --git a/GormLib/IBInspectorManager.h b/InterfaceBuilder/IBInspectorManager.h similarity index 100% rename from GormLib/IBInspectorManager.h rename to InterfaceBuilder/IBInspectorManager.h diff --git a/GormLib/IBInspectorManager.m b/InterfaceBuilder/IBInspectorManager.m similarity index 97% rename from GormLib/IBInspectorManager.m rename to InterfaceBuilder/IBInspectorManager.m index 786173cc..16efc61f 100644 --- a/GormLib/IBInspectorManager.m +++ b/InterfaceBuilder/IBInspectorManager.m @@ -24,8 +24,8 @@ #include -#include -#include +#include "IBInspectorManager.h" +#include "IBInspectorMode.h" #include diff --git a/GormLib/IBInspectorMode.h b/InterfaceBuilder/IBInspectorMode.h similarity index 100% rename from GormLib/IBInspectorMode.h rename to InterfaceBuilder/IBInspectorMode.h diff --git a/GormLib/IBInspectorMode.m b/InterfaceBuilder/IBInspectorMode.m similarity index 98% rename from GormLib/IBInspectorMode.m rename to InterfaceBuilder/IBInspectorMode.m index 75f436e5..a7e6dde2 100644 --- a/GormLib/IBInspectorMode.m +++ b/InterfaceBuilder/IBInspectorMode.m @@ -24,7 +24,7 @@ #include -#include +#include "IBInspectorMode.h" /** * IBInspectorMode is an internal class in the InterfaceBuilder framework. diff --git a/GormLib/IBObjectAdditions.h b/InterfaceBuilder/IBObjectAdditions.h similarity index 100% rename from GormLib/IBObjectAdditions.h rename to InterfaceBuilder/IBObjectAdditions.h diff --git a/GormLib/IBObjectAdditions.m b/InterfaceBuilder/IBObjectAdditions.m similarity index 97% rename from GormLib/IBObjectAdditions.m rename to InterfaceBuilder/IBObjectAdditions.m index b4e38d0f..f3d5a803 100644 --- a/GormLib/IBObjectAdditions.m +++ b/InterfaceBuilder/IBObjectAdditions.m @@ -24,7 +24,7 @@ #include -#include +#include "IBObjectAdditions.h" // object additions -- object adopts protocol @implementation NSObject (_IBObjectAdditions) diff --git a/GormLib/IBObjectProtocol.h b/InterfaceBuilder/IBObjectProtocol.h similarity index 100% rename from GormLib/IBObjectProtocol.h rename to InterfaceBuilder/IBObjectProtocol.h diff --git a/GormLib/IBPalette.h b/InterfaceBuilder/IBPalette.h similarity index 100% rename from GormLib/IBPalette.h rename to InterfaceBuilder/IBPalette.h diff --git a/GormLib/IBPalette.m b/InterfaceBuilder/IBPalette.m similarity index 99% rename from GormLib/IBPalette.m rename to InterfaceBuilder/IBPalette.m index fe0d1ba9..3dd36b58 100644 --- a/GormLib/IBPalette.m +++ b/InterfaceBuilder/IBPalette.m @@ -25,7 +25,7 @@ #include #include -#include +#include "IBPalette.h" NSString *IBCellPboardType = @"IBCellPboardType"; NSString *IBMenuPboardType = @"IBMenuPboardType"; diff --git a/GormLib/IBPlugin.h b/InterfaceBuilder/IBPlugin.h similarity index 100% rename from GormLib/IBPlugin.h rename to InterfaceBuilder/IBPlugin.h diff --git a/GormLib/IBPlugin.m b/InterfaceBuilder/IBPlugin.m similarity index 98% rename from GormLib/IBPlugin.m rename to InterfaceBuilder/IBPlugin.m index 861b6590..ff0cf73d 100644 --- a/GormLib/IBPlugin.m +++ b/InterfaceBuilder/IBPlugin.m @@ -25,7 +25,7 @@ #include #include -#include +#include "IBPlugin.h" static NSMapTable *instanceMap = 0; diff --git a/GormLib/IBProjectFiles.h b/InterfaceBuilder/IBProjectFiles.h similarity index 100% rename from GormLib/IBProjectFiles.h rename to InterfaceBuilder/IBProjectFiles.h diff --git a/GormLib/IBProjects.h b/InterfaceBuilder/IBProjects.h similarity index 100% rename from GormLib/IBProjects.h rename to InterfaceBuilder/IBProjects.h diff --git a/GormLib/IBResourceManager.h b/InterfaceBuilder/IBResourceManager.h similarity index 100% rename from GormLib/IBResourceManager.h rename to InterfaceBuilder/IBResourceManager.h diff --git a/GormLib/IBResourceManager.m b/InterfaceBuilder/IBResourceManager.m similarity index 97% rename from GormLib/IBResourceManager.m rename to InterfaceBuilder/IBResourceManager.m index e9dd1659..7cfa403a 100644 --- a/GormLib/IBResourceManager.m +++ b/InterfaceBuilder/IBResourceManager.m @@ -25,9 +25,9 @@ #include #include -#include -#include -#include +#include "IBResourceManager.h" +#include "IBObjectAdditions.h" +#include "IBPalette.h" NSString *IBResourceManagerRegistryDidChangeNotification = @"IBResourceManagerRegistryDidChangeNotification"; diff --git a/GormLib/IBSystem.h b/InterfaceBuilder/IBSystem.h similarity index 97% rename from GormLib/IBSystem.h rename to InterfaceBuilder/IBSystem.h index dc518310..4ae9da94 100644 --- a/GormLib/IBSystem.h +++ b/InterfaceBuilder/IBSystem.h @@ -29,7 +29,7 @@ #ifdef GNUSTEP_WITH_DLL -#if BUILD_libGorm_DLL +#if BUILD_libInterfaceBuilder_DLL # if defined(__MINGW32__) /* On Mingw, the compiler will export all symbols automatically, so * __declspec(dllexport) is not needed. diff --git a/GormLib/IBViewAdditions.h b/InterfaceBuilder/IBViewAdditions.h similarity index 100% rename from GormLib/IBViewAdditions.h rename to InterfaceBuilder/IBViewAdditions.h diff --git a/GormLib/IBViewProtocol.h b/InterfaceBuilder/IBViewProtocol.h similarity index 100% rename from GormLib/IBViewProtocol.h rename to InterfaceBuilder/IBViewProtocol.h diff --git a/GormLib/IBViewResourceDragging.h b/InterfaceBuilder/IBViewResourceDragging.h similarity index 100% rename from GormLib/IBViewResourceDragging.h rename to InterfaceBuilder/IBViewResourceDragging.h diff --git a/GormLib/InterfaceBuilder.h b/InterfaceBuilder/InterfaceBuilder.h similarity index 100% rename from GormLib/InterfaceBuilder.h rename to InterfaceBuilder/InterfaceBuilder.h diff --git a/InterfaceBuilder/README.md b/InterfaceBuilder/README.md new file mode 100644 index 00000000..e013220b --- /dev/null +++ b/InterfaceBuilder/README.md @@ -0,0 +1,10 @@ +# InterfaceBuilder framework + +This is a clone of the InterfaceBuilder framework. + +InteraceBuilder framework's primary purpose is to allow the creation of custom palettes and +inspectors outside of Gorm. This will also facilitate the extension of Gorm +since it will allow outside applications to have an interface with which they +can interact with the running Gorm application. + +You must install this library before you can build Gorm. diff --git a/GormLib/Version b/InterfaceBuilder/Version similarity index 100% rename from GormLib/Version rename to InterfaceBuilder/Version diff --git a/Palettes/0Menus/GNUmakefile.preamble b/Palettes/0Menus/GNUmakefile.preamble deleted file mode 100644 index a18ea05f..00000000 --- a/Palettes/0Menus/GNUmakefile.preamble +++ /dev/null @@ -1,21 +0,0 @@ -# Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. - -ifeq ($(GNUSTEP_TARGET_OS),mingw32) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore -endif -ifeq ($(GNUSTEP_TARGET_OS),cygwin) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -0Menus_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore -endif \ No newline at end of file diff --git a/Palettes/1Windows/GNUmakefile.preamble b/Palettes/1Windows/GNUmakefile.preamble deleted file mode 100644 index 5af9107e..00000000 --- a/Palettes/1Windows/GNUmakefile.preamble +++ /dev/null @@ -1,21 +0,0 @@ -# Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. - -ifeq ($(GNUSTEP_TARGET_OS),mingw32) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore -endif -ifeq ($(GNUSTEP_TARGET_OS),cygwin) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -1Windows_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore -endif \ No newline at end of file diff --git a/Palettes/2Controls/ControlsPalette.gorm/objects.gorm b/Palettes/2Controls/ControlsPalette.gorm/objects.gorm deleted file mode 100644 index 163fe0eb..00000000 Binary files a/Palettes/2Controls/ControlsPalette.gorm/objects.gorm and /dev/null differ diff --git a/Palettes/2Controls/GNUmakefile.preamble b/Palettes/2Controls/GNUmakefile.preamble deleted file mode 100644 index 4ef816d6..00000000 --- a/Palettes/2Controls/GNUmakefile.preamble +++ /dev/null @@ -1,21 +0,0 @@ -# Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. - -ifeq ($(GNUSTEP_TARGET_OS),mingw32) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore -endif -ifeq ($(GNUSTEP_TARGET_OS),cygwin) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -2Controls_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore -endif \ No newline at end of file diff --git a/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/objects.gorm b/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/objects.gorm deleted file mode 100644 index 74d629f8..00000000 Binary files a/Palettes/2Controls/GormNSPopUpButtonInspector.gorm/objects.gorm and /dev/null differ diff --git a/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/objects.gorm b/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/objects.gorm deleted file mode 100644 index 17673780..00000000 Binary files a/Palettes/2Controls/GormNSProgressIndicatorInspector.gorm/objects.gorm and /dev/null differ diff --git a/Palettes/3Containers/GNUmakefile.preamble b/Palettes/3Containers/GNUmakefile.preamble deleted file mode 100644 index c17823a5..00000000 --- a/Palettes/3Containers/GNUmakefile.preamble +++ /dev/null @@ -1,21 +0,0 @@ -# Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. - -ifeq ($(GNUSTEP_TARGET_OS),mingw32) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore -endif -ifeq ($(GNUSTEP_TARGET_OS),cygwin) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -3Containers_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore -endif \ No newline at end of file diff --git a/Palettes/4Data/GNUmakefile.preamble b/Palettes/4Data/GNUmakefile.preamble deleted file mode 100644 index e9249b0e..00000000 --- a/Palettes/4Data/GNUmakefile.preamble +++ /dev/null @@ -1,21 +0,0 @@ -# Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. - -ifeq ($(GNUSTEP_TARGET_OS),mingw32) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore -endif -ifeq ($(GNUSTEP_TARGET_OS),cygwin) -ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) - -4Data_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore -endif \ No newline at end of file diff --git a/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.info b/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.info deleted file mode 100644 index 744f736a..00000000 Binary files a/Palettes/4Data/GormNSDateFormatterInspector.gorm/data.info and /dev/null differ diff --git a/Palettes/4Data/GormNSDateFormatterInspector.gorm/objects.gorm b/Palettes/4Data/GormNSDateFormatterInspector.gorm/objects.gorm deleted file mode 100644 index 1b141bf3..00000000 Binary files a/Palettes/4Data/GormNSDateFormatterInspector.gorm/objects.gorm and /dev/null differ diff --git a/Palettes/4Data/GormNSImageViewInspector.gorm/data.info b/Palettes/4Data/GormNSImageViewInspector.gorm/data.info deleted file mode 100644 index 744f736a..00000000 Binary files a/Palettes/4Data/GormNSImageViewInspector.gorm/data.info and /dev/null differ diff --git a/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.info b/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.info deleted file mode 100644 index 744f736a..00000000 Binary files a/Palettes/4Data/GormNSNumberFormatterInspector.gorm/data.info and /dev/null differ diff --git a/Palettes/4Data/GormNSNumberFormatterInspector.gorm/objects.gorm b/Palettes/4Data/GormNSNumberFormatterInspector.gorm/objects.gorm deleted file mode 100644 index 5ed889d1..00000000 Binary files a/Palettes/4Data/GormNSNumberFormatterInspector.gorm/objects.gorm and /dev/null differ diff --git a/Palettes/4Data/GormNSTextViewInspector.gorm/data.info b/Palettes/4Data/GormNSTextViewInspector.gorm/data.info deleted file mode 100644 index 744f736a..00000000 Binary files a/Palettes/4Data/GormNSTextViewInspector.gorm/data.info and /dev/null differ diff --git a/Plugins/GModel/GNUmakefile.preamble b/Plugins/GModel/GNUmakefile.preamble index beccc87f..7ac08068 100644 --- a/Plugins/GModel/GNUmakefile.preamble +++ b/Plugins/GModel/GNUmakefile.preamble @@ -1,21 +1,19 @@ # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. +ADDITIONAL_INCLUDE_DIRS += -I../../ ifeq ($(GNUSTEP_TARGET_OS),mingw32) ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../GormCore/GormCore.framework -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore endif ifeq ($(GNUSTEP_TARGET_OS),cygwin) ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../GormCore/GormCore.framework -GModel_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore +$(BUNDLE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore endif \ No newline at end of file diff --git a/Plugins/GModel/GormGModelWrapperLoader.m b/Plugins/GModel/GormGModelWrapperLoader.m index 78c891ef..83eb00c7 100644 --- a/Plugins/GModel/GormGModelWrapperLoader.m +++ b/Plugins/GModel/GormGModelWrapperLoader.m @@ -58,10 +58,10 @@ static BOOL gormFileOwnerDecoded; @interface GModelApplication : NSObject { - id mainMenu; - id windowMenu; - id delegate; - NSArray *windows; + id _mainMenu; + id _windowMenu; + id _delegate; + NSArray *_windows; } + (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver; @@ -81,10 +81,10 @@ static BOOL gormFileOwnerDecoded; NSEnumerator *enumerator; NSWindow *win; - mainMenu = [unarchiver decodeObjectWithName:@"mainMenu"]; + _mainMenu = [unarchiver decodeObjectWithName:@"mainMenu"]; - windows = [unarchiver decodeObjectWithName:@"windows"]; - enumerator = [windows objectEnumerator]; + _windows = [unarchiver decodeObjectWithName:@"windows"]; + enumerator = [_windows objectEnumerator]; while ((win = [enumerator nextObject]) != nil) { /* Fix up window frames */ @@ -98,29 +98,29 @@ static BOOL gormFileOwnerDecoded; [win setBackgroundColor: [NSColor windowBackgroundColor]]; } - delegate = [unarchiver decodeObjectWithName:@"delegate"]; + _delegate = [unarchiver decodeObjectWithName:@"delegate"]; return self; } - (NSArray *) windows { - return windows; + return _windows; } - mainMenu { - return mainMenu; + return _mainMenu; } - windowMenu { - return windowMenu; + return _windowMenu; } - delegate { - return delegate; + return _delegate; } + (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver @@ -163,11 +163,11 @@ static BOOL gormFileOwnerDecoded; - (id)initWithModelUnarchiver: (GMUnarchiver*)unarchiver { - id extension; + // id extension; id realObject; theClass = RETAIN([unarchiver decodeStringWithName: @"className"]); - extension = [unarchiver decodeObjectWithName: @"extension"]; + // extension = [unarchiver decodeObjectWithName: @"extension"]; realObject = [unarchiver decodeObjectWithName: @"realObject"]; //real = [unarchiver representationForName: @"realObject" isLabeled: &label]; @@ -193,10 +193,10 @@ static BOOL gormFileOwnerDecoded; { NSString *cn; id realObject; - id extension; + // id extension; cn = [unarchiver decodeStringWithName: @"className"]; - extension = [unarchiver decodeObjectWithName: @"extension"]; + // extension = [unarchiver decodeObjectWithName: @"extension"]; realObject = [unarchiver decodeObjectWithName: @"realObject"]; [self setFrame: [unarchiver decodeRectWithName: @"frame"]]; [self setClassName: cn]; diff --git a/Plugins/Gorm/GNUmakefile.preamble b/Plugins/Gorm/GNUmakefile.preamble index 3afa7b63..7ac08068 100644 --- a/Plugins/Gorm/GNUmakefile.preamble +++ b/Plugins/Gorm/GNUmakefile.preamble @@ -1,21 +1,19 @@ # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. +ADDITIONAL_INCLUDE_DIRS += -I../../ ifeq ($(GNUSTEP_TARGET_OS),mingw32) ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../GormCore/GormCore.framework -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore endif ifeq ($(GNUSTEP_TARGET_OS),cygwin) ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../GormCore/GormCore.framework -Gorm_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore +$(BUNDLE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore endif \ No newline at end of file diff --git a/Plugins/Gorm/GormGormWrapperBuilder.m b/Plugins/Gorm/GormGormWrapperBuilder.m index 5deb2347..b9d374cb 100644 --- a/Plugins/Gorm/GormGormWrapperBuilder.m +++ b/Plugins/Gorm/GormGormWrapperBuilder.m @@ -1,6 +1,4 @@ /* GormWrapperBuilder - * - * This class is a subclass of the NSDocumentController * * Copyright (C) 2006 Free Software Foundation, Inc. * @@ -221,7 +219,7 @@ NSString *gormPath = @"objects.gorm"; NSString *classesPath = @"data.classes"; NSString *infoPath = @"data.info"; - GormPalettesManager *palettesManager = [(id)NSApp palettesManager]; + GormPalettesManager *palettesManager = [(id)[NSApp delegate] palettesManager]; NSDictionary *substituteClasses = [palettesManager substituteClasses]; NSEnumerator *en = [substituteClasses keyEnumerator]; NSString *subClassName = nil; @@ -234,23 +232,6 @@ GormFilePrefsManager *filePrefsManager = [document filePrefsManager]; GSNibContainer *container = nil; - // - // If we are a nib, currently, and it's not being saved using the Latest, then - // flag an error. NOTE: The next time the gorm container version is - // changed, it will be necessary to add to the list here... - // - if([[document fileType] isEqual: @"GSNibFileType"] && - [[document filePrefsManager] isLatest] == NO) - { - NSRunAlertPanel(_(@"Incorrect gui version"), - _(@"Nibs cannot be converted to gui-0.10.3 and older"), - _(@"OK"), - nil, - nil, - nil); - return nil; - } - [document prepareConnections]; container = [[GSNibContainer alloc] initWithDocument: document]; diff --git a/Plugins/Gorm/GormGormWrapperLoader.m b/Plugins/Gorm/GormGormWrapperLoader.m index d20e4d1d..d50664e9 100644 --- a/Plugins/Gorm/GormGormWrapperLoader.m +++ b/Plugins/Gorm/GormGormWrapperLoader.m @@ -1,6 +1,4 @@ /* GormDocumentController.m - * - * This class is a subclass of the NSDocumentController * * Copyright (C) 2006 Free Software Foundation, Inc. * @@ -33,9 +31,9 @@ @interface GormGormWrapperLoader : GormWrapperLoader { NSMutableArray *_repairLog; - id message; - id textField; - id panel; + id _message; + id _textField; + id _panel; } @end @@ -83,14 +81,14 @@ } else { - [message setStringValue: msg]; + [_message setStringValue: msg]; while((m = [en nextObject]) != nil) { - [textField insertText: m]; + [_textField insertText: m]; } - [panel orderFront: self]; + [_panel orderFront: self]; } [_repairLog removeAllObjects]; @@ -374,7 +372,7 @@ NSString *ownerClass, *key = nil; BOOL repairFile = [[NSUserDefaults standardUserDefaults] boolForKey: @"GormRepairFileOnLoad"]; - GormPalettesManager *palettesManager = [(id)NSApp palettesManager]; + GormPalettesManager *palettesManager = [(id)[NSApp delegate] palettesManager]; NSDictionary *substituteClasses = [palettesManager substituteClasses]; NSEnumerator *en = [substituteClasses keyEnumerator]; NSString *subClassName = nil; @@ -648,9 +646,10 @@ } NS_HANDLER { - NSRunAlertPanel(_(@"Problem Loading"), - [NSString stringWithFormat: @"Failed to load file. Exception: %@",[localException reason]], - _(@"OK"), nil, nil); + id delegate = [NSApp delegate]; + NSString *errorMessage = [NSString stringWithFormat: @"Failed to load file. Exception: %@",[localException reason]]; + + [delegate exceptionWhileLoadingModel: errorMessage]; result = NO; } NS_ENDHANDLER; diff --git a/Plugins/Nib/GNUmakefile.preamble b/Plugins/Nib/GNUmakefile.preamble index 5c5abbb6..7ac08068 100644 --- a/Plugins/Nib/GNUmakefile.preamble +++ b/Plugins/Nib/GNUmakefile.preamble @@ -1,21 +1,19 @@ # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. +ADDITIONAL_INCLUDE_DIRS += -I../../ ifeq ($(GNUSTEP_TARGET_OS),mingw32) ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../GormCore/GormCore.framework -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore endif ifeq ($(GNUSTEP_TARGET_OS),cygwin) ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../GormCore/GormCore.framework -Nib_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore +$(BUNDLE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore endif \ No newline at end of file diff --git a/Plugins/Nib/GormNibWrapperBuilder.m b/Plugins/Nib/GormNibWrapperBuilder.m index 8f221f2a..81e25dfb 100644 --- a/Plugins/Nib/GormNibWrapperBuilder.m +++ b/Plugins/Nib/GormNibWrapperBuilder.m @@ -1,6 +1,4 @@ /* GormWrapperBuilder - * - * This class is a subclass of the NSDocumentController * * Copyright (C) 2006-2013 Free Software Foundation, Inc. * @@ -340,7 +338,7 @@ NSString *nibPath = @"keyedobjects.nib"; NSString *classesPath = @"classes.nib"; NSString *infoPath = @"info.nib"; - GormPalettesManager *palettesManager = [(id)NSApp palettesManager]; + GormPalettesManager *palettesManager = [(id)[NSApp delegate] palettesManager]; NSDictionary *substituteClasses = [palettesManager substituteClasses]; NSEnumerator *en = [substituteClasses keyEnumerator]; NSString *subClassName = nil; diff --git a/Plugins/Nib/GormNibWrapperLoader.h b/Plugins/Nib/GormNibWrapperLoader.h index 582ad1e0..9becc688 100644 --- a/Plugins/Nib/GormNibWrapperLoader.h +++ b/Plugins/Nib/GormNibWrapperLoader.h @@ -33,8 +33,8 @@ @interface GormNibWrapperLoader : GormWrapperLoader { - NSIBObjectData *container; - id nibFilesOwner; + NSIBObjectData *_container; + id _nibFilesOwner; } - (BOOL) isTopLevelObject: (id)obj; @end diff --git a/Plugins/Nib/GormNibWrapperLoader.m b/Plugins/Nib/GormNibWrapperLoader.m index 3d73fd94..167c8b91 100644 --- a/Plugins/Nib/GormNibWrapperLoader.m +++ b/Plugins/Nib/GormNibWrapperLoader.m @@ -45,11 +45,11 @@ - (BOOL) isTopLevelObject: (id)obj { - NSMapTable *objects = [container objects]; + NSMapTable *objects = [_container objects]; id val = NSMapGet(objects,obj); BOOL result = NO; - if(val == nibFilesOwner || val == nil) + if(val == _nibFilesOwner || val == nil) { result = YES; } @@ -67,7 +67,7 @@ NSData *classes = nil; NSKeyedUnarchiver *u = nil; NSString *key = nil; - GormPalettesManager *palettesManager = [(id)NSApp palettesManager]; + GormPalettesManager *palettesManager = [(id)[NSApp delegate] palettesManager]; NSDictionary *substituteClasses = [palettesManager substituteClasses]; NSString *subClassName = nil; NSDictionary *fileWrappers = nil; @@ -143,8 +143,6 @@ /* * Special internal classes */ - [u setClass: [GormObjectProxy class] - forClassName: @"NSCustomObject"]; [u setClass: [GormCustomView class] forClassName: @"NSCustomView"]; [u setClass: [GormWindowTemplate class] @@ -167,17 +165,17 @@ // // decode // - container = [u decodeObjectForKey: @"IB.objectdata"]; - if (container == nil || [container isKindOfClass: [NSIBObjectData class]] == NO) + _container = [u decodeObjectForKey: @"IB.objectdata"]; + if (_container == nil || [_container isKindOfClass: [NSIBObjectData class]] == NO) { result = NO; } else { - nibFilesOwner = [container objectForName: @"File's Owner"]; + _nibFilesOwner = [_container objectForName: @"File's Owner"]; docFilesOwner = [document filesOwner]; - objects = [container names]; + objects = [_container names]; objs = NSAllMapTableKeys(objects); en = [objs objectEnumerator]; o = nil; @@ -185,9 +183,9 @@ // // set the current class on the File's owner... // - if([nibFilesOwner isKindOfClass: [GormObjectProxy class]]) + if([_nibFilesOwner isKindOfClass: [NSCustomObject class]]) { - [docFilesOwner setClassName: [nibFilesOwner className]]; + [docFilesOwner setClassName: [_nibFilesOwner className]]; } // @@ -200,9 +198,26 @@ NSString *objName = nil; // skip the file's owner, it is handled above... - if(o == nibFilesOwner) - continue; + if(o == _nibFilesOwner + || o == [document firstResponder]) + { + continue; + } + // + // If it's NSApplication (most likely the File's Owner) + // skip it... + // + if ([o isKindOfClass: [NSCustomObject class]]) + { + if ([[o className] isEqualToString: @"NSApplication"]) + { + continue; + } + + customClassName = [o className]; + } + // // if it's a window template, then replace it with an actual window. // @@ -210,7 +225,7 @@ { NSString *className = [o className]; BOOL isDeferred = [o isDeferred]; - BOOL isVisible = [[container visibleWindows] + BOOL isVisible = [[_container visibleWindows] containsObject: o]; // make the object deferred/visible... @@ -218,14 +233,17 @@ [document setObject: obj isDeferred: isDeferred]; [document setObject: obj isVisibleAtLaunch: isVisible]; - + + [document attachObject: obj + toParent: nil]; + // record the custom class... if([classManager isCustomClass: className]) { customClassName = className; } } - + if([self isTopLevelObject: obj]) { [document attachObject: obj @@ -243,7 +261,7 @@ // // Add custom classes... // - classesTable = [container classes]; + classesTable = [_container classes]; classKeys = NSAllMapTableKeys(classesTable); en = [classKeys objectEnumerator]; while((o = [en nextObject]) != nil) @@ -263,7 +281,7 @@ // // add connections... // - en = [[container connections] objectEnumerator]; + en = [[_container connections] objectEnumerator]; o = nil; while((o = [en nextObject]) != nil) { @@ -285,7 +303,7 @@ } } - if(dest == nibFilesOwner) + if(dest == _nibFilesOwner) { [o setDestination: [document filesOwner]]; } @@ -294,7 +312,7 @@ [o setDestination: [document firstResponder]]; } - if(src == nibFilesOwner) + if(src == _nibFilesOwner) { [o setSource: [document filesOwner]]; } @@ -379,6 +397,11 @@ [obj setTarget: nil]; [obj setAction: NULL]; } + else if([obj isKindOfClass: [NSCustomObject class]]) + { + GormObjectProxy *o = [[GormObjectProxy alloc] initWithClassName: [obj className]]; + obj = o; // replace the object if it's an NSCustomObject... + } return obj; } diff --git a/Plugins/Xib/GNUmakefile b/Plugins/Xib/GNUmakefile index 897c0bf9..77130554 100644 --- a/Plugins/Xib/GNUmakefile +++ b/Plugins/Xib/GNUmakefile @@ -29,7 +29,9 @@ BUNDLE_EXTENSION = .plugin Xib_PRINCIPAL_CLASS = GormXibPlugin Xib_OBJC_FILES = GormXibPlugin.m \ -GormXibWrapperLoader.m + GormXibWrapperLoader.m \ + GormXibWrapperBuilder.m \ + GormXIBModelGenerator.m \ Xib_RESOURCE_FILES = @@ -42,4 +44,3 @@ Xib_STANDARD_INSTALL = no include $(GNUSTEP_MAKEFILES)/bundle.make -include GNUmakefile.postamble - diff --git a/Plugins/Xib/GNUmakefile.preamble b/Plugins/Xib/GNUmakefile.preamble index 5c5abbb6..7ac08068 100644 --- a/Plugins/Xib/GNUmakefile.preamble +++ b/Plugins/Xib/GNUmakefile.preamble @@ -1,21 +1,19 @@ # Additional include directories the compiler should search -ADDITIONAL_INCLUDE_DIRS += -I../.. +ADDITIONAL_INCLUDE_DIRS += -I../../ ifeq ($(GNUSTEP_TARGET_OS),mingw32) ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../GormCore/GormCore.framework -ADDITIONAL_GUI_LIBS += -lGorm -lGormCore +ADDITIONAL_GUI_LIBS += -lInterfaceBuilder -lGormCore endif ifeq ($(GNUSTEP_TARGET_OS),cygwin) ADDITIONAL_LIB_DIRS += \ - -L../../GormLib/$(GNUSTEP_OBJ_DIR) \ + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ - -L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \ - -L../../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../GormCore/GormCore.framework -Nib_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore +$(BUNDLE_NAME)_LIBRARIES_DEPEND_UPON += -lInterfaceBuilder -lGormCore endif \ No newline at end of file diff --git a/Plugins/Xib/GormXIBModelGenerator.h b/Plugins/Xib/GormXIBModelGenerator.h new file mode 100644 index 00000000..4aff6533 --- /dev/null +++ b/Plugins/Xib/GormXIBModelGenerator.h @@ -0,0 +1,73 @@ +/** GormXIBKeyedArchiver + + Interface of GormXIBKeyedArchiver + + Copyright (C) 2023 Free Software Foundation, Inc. + + Author: Gregory John Casamento + Date: 2023 + + This file is part of the GNUstep GUI Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef GormXIBModelGenerator_H_INCLUDE +#define GormXIBModelGenerator_H_INCLUDE + +#import + +@class GormDocument; +@class NSMutableDictionary; +@class NSString; +@class NSData; +@class NSMutableArray; +@class NSMapTable; + +@interface GormXIBModelGenerator : NSObject +{ + GormDocument *_gormDocument; + NSMutableDictionary *_mappingDictionary; + NSMutableArray *_allIdentifiers; + NSMapTable *_objectToIdentifier; +} + +/** + * Returns an autoreleased GormXIBModelGenerator object; + */ ++ (instancetype) xibWithGormDocument: (GormDocument *)doc; + +/** + * Initialize with GormDocument object to parse the XML from or into. + */ +- (instancetype) initWithGormDocument: (GormDocument *)doc; + +/** + * The data for the XIB document that has been created + */ +- (NSData *) data; + +/** + * Exports XIB file. This method starts the process and calls + * another method that recurses through the objects in the model and + * maps any properties as appropriate when exporting. + */ +- (BOOL) exportXIBDocumentWithName: (NSString *)name; + +@end + +#endif // GormXIBModelGenerator_H_INCLUDE diff --git a/Plugins/Xib/GormXIBModelGenerator.m b/Plugins/Xib/GormXIBModelGenerator.m new file mode 100644 index 00000000..f5e9f0e4 --- /dev/null +++ b/Plugins/Xib/GormXIBModelGenerator.m @@ -0,0 +1,1977 @@ +/** GormXIBKeyedArchiver + + Interface of GormXIBKeyedArchiver + + Copyright (C) 2023 Free Software Foundation, Inc. + + Author: Gregory John Casamento + Date: 2023 + + This file is part of the GNUstep GUI Library. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; see the file COPYING.LIB. + If not, see or write to the + Free Software Foundation, 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#import +#import +#import +#import +#import +#import +#import +#import + +#import +#import +#import +#import +#import +#import +#import +#import +#import + +#import + +#import +#import +#import +#import +#import + +#import "GormXIBModelGenerator.h" + +static NSArray *_allowedSizeKeys = nil; +static NSArray *_externallyReferencedClasses = nil; +static NSDictionary *_signatures = nil; +static NSArray *_skipClass = nil; +static NSArray *_skipCollectionForKey = nil; +static NSArray *_singletonObjects = nil; +static NSDictionary *_methodToKeyName = nil; +static NSDictionary *_nonProperties = nil; +static NSArray *_excludedKeys = nil; +static NSDictionary *_mappedClassNames = nil; +static NSDictionary *_valueMapping = nil; + +static NSUInteger _count = INT_MAX; + +/* +NSString* XIBStringFromClass(Class cls) +{ + NSString *className = NSStringFromClass(cls); + + if (className != nil) + { + NSString *newClassName = [_mappedClassNames objectForKey: className]; + + if (newClassName != nil) + { + className = newClassName; + } + } + + return className; +} +*/ + +@interface NSButtonCell (_Private_) + +- (NSButtonType) buttonType; + +@end + +@implementation NSButtonCell (_Private_) + +- (NSButtonType) buttonType +{ + NSButtonType type = 0; + NSInteger highlightsBy = [self highlightsBy]; + NSInteger showsStateBy = [self showsStateBy]; + BOOL imageDimsWhenDisabled = [self imageDimsWhenDisabled]; + NSString *imageName = [[self image] name]; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtautological-bitwise-compare" + if ([imageName isEqualToString: @"GSSwitch"]) + { + type = NSSwitchButton; + } + else if ([imageName isEqualToString: @"GSRadio"]) + { + type = NSRadioButton; + } + else if ((highlightsBy | NSChangeBackgroundCellMask) + && (showsStateBy | NSNoCellMask) + && (imageDimsWhenDisabled == YES)) + { + type = NSMomentaryLightButton; + } + else if ((highlightsBy | (NSPushInCellMask | NSChangeGrayCellMask)) + && (showsStateBy | NSNoCellMask) + && (imageDimsWhenDisabled == YES)) + { + type = NSMomentaryPushInButton; + } + else if ((highlightsBy | NSContentsCellMask) + && (showsStateBy | NSNoCellMask) + && (imageDimsWhenDisabled == YES)) + { + type = NSMomentaryChangeButton; + } + else if ((highlightsBy | (NSPushInCellMask | NSChangeGrayCellMask)) + && (showsStateBy | NSChangeBackgroundCellMask) + && (imageDimsWhenDisabled == YES)) + { + type = NSPushOnPushOffButton; + } + else if ((highlightsBy | (NSPushInCellMask | NSContentsCellMask)) + && (showsStateBy | NSContentsCellMask) + && (imageDimsWhenDisabled == YES)) + { + type = NSOnOffButton; + } +#pragma GCC diagnostic pop + + return type; +} + +- (NSString *) buttonTypeString +{ + NSButtonType type = [self buttonType]; + NSString *result = @""; + + switch (type) + { + case NSMomentaryLightButton: + result = @"push"; + break; + case NSMomentaryPushInButton: + result = @"push"; // @"momentaryPushIn"; + break; + case NSMomentaryChangeButton: + result = @"momentarychange"; + break; + case NSPushOnPushOffButton: + result = @"push"; // @"pushonpushoff"; + break; + case NSOnOffButton: + result = @"onoff"; + break; + case NSToggleButton: + result = @"toggle"; + break; + case NSSwitchButton: + result = @"check"; + break; + case NSRadioButton: + result = @"radio"; + break; + default: + NSLog(@"Using unsupported button type %d", type); + break; + } + + return result; +} +@end + +@interface NSString (_hex_) + +- (NSString *) lowercaseFirstCharacter; +- (NSString *) splitString; +- (NSString *) hexString; ++ (NSString *) randomHex; + +@end + +@implementation NSString (_hex_) + +- (NSString *) lowercaseFirstCharacter +{ + // Lowercase the first letter of the class to make the element name + NSString *first = [[self substringToIndex: 1] lowercaseString]; + NSString *rest = [self substringFromIndex: 1]; + NSString *result = [NSString stringWithFormat: @"%@%@", first, rest]; + return result; +} + +- (NSString *) splitString +{ + NSString *result = [self substringFromIndex: [self length] - 8]; + + result = [NSString stringWithFormat: @"%@-%@-%@", + [result substringWithRange: NSMakeRange(0,3)], + [result substringWithRange: NSMakeRange(3,2)], + [result substringWithRange: NSMakeRange(5,3)]]; + + return result; +} + +- (NSString *) hexString +{ + NSUInteger l = [self length]; + unichar *c = malloc(l * sizeof(unichar)); + NSUInteger i = 0; + + [self getCharacters: c]; + + NSString *result = @""; + + for (i = 0; i < l; i++) + { + result = [result stringByAppendingString: [NSString stringWithFormat: @"%x", c[i]]]; + } + + free(c); + + return result; +} + ++ (NSString *) randomHex +{ + srand((unsigned int)_count--); + uint32_t r = (uint32_t)rand(); + return [NSString stringWithFormat: @"%08X", r]; // uppercase so we know it was generated... +} + +@end + +@interface GormXIBModelGenerator (Private) + +- (void) _collectObjectsFromObject: (id)obj + withParent: (NSXMLElement *)node; + +- (void) _collectObjectsFromObject: (id)obj + ForKey: (NSString *)keyName + withParent: (NSXMLElement *)node; + +@end + + +@implementation GormXIBModelGenerator + ++ (void) initialize +{ + if (self == [GormXIBModelGenerator class]) + { + _allowedSizeKeys = + [[NSArray alloc] initWithObjects: + @"cellSize", + @"intercellSpacing", + nil]; + + _externallyReferencedClasses = + [[NSArray alloc] initWithObjects: + @"NSTableHeaderView", + nil]; + + _valueMapping = + [[NSDictionary alloc] initWithObjectsAndKeys: + @"catalog", @"NSNamedColorSpace", + @"white", @"NSWhiteColorSpace", + @"deviceWhite", @"NSDeviceWhiteColorSpace", + @"calibratedWhite", @"NSCalibratedWhiteColorSpace", + @"deviceCMYK", @"NSDeviceCMYKColorSpace", + @"RGB", @"NSRGBColorSpace", + @"deviceRGB", @"NSDeviceRGBColorSpace", + @"calibratedRGB", @"NSCalibratedRGBColorSpace", + @"pattern", @"NSPatternColorSpace", + nil]; + + _signatures = + [[NSDictionary alloc] initWithObjectsAndKeys: + @"char", @"c", + @"NSUInteger", @"i", // this might be wrong.. maybe it should be NSInteger or just int + @"short", @"s", + @"long", @"l", + @"long long", @"q", + @"BOOL", @"C", // unsigned char + @"NSUInteger", @"I", + @"unsigned short",@"S", + @"unsigned long", @"L", + @"long long", @"Q", + @"float", @"f", + @"CGFloat", @"d", + @"bool", @"B", + @"void", @"v", + @"char*", @"*", + @"id", @"@", + @"Class", @"#", + @"SEL", @":", + @"NSRect", @"{_NSRect={_NSPoint=dd}{_NSSize=dd}}", + @"NSSize", @"{_NSSize=dd}", + @"NSPoint", @"{_NSPoint=dd}", + nil]; + _skipClass = + [[NSArray alloc] initWithObjects: + @"NSBrowserCell", + @"NSDateFormatter", + @"NSNumberFormatter", + nil]; + + _skipCollectionForKey = + [[NSArray alloc] initWithObjects: + @"headerView", + @"controlView", + @"outlineTableColumn", + @"documentView", + @"menu", + @"owner", + @"subviews", + @"contentView", + @"titleCell", + nil]; + + _singletonObjects = + [[NSArray alloc] initWithObjects: + @"GSNamedColor", + @"NSFont", + @"NSColor", + @"NSImage", + @"GSCalibratedWhiteColor", + nil]; + + _methodToKeyName = + [[NSDictionary alloc] initWithObjectsAndKeys: + @"name", @"colorNameComponent", + @"catalog", @"catalogNameComponent", + @"colorSpace", @"colorSpaceName", + @"white", @"whiteComponent", + @"red", @"redComponent", + @"green", @"greenComponent", + @"blue", @"blueComponent", + @"alpha", @"alphaComponent", + @"cyan", @"cyanComponent", + @"magenta", @"magentaComponent", + @"yellow", @"yellowComponent", + @"black", @"blackComponent", + nil]; + + _nonProperties = + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSArray arrayWithObject: @"cells"], + @"NSMatrix", + [NSArray arrayWithObjects: + @"colorNameComponent", + @"catalogNameComponent", + @"colorSpaceName", nil], + @"GSNamedColor", + [NSArray arrayWithObjects: + @"wjoteComponent", + @"colorSpaceName", nil], + @"GSWhiteColor", + [NSArray arrayWithObjects: + @"whiteComponent", + @"colorSpaceName", nil], + @"GSDeviceWhiteColor", + [NSArray arrayWithObjects: + @"whiteComponent", + @"colorSpaceName", nil], + @"GSCalibratedWhiteColor", + [NSArray arrayWithObjects: + @"cyanComponent", + @"magentaComponent", + @"yellowComponent", + @"blackComponent", + @"alphaComponent", + @"colorSpaceName", nil], + @"GSDeviceCMYKColor", + [NSArray arrayWithObjects: + @"redComponent", + @"blueComponent", + @"greenComponent", + @"alphaComponent", + @"colorSpaceName", nil], + @"GSRGBColor", + [NSArray arrayWithObjects: + @"redComponent", + @"blueComponent", + @"greenComponent", + @"alphaComponent", + @"colorSpaceName", nil], + @"GSDeviceRGBColor", + [NSArray arrayWithObjects: + @"redComponent", + @"blueComponent", + @"greenComponent", + @"alphaComponent", + @"colorSpaceName", nil], + @"GSCalibratedRBGColor", + [NSArray arrayWithObjects: + @"patternImage", + @"colorSpaceName", nil], + @"GSPatternColor", + nil]; + + _mappedClassNames = + [[NSDictionary alloc] initWithObjectsAndKeys: + @"NSColor", @"GSNamedColor", + @"NSColor", @"GSWhiteColor", + @"NSColor", @"GSDeviceWhiteColor", + @"NSColor", @"GSCalibratedWhiteColor", + @"NSColor", @"GSDeviceCMYKColor", + @"NSColor", @"GSRGBColor", + @"NSColor", @"GSDeviceRGBColor", + @"NSColor", @"GSCalibratedRGBColor", + @"NSColor", @"GSPatternColor", + @"NSView", @"GSTableCornerView", + @"NSWindow", @"NSPanel", + @"NSWindow", @"GormNSPanel", + nil]; + _excludedKeys = + [[NSArray alloc] initWithObjects: + @"font", + @"alphaValue", + @"servicesProvider", + @"servicesMenu", + @"nextResponder", + @"supermenu", + @"attributedStringValue", + @"stringValue", + @"objectValue", + @"menuView", @"menu", + @"attributedAlternateTitle", + @"attributedTitle", + @"miniwindowImage", + @"menuItem", + @"showsResizeIndicator", + @"titleFont", + @"target", + @"action", + @"textContainer", + @"subviews", + @"selectedRanges", + @"linkTextAttributes", + @"typingAttributes", + @"defaultParagraphStyle", + @"tableView", + @"sortDescriptors", + @"previousText", + @"nextText", + @"needsDisplay", + @"postsFrameChangedNotifications", + @"postsBoundsChangedNotifications", + @"menuRepresentation", + @"submenu", + @"initialFirstResponder", + @"cornerView", + @"doubleValue", + @"intValue", + @"previousKeyView", + @"nextKeyView", + @"prototype", + @"keyCell", + @"isLenient", + nil]; + } +} + +/** + * Returns an autoreleast GormXIBDocument object; + */ ++ (instancetype) xibWithGormDocument: (GormDocument *)doc +{ + return AUTORELEASE([[self alloc] initWithGormDocument: doc]); +} + +/** + * Initialize with GormDocument object to parse the XML from or into. + */ +- (instancetype) initWithGormDocument: (GormDocument *)doc +{ + self = [super init]; + if (self != nil) + { + ASSIGN(_gormDocument, doc); + _mappingDictionary = [[NSMutableDictionary alloc] init]; + _allIdentifiers = [[NSMutableArray alloc] init]; + _objectToIdentifier = RETAIN([NSMapTable weakToWeakObjectsMapTable]); + } + return self; +} + +- (void) dealloc +{ + DESTROY(_gormDocument); + DESTROY(_mappingDictionary); + DESTROY(_allIdentifiers); + DESTROY(_objectToIdentifier); + + [super dealloc]; +} + +- (NSString *) _convertName: (NSString *)name +{ + NSString *className = name; + + // NSLog(@"Name = %@", name); + + if ([_mappedClassNames objectForKey: name]) + { + className = [_mappedClassNames objectForKey: name]; + // NSLog(@"%@ => %@", name, className); + } + + NSString *result = [className stringByReplacingOccurrencesOfString: @"NS" + withString: @""]; + + // Try removing other prefixes... + result = [result stringByReplacingOccurrencesOfString: @"GS" + withString: @""]; + result = [result stringByReplacingOccurrencesOfString: @"Gorm" + withString: @""]; + + // Lowercase the first letter of the class to make the element name + result = [result lowercaseFirstCharacter]; + + // Map certain names to XIB equivalents... + if ([result isEqualToString: @"objectProxy"]) + { + result = @"customObject"; + } + + // NSLog(@"Result = %@", result); + + return result; +} + +- (BOOL) _isSameClass: (NSString *)className1 + and: (NSString *)className2 +{ + NSString *cc1 = [self _convertName: className1]; + NSString *cc2 = [self _convertName: className2]; + + return [cc1 isEqualToString: cc2]; +} + +- (NSString *) _createIdentifierForObject: (id)obj +{ + NSString *result = nil; + + if (obj != nil) + { + result = [_objectToIdentifier objectForKey: obj]; + if (result == nil) + { + if ([obj isKindOfClass: [GormObjectProxy class]]) + { + NSString *className = [obj className]; + + if ([className isEqualToString: @"NSApplication"]) + { + result = @"-3"; + return result; + } + else if ([className isEqualToString: @"NSOwner"]) + { + result = @"-2"; + return result; + } + else if ([className isEqualToString: @"NSFirst"]) + { + result = @"-1"; + return result; + } + } + else if([obj isKindOfClass: [GormFilesOwner class]]) + { + result = @"-2"; + return result; + } + else if([obj isKindOfClass: [GormFirstResponder class]]) + { + result = @"-1"; + return result; + } + else + { + result = [_gormDocument nameForObject: obj]; + } + + // Encoding + NSString *originalName = [result copy]; + NSString *stackedResult = [NSString stringWithFormat: @"%@%@%@%@", result, + result, result, result]; // kludge... + // + result = [stackedResult hexString]; + result = [result splitString]; + + // Collision... + id o = [_mappingDictionary objectForKey: result]; + if (o != nil) + { + result = [[NSString randomHex] splitString]; + } + + // If the id already exists, but isn't mapped... + if ([_allIdentifiers containsObject: result]) + { + result = [[NSString randomHex] splitString]; + } + + if (originalName != nil) + { + // Map the name... + [_mappingDictionary setObject: originalName + forKey: result]; + } + + // Record the id... + [_allIdentifiers addObject: result]; + + // Record the mapping of obj -> identifier... + [_objectToIdentifier setObject: result + forKey: obj]; + } + } + + return result; +} + +- (NSString *) _userLabelForObject: (id)obj +{ + NSString *result = nil; + + if ([obj isKindOfClass: [GormObjectProxy class]]) + { + NSString *className = [obj className]; + + if ([className isEqualToString: @"NSApplication"]) + { + result = @"Application"; + } + else if ([className isEqualToString: @"NSOwner"]) + { + result = @"File's Owner"; + } + else if ([className isEqualToString: @"NSFirst"]) + { + result = @"First Responder"; + } + } + + return result; +} + +- (void) _createPlaceholderObjects: (NSXMLElement *)elem +{ + NSXMLElement *co = nil; + NSXMLNode *attr = nil; + GormFilesOwner *filesOwner = [_gormDocument filesOwner]; + NSString *ownerClassName = [filesOwner className]; + + // Application... + co = [NSXMLNode elementWithName: @"customObject"]; + attr = [NSXMLNode attributeWithName: @"id" stringValue: @"-3"]; + [co addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"userLabel" stringValue: @"Application"]; + [co addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"customClass" stringValue: @"NSObject"]; + [co addAttribute: attr]; + [elem addChild: co]; + + // File's Owner... + co = [NSXMLNode elementWithName: @"customObject"]; + attr = [NSXMLNode attributeWithName: @"id" stringValue: @"-2"]; + [co addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"userLabel" stringValue: @"File's Owner"]; + [co addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"customClass" stringValue: ownerClassName]; + [co addAttribute: attr]; + [elem addChild: co]; + [self _addAllConnections: co fromObject: filesOwner]; + + // First Responder + co = [NSXMLNode elementWithName: @"customObject"]; + attr = [NSXMLNode attributeWithName: @"id" stringValue: @"-1"]; + [co addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"userLabel" stringValue: @"First Responder"]; + [co addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"customClass" stringValue: @"FirstResponder"]; + [co addAttribute: attr]; + [elem addChild: co]; +} + +- (NSArray *) _propertiesFromMethods: (NSArray *)methods + forObject: (id)obj +{ + NSEnumerator *en = [methods objectEnumerator]; + NSString *name = nil; + NSMutableArray *result = [NSMutableArray array]; + + while ((name = [en nextObject]) != nil) + { + if ([name isEqualToString: @"set"] == NO) // this is the [NSFont set] method... skip... + { + NSString *substring = [name substringToIndex: 3]; + if ([substring isEqualToString: @"set"]) + { + NSString *os = [[name substringFromIndex: 3] + stringByReplacingOccurrencesOfString: @":" + withString: @""]; + NSString *s = [os lowercaseFirstCharacter]; + NSString *iss = [NSString stringWithFormat: @"is%@", os]; + + if ([methods containsObject: s]) + { + SEL sel = NSSelectorFromString(s); + if (sel != NULL) + { + NSDebugLog(@"selector = %@",s); + // NSMethodSignature *sig = [obj methodSignatureForSelector: sel]; + + // NSLog(@"methodSignatureForSelector %@ -> %s", s, [sig methodReturnType]); + if ([obj respondsToSelector: sel]) // if it has a normal getting, fine... + { + [result addObject: s]; + } + } + } + else if ([methods containsObject: iss]) + { + NSDebugLog(@"***** retrying with getter name: %@", iss); + SEL sel = NSSelectorFromString(iss); + if (sel != nil) + { + if ([obj respondsToSelector: sel]) + { + NSDebugLog(@"Added... %@", iss); + [result addObject: iss]; + } + } + } + } + } + } + + return result; +} + +- (void) _addRect: (NSRect)r toElement: (NSXMLElement *)elem withName: (NSString *)name +{ + NSXMLElement *rectElem = [NSXMLNode elementWithName: @"rect"]; + NSXMLNode *attr = nil; + + attr = [NSXMLNode attributeWithName: @"key" stringValue: name]; + [rectElem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"x" stringValue: [NSString stringWithFormat: @"%.1f",r.origin.x]]; + [rectElem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"y" stringValue: [NSString stringWithFormat: @"%.1f",r.origin.y]]; + [rectElem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"width" stringValue: [NSString stringWithFormat: @"%ld", (NSUInteger)r.size.width]]; + [rectElem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"height" stringValue: [NSString stringWithFormat: @"%ld", (NSUInteger)r.size.height]]; + [rectElem addAttribute: attr]; + + [elem addChild: rectElem]; +} + +- (void) _addSize: (NSSize)size toElement: (NSXMLElement *)elem withName: (NSString *)name +{ + NSXMLElement *rectElem = [NSXMLNode elementWithName: @"size"]; + NSXMLNode *attr = nil; + + attr = [NSXMLNode attributeWithName: @"key" stringValue: name]; + [rectElem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"width" stringValue: [NSString stringWithFormat: @"%ld", (NSUInteger)size.width]]; + [rectElem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"height" stringValue: [NSString stringWithFormat: @"%ld", (NSUInteger)size.height]]; + [rectElem addAttribute: attr]; + + [elem addChild: rectElem]; +} + +- (void) _addKeyEquivalent: (NSString *)ke toElement: (NSXMLElement *)elem +{ + if ([ke isEqualToString: @""] == NO) + { + NSCharacterSet *cs = [NSCharacterSet alphanumericCharacterSet]; + unichar c = [ke characterAtIndex: 0]; + + if ([cs characterIsMember: c]) + { + NSXMLNode *attr = [NSXMLNode attributeWithName: @"keyEquivalent" stringValue: ke]; + [elem addAttribute: attr]; + } + + NSDebugLog(@"elem = %@", elem); + } +} + +- (void) _addKeyEquivalentModifierMask: (NSUInteger)mask toElement: (NSXMLElement *)elem +{ + NSXMLNode *attr = nil; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtautological-bitwise-compare" + NSDebugLog(@"keyEquivalentModifierMask = %ld, element = %@", mask, elem); + if ([elem attributeForName: @"keyEquivalent"] != nil) + { + if (mask | NSCommandKeyMask) + { + attr = [NSXMLNode attributeWithName: @"command" stringValue: @"YES"]; + [elem addAttribute: attr]; + } + if (mask | NSShiftKeyMask) + { + attr = [NSXMLNode attributeWithName: @"shift" stringValue: @"YES"]; + [elem addAttribute: attr]; + } + if (mask | NSControlKeyMask) + { + attr = [NSXMLNode attributeWithName: @"control" stringValue: @"YES"]; + [elem addAttribute: attr]; + } + if (mask | NSAlternateKeyMask) + { + attr = [NSXMLNode attributeWithName: @"option" stringValue: @"YES"]; + [elem addAttribute: attr]; + } + } +#pragma GCC diagnostic pop +} + +- (void) _addWindowStyleMask: (NSUInteger)mask toElement: (NSXMLElement *)elem +{ + NSXMLNode *attr = nil; + + NSDebugLog(@"styleMask = %ld, element = %@", mask, elem); + + NSXMLElement *styleMaskElem = [NSXMLNode elementWithName: @"windowStyleMask"]; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtautological-bitwise-compare" + if (mask | NSWindowStyleMaskTitled) + { + attr = [NSXMLNode attributeWithName: @"titled" stringValue: @"YES"]; + [styleMaskElem addAttribute: attr]; + } + if (mask | NSWindowStyleMaskClosable) + { + attr = [NSXMLNode attributeWithName: @"closable" stringValue: @"YES"]; + [styleMaskElem addAttribute: attr]; + } + if (mask | NSWindowStyleMaskMiniaturizable) + { + attr = [NSXMLNode attributeWithName: @"miniaturizable" stringValue: @"YES"]; + [styleMaskElem addAttribute: attr]; + } + if (mask | NSWindowStyleMaskResizable) + { + attr = [NSXMLNode attributeWithName: @"resizable" stringValue: @"YES"]; + [styleMaskElem addAttribute: attr]; + } +#pragma GCC diagnostic pop + + attr = [NSXMLNode attributeWithName: @"key" stringValue: @"styleMask"]; + [styleMaskElem addAttribute: attr]; + + [elem addChild: styleMaskElem]; +} + +- (void) _addButtonType: (NSString *)buttonTypeString toElement: (NSXMLElement *)elem +{ + NSXMLNode *attr = nil; + + attr = [NSXMLNode attributeWithName: @"type" stringValue: buttonTypeString]; + [elem addAttribute: attr]; + + if ([buttonTypeString isEqualToString: @"check"] + || [buttonTypeString isEqualToString: @"radio"]) + { + attr = [NSXMLNode attributeWithName: @"imagePosition" stringValue: @"left"]; + [elem addAttribute: attr]; + } +} + +- (void) _addAlignment: (NSUInteger)alignment toElement: (NSXMLElement *)elem +{ + NSXMLNode *attr = nil; + NSString *string = nil; + + switch (alignment) + { + case NSLeftTextAlignment: + string = @"left"; + break; + case NSRightTextAlignment: + string = @"right"; + break; + case NSCenterTextAlignment: + string = @"center"; + break; + case NSJustifiedTextAlignment: + string = @"justified"; + break; + case NSNaturalTextAlignment: + string = @"natural"; + break; + } + + attr = [NSXMLNode attributeWithName: @"alignment" stringValue: string]; + [elem addAttribute: attr]; +} + +- (void) _addBezelStyleForObject: (id)obj + toElement: (NSXMLElement *)elem +{ + NSString *result = nil; + NSXMLNode *attr = nil; + + if ([obj isKindOfClass: [NSButtonCell class]]) + { + NSBezelStyle bezel = (NSBezelStyle)[obj bezelStyle] - 1; + NSArray *bezelTypeArray = [NSArray arrayWithObjects: + @"rounded", + @"regularSquare", + @"thick", + @"thicker", + @"disclosure", + @"shadowlessSquare", + @"circular", + @"texturedSquare", + @"helpButton", + @"smallSquare", + @"texturedRounded", + @"roundRect", + @"recessed", + @"roundedDisclosure", + @"next", + @"pushButton", + @"smallIconButton", + @"mediumIconButton", + @"largeIconButton", nil]; + if (bezel >= 0 && bezel <= 18) + { + result = [bezelTypeArray objectAtIndex: bezel]; + } + } + else if ([obj isKindOfClass: [NSTextFieldCell class]]) + { + NSTextFieldBezelStyle bezel = (NSTextFieldBezelStyle)[obj bezelStyle]; + NSArray *bezelTypeArray = [NSArray arrayWithObjects: + @"square", + @"rounded", nil]; + + if (bezel >= 0 && bezel <= 1) + { + result = [bezelTypeArray objectAtIndex: bezel]; + } + } + + if (result != nil) + { + attr = [NSXMLNode attributeWithName: @"bezelStyle" stringValue: result]; + [elem addAttribute: attr]; + } +} + +- (void) _addBorderStyle: (BOOL)bordered toElement: (NSXMLElement *)elem +{ + if (bordered) + { + NSXMLNode *attr = [NSXMLNode attributeWithName: @"borderStyle" stringValue: @"border"]; + [elem addAttribute: attr]; + } +} + +- (void) _addAutoresizingMask: (NSAutoresizingMaskOptions)m toElement: (NSXMLElement *)elem +{ + if (m != 0) + { + NSXMLElement *autoresizingMaskElem = [NSXMLNode elementWithName: @"autoresizingMask"]; + NSXMLNode *attr = nil; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtautological-bitwise-compare" + if (m | NSViewWidthSizable) + { + attr = [NSXMLNode attributeWithName: @"widthSizable" stringValue: @"YES"]; + } + if (m | NSViewHeightSizable) + { + attr = [NSXMLNode attributeWithName: @"heightSizable" stringValue: @"YES"]; + } + if (m | NSViewMaxXMargin) + { + attr = [NSXMLNode attributeWithName: @"flexibleMaxX" stringValue: @"YES"]; + } + if (m | NSViewMaxYMargin) + { + attr = [NSXMLNode attributeWithName: @"flexibleMaxY" stringValue: @"YES"]; + } + if (m | NSViewMinXMargin) + { + attr = [NSXMLNode attributeWithName: @"flexibleMinX" stringValue: @"YES"]; + } + if (m | NSViewMinYMargin) + { + attr = [NSXMLNode attributeWithName: @"flexibleMinY" stringValue: @"YES"]; + } +#pragma GCC diagnostic pop + + [autoresizingMaskElem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"key" stringValue: @"autoresizeMask"]; + [autoresizingMaskElem addAttribute: attr]; + + [elem addChild: autoresizingMaskElem]; + } +} + +- (void) _addTitlePosition: (NSTitlePosition)p toElement: (NSXMLElement *)elem +{ + NSString *result = nil; + + switch (p) + { + case NSNoTitle: + result = @"noTitle"; + break; + case NSAboveTop: + result = @"aboveTop"; + break; + case NSAtTop: + break; + case NSBelowTop: + result = @"belowTop"; + break; + case NSAboveBottom: + result = @"aboveBottom"; + break; + case NSAtBottom: + result = @"atBottom"; + break; + case NSBelowBottom: + result = @"belowBottom"; + break; + } + + if (result != nil) + { + NSXMLNode *attr = [NSXMLNode attributeWithName: @"titlePosition" stringValue: result]; + [elem addAttribute: attr]; + } +} + +- (void) _addTableColumns: (NSArray *)cols toElement: (NSXMLElement *)elem +{ + if ([cols count] > 0) + { + NSXMLElement *tblColElem = [NSXMLNode elementWithName: @"tableColumns"]; + NSEnumerator *en = [cols objectEnumerator]; + id col = nil; + + // NSLog(@"cols = %@", cols); + while ((col = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: col + withParent: tblColElem]; + } + + [elem addChild: tblColElem]; + } +} + +- (void) _addBoolean: (BOOL)flag withName: (NSString *)name toElement: (NSXMLElement *)elem +{ + if (flag == YES) + { + NSXMLNode *attr = [NSXMLNode attributeWithName: name + stringValue: @"YES"]; + [elem addAttribute: attr]; + + // Somewhat kludgy fix for button border problem... + if ([name isEqualToString: @"bordered"]) + { + attr = [NSXMLNode attributeWithName: @"borderStyle" + stringValue: @"border"]; + [elem addAttribute: attr]; + } + } +} + +- (void) _addFloat: (CGFloat)f withName: (NSString *)name toElement: (NSXMLElement *)elem +{ + NSString *val = [NSString stringWithFormat: @"%.1f",f]; + NSXMLNode *attr = [NSXMLNode attributeWithName: name + stringValue: val]; + [elem addAttribute: attr]; +} + +- (void) _addString: (NSString *)val withName: (NSString *)name toElement: (NSXMLElement *)elem +{ + if (val != nil && [val isEqualToString: @""] == NO) + { + NSXMLNode *attr = [NSXMLNode attributeWithName: name + stringValue: val]; + [elem addAttribute: attr]; + } +} + +- (void) _addCellsFromMatrix: (NSMatrix *)matrix toElement: (NSXMLElement *)elem +{ + NSRect rect = [matrix frame]; + NSSize cellSize = [matrix cellSize]; + NSSize inter = [matrix intercellSpacing]; + NSUInteger itemsPerCol = (rect.size.width + inter.width) / cellSize.width; + NSUInteger itemsPerRow = (rect.size.height + inter.height) / cellSize.height; + NSUInteger c = 0; + NSUInteger r = 0; + NSArray *cells = [matrix cells]; + NSUInteger count = [cells count]; + NSUInteger i = 0; + NSXMLElement *cellsElem = [NSXMLNode elementWithName: @"cells"]; + NSString *cellClass = nil; + + NSDebugLog(@"cells = %@\nelem = %@", [matrix cells], elem); + NSLog(@"WARNING: NSMatrix is not fully supported by Xcode, this might cause it to crash or may not be reloadable by this application"); + + if (count > 0) + { + [elem addChild: cellsElem]; + for (c = 0; c < itemsPerCol; c++) + { + NSXMLElement *columnElem = [NSXMLNode elementWithName: @"column"]; + + for (r = 0; r < itemsPerRow; r++) + { + id cell = nil; + + i = (c * itemsPerCol) + r; + + // If we go past the end of the array... + if (i >= count) + { + continue; + } + + cell = [cells objectAtIndex: i]; + if (cellClass == nil) + { + cellClass = NSStringFromClass([cell class]); + } + + [self _collectObjectsFromObject: cell + withParent: columnElem]; + } + [cellsElem addChild: columnElem]; + } + } + + // Add the cell class, so that it doesn't crash on reload... + if (cellClass != nil) + { + NSXMLNode *attr = [NSXMLNode attributeWithName: @"cellClass" stringValue: cellClass]; + [elem addAttribute: attr]; + } + else + { + NSXMLNode *attr = [NSXMLNode attributeWithName: @"cellClass" stringValue: @"NSButtonCell"]; + [elem addAttribute: attr]; + } +} + +- (void) _addHoldingPrioritiesForSplitView: (NSSplitView *)sv toElement: (NSXMLElement *)elem +{ + NSUInteger count = [[sv subviews] count]; + NSXMLElement *holdingPrioritiesElement = [NSXMLNode elementWithName: @"holdingPriorities"]; + NSUInteger i = 0; + + for (i = 0; i < count; i++) + { + NSXMLElement *realElement = [NSXMLNode elementWithName: @"real"]; + NSXMLNode *attr = [NSXMLNode attributeWithName: @"value" stringValue: @"250"]; // default value + + [realElement addAttribute: attr]; + [holdingPrioritiesElement addChild: realElement]; + } + + [elem addChild: holdingPrioritiesElement]; +} + +- (void) _addProperty: (NSString *)name + withType: (NSString *)type + toElement: (NSXMLElement *)elem + fromObject: (id)obj +{ + NSString *objClassName = NSStringFromClass([obj class]); + + if ([_excludedKeys containsObject: name]) + { + NSDebugLog(@"skipping %@", name); + return; // do not process anything in the excluded key list... + } + + if ([_skipClass containsObject: objClassName] || objClassName == nil) + { + return; + } + + if ([name isEqualToString: @"cells"] + && [obj isKindOfClass: [NSMatrix class]]) + { + [self _addCellsFromMatrix: obj toElement: elem]; + return; + } + + if ([type isEqualToString: @"id"]) // clz != nil) // type is a class + { + SEL s = NSSelectorFromString(name); + + // NSLog(@"%@ -> %@", name, type); + if (s != NULL) + { + if ([obj respondsToSelector: s]) + { + id o = [obj performSelector: s]; + if (o != nil) + { + NSString *newName = [_methodToKeyName objectForKey: name]; + + if (newName != nil) + { + name = newName; + } + + if ([o isKindOfClass: [NSString class]]) + { + NSDebugLog(@"Adding string property %@ = %@", name, o); + if ([_valueMapping objectForKey: o] != nil) + { + o = [_valueMapping objectForKey: o]; + } + + if ([name isEqualToString: @"keyEquivalent"]) + { + [self _addKeyEquivalent: o + toElement: elem]; + } + else if (o != nil && [o isEqualToString: @""] == NO) + { + NSXMLNode *attr = [NSXMLNode attributeWithName: name + stringValue: o]; + + [elem addAttribute: attr]; + } + } + else + { + NSString *className = NSStringFromClass([o class]); + + if ([_singletonObjects containsObject: className] == NO + || [_externallyReferencedClasses containsObject: className]) + { + NSString *ident = [self _createIdentifierForObject: o]; + NSXMLNode *attr = [NSXMLNode attributeWithName: name + stringValue: ident]; + [elem addAttribute: attr]; + } + + if ([_skipCollectionForKey containsObject: name] == NO) + { + [self _collectObjectsFromObject: o + forKey: name + withParent: elem]; + } + } + } + } + } + } + else if ([type isEqualToString: @"NSRect"]) + { + SEL sel = NSSelectorFromString(name); + if (sel != NULL) + { + IMP imp = [obj methodForSelector: sel]; + + if (imp != NULL) + { + NSRect f = ((NSRect (*)(id, SEL))imp)(obj, sel); + [self _addRect: f toElement: elem withName: name]; + + } + } + } + else if ([type isEqualToString: @"NSSize"]) + { + if ([_allowedSizeKeys containsObject: name]) + { + SEL sel = NSSelectorFromString(name); + if (sel != NULL) + { + IMP imp = [obj methodForSelector: sel]; + + if (imp != NULL) + { + NSSize s = ((NSSize (*)(id, SEL))imp)(obj, sel); + [self _addSize: s toElement: elem withName: name]; + + } + } + } + } + else if ([type isEqualToString: @"CGFloat"]) + { + NSString *keyName = name; + SEL sel = NSSelectorFromString(name); + if (sel != NULL) + { + IMP imp = [obj methodForSelector: sel]; + + if (imp != NULL) + { + CGFloat f = ((CGFloat (*)(id, SEL))imp)(obj, sel); + + [self _addFloat: f + withName: keyName + toElement: elem]; + } + } + } + else if ([type isEqualToString: @"BOOL"]) + { + NSString *keyName = name; + + if ([[name substringToIndex: 2] isEqualToString: @"is"]) + { + keyName = [name substringFromIndex: 2]; + keyName = [keyName lowercaseString]; + } + + SEL sel = NSSelectorFromString(name); + if (sel != NULL) + { + IMP imp = [obj methodForSelector: sel]; + + if (imp != NULL) + { + BOOL f = ((BOOL (*)(id, SEL))imp)(obj, sel); + + [self _addBoolean: f + withName: keyName + toElement: elem]; + } + } + } + else if ([name isEqualToString: @"keyEquivalentModifierMask"]) + { + NSUInteger k = [obj keyEquivalentModifierMask]; + [self _addKeyEquivalentModifierMask: k toElement: elem]; + } + else if ([name isEqualToString: @"buttonType"]) + { + NSString *buttonTypeString = [obj buttonTypeString]; + [self _addButtonType: buttonTypeString + toElement: elem]; + } + else if ([name isEqualToString: @"autoresizingMask"]) + { + NSAutoresizingMaskOptions m = [obj autoresizingMask]; + [self _addAutoresizingMask: m + toElement: elem]; + } + else if ([name isEqualToString: @"alignment"] && [obj respondsToSelector: @selector(cell)] == NO) + { + [self _addAlignment: [obj alignment] + toElement: elem]; + } + else if ([name isEqualToString: @"bezelStyle"] && [obj respondsToSelector: @selector(cell)] == NO) + { + [self _addBezelStyleForObject: obj + toElement: elem]; + } + else if ([name isEqualToString: @"isBordered"] && [obj respondsToSelector: @selector(cell)] == NO) + { + BOOL bordered = [obj isBordered]; + NSDebugLog(@"Handling isBordered..."); + [self _addBorderStyle: bordered + toElement: elem]; + } + else if ([name isEqualToString: @"titlePosition"]) + { + NSTitlePosition p = [obj titlePosition]; + [self _addTitlePosition: p + toElement: elem]; + } +} + +- (void) _addPropertiesFromArray: (NSArray *)props toElement: (NSXMLElement *)elem fromObject: (id)obj +{ + if ([props count] > 0) + { + NSEnumerator *en = [props objectEnumerator]; + NSString *name = nil; + + while ((name = [en nextObject]) != nil) + { + SEL sel = NSSelectorFromString(name); + if (sel != NULL) + { + if ([obj respondsToSelector: sel] == NO) + continue; + + if ([_excludedKeys containsObject: name]) + continue; + + NSMethodSignature *sig = [obj methodSignatureForSelector: sel]; + if (sig != NULL) + { + const char *ctype = [sig methodReturnType]; + if (ctype != NULL) + { + NSString *ctypeString = [NSString stringWithCString: ctype + encoding: NSUTF8StringEncoding]; + NSString *type = [_signatures objectForKey: ctypeString]; + + if (type != nil) + { + [self _addProperty: name withType: type toElement: elem fromObject: obj]; + } + } + } + } + } + } +} + +- (void) _addAllProperties: (NSXMLElement *)elem fromObject: (id)obj +{ + NSArray *methods = GSObjCMethodNames(obj, YES); + NSArray *props = [self _propertiesFromMethods: methods forObject: obj]; + + [self _addPropertiesFromArray: props toElement: elem fromObject: obj]; + NSDebugLog(@"methods = %@", props); +} + +- (void) _addAllNonProperties: (NSXMLElement *)elem fromObject: (id)obj +{ + NSString *className = NSStringFromClass([obj class]); + if (className != nil) + { + NSArray *props = [_nonProperties objectForKey: className]; + + [self _addPropertiesFromArray: props toElement: elem fromObject: obj]; + } +} + +- (void) _addAllConnections: (NSXMLElement *)elem fromObject: (id)obj +{ + NSArray *connectors = [_gormDocument connectorsForSource: obj + ofClass: [NSNibControlConnector class]]; + if ([connectors count] > 0) + { + NSXMLElement *conns = [NSXMLNode elementWithName: @"connections"]; + NSEnumerator *en = [connectors objectEnumerator]; + NSNibControlConnector *action = nil; + + // Get actions... + while ((action = [en nextObject]) != nil) + { + NSString *targetId = [self _createIdentifierForObject: [action destination]]; + + if ([targetId isEqualToString: @""] == NO && targetId != nil) + { + NSDebugLog(@"action = %@", action); + NSXMLElement *actionElem = [NSXMLNode elementWithName: @"action"]; + NSXMLNode *attr = [NSXMLNode attributeWithName: @"selector" + stringValue: [action label]]; + [actionElem addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"target" + stringValue: targetId]; + [actionElem addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"id" + stringValue: [[NSString randomHex] splitString]]; + [actionElem addAttribute: attr]; + + [conns addChild: actionElem]; + } + } + + [elem addChild: conns]; + } + + connectors =[_gormDocument connectorsForSource: obj + ofClass: [NSNibOutletConnector class]]; + + NSDebugLog(@"outlet connectors = %@, for obj = %@", connectors, obj); + + if ([connectors count] > 0) + { + NSXMLElement *conns = [NSXMLNode elementWithName: @"connections"]; + NSEnumerator *en = [connectors objectEnumerator]; + NSNibOutletConnector *outlet = nil; + + // Get actions... + while ((outlet = [en nextObject]) != nil) + { + NSString *destinationId = [self _createIdentifierForObject: [outlet destination]]; + + if([destinationId isEqualToString: @""] == NO && destinationId != nil) + { + NSDebugLog(@"outlet = %@", outlet); + NSXMLElement *outletElem = [NSXMLNode elementWithName: @"outlet"]; + NSXMLNode *attr = [NSXMLNode attributeWithName: @"property" + stringValue: [outlet label]]; + [outletElem addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"destination" + stringValue: destinationId]; + [outletElem addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"id" + stringValue: [[NSString randomHex] splitString]]; + [outletElem addAttribute: attr]; + + [conns addChild: outletElem]; + } + } + + [elem addChild: conns]; + } +} + +// This method recursively navigates the entire object tree and emits XML +- (void) _collectObjectsFromObject: (id)obj + forKey: (NSString *)keyName + withParent: (NSXMLElement *)pNode +{ + NSString *ident = [self _createIdentifierForObject: obj]; + + if (ident != nil) + { + NSXMLElement *parentNode = pNode; + NSString *className = NSStringFromClass([obj class]); + + if ([_skipClass containsObject: className]) + { + return; + } + + NSString *elementName = [self _convertName: className]; + // NSLog(@"elementName = %@", elementName); + NSXMLElement *elem = [NSXMLNode elementWithName: elementName]; + NSXMLNode *attr = nil; + + // If the object is a singleton, then there is no need for the id to be presented. + if ([_singletonObjects containsObject: className] == NO) + { + attr = [NSXMLNode attributeWithName: @"id" stringValue: ident]; + [elem addAttribute: attr]; + } + + NSString *name = [_gormDocument nameForObject: obj]; + NSString *userLabel = [self _userLabelForObject: obj]; + if (userLabel != nil) + { + attr = [NSXMLNode attributeWithName: @"userLabel" stringValue: userLabel]; + [elem addAttribute: attr]; + } + + // Add key to elem... + if (keyName != nil && [keyName isEqualToString: @""] == NO) + { + attr = [NSXMLNode attributeWithName: @"key" stringValue: keyName]; + [elem addAttribute: attr]; + } + + if ([obj isKindOfClass: [GormObjectProxy class]] || + [obj respondsToSelector: @selector(className)]) + { + if ([self _isSameClass: className and: [obj className]] == NO) + { + className = [obj className]; + attr = [NSXMLNode attributeWithName: @"customClass" stringValue: className]; + [elem addAttribute: attr]; + } + } + + // Add all of the connections for a given object... + [self _addAllConnections: elem fromObject: obj]; + + // Add all properties, then add the element to the parent... + [self _addAllProperties: elem fromObject: obj]; + + // Add some items that are not actually properties, but should be reflected in the XML... + [self _addAllNonProperties: elem fromObject: obj]; + + // Move this to its grandfather node... XIB files seem to expect this in the scroll view... + if ([obj isKindOfClass: [NSScrollView class]]) + { + NSClipView *cv = [obj contentView]; + NSArray *sv = [cv subviews]; + + if ([sv count] > 0) + { + id view = [[cv subviews] objectAtIndex: 0]; + + if ([view respondsToSelector: @selector(headerView)]) + { + id hv = [view headerView]; + [self _collectObjectsFromObject: hv + forKey: nil + withParent: elem]; + } + } + } + + // Don't add the MainMenu directly, since we need to wrap it.. NSMenu... + if ([name isEqualToString: @"NSMenu"] == NO) + { + [parentNode addChild: elem]; + } + + // For each different class, recurse through the structure as needed. + + // For NSMenu, there is a special case, since it needs to be contained in another menu. + if ([obj isKindOfClass: [NSMenu class]]) + { + NSArray *items = [obj itemArray]; + NSEnumerator *en = [items objectEnumerator]; + id item = nil; + + if ([name isEqualToString: @"NSMenu"]) + { + NSXMLNode *systemMenuAttr = [NSXMLNode attributeWithName: @"systemMenu" stringValue: @"apple"]; + [elem addAttribute: systemMenuAttr]; + + NSXMLElement *mainMenuElem = [NSXMLNode elementWithName: @"menu"]; + + attr = [NSXMLNode attributeWithName: @"id" stringValue: [[NSString randomHex] splitString]]; + [mainMenuElem addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"systemMenu" stringValue: @"main"]; + [mainMenuElem addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"title" stringValue: @"Main Menu"]; + [mainMenuElem addAttribute: attr]; + + NSXMLElement *mainItemsElem = [NSXMLNode elementWithName: @"items"]; + [mainMenuElem addChild: mainItemsElem]; + + NSXMLElement *mainMenuItem = [NSXMLNode elementWithName: @"menuItem"]; + [mainItemsElem addChild: mainMenuItem]; + attr = [NSXMLNode attributeWithName: @"id" stringValue: [[NSString randomHex] splitString]]; + [mainMenuItem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"title" stringValue: [obj title]]; + + [mainMenuItem addChild: elem]; // Now add the node, since we have inserted the proper system menu + + [parentNode addChild: mainMenuElem]; + } + + // Add submenu attribute... + attr = [NSXMLNode attributeWithName: @"key" stringValue: @"submenu"]; + [elem addAttribute: attr]; + + // Add services menu... + if (obj == [_gormDocument servicesMenu]) + { + attr = [NSXMLNode attributeWithName: @"systemMenu" stringValue: @"services"]; + [elem addAttribute: attr]; + } + + NSXMLElement *itemsElem = [NSXMLNode elementWithName: @"items"]; + while ((item = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: item + withParent: itemsElem]; + } + [elem addChild: itemsElem]; // Add to parent element... + } + + if ([obj isKindOfClass: [NSMenuItem class]]) + { + NSMenu *sm = [obj submenu]; + if (sm != nil) + { + [self _collectObjectsFromObject: sm + withParent: elem]; + } + } + + // Handle special case for popup, we need to add the selected item, and contain them + // in a "menu" instance which doesn't exist on GNUstep... + if ([obj isKindOfClass: [NSPopUpButtonCell class]]) + { + NSArray *items = [obj itemArray]; + NSEnumerator *en = [items objectEnumerator]; + id item = nil; + NSXMLElement *menuElem = [NSXMLNode elementWithName: @"menu"]; + NSXMLElement *itemsElem = [NSXMLNode elementWithName: @"items"]; + NSXMLNode *attr = nil; + + attr = [NSXMLNode attributeWithName: @"key" stringValue: @"menu"]; + [menuElem addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"id" stringValue: [[NSString randomHex] splitString]]; + [menuElem addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"key" stringValue: @"cell"]; + [elem addAttribute: attr]; + + id selectedItem = [obj selectedItem]; + if (selectedItem != nil) + { + NSString *selectedItemId = [self _createIdentifierForObject: selectedItem]; + attr = [NSXMLNode attributeWithName: @"selectedItem" stringValue: selectedItemId]; + while ((item = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: item + withParent: itemsElem]; + } + [elem addAttribute: attr]; + } + + [menuElem addChild: itemsElem]; + [elem addChild: menuElem]; // Add to parent element... + } + + if ([obj isKindOfClass: [NSTableHeaderView class]]) + { + NSXMLNode *attr = [NSXMLNode attributeWithName: @"key" stringValue: @"headerView"]; + [elem addAttribute: attr]; + } + + if ([obj isKindOfClass: [NSWindow class]]) + { + NSRect s = [[NSScreen mainScreen] frame]; + NSRect c = [[obj contentView] frame]; + NSUInteger m = [obj styleMask]; + + [self _addWindowStyleMask: m toElement: elem]; + [self _addRect: c toElement: elem withName: @"contentRect"]; + [self _addRect: s toElement: elem withName: @"screenRect"]; + [self _collectObjectsFromObject: [obj contentView] + withParent: elem]; + } + + if ([obj isKindOfClass: [NSPanel class]]) + { + NSString *className = NSStringFromClass([obj class]); + + if ([className isEqualToString: @"GormNSPanel"]) + { + className = @"NSPanel"; + } + + NSXMLNode *attr = [NSXMLNode attributeWithName: @"customClass" stringValue: className]; + [elem addAttribute: attr]; + } + + if ([obj isKindOfClass: [NSView class]]) // && [obj resondsToSelect: @selector(contentView)] == NO) + { + id sv = [obj superview]; + + if (obj == [[obj window] contentView]) + { + NSXMLNode *contentViewAttr = [NSXMLNode attributeWithName: @"key" stringValue: @"contentView"]; + [elem addAttribute: contentViewAttr]; + } + + if ([sv respondsToSelector: @selector(contentView)]) + { + if ([sv contentView] == obj) + { + NSXMLNode *contentViewAttr = [NSXMLNode attributeWithName: @"key" stringValue: @"contentView"]; + [elem addAttribute: contentViewAttr]; + } + } + + if ([obj respondsToSelector: @selector(contentView)]) + { + NSView *cv = [obj contentView]; + [self _collectObjectsFromObject: cv + withParent: elem]; + } + else + { + if ([obj isKindOfClass: [NSTabView class]] == NO) + { + NSArray *subviews = [obj subviews]; + + if ([subviews count] > 0) + { + NSEnumerator *en = [subviews objectEnumerator]; + id v = nil; + NSXMLElement *subviewsElement = [NSXMLNode elementWithName: @"subviews"]; + + while ((v = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: v + withParent: subviewsElement]; + } + [elem addChild: subviewsElement]; + } + } + } + + if ([obj respondsToSelector: @selector(tabViewItems)]) + { + NSArray *items = [obj tabViewItems]; + + if ([items count] > 0) + { + NSEnumerator *en = [items objectEnumerator]; + id v = nil; + NSXMLElement *itemsElement = [NSXMLNode elementWithName: @"tabViewItems"]; + + while ((v = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: v + withParent: itemsElement]; + } + [elem addChild: itemsElement]; + } + } + } + + // Add the holding priorities for NSSplitView. GNUstep doesn't have these so we need to generate it... + if ([obj isKindOfClass: [NSSplitView class]]) + { + [self _addHoldingPrioritiesForSplitView: obj toElement: elem]; + } + + /* Cheap way to not encoding fake table columns to prevent crash on the mac when reading the XIB. + Not ideal, but it should work for now. */ + /* + if ([obj respondsToSelector: @selector(tableColumns)]) + { + [self _addTableColumns: [obj tableColumns] + toElement: elem]; + } + */ + } +} + +- (void) _collectObjectsFromObject: (id)obj + withParent: (NSXMLElement *)node +{ + [self _collectObjectsFromObject: obj + forKey: nil + withParent: node]; +} + + +- (void) _buildXIBDocumentWithParentNode: (NSXMLElement *)parentNode +{ + NSEnumerator *en = [[_gormDocument topLevelObjects] objectEnumerator]; + id o = nil; + + [_gormDocument deactivateEditors]; + while ((o = [en nextObject]) != nil) + { + [self _collectObjectsFromObject: o + withParent: parentNode]; + } + [_gormDocument reactivateEditors]; +} + +- (NSData *) data +{ + NSString *plugInId = @"com.apple.InterfaceBuilder.CocoaPlugin"; + NSString *typeId = @"com.apple.InterfaceBuilder3.Cocoa.XIB"; + NSString *toolVersion = @"21507"; + + // Build root element... + NSXMLElement *rootElement = [NSXMLNode elementWithName: @"document"]; + NSXMLNode *attr = [NSXMLNode attributeWithName: @"type" + stringValue: typeId]; + [rootElement addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"version" stringValue: @"3.0"]; + [rootElement addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"toolsVersion" stringValue: toolVersion]; + [rootElement addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"targetRuntime" stringValue: @"MacOSX.Cocoa"]; + [rootElement addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"useAutolayout" stringValue: @"YES"]; + [rootElement addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"propertyAccessControl" stringValue: @"none"]; + [rootElement addAttribute: attr]; + + attr = [NSXMLNode attributeWithName: @"customObjectInstantiationMethod" stringValue: @"direct"]; + [rootElement addAttribute: attr]; + + // Build dependencies... + NSXMLElement *dependencies = [NSXMLNode elementWithName: @"dependencies"]; + NSXMLElement *deployment = [NSXMLNode elementWithName: @"deployment"]; + attr = [NSXMLNode attributeWithName: @"identifier" stringValue: @"macosx"]; + [deployment addAttribute: attr]; + [dependencies addChild: deployment]; + + NSXMLElement *plugIn = [NSXMLNode elementWithName: @"plugIn"]; + attr = [NSXMLNode attributeWithName: @"identifier" stringValue: plugInId]; + [plugIn addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"version" stringValue: toolVersion]; + [plugIn addAttribute: attr]; + [dependencies addChild: plugIn]; + + NSXMLElement *capability = [NSXMLNode elementWithName: @"capability"]; + attr = [NSXMLNode attributeWithName: @"name" stringValue: @"documents saved in the Xcode 8 format"]; + [capability addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"minToolsVersion" stringValue: @"8"]; + [capability addAttribute: attr]; + [dependencies addChild: capability]; + [rootElement addChild: dependencies]; + + NSXMLDocument *xibDocument = [NSXMLNode documentWithRootElement: rootElement]; + NSXMLElement *objects = [NSXMLNode elementWithName: @"objects"]; + + // Add placeholder objects to XIB + [self _createPlaceholderObjects: objects]; + + // add body to document... + [rootElement addChild: objects]; + + // Recursively build the XIB document from the GormDocument... + [self _buildXIBDocumentWithParentNode: objects]; + + NSData *data = [xibDocument XMLDataWithOptions: NSXMLNodePrettyPrint | NSXMLDocumentTidyXML | NSXMLNodeCompactEmptyElement ]; + + return data; +} + +- (BOOL) exportXIBDocumentWithName: (NSString *)name +{ + BOOL result = NO; + + if (name != nil) + { + NSData *data = [self data]; + NSString *xmlString = [[NSString alloc] initWithBytes: [data bytes] length: [data length] encoding: NSUTF8StringEncoding]; + + AUTORELEASE(xmlString); + result = [xmlString writeToFile: name atomically: YES]; + } + + return result; +} + +@end diff --git a/Plugins/Xib/GormXibWrapperBuilder.m b/Plugins/Xib/GormXibWrapperBuilder.m new file mode 100644 index 00000000..b1dc02d6 --- /dev/null +++ b/Plugins/Xib/GormXibWrapperBuilder.m @@ -0,0 +1,51 @@ +/* GormWrapperBuilder + * + * Copyright (C) 2006-2013 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2006 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + */ + +#import +#import + +#import + +#import "GormXIBModelGenerator.h" + +@interface GormXibWrapperBuilder : GormWrapperBuilder +@end + +@implementation GormXibWrapperBuilder + ++ (NSString *) fileType +{ + return @"GSXibFileType"; +} + +- (NSFileWrapper *) buildFileWrapperWithDocument: (GormDocument *)doc +{ + GormXIBModelGenerator *generator = [GormXIBModelGenerator xibWithGormDocument: doc]; + NSData *data = [generator data]; + NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] initRegularFileWithContents: data]; + + return fileWrapper; +} + +@end diff --git a/Plugins/Xib/GormXibWrapperLoader.h b/Plugins/Xib/GormXibWrapperLoader.h index 0a36ed1a..7c5b4062 100644 --- a/Plugins/Xib/GormXibWrapperLoader.h +++ b/Plugins/Xib/GormXibWrapperLoader.h @@ -31,8 +31,11 @@ @interface GormXibWrapperLoader : GormWrapperLoader { - IBObjectContainer *container; - id nibFilesOwner; + NSMutableDictionary *_idToName; + NSDictionary *_customClasses; + NSDictionary *_decoded; + IBObjectContainer *_container; + id _nibFilesOwner; } @end diff --git a/Plugins/Xib/GormXibWrapperLoader.m b/Plugins/Xib/GormXibWrapperLoader.m index b459d600..05d9697a 100644 --- a/Plugins/Xib/GormXibWrapperLoader.m +++ b/Plugins/Xib/GormXibWrapperLoader.m @@ -30,49 +30,201 @@ #include "GormXibWrapperLoader.h" -/* - * Forward declarations for classes - */ -@class GormNSWindow; - /* * This allows us to retrieve the customClasses from the XIB unarchiver. */ - @interface NSKeyedUnarchiver (Private) - (NSDictionary *) customClasses; - (NSDictionary *) decoded; @end +/* + * Allow access to the method to instantiate the font manager + */ +@interface GormDocument (XibPluginPrivate) +- (void) _instantiateFontManager; +@end /* * Xib loader... */ @implementation GormXibWrapperLoader + + (NSString *) fileType { return @"GSXibFileType"; } -- (id) _replaceProxyInstanceWithRealObject: (id)obj +- (instancetype) init { - if ([obj isKindOfClass: [GormObjectProxy class]]) + self = [super init]; + if (self != nil) { - if ([[obj className] isEqualToString: @"NSApplication"]) - { - return [document filesOwner]; - } + _idToName = [[NSMutableDictionary alloc] init]; + _container = nil; + _nibFilesOwner = nil; + } + return self; +} - if ([[obj className] isEqualToString: @"FirstResponder"]) - { - return [document firstResponder]; - } - } - else if (obj == nil) +- (void) dealloc +{ + RELEASE(_idToName); + [super dealloc]; +} + +// +// This method returns the "real" object that should be used in gorm for either +// the custom object, its substitute, or a standin object such as file's owner +// or first responder. +// +- (id) _replaceProxyInstanceWithRealObject: (id)obj + classManager: (GormClassManager *)classManager + withID: (NSString *)theId +{ + id result = obj; + + if ([obj isKindOfClass: [NSCustomObject class]]) { - return [document firstResponder]; + NSString *className = [obj className]; + if ([className isEqualToString: @"NSApplication"]) + { + result = [document filesOwner]; + [obj setRealObject: result]; + } + else if ([className isEqualToString: @"FirstResponder"]) + { + result = [document firstResponder]; + [obj setRealObject: result]; + } + else if ([className isEqualToString: @"NSFontManager"]) + { + [document _instantiateFontManager]; + result = [document fontManager]; + [obj setRealObject: result]; + } + else + { + result = [obj realObject]; + } + } + else if (theId != nil) + { + id o = [_idToName objectForKey: theId]; + if (o != nil) + { + result = o; + } + else + { + result = [document firstResponder]; + } + } + else + { + NSDebugLog(@"### ID not provided and could not find name for object %@", obj); + } + + return result; +} + +// +// This method instantiates the custom class and inserts it into the document +// so that it can be referenced from elsewhere in the data. +// +- (void) _handleCustomClassWithObject: (id)obj + withDocument: (GormDocument *)doc +{ + if ([obj isKindOfClass: [NSCustomObject class]]) + { + NSString *customClassName = [obj className]; + NSDictionary *customClassDict = [_customClasses objectForKey: customClassName];; + NSString *theId = [customClassDict objectForKey: @"id"]; + NSString *parentClassName = [customClassDict objectForKey: @"parentClassName"]; + id realObject = [_decoded objectForKey: theId]; + NSString *theName = nil; + GormClassManager *classManager = [doc classManager]; + + // Set the file's owner correctly... + if ([theId isEqualToString: @"-2"]) // The File's Owner node... + { + [[doc filesOwner] setClassName: customClassName]; + return; + } + + // these are preset values + if ([theId isEqualToString: @"-1"] + || [theId isEqualToString: @"-3"]) + { + return; + } + + // Get the "real" object... + realObject = [self _replaceProxyInstanceWithRealObject: realObject + classManager: classManager + withID: theId]; + + // Check that it has a name... + NSDebugLog(@"realObject = %@", realObject); + if ([doc containsObject: realObject]) + { + theName = [doc nameForObject: realObject]; + NSDebugLog(@"Found name = %@ for realObject = %@", theName, realObject); + } + else + { + NSDebugLog(@"realObject = %@ has no name in document", realObject); + } + + // If the parent class is "NSCustomObject" or it's derivatives... + // then the parent is NSObject + if ([parentClassName isEqualToString: @"NSCustomObject5"] + || [parentClassName isEqualToString: @"NSCustomObject"]) + { + parentClassName = @"NSObject"; + } + + // Add the custom class to the document + NSDebugLog(@"Adding customClassName = %@ with parent className = %@", customClassName, + parentClassName); + [classManager addClassNamed: customClassName + withSuperClassNamed: parentClassName + withActions: nil + withOutlets: nil + isCustom: YES]; + + // If the name of the object does not exist, then create it... + // the name not existing means the object is not attached or associated + // with the document, so we must create it here since it is a + // custom object. + if (theName == nil) + { + theName = [doc instantiateClassNamed: customClassName]; + } + + // Create a mapping between the name and the id. This way we can look + // this up when needed later, if necessary. It is not done in the above + // if since the object might already have a name. + if (theName != nil) + { + [_idToName setObject: theName forKey: theId]; + } + + // Add the instantiated object to the NSCustomObject + id instantiatedObject = [doc objectForName: theName]; + if (instantiatedObject != nil) + { + [obj setRealObject: instantiatedObject]; + } + else + { + NSDebugLog(@"Instantiated object not found for %@", theName); + } + } + else + { + NSDebugLog(@"%@ is not an instance of NSCustomObject", obj); } - return obj; } - (BOOL) loadFileWrapper: (NSFileWrapper *)wrapper withDocument: (GormDocument *) doc @@ -81,11 +233,12 @@ NS_DURING { - GormPalettesManager *palettesManager = [(id)NSApp palettesManager]; + GormPalettesManager *palettesManager = [(id)[NSApp delegate] palettesManager]; NSDictionary *substituteClasses = [palettesManager substituteClasses]; NSString *subClassName = nil; GormClassManager *classManager = [doc classManager]; + document = doc; // make sure they are the same... if ([super loadFileWrapper: wrapper withDocument: doc] && [wrapper isDirectory] == NO) @@ -117,10 +270,6 @@ // // Special internal classes // - [u setClass: [GormObjectProxy class] - forClassName: @"NSCustomObject"]; - [u setClass: [GormObjectProxy class] - forClassName: @"NSCustomObject5"]; [u setClass: [GormCustomView class] forClassName: @"NSCustomView"]; [u setClass: [GormWindowTemplate class] @@ -131,7 +280,9 @@ forClassName: @"IBUserDefinedRuntimeAttribute5"]; // - // Substitute any classes specified by the palettes... + // Substitute any classes specified by the palettes... Palettes can specify + // substitute classes to use in place of certain classes, among them is + // NSMenu, this is so that their standins can be automatically used. // en = [substituteClasses keyEnumerator]; while ((subClassName = [en nextObject]) != nil) @@ -145,8 +296,8 @@ // // decode // - container = [u decodeObjectForKey: @"IBDocument.Objects"]; - if (container == nil || [container isKindOfClass: [IBObjectContainer class]] == NO) + _container = [u decodeObjectForKey: @"IBDocument.Objects"]; + if (_container == nil || [_container isKindOfClass: [IBObjectContainer class]] == NO) { result = NO; } @@ -157,16 +308,18 @@ id xibFirstResponder = nil; rootObjects = [u decodeObjectForKey: @"IBDocument.RootObjects"]; - nibFilesOwner = [rootObjects objectAtIndex: 0]; xibFirstResponder = [rootObjects objectAtIndex: 1]; docFilesOwner = [doc filesOwner]; - + _customClasses = [u customClasses]; + _nibFilesOwner = [rootObjects objectAtIndex: 0]; + _decoded = [u decoded]; + // // set the current class on the File's owner... // - if ([nibFilesOwner isKindOfClass: [GormObjectProxy class]]) + if ([_nibFilesOwner isKindOfClass: [NSCustomObject class]]) { - [docFilesOwner setClassName: [nibFilesOwner className]]; + [docFilesOwner setClassName: [_nibFilesOwner className]]; } // @@ -180,7 +333,8 @@ NSString *objName = nil; // skip the file's owner, it is handled above... - if ((obj == nibFilesOwner) || (obj == xibFirstResponder)) + if ((obj == _nibFilesOwner) + || (obj == xibFirstResponder)) { continue; } @@ -189,7 +343,7 @@ // If it's NSApplication (most likely the File's Owner) // skip it... // - if ([obj isKindOfClass: [GormObjectProxy class]]) + if ([obj isKindOfClass: [NSCustomObject class]]) { if ([[obj className] isEqualToString: @"NSApplication"]) { @@ -212,27 +366,39 @@ // make the object deferred/visible... o = [obj nibInstantiate]; - + NSDebugLog(@"Decoding window as %@", o); + [doc setObject: o isDeferred: isDeferred]; [doc setObject: o isVisibleAtLaunch: isVisible]; - // Add to the document... + // Add to the document... [doc attachObject: o - toParent: nil]; - + toParent: nil]; + // record the custom class... if ([classManager isCustomClass: className]) { customClassName = className; } } - + + // Handle custom classes if ([rootObjects containsObject: obj] && obj != nil && [obj isKindOfClass: [GormWindowTemplate class]] == NO) { - NSLog(@"obj = %@",obj); + NSDebugLog(@"obj = %@",obj); + if ([obj respondsToSelector: @selector(className)]) + { + if ([obj isKindOfClass: [NSCustomObject class]]) + { + [self _handleCustomClassWithObject: obj + withDocument: doc]; + continue; + } + } + [doc attachObject: obj - toParent: nil]; + toParent: nil]; } if (customClassName != nil) @@ -246,59 +412,11 @@ } } - /* - * Add custom classes... - */ - NSDictionary *customClasses = [u customClasses]; - NSEnumerator *en = [customClasses keyEnumerator]; - NSString *customClassName = nil; - NSDictionary *decoded = [u decoded]; - - NSDebugLog(@"customClasses = %@", customClasses); - while ((customClassName = [en nextObject]) != nil) - { - NSDictionary *customClassDict = [customClasses objectForKey: customClassName];; - NSString *theId = [customClassDict objectForKey: @"id"]; - NSString *parentClassName = [customClassDict objectForKey: @"parentClassName"]; - id realObject = [decoded objectForKey: theId]; - NSString *theName = nil; - - realObject = [self _replaceProxyInstanceWithRealObject: realObject]; - NSDebugLog(@"realObject = %@", realObject); - - if ([doc containsObject: realObject]) - { - theName = [doc nameForObject: realObject]; - NSDebugLog(@"Found name = %@ for realObject = %@", theName, realObject); - } - else - { - NSDebugLog(@"realObject = %@ has no name in document", realObject); - continue; - } - - if ([parentClassName isEqualToString: @"NSCustomObject5"]) - { - parentClassName = @"NSObject"; - } - - NSDebugLog(@"Adding customClassName = %@ with parent className = %@", customClassName, - parentClassName); - [classManager addClassNamed: customClassName - withSuperClassNamed: parentClassName - withActions: nil - withOutlets: nil - isCustom: YES]; - - NSDebugLog(@"Assigning %@ as customClass = %@", theName, customClassName); - [classManager setCustomClass: customClassName - forName: theName]; - } - /* * add connections... */ - en = [container connectionRecordEnumerator]; + NSDebugLog(@"_idToName = %@", _idToName); + en = [_container connectionRecordEnumerator]; while ((cr = [en nextObject]) != nil) { IBConnection *conn = [cr connection]; @@ -312,15 +430,29 @@ id dest = [o destination]; id src = [o source]; - // Replace files owner with the document files owner for loading... - dest = [self _replaceProxyInstanceWithRealObject: dest]; - src = [self _replaceProxyInstanceWithRealObject: src]; + NSDebugLog(@"Initial connector = %@", o); + NSDebugLog(@"dest = %@, src = %@", dest, src); + + // Replace files owner with the document files owner for loading... + dest = [self _replaceProxyInstanceWithRealObject: dest + classManager: classManager + withID: nil]; + + src = [self _replaceProxyInstanceWithRealObject: src + classManager: classManager + withID: nil]; - // Reset them... + NSString *destName = [document nameForObject: dest]; + NSString *srcName = [document nameForObject: src]; + + NSDebugLog(@"destName = %@, srcName = %@", destName, srcName); + + // Use tne names, since this is how connectors are + // stored in gorm until they are written out. [o setDestination: dest]; [o setSource: src]; - NSDebugLog(@"connector = %@", o); + NSDebugLog(@"*** After connector update = %@", o); if([o isKindOfClass: [NSNibControlConnector class]]) { @@ -333,7 +465,10 @@ NSString *newTag = [NSString stringWithFormat: @"%@:",tag]; [o setLabel: (id)newTag]; } - + + NSDebugLog(@"*** Action: label = %@ for src = %@, srcName = %@", + [o label], src, srcName); + [classManager addAction: [o label] forObject: src]; @@ -343,6 +478,9 @@ } else if ([o isKindOfClass: [NSNibOutletConnector class]]) { + NSDebugLog(@"*** Outlet: label = %@ for src = %@, srcName = %@", + [o label], src, srcName); + [classManager addOutlet: [o label] forObject: src]; } @@ -380,6 +518,10 @@ result = YES; } } + + NSArray *errors = [doc validate]; + NSDebugLog(@"errors = %@", errors); + [NSClassSwapper setIsInInterfaceBuilder: NO]; } } @@ -408,15 +550,21 @@ if ([obj isKindOfClass: [NSWindowTemplate class]]) { GormClassManager *classManager = [document classManager]; - Class clz ; + // Class clz; NSString *className = [obj className]; if([classManager isCustomClass: className]) { className = [classManager nonCustomSuperClassOf: className]; } - clz = [unarchiver classForClassName: className]; - // [obj setBaseWindowClass: clz]; + // clz = [unarchiver classForClassName: className]; + } + else if ([obj isKindOfClass: [NSMatrix class]]) + { + if ([obj cellClass] == NULL) + { + [obj setCellClass: [NSButtonCell class]]; + } } else if ([obj respondsToSelector: @selector(setTarget:)] && [obj respondsToSelector: @selector(setAction:)] && diff --git a/README.md b/README.md new file mode 100644 index 00000000..28af550f --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# apps-gorm + +[![CI](https://github.com/gnustep/apps-gorm/actions/workflows/main.yml/badge.svg)](https://github.com/gnustep/apps-gorm/actions/workflows/main.yml?query=branch%3Amaster) + +## Introduction + +* Gorm is an acronym for Graphic Object Relationship modeler (or perhaps GNUstep Object Relationship Modeler). +* Gorm is a clone of the Cocoa (OpenStep/NeXTSTEP) 'Interface Builder' application for GNUstep. +* Gorm is part of the GNUstep project, and is copyrighted by the Free Software Foundation. +* Gorm is released under the GPL - see the file 'COPYING' for details. +* Documentation for Gorm is located in the Documentation directory. +* Please see the README files in each of the subdirectories for more complete information. + +## Organization + +* Gorm is comprised of the GormCore, InterfaceBuilder, and GormObjCHeaderParser libraries/frameworks as well as the Gorm application and gormtool +* The purpose of this organization is so that Gorm's functionality can be re-used in other applications. + +## Status + +Gorm is usable and stable. Please report bugs [here](https://github.com/gnustep/apps-gorm/issues) + +## Acknowledgements + +* Icons - Mostly by Andrew Lindsay. Gorm application icon by Jesse Ross. +* Code - GormViewKnobs.m adapted from code by Gerrit van Dyk. diff --git a/Tools/GNUmakefile b/Tools/GNUmakefile new file mode 100644 index 00000000..aaa2a1c8 --- /dev/null +++ b/Tools/GNUmakefile @@ -0,0 +1,41 @@ +# GNUmakefile: main makefile for Gorm palettes +# +# Copyright (C) 1999 Free Software Foundation, Inc. +# +# Author: Gregory John Casamento +# Date: 2007 +# +# This file is part of GNUstep. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. +# + +PACKAGE_NAME = gorm +include $(GNUSTEP_MAKEFILES)/common.make + +# +# Each palette is a subproject +# +SUBPROJECTS = \ + gormtool + +-include GNUmakefile.preamble + +-include GNUmakefile.local + +include $(GNUSTEP_MAKEFILES)/aggregate.make + +-include GNUmakefile.postamble + diff --git a/Tools/README.md b/Tools/README.md new file mode 100644 index 00000000..5c639531 --- /dev/null +++ b/Tools/README.md @@ -0,0 +1,16 @@ +# gormtool +This tool allows the user to access certain features of Gorm from the command line. It is a "hybrid" tool/headless application. + +Usage: gormtool [options] inputfile + +## Options include: +* ```--import-strings-file``` - this option imports a file in the .strings format and replaces the text in the model file with the mappings. It takes a parameter which is the strings file to be imported. +* ```--export-strings-file``` - this option exports a string file from the model file to the file specified by the parameter. +* ```--export-xliff``` - this option exports an XLIFF1.2 file from the model file to the file specified by the parameter. +* ```--import-xliff``` - this option imports an XLIFF1.2 file into the model file to the file specified by the parameter. +* ```--import-class``` - this option parses the header given by the parameter passed in, it will break any existing connections if the class is instantiated +* ```--export-class``` - this option exports the named class (passed in as a parameter) to a file by the same name in the current directory +* ```--read``` - specifies this file is to be the one read... optional. If not used the last parameter is considered the input file. +* ```--write``` - specifies the output file the model is to be written to + +NOTE: This tool is currently experimental please report any bugs. Thank you. GC diff --git a/Tools/gormtool/AppDelegate.h b/Tools/gormtool/AppDelegate.h new file mode 100644 index 00000000..69462628 --- /dev/null +++ b/Tools/gormtool/AppDelegate.h @@ -0,0 +1,43 @@ +/* AppDelegate.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#include +#include + +@class NSDictionary; +@class NSImage; +@class NSMenu; +@class NSMutableArray; +@class NSSet; + +@interface AppDelegate : GormAbstractDelegate +{ + GormDocument *_doc; +} + +- (NSDictionary *) parseArguments; +- (void) process; + +@end diff --git a/Tools/gormtool/AppDelegate.m b/Tools/gormtool/AppDelegate.m new file mode 100644 index 00000000..215351e7 --- /dev/null +++ b/Tools/gormtool/AppDelegate.m @@ -0,0 +1,555 @@ +/* AppDelegate.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#import "ArgPair.h" +#import "GormToolPrivate.h" +#import "AppDelegate.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wobjc-protocol-method-implementation" +// Smash this method in NSDocument to prevent it from popping up an NSRunAlertPanel +@interface NSDocument (__ReplaceLoadPrivate__) + +- (id) initWithContentsOfFile: (NSString *)fileName ofType: (NSString *)fileType; + +@end + +@implementation NSDocument (__ReplaceLoadPrivate__) + +- (id) initWithContentsOfFile: (NSString *)fileName ofType: (NSString *)fileType +{ + self = [self init]; + if (self != nil) + { + [self setFileType: fileType]; + [self setFileName: fileName]; + if (![self readFromFile: fileName ofType: fileType]) + { + NSLog(@"Load failed, could not load file"); + DESTROY(self); + } + } + return self; +} + +@end +#pragma GCC diagnostic pop + +// AppDelegate... +@implementation AppDelegate + +// Are we in a tool? +- (BOOL) isInTool +{ + return YES; +} + +// Handle all alerts... + +- (BOOL) shouldUpgradeOlderArchive +{ + NSLog(@"Upgrading archive to latest version of .gorm format"); + return YES; +} + +- (BOOL) shouldLoadNewerArchive +{ + NSLog(@"Refusing to load archive since it is from a newer version of Gorm/gormtool"); + return NO; +} + +- (BOOL) shouldBreakConnectionsForClassNamed: (NSString *)className +{ + NSLog(@"Breaking connections for instances of class: %@", className); + return YES; +} + +- (BOOL) shouldRenameConnectionsForClassNamed: (NSString *)className toClassName: (NSString *)newName +{ + NSLog(@"Renaming connections from class %@ to class %@", className, newName); + return YES; +} + +- (BOOL) shouldBreakConnectionsModifyingLabel: (NSString *)name isAction: (BOOL)action prompted: (BOOL)prompted +{ + NSLog(@"Breaking connections for %@ %@", action?@"action":@"outlet", name); + return YES; +} + +- (void) couldNotParseClassAtPath: (NSString *)path; +{ + NSLog(@"Could not parse class at path: %@", path); +} + +- (void) exceptionWhileParsingClass: (NSException *)localException +{ + NSLog(@"Exception while parsing class: %@", [localException reason]); +} + +- (BOOL) shouldBreakConnectionsReparsingClass: (NSString *)className +{ + NSLog(@"Breaking any existing connections with instances of class %@", className); + return YES; +} + +// Document + +- (id) activeDocument +{ + return _doc; +} + +// Handle arguments + +- (NSDictionary *) parseArguments +{ + GormDocumentController *dc = [GormDocumentController sharedDocumentController]; + NSMutableDictionary *result = [NSMutableDictionary dictionary]; + NSProcessInfo *pi = [NSProcessInfo processInfo]; + NSMutableArray *args = [NSMutableArray arrayWithArray: [pi arguments]]; + // BOOL filenameIsLastObject = NO; + NSString *file = nil; + + // If the --read option isn't specified, we assume that the last argument is + // the file to be processed. + if ([args containsObject: @"--read"] == NO) + { + file = [args lastObject]; + // filenameIsLastObject = YES; + [args removeObject: file]; + NSDebugLog(@"file = %@", file); + + NSString *type = [dc typeFromFileExtension: [file pathExtension]]; + + if (type != nil) + { + ArgPair *pair = AUTORELEASE([[ArgPair alloc] init]); + + [pair setArgument: @"--read"]; + [pair setValue: file]; + + [result setObject: pair forKey: @"--read"]; + NSDebugLog(@"Faking read pair %@", file); + } + } + + NSEnumerator *en = [args objectEnumerator]; + id obj = nil; + BOOL parse_val = NO; + ArgPair *pair = AUTORELEASE([[ArgPair alloc] init]); + + while ((obj = [en nextObject]) != nil) + { + if (parse_val) + { + [pair setValue: obj]; + [result setObject: pair forKey: [pair argument]]; + parse_val = NO; + continue; + } + else + { + pair = AUTORELEASE([[ArgPair alloc] init]); + + if ([obj isEqualToString: @"--read"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--write"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--export-strings-file"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--import-strings-file"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--export-class"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--import-class"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--output-path"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--connections"]) + { + [pair setArgument: obj]; + parse_val = NO; + } + + if ([obj isEqualToString: @"--classes"]) + { + [pair setArgument: obj]; + parse_val = NO; + } + + if ([obj isEqualToString: @"--objects"]) + { + [pair setArgument: obj]; + parse_val = NO; + } + + if ([obj isEqualToString: @"--errors"]) + { + [pair setArgument: obj]; + parse_val = NO; + } + + if ([obj isEqualToString: @"--warnings"]) + { + [pair setArgument: obj]; + parse_val = NO; + } + + if ([obj isEqualToString: @"--notices"]) + { + [pair setArgument: obj]; + parse_val = NO; + } + + if ([obj isEqualToString: @"--source-language"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--target-language"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--export-xliff"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--import-xliff"]) + { + [pair setArgument: obj]; + parse_val = YES; + } + + if ([obj isEqualToString: @"--test"]) + { + [pair setArgument: obj]; + parse_val = NO; + } + + // If there is no parameter for the argument, set it anyway... + if (parse_val == NO) + { + [result setObject: pair forKey: obj]; + } + } + } + + return result; +} + +- (void) process +{ + NSProcessInfo *pi = [NSProcessInfo processInfo]; + + [NSClassSwapper setIsInInterfaceBuilder: YES]; + + _isTesting = NO; + + if ([[pi arguments] count] > 1) + { + NSString *file = nil; + NSString *outputPath = @"./"; + GormDocumentController *dc = [GormDocumentController sharedDocumentController]; + // GormDocument *doc = nil; + NSDictionary *args = [self parseArguments]; + ArgPair *opt = nil; + NSString *slang = nil; + NSString *tlang = nil; + + NSDebugLog(@"args = %@", args); + NSDebugLog(@"file = %@", file); + + // Get the file to write out to... + NSString *outputFile = nil; + + opt = [args objectForKey: @"--read"]; + if (opt != nil) + { + file = [opt value]; + } + + NS_DURING + { + if (file != nil) + { + _doc = [dc openDocumentWithContentsOfFile: file display: NO]; + if (_doc == nil) + { + NSLog(@"Unable to load document %@", file); + return; + } + } + else + { + NSLog(@"No document specified"); + return; + } + } + NS_HANDLER + { + NSLog(@"Exception: %@", [localException reason]); + } + NS_ENDHANDLER; + + NSDebugLog(@"Document = %@", _doc); + + // Get other options... + opt = [args objectForKey: @"--output-path"]; + if (opt != nil) + { + outputPath = [opt value]; + } + + opt = [args objectForKey: @"--export-strings-file"]; + if (opt != nil) + { + NSString *stringsFile = [opt value]; + + [_doc exportStringsToFile: stringsFile]; + } + + opt = [args objectForKey: @"--import-strings-file"]; + if (opt != nil) + { + NSString *stringsFile = [opt value]; + [_doc importStringsFromFile: stringsFile]; + } + + opt = [args objectForKey: @"--export-class"]; + if (opt != nil) + { + NSString *className = [opt value]; + BOOL saved = NO; + GormClassManager *cm = [_doc classManager]; + NSString *hFile = [className stringByAppendingPathExtension: @"h"]; + NSString *mFile = [className stringByAppendingPathExtension: @"m"]; + NSString *hPath = [outputPath stringByAppendingPathComponent: hFile]; + NSString *mPath = [outputPath stringByAppendingPathComponent: mFile]; + + saved = [cm makeSourceAndHeaderFilesForClass: className + withName: mPath + and: hPath]; + + if (saved == NO) + { + NSLog(@"Class named %@ not saved", className); + } + } + + opt = [args objectForKey: @"--import-class"]; + if (opt != nil) + { + NSString *classFile = [opt value]; + GormClassManager *cm = [_doc classManager]; + + [cm parseHeader: classFile]; + } + + opt = [args objectForKey: @"--connections"]; + if (opt != nil) + { + NSArray *connections = [_doc connections]; + puts([[NSString stringWithFormat: @"%@", connections] cStringUsingEncoding: NSUTF8StringEncoding]); + } + + opt = [args objectForKey: @"--classes"]; + if (opt != nil) + { + NSDictionary *classes = [[_doc classManager] customClassInformation]; + puts([[NSString stringWithFormat: @"%@", classes] cStringUsingEncoding: NSUTF8StringEncoding]); + } + + opt = [args objectForKey: @"--objects"]; + if (opt != nil) + { + NSSet *objects = [_doc topLevelObjects]; + puts([[NSString stringWithFormat: @"%@", objects] cStringUsingEncoding: NSUTF8StringEncoding]); + } + + opt = [args objectForKey: @"--errors"]; + if (opt != nil) + { + GormFilePrefsManager *mgr = [_doc filePrefsManager]; + NSDictionary *p = [NSDictionary dictionaryWithDictionary: [mgr currentProfile]]; + puts([[NSString stringWithFormat: @"%@", p] cStringUsingEncoding: NSUTF8StringEncoding]); + } + + opt = [args objectForKey: @"--warnings"]; + if (opt != nil) + { + GormFilePrefsManager *mgr = [_doc filePrefsManager]; + NSDictionary *p = [NSDictionary dictionaryWithDictionary: [mgr currentProfile]]; + puts([[NSString stringWithFormat: @"%@", p] cStringUsingEncoding: NSUTF8StringEncoding]); + } + + opt = [args objectForKey: @"--notices"]; + if (opt != nil) + { + GormFilePrefsManager *mgr = [_doc filePrefsManager]; + NSDictionary *p = [NSDictionary dictionaryWithDictionary: [mgr currentProfile]]; + puts([[NSString stringWithFormat: @"%@", p] cStringUsingEncoding: NSUTF8StringEncoding]); + } + + opt = [args objectForKey: @"--source-language"]; + if (opt != nil) + { + slang = [opt value]; + } + + opt = [args objectForKey: @"--target-language"]; + if (opt != nil) + { + tlang = [opt value]; + } + + opt = [args objectForKey: @"--export-xliff"]; + if (opt != nil) + { + NSString *xliffDocumentName = [opt value]; + BOOL result = NO; + GormXLIFFDocument *xd = [GormXLIFFDocument xliffWithGormDocument: _doc]; + + if (slang == nil) + { + NSLog(@"Please specify a source language"); + } + + result = [xd exportXLIFFDocumentWithName: xliffDocumentName + withSourceLanguage: slang + andTargetLanguage: tlang]; + if (result == NO) + { + NSLog(@"File not generated"); + } + } + + opt = [args objectForKey: @"--import-xliff"]; + if (opt != nil) + { + NSString *xliffDocumentName = [opt value]; + BOOL result = NO; + GormXLIFFDocument *xd = [GormXLIFFDocument xliffWithGormDocument: _doc]; + + result = [xd importXLIFFDocumentWithName: xliffDocumentName]; + if (result == NO) + { + NSLog(@"No translation performed."); + } + } + + // These options sound always be processed last... + opt = [args objectForKey: @"--write"]; + if (opt != nil) + { + outputFile = [opt value]; + if (outputFile != nil) + { + BOOL saved = NO; + NSURL *file = [NSURL fileURLWithPath: outputFile isDirectory: YES]; + NSString *type = [dc typeFromFileExtension: [outputFile pathExtension]]; + NSError *error = nil; + + saved = [_doc saveToURL: file + ofType: type + forSaveOperation: NSSaveOperation + error: &error]; + if ( !saved ) + { + NSLog(@"Document %@ of type %@ was not saved", file, type); + } + + if (error != nil) + { + NSLog(@"Error = %@", error); + } + } + } + + opt = [args objectForKey: @"--test"]; + if (opt != nil) + { + NSLog(@"Control-C to end"); + _isTesting = YES; + [self testInterface: self]; + } + } + + [NSClassSwapper setIsInInterfaceBuilder: NO]; +} + +- (void) exceptionWhileLoadingModel: (NSString *)errorMessage +{ + NSLog(@"Exception: %@", errorMessage); +} + +- (void) applicationDidFinishLaunching: (NSNotification *)n +{ + NSDebugLog(@"processInfo: %@", [NSProcessInfo processInfo]); + [self process]; + + if (_isTesting == NO) + { + [NSApp terminate: nil]; + } +} + +- (void) applicationWillTerminate: (NSNotification *)n +{ +} + +@end diff --git a/Tools/gormtool/ArgPair.h b/Tools/gormtool/ArgPair.h new file mode 100644 index 00000000..319153e7 --- /dev/null +++ b/Tools/gormtool/ArgPair.h @@ -0,0 +1,46 @@ +/* ArgPair.h + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#ifndef INCLUDE_ArgPair_H +#define INCLUDE_ArgPair_H + +#import + +@class NSString; + +@interface ArgPair : NSObject +{ + NSString *_argument; + NSString *_value; +} + +- (void) setArgument: (NSString *)arg; +- (NSString *) argument; + +- (void) setValue: (NSString *)val; +- (NSString *) value; +@end + +#endif // INCLUDE_ArgPair_H diff --git a/Tools/gormtool/ArgPair.m b/Tools/gormtool/ArgPair.m new file mode 100644 index 00000000..62351e99 --- /dev/null +++ b/Tools/gormtool/ArgPair.m @@ -0,0 +1,81 @@ +/* AppDelegate.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#import + +#import "ArgPair.h" + +@implementation ArgPair + +- (id) init +{ + self = [super init]; + if (self != nil) + { + _argument = nil; + _value = nil; + } + return self; +} + +- (void) dealloc +{ + RELEASE(_argument); + RELEASE(_value); + + [super dealloc]; +} + +- (void) setArgument: (NSString *)arg +{ + ASSIGN(_argument, arg); +} + +- (NSString *) argument +{ + return _argument; +} + +- (void) setValue: (NSString *)val +{ + ASSIGN(_value, val); +} + +- (NSString *) value +{ + return _value; +} + +- (id) copyWithZone: (NSZone *)z +{ + id obj = [[[self class] allocWithZone: z] init]; + + [obj setArgument: _argument]; + [obj setValue: _value]; + + return obj; +} + +@end diff --git a/Tools/gormtool/GNUmakefile b/Tools/gormtool/GNUmakefile new file mode 100644 index 00000000..1493d55c --- /dev/null +++ b/Tools/gormtool/GNUmakefile @@ -0,0 +1,24 @@ +# +# GNUmakefile -- gormtool +# + +include $(GNUSTEP_MAKEFILES)/common.make + +PACKAGE_NAME = gormtool +TOOL_NAME = gormtool + +gormtool_HEADER_FILES = AppDelegate.h \ + GormToolPrivate.h \ + ArgPair.h + +gormtool_OBJC_FILES = main.m \ + AppDelegate.m \ + GormToolPrivate.m \ + ArgPair.m + +-include GNUmakefile.preamble + +include $(GNUSTEP_MAKEFILES)/aggregate.make +include $(GNUSTEP_MAKEFILES)/tool.make + +-include GNUmakefile.postamble diff --git a/Tools/gormtool/GNUmakefile.postamble b/Tools/gormtool/GNUmakefile.postamble new file mode 100644 index 00000000..815ea766 --- /dev/null +++ b/Tools/gormtool/GNUmakefile.postamble @@ -0,0 +1,41 @@ +# +# GNUmakefile.postamble +# +# Copyright (C) 2003 Free Software Foundation, Inc. +# +# Author: Gregory John Casamento +# +# This file is part of GNUstep +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; see the file COPYING.LIB. +# If not, write to the Free Software Foundation, +# 51 Franklin Street, Fifth Floor, Boston, MA 02111 +# USA. +# + +# Define this variable if not defined for backwards-compatibility as +# it is only available in gnustep-make >= 2.0.5 +ifeq ($(LN_S_RECURSIVE),) + LN_S_RECURSIVE = $(LN_S) +endif + +before-all:: + +after-all:: + +after-clean:: + +after-distclean:: + +after-clean:: diff --git a/GormPrefs/GNUmakefile.preamble b/Tools/gormtool/GNUmakefile.preamble similarity index 72% rename from GormPrefs/GNUmakefile.preamble rename to Tools/gormtool/GNUmakefile.preamble index 4d6743af..85e59735 100644 --- a/GormPrefs/GNUmakefile.preamble +++ b/Tools/gormtool/GNUmakefile.preamble @@ -19,14 +19,21 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 +# USA. # -# ADDITIONAL_OBJCFLAGS += -Wall -Werror -ADDITIONAL_GUI_LIBS += \ +ADDITIONAL_TOOL_LIBS += \ -lGormCore \ - -lGorm + -lInterfaceBuilder \ + -lGormObjCHeaderParser \ + -lgnustep-base \ + -lgnustep-gui + +ADDITIONAL_INCLUDE_DIRS += \ + -I../../ ADDITIONAL_LIB_DIRS += \ - -L../GormLib/$(GNUSTEP_OBJ_DIR) \ - -L../GormCore/$(GNUSTEP_OBJ_DIR) + -L../../InterfaceBuilder/$(GNUSTEP_OBJ_DIR) \ + -L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \ + -L../../GormCore/GormCore.framework diff --git a/Tools/gormtool/GormToolPrivate.h b/Tools/gormtool/GormToolPrivate.h new file mode 100644 index 00000000..fcfd0f86 --- /dev/null +++ b/Tools/gormtool/GormToolPrivate.h @@ -0,0 +1,68 @@ +/* GormToolPrivate.h + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + + +#ifndef INCLUDE_GormToolPrivate_H +#define INCLUDE_GormToolPrivate_H + +#import +#import + +#import +#import +#import +#import + +#import + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wobjc-protocol-method-implementation" + +// Special method category smashes so that we can register types... + +@interface NSDocumentController (ToolPrivate) + +- (Class) documentClassForType: (NSString *)type; +- (NSString *) typeFromFileExtension: (NSString *)fileExtension; + +@end + +@interface GormDocument (ToolPrivate) + ++ (BOOL) isNativeType: (NSString *)type; + +@end + +@interface GormPlugin (ToolPrivate) + +- (void) registerDocumentTypeName: (NSString *)name + humanReadableName: (NSString *)hrName + forExtensions: (NSArray *)extensions; + +@end + +#pragma GCC diagnostic pop + +#endif diff --git a/Tools/gormtool/GormToolPrivate.m b/Tools/gormtool/GormToolPrivate.m new file mode 100644 index 00000000..c34db57e --- /dev/null +++ b/Tools/gormtool/GormToolPrivate.m @@ -0,0 +1,102 @@ +/* GormToolPrivate.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +#import "GormToolPrivate.h" + +static NSMutableArray *__types = nil; + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wobjc-protocol-method-implementation" + +// Special method category smashes so that we can register types... + +@implementation NSDocumentController (ToolPrivate) + +- (Class) documentClassForType: (NSString *)type +{ + return [GormDocument class]; +} + +- (NSString *) typeFromFileExtension: (NSString *)fileExtension +{ + int i, count = [__types count]; + + // Check for a document type with the supplied extension + for (i = 0; i < count; i++) + { + NSDictionary *typeInfo = [__types objectAtIndex: i]; + NSArray *array = [typeInfo objectForKey: @"NSUnixExtensions"]; + + NSDebugLog(@"typeInfo = %@", typeInfo); + NSDebugLog(@"fileExtension = %@", fileExtension); + + if ([array containsObject: fileExtension]) + { + NSString *type = [typeInfo objectForKey: @"NSName"]; + NSDebugLog(@"type = %@", type); + return type; + } + } + + NSDebugLog(@"FAILED"); + return nil; +} + +@end + +@implementation GormDocument (ToolPrivate) + ++ (BOOL) isNativeType: (NSString *)type +{ + return YES; +} + +@end + +@implementation GormPlugin (ToolPrivate) + +- (void) registerDocumentTypeName: (NSString *)name + humanReadableName: (NSString *)hrName + forExtensions: (NSArray *)extensions +{ + if (__types == nil) + { + __types = [NSMutableArray arrayWithCapacity: 10]; + } + + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: + name, @"NSName", + hrName, @"NSHumanReadableName", + extensions, @"NSUnixExtensions", + @"Editor", @"NSRole", + nil]; + [__types addObject: dict]; + + NSDebugLog(@"__types = %@", __types); +} + +@end + +#pragma GCC diagnostic pop diff --git a/Tools/gormtool/main.m b/Tools/gormtool/main.m new file mode 100644 index 00000000..7f4a149f --- /dev/null +++ b/Tools/gormtool/main.m @@ -0,0 +1,59 @@ +/* main.m + * + * Copyright (C) 2023 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + * Date: 2023 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 + * USA. + */ + +// main.m + +#import +#import + +#import +#import + +#import "AppDelegate.h" + +int main(int argc, char **argv) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSApplication *app = [NSApplication sharedApplication]; + AppDelegate *delegate = [[AppDelegate alloc] init]; + extern char **environ; + + // Don't show icon... + [[NSUserDefaults standardUserDefaults] setBool: YES forKey: @"GSSuppressAppIcon"]; + + // Initialize process... + [NSProcessInfo initializeWithArguments: (char **)argv + count: argc + environment: environ]; + + // Run... + [app setDelegate: delegate]; + [app run]; + + RELEASE(pool); + + return 0; +} diff --git a/Version b/Version index 4b914fa6..cccacfbe 100644 --- a/Version +++ b/Version @@ -1,4 +1,3 @@ - # This file is included in various Makefile's to get version information. # Compatible with Bourne shell syntax, so it can included there too. @@ -6,10 +5,10 @@ GNUSTEP_GCC=4.3.0 # GNUstep GUI version required -GNUSTEP_CORE_VERSION=0.30.0 +GNUSTEP_CORE_VERSION=0.31.1 # The version number of this release. MAJOR_VERSION=1 -MINOR_VERSION=3 -SUBMINOR_VERSION=1 +MINOR_VERSION=5 +SUBMINOR_VERSION=0 VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION}