From f34100ac45388fcf94981d6943f3224d2649d1b2 Mon Sep 17 00:00:00 2001 From: fedor Date: Sat, 19 Feb 2000 00:40:47 +0000 Subject: [PATCH] Merge from 0.6.5 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6040 72102866-910b-0410-8b05-ffd578937521 --- ANNOUNCE | 78 +++- BUGS | 93 +++++ ChangeLog | 297 ++++++++++++++- Documentation/announce.tmpl.texi | 5 - Documentation/faq.tmpl.texi | 124 ------- Documentation/gnustep-gui.tmpl.texi | 122 +++++- Documentation/news.tmpl.texi | 43 +++ Documentation/readme.tmpl.texi | 4 - Documentation/todo.tmpl.texi | 83 ++++- Headers/gnustep/gui/NSBezierPath.h | 1 + Headers/gnustep/gui/NSCell.h | 11 +- Headers/gnustep/gui/NSMenuItem.h | 1 - Headers/gnustep/gui/NSMenuItemCell.h | 4 + Headers/gnustep/gui/config.h.in | 3 + INSTALL | 2 +- Model/GMAppKit.m | 33 +- NEWS | 70 +++- README | 6 +- Source/NSAffineTransform.m | 5 +- Source/NSApplication.m | 28 +- Source/NSBezierPath.m | 177 ++++++++- Source/NSBrowser.m | 7 +- Source/NSButtonCell.m | 96 +++-- Source/NSCell.m | 14 +- Source/NSGraphicsContext.m | 2 +- Source/NSLayoutManager.m | 536 ++++++++++++++------------- Source/NSMatrix.m | 19 + Source/NSMenu.m | 94 ++--- Source/NSMenuItem.m | 3 - Source/NSMenuItemCell.m | 13 +- Source/NSMenuView.m | 10 + Source/NSPopUpButton.m | 90 +++-- Source/NSPopUpButtonCell.m | 172 ++++++--- Source/NSText.m | 417 ++++++++------------- Source/NSTextContainer.m | 67 ++-- Source/NSTextView.m | 471 ++++++++++++----------- Source/NSView.m | 27 +- Source/NSWindow.m | 43 ++- Version | 4 +- configure | 114 +++++- configure.in | 3 + gnustep-gui.spec | 121 ++++++ 42 files changed, 2343 insertions(+), 1170 deletions(-) create mode 100644 BUGS delete mode 100644 Documentation/faq.tmpl.texi create mode 100644 gnustep-gui.spec diff --git a/ANNOUNCE b/ANNOUNCE index 2b80b8dcc..27b212128 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,7 +1,7 @@ ANNOUNCE ******** -This is version 0.6.0 of the GNUstep GUI library (`gnustep-gui'). +This is version 0.6.5 of the GNUstep GUI library (`gnustep-gui'). What is the GNUstep GUI Library? ================================ @@ -31,11 +31,74 @@ component like the GNUstep X/DPS GUI Backend. What's new in this release? =========================== - The currently released version of the library is `0.6.0'. + The currently released version of the library is `0.6.5'. + +Noteworthy changes in version `0.6.5' +===================================== + + Many of the basic GUI classes have been vastly improved or +rewritten, thanks to Nicola Pero and many +others. + + * New Info Panel support + + * New NSBezierPath + + * Rewrite of several classes including Cell and Button classes. + + * Rewrite of NSBrowser, NSSavePanel, menus, text classes, + NSTableHeader. + + * RTF Parser + + * Implemented image caching. + + * Implemented editing in Forms, Matricies. + + * New autolayout classes GSHBox, GSTable, and GSVBox. + + * Almost all back-end classes have been removed and code incorporated + in a DPS-like graphics context structure. + + * Better keyboard handling. + + * NSHelpManager, NSComboBox, ProgressIndicator written. + + In addition a preliminary version of an Interface Builder (Gorm) has +been written, thanks to Richard Frith-Macdonald + Noteworthy changes in version `0.6.0' ===================================== + A Huge amount of progress, although a lot still needs to be done. +It's usable for a large base of moderately simple apps. Several +NeXT/OpenStep apps and libraries have been ported with little changes. + + * Drag and Drop support fleshed out but not completed. + + * NSText and related classes rewritten. Basic functionality but much + needs to be done to finish them off. + + * nib2gmodel app works with MacOS-X + + * Work done in minimizing the backend which allowed a lot of + functionality to move to the GNU library. + + * Menu code rewritten. + + * PopupButtons now work. + + * Many new images + + * Basic functionality for NSTabView + + * Much better lockFocus support in NSView. Flipped views handled. + + * Rewrite of NSSavePanel and NSOpenPanel + + * Several fixes that at least double the speed of the gui. + Noteworthy changes in version `0.5.5' ===================================== @@ -44,6 +107,7 @@ Noteworthy changes in version `0.5.5' * A lot of rewritting has been done to the classes, with general cleanup of coordinate conversion code, etc. + Noteworthy changes in version `0.5.0' ===================================== @@ -93,6 +157,7 @@ Noteworthy changes in version `0.5.0' * Several cleanups and as usual, many bug fixes. + How can I get support for this software? ======================================== @@ -105,7 +170,7 @@ the GNUstep Web Pages for more information regarding GNUstep resources Where can you get it? How can you compile it? ============================================== - The gstep-gui-0.6.0.tar.gz distribution file has been placed on + The gstep-gui-0.6.5.tar.gz distribution file has been placed on `ftp.gnustep.org' in `pub/gnustep/core'. The program requires gcc 2.8.0 or higher. @@ -115,7 +180,7 @@ library version 3.4 may be required depending on the backend you choose. It also requires a FoundationKit library as specified by the OpenStep specification. The FoundationKit libraries known to work are the -GNUstep Base Library version `0.6.0'. +GNUstep Base Library version `0.6.5'. The `.tar' file is compressed with GNU gzip. Gzip can be obtained by anonymous ftp at any of the GNU archive sites. @@ -132,13 +197,10 @@ Where do I send bug reports? Bug reports can be sent to . -Creators rejoice! -Scott Christley - Obtaining GNU Software ====================== -Check out the GNU web site. (`http://www.gnu.org/') + Check out the GNU web site. (`http://www.gnu.org/') Check out the GNUstep web site. (`http://www.gnustep.org/') diff --git a/BUGS b/BUGS new file mode 100644 index 000000000..9f3a231eb --- /dev/null +++ b/BUGS @@ -0,0 +1,93 @@ +TODO +**** + +Bugs in the GUI library +======================= + +Windows +------- + + * Code to manage window decorations is not finished. The reported + frame origin of a window might be wrong. + + * Windows never get released. Setting isReleasedWhenClosed does not + work. + + Fixing these bugs requires touching delicate parts of the library. + This is why fixing them has been postponed after 0.6.5, to keep + 0.6.5 reasonably stable. + +Texts +----- + + * The NSText code is particularly complex to work on and it has not + improved much since 0.6.0. Many bugs are know in the code - it is + somewhat usable though. We hope on a big improvement of this area + for next release. + +Matrices +-------- + + * Encoding/Decoding of matrices is unimplemented. There are some + minor known bugs with handling of mouse down in matrices. + +Cells +----- + + * Since NSText does only left alignment, when you select or edit text + in a cell it becomes automatically left aligned regardless of the + original alignment. + + * Multi line texts are unsupported; isScrollable, wordWraps etc do + nothing. This restriction will hopefully be removed in next + releases. + +Images anf Graphics +------------------- + + * There are problems with alpha composing. To avoid these problems, + you may set manually the background color of your image when + displaying it. + + * Only TIFF images are supported in 0.6.5. Support at least for PNG + and JPEG images is planned for next release. + + * alpha drawing and compositing of graphics doesn't work. + + +Alert, Info Panels +------------------ + + * Multi line messages are generally unsupported due to the similar + restriction in the cells code. + +Unimplemented Classes +--------------------- + + The following classes are currently unimplemented or unfinished to +such a degree to be unusable. + + * NSColorPanel + + * NSDataLink + + * NSFontManager + + * NSFontPanel + + * NSHelpPanel + + * NSLayoutManager + + * NSPageLayout + + * NSPrintPanel + + * NSSecureTextField + + * NSSpellChecker + + * NSTableView + + * NSTextView + diff --git a/ChangeLog b/ChangeLog index 7efa3d155..d2481e8f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,3 @@ -Wed Feb 09 18:50:12 2000 Enrico Sersale - - * Source/NSBezierPath.m Headers/gnustep/gui/NSBezierPath.h : - Rewritten conforming to MacOS-X implementation details. - Tue Jan 25 14:52:27 2000 Nicola Pero Contributed by Fred Kiefer: @@ -11,6 +6,284 @@ Tue Jan 25 14:52:27 2000 Nicola Pero * Headers/AppKit/NSFontManager.h: Corresponding rewrite. * Headers/AppKit/NSFontPanel.h: Idem. +2000-02-17 Adam Fedor + + * Version: 0.6.5 released. + +2000-02-16 Adam Fedor + + * gnustep-gui.spec: Newfile + +2000-02-15 Adam Fedor + + * configure.in: Fix test for rintf + +2000-02-14 Adam Fedor + + * Version: Update version number + * Documentation/announce.tmpl.texi: Update + * Documentation/readme.tmpl.texi: Likewise. + * Documentation/news.tmpl.texi: Likewise. + * Documentation/todo.tmpl.texi: Likewise. + * ANNOUNCE, BUGS, NEWS, README: Regenerate + +Mon Feb 14 13:23:00 2000 Richard Frith-Macdonald + + * Source/NSLayoutManager.m: Tidied and simplified by removing + inefficient scanner class and using NSScanner instead. + * Source/NSText.m: ditto. + * Source/NSTextView.m: fix a couple of bugs that were causing crash in + text network demo - lets the demo run a while longer before crashing. + +2000-02-13 Adam Fedor + + * Source/NSAffineTransform (-transformBezierPath:): Implement. + (from Enrico Sersale ). + +Mon Feb 14 00:59:33 2000 Nicola Pero + + * Source/NSApplication.m ([-orderFrontStandardAboutPanel:]): Fixed + typo/bug. Reported by Fred Kiefer + +Sun Feb 13 22:24:54 2000 Nicola Pero + + This fixes a bug; the same bug that produced those little white + vertical lines at the bottom of windows with editable textfields + when windows were ordered out then in after editing. + * Source/NSView.m ([-removeFromSuperviewWithoutNeedingDisplay]), + ([-removeFromSuperview]): Ask the window to take first responder + status in our place if we are. Important: this is done *before* + any other action is undertaken, because changing first responder + invokes -resignFirstResponder:, which should be allowed to assume + that the view is normally placed in the view hierarchy. + +Sun Feb 13 19:20:00 2000 Enrico Sersale + + * Source/NSBezierPath.m: ([-copyWithZone:]) implemented. + +Sat Feb 12 21:16:00 2000 Nicola Pero + + * Source/NSBrowser.m ([-loadColumnZero]), ([-reloadColumn:]): + Adjust frame of column after loading it. + +Sat Feb 12 20:27:00 2000 Richard Frith-Macdonald + + * Source/NSView.m: ([setNeedsDisplayInRect:]) change to ensure that + superviews are always marked as needing display when we are. + * Source/NSPopUpButton.m: ([-encodeWithCoder:]) ([-initWithCoder:]) + implemented for Gorm. + +Sat Feb 12 19:47:14 2000 Nicola Pero + + * Source/NSPopUpButton.m ([-selectItem:]): Bug fix: Update menu + knowledge of the selected item. ([-selectItemWithTitle:]), + ([-selectItemAtIndex:]), ([-selectItem:]): Bug fix: Invoke + synchronizeTitleAndSelectedItem to update what is displayed. + +Sat Feb 12 18:11:32 2000 Nicola Pero + + * Source/NSWindow.m ([-setContentView:]): When expanding the new + content view to cover the whole window, do it using the nice way, + resizeWithOldSuperviewSize:, which allows the view to reorganize + its subviews for the new size. + +Sat Feb 12 17:53:00 2000 Richard Frith-Macdonald + + * Source/NSMenu.m: Replace non-working archiving code with + drastically simplified code that does work in the normal case, but + doesn't deal with non-standard menu representations. This lets + Gorm work with menus. + * Source/NSMenuItem.m: Don't archive parent menu. + +Fri Feb 11 20:18:10 2000 Enrico Sersale + + * Source/NSBezierPath.m: ([-transformUsingAffineTransform:]) implement. + +2000-02-09 Adam Fedor + + * Documentation/announce.tmpl.texi: Update. + * Documentation/news.tmpl.texi: Likewise. + * Documentation/readme.tmpl.texi: Likewise. + +Thu Feb 10 00:56:08 2000 Nicola Pero + + * Source/NSText.m ([-keyDown:]): Implemented NSDeleteFunctionKey, + which was unimplemented - problem reported by Jory van Zessen. + + Simple superficial improvements to make NSText just a little + faster: + * Source/NSText.m: Changed everywhere [self selectedRange] simply + to selected_range. ([-moveCursorUp:]), ([-moveCursorLeft:]): + Return at once if cursor is already at the beginning of text. + ([-moveCursorDown:]), ([-moveCursorRight:]): Return at once if + cursor is already at the end of text. + +Wed Feb 09 18:59:02 2000 Enrico Sersale + + * Source/NSBezierPath.m Headers/gnustep/gui/NSBezierPath.h : + Rewritten conforming to MacOS-X implementation details. + +Tue Feb 8 17:22:05 2000 Nicola Pero + + * Model/GMAppKit.m ([NSMenuItem -initWithModelUnarchiver:]): Fix + for having GNUstep load gmodels created from OPENSTEP NIBs. + NSMenu internals are slightly different in GNUstep and OPENSTEP; + OPENSTEP stores an item submenu as the item target, while GNUstep + stores it in a special mi_submenu ivar. This patch, for GNUstep + only, sets the submenu ivar from the target for items which have a + submenu. + +2000-02-07 Adam Fedor + + * configure.in: Add check for rintf. + * Source/NSBrowser.m: Use rint i no rintf. + + * Source/NSApplication.m: Convert NSDebugLog to NSDebugLLog for + various NSEvent debugs. + + * Source/NSMenuItemCell.m ([NSMenuItemCell -calcSize]): Make + sure anImage exists before getting size (methods with nil receivers + returning structs segfaults on Solaris). + +Mon Feb 7 18:55:29 2000 Nicola Pero + + * Source/NSMatrix.m ([-mouseDown:]): Pass mouse down to super if + we have no cells. + +Mon Feb 7 03:06:36 2000 Nicola Pero + + This bug was crashing GNUstep while I was doing experiments with + the Save Panel's code. It wasn't easy to find. + * Source/NSMatrix.m ([-putCell:atRow:column:]): Fixed bug. If we + are putting a new cell precisely in _selectedRow, _selectedColumn, + we have to update _selectedCell, otherwise it remains pointing to + the released cell! ([-insertRow:withCells:]): Update _selectedRow + if needed. ([-insertColumn:withCells:]): Update _selectedColumn if + needed. + +Sun Feb 6 8:52:00 2000 Richard Frith-Macdonald + + * Source/GSInfoPanel.m: Make newly created panel appear in center + of screen. + +Sun Feb 6 05:50:20 2000 Nicola Pero + + * Documentation/gnustep-gui.tmpl.texi (Window Manager): Added a + tiny section recommending to set "Click Window To Focus" in the + window manager configuration. Also, improved the section on the + Standard Info Panel. + +Sat Feb 5 03:02:04 2000 Nicola Pero + + * Source/NSWindow.m ([-orderWindow:relativeTo:]): Fixed a quite + serious bug appearing twice, in two for loops. It was messing + window ordering, causing the app to freeze under certain + circumstances. + +Fri Feb 4 18:35:59 2000 Nicola Pero + + * Source/GSInfoPanel.m ([-initWithDictionary:]): Use + Helvetica-Bold instead of Helvetica-BoldOblique [for now]. + +Thu Feb 3 17:24:00 2000 Richard Frith-Macdonald + + * Source/NSMenu.m: ([NSMenuWindowTitleView -mouseDown:]) fix memory + allocation error when setting new menu location frame info. + +Thu Feb 3 02:56:10 2000 Enrico Sersale + + * Source/NSBezierPath.m Partially rewritten, fixed, + added a concrete class + ([-setCachesBezierPath:]): Implemented using NSImage. + +Thu Feb 3 03:45:08 2000 Nicola Pero + + * Source/NSButtonCell.m ([-drawInteriorWithFrame:inView:]): + NSImageAbove, NSImageBelow: Rewritten. In these cases now we + determine the space taken by the text; then all the remaining + space is given to the image, which is centered in it. + +Thu Feb 3 02:20:29 2000 Nicola Pero + + * Source/NSButtonCell.m ([-cellSize]): Bug fix: typo would prevent + button with both image and text, image above/below text, to size + correctly. + +Wed Feb 2 06:56:33 2000 Nicola Pero + + With a hack the library is now able to pop up popupbuttons in the + right position, correcting at run time bugs in the window frame + code. This was hard. + * Source/NSPopUpButtonCell.m (_convertBaseToScreen_with_fix): + Added private function to do the conversion right, automatically + fixing window frame origin bugs. + * Source/NSPopUpButtonCell.m ([-attachPopUpWithFrame:inView:]): + Use the above mentioned function to perform the coordinate + conversion right. + * Source/NSPopUpButton.m ([-mouseDown:]): Idem. + +Tue Feb 1 00:46:42 2000 Nicola Pero + + * Headers/AppKit/NSMenuItem.h: Removed unused ivar mi_hasSubmenu. + * Source/NSMenuItem.m ([-init]): Removed reference to the unused + ivar. + +Mon Jan 31 00:24:17 2000 Nicola Pero + + Rewritten, fixed, NSPopUpButton appearance. NB: When the button + popups in the wrong position, that is a bug elsewhere. + * Headers/AppKit/NSMenuItemCell.h: Added ivar + _mcell_belongs_to_popupbutton. + * Source/NSMenuItemCell.m ([-imageRectForBounds:]): In the special + case _mcell_belongs_to_popupbutton == YES and there is an image, + draw it at the extreme right. + * Source/NSPopUpButtonCell.m: Added private method [NSMenuItemCell + -setBelongsToPopUpButton:]. ([+initialize]): Added method. We + are now caching the two standard images. ([-addItemWithTitle:]): + Simplified. ([-insertItemWithTitle:atIndex:]): Set image position + to right, and set cell to belong to popup button. + ([-selectItem:]): Invoke setChangesState: NO and set proper image + after setting state of any item. ([-selectItemAtIndex:]): Made + code readable. ([-drawWithFrame:inView:]): Set background of + image. + + * Source/NSMenuItemCell.m ([-calcSize]): Bug fix: don't move the + image to the left if a valid image position has been already set. + * Source/NSMenuView.m ([-setMenuItemCell:forItemAtIndex:]): Bug + fix: Connect new cell to menuItem and menu so that it works. + * Source/NSApplication.m + ([-orderFrontStandardAboutPanelWithOptions:]): Display 'Info' in + the title. + +2000-01-28 Adam Fedor + + * Source/NSBrowser.m ([NSBrowser -_performLoadOfColumn:]): Don't + release columns's columnMatrix, the column will do it. + +2000-01-26 Adam Fedor + + * Source/NSGraphicsContext.m ([NSGraphicsContext + +setCurrentContext:]): Retain (assign) the new context (fix + suggested by Jonathan Gapen ) + + * gui/Model/GMAppkit.m ([NSMenuItem -encodeWithModelArchiver:]): + Check to see if object responds to various selectors before + invoking them. + +Wed Jan 26 06:50:14 2000 Nicola Pero + + Fixed mixed state stuff so that it is exactly as in macosx + [untested]: + * Headers/AppKit/NSCell.h: Turned _cell.state into a normal int; + changed NSMixedState to -1. + * Source/NSCell.m ([-setState:]): Rewritten, mixed state support. + +Wed Jan 26 02:03:25 2000 Nicola Pero + + * Documentation/gnustep-gui.tmpl.texi (Standard Info Panel): Added + documentation for [NSApplication -orderFrontInfoPanel:] and + [NSApplication -orderFrontInfoPanelWithOptions:]. + Mon Jan 24 23:45:30 2000 Nicola Pero Implemented a standard Info Panel for GNUstep. To make everyone @@ -18,17 +291,19 @@ Mon Jan 24 23:45:30 2000 Nicola Pero -orderFrontStandardInfoPanel: are available; one displays 'About' in the title, and the other displays 'Info'; they are otherwise identical. GNUstep recommends using the 'Info' version. - * Source/GNUmakefile (libgnustep-gui_OBJC_FILES): Added GSInfoPanel. - (libgnustep-gui_HEADER_FILES): Idem. + * Source/GNUmakefile (libgnustep-gui_OBJC_FILES): Added + GSInfoPanel. (libgnustep-gui_HEADER_FILES): Idem. * Source/GSInfoPanel.m: New class. * Headers/AppKit/GSInfoPanel.h: New class. * Headers/AppKit/NSApplication.h: Added ivar _infoPanel, declaration of new methods. * Source/NSApplication.m - ([-orderFrontStandardInfoPanelWithOptions:]): New method, implemented. - ([-orderFrontStandardInfoPanel:]): Idem. ([-orderFrontStandardAboutPanel:]): - Idem. ([-orderFrontStandardAboutPanelWithOptions:]): Idem. ([-dealloc]): - Added release of _infoPanel. + ([-orderFrontStandardInfoPanelWithOptions:]): New method, + implemented. + ([-orderFrontStandardInfoPanel:]): Idem. + ([-orderFrontStandardAboutPanel:]): Idem. + ([-orderFrontStandardAboutPanelWithOptions:]): Idem. + ([-dealloc]): Added release of _infoPanel. Mon Jan 24 04:01:55 2000 Nicola Pero diff --git a/Documentation/announce.tmpl.texi b/Documentation/announce.tmpl.texi index c929b96eb..a753ca78d 100644 --- a/Documentation/announce.tmpl.texi +++ b/Documentation/announce.tmpl.texi @@ -81,11 +81,6 @@ be placed in Bug reports can be sent to @email{bug-gnustep@@gnu.org}. -@noindent -Creators rejoice!@* -Scott Christley@* -@email{scottc@@net-community.com}@* - @section Obtaining GNU Software Check out the GNU web site. (@url{http://www.gnu.org/}) diff --git a/Documentation/faq.tmpl.texi b/Documentation/faq.tmpl.texi deleted file mode 100644 index 3ce52cd8c..000000000 --- a/Documentation/faq.tmpl.texi +++ /dev/null @@ -1,124 +0,0 @@ -@c -*-texinfo-*- -@chapter Frequently Asked Questions With Answers - -@ifset TEXT-ONLY -@include version.texi -@end ifset - -Maintained by Scott Christley @email{scottc@@net-community.com}. - -Last updated March 28 1997. The most up-to-date version of this FAQ -is available at: - -@example -@url{ftp://www.gnustep.org/Documentation/gnustep-gui/gnustep-gui_toc.html} -@end example - -Please send corrections to @email{scottc@@net-community.com}. - -@enumerate - -@item @b{What is the GNUstep GUI Library?} - -The GNUstep GUI Library is a library of objects useful for writing -graphical applications. For example, it includes classes for drawing -and manipulating graphics objects on the screen: windows, menus, -buttons, sliders, text fields, and events. There are also many -peripheral classes that offer operating-system-independent interfaces to -images, cursors, colors, fonts, pasteboards, printing. There are also -workspace support classes such as data links, open/save panels, -context-dependent help, spell checking. - -It provides functionality that aims to implement the @samp{AppKit} -portion of the OpenStep standard. However the implementation has -been written to take advantage of GNUstep enhancements wherever possible. - - -@item @b{Explain the organization of the front and back-ends.} - -The GNUstep GUI Library is divided into a front and back-end. The -front-end contains the majority of implementation, but leaves out the -low-level drawing and event code. A back-end can override whatever -methods necessary in order to implement low-level drawing event -receiving. Different back-ends will make GNUstep available on various -platforms. The default GNU back-end will run on top of the X Window -System and the Display Ghostscript Server. Other back-ends could allow -GNUstep to run on Mac, OS/2, and WIN32 graphics/event platforms. -Much work will be saved by this clean separation between front and -back-end, because it allows different platforms to share the large -amount of front-end code. - -The front-end does not specify what mechanism to use in order to "plug -in" the back-end; that is the back-end implementor's choice. At least -two backends will use @samp{+poseAs:} method, for example, running -@samp{[XDPSWindow poseAs: [NSWindow class]]}. Using @samp{+poseAs:} is -more flexible than using Categories because it allows the the back-end -implementor to choose what to override in the front-end, instead of -having the interface between front and back-end fixed by the front-end. - - -@item @b{What is the current state of development of the front-end?} - -A number of classes in the front-end are complete or almost complete; -these include: NSActionCell, NSButtonCell, NSButton, NSCell, NSColor, -NSColorWell, NSControl, NSCursor, NSEvent, NSFont, NSImage, NSImageRep, -NSBitmapImageRep, NSResponder, NSSlider, NSScroller, NSTextField, and -NSTextFieldCell. - -Other classes are complete enough to use, but still require some major -additions before being considered almost complete: NSApplication, NSBox, -NSFontManager, NSMatrix, NSMenu, NSMenuCell, NSPopUpButton, -NSSliderCell, NSText, NSView, and NSWindow. - -You can review the most up-to-date status report at: - -@example -@url{http://www.gnustep.org/Documentation/gnustep-gui/gnustep-gui_toc.html}. -@end example - -@item @b{What back-ends are available?} - -The official back-end is the GNUstep X/DPS GUI Backend which runs -under the X Window System and interfaces to the Display Ghostscript -System. You can learn more at: - -@example -@url{http://www.gnustep.org/Documentation/gnustep-xdps/gnustep-xdps_toc.html} -@end example - -@item @b{Where can I get a copy?} - -@ifset GNUSTEP-GUI-FTP-MACHINE -The gstep-gui-@value{GNUSTEP-GUI-VERSION}.tar.gz distribution -file has been placed on @samp{@value{GNUSTEP-GUI-FTP-MACHINE}} in -@samp{@value{GNUSTEP-GUI-FTP-DIRECTORY}}. -@end ifset -@ifclear GNUSTEP-GUI-FTP-MACHINE -The gstep-gui-@value{GNUSTEP-GUI-VERSION}.tar.gz distribution -file has not been made available by anonymous ftp. -@end ifclear - -The program requires gcc @value{GNUSTEP-GUI-GCC} or higher. - -It requires the Display Ghostscript System version -@value{GNUSTEP-GUI-DGS} and the TIFF Graphics library version -@value{GNUSTEP-GUI-LIBTIFF}. - -It also requires a FoundationKit library as specified by the OpenStep -specification. The FoundationKit libraries known to work are the GNUstep -Base Library version @samp{@value{GNUSTEP-GUI-BASE}} and libFoundation version -@samp{@value{LIB-FOUNDATION}}. - -The @samp{.tar} file is compressed with GNU gzip. Gzip can be obtained by -anonymous ftp at any of the GNU archive sites. - -For info about FTP via email, send email to -@email{ftpmail@@decwrl.dec.com} with no subject line, and two-line body -with line one @samp{help} and line two @samp{quit}. - -The most recent (not necessarily tested) snapshots of the library will -be placed in -@url{ftp://@value{GNUSTEP-GUI-SNAP-FTP-MACHINE}/@value{GNUSTEP-GUI-SNAP-FTP-DIRECTORY}}. - -@end enumerate - diff --git a/Documentation/gnustep-gui.tmpl.texi b/Documentation/gnustep-gui.tmpl.texi index 516c2c20e..4f1f5a7a3 100644 --- a/Documentation/gnustep-gui.tmpl.texi +++ b/Documentation/gnustep-gui.tmpl.texi @@ -147,6 +147,7 @@ installed the GNUstep Makefile Pacakge and the GNUstep Base Library. @chapter Special Features of GUI Classes. @menu +* NSApplication:: * NSBrowserCell:: * NSSavePanel:: * GSHbox:: @@ -154,7 +155,111 @@ installed the GNUstep Makefile Pacakge and the GNUstep Base Library. * GSVbox:: @end menu -@node NSBrowserCell, NSSavePanel, Classes, Classes +@node NSApplication, NSBrowserCell, Classes, Classes +@section NSApplication + +@menu +* Standard Info Panel:: +@end menu + +@node Standard Info Panel, , NSApplication, NSApplication +@subsection Standard Info Panel + +GNUstep NSApplication provides the following two methods to easily +create a standard Info Panel for your application: + +@noindent +- (void) @b{orderFrontStandardInfoPanel:} (id)@t{sender} + +Invokes @code{orderFrontStandardInfoPanelWithOptions:} with a @code{nil} +dictionary. You may use this method as action of a menu item, even +if it is generally preferred to use the full method so that you can +fill in all the information to show in the Info Panel. + +@noindent +- (void) @b{orderFrontStandardInfoPanelWithOptions:} (NSDictionary *)@t{dictionary} + +Orders front the standard info panel for the application, taking the +needed information from the @t{dictionary} argument. There is a single +standard info panel per application; it is created the first time that +this method is invoked, and then reused in all subsequent calls. The +application standard info panel is immutable and can not be changed +after creation. Useful keys for the @t{dictionary} are: + +@code{ApplicationName}: A string with the name of the application (eg, +@code{@@"Gorm"}). If not available, the @file{Info-gnustep.plist} file is +searched for the value of @code{ApplicationName}; if this fails, the +@file{Info-gnustep.plist} file is searched for the value of +@code{NSHumanReadableShortName}; if this also fails, the string returned +by @code{[[NSProcessInfo processInfo] processName]} is used. + +@code{ApplicationDescription}: A string with a very short description +of the application (eg, @code{@@"GNUstep Graphics Objects Relationship +Modeller"}). If not available, @file{Info-gnustep.plist} is searched +for that key; if this fails, no application description is shown. + +@code{ApplicationIcon}: An image to be shown near the title. If not +available, @file{Info-gnustep.plist} is looked for +@code{ApplicationIcon}; if this fails, @code{[NSApp +applicationIconImage]} is used instead. Since this is what you usually +want, you usually do not need to set the @code{ApplicationIcon} +key/value in the @code{dictionary}. + +@code{ApplicationRelease}: A string with the name of the application, +release included (eg, @code{@@"Gorm 0.1"}). If not available, the value +for @code{ApplicationVersion} is used instead. If this fails, +@file{Info-gnustep.plist} is looked for @code{ApplicationRelease} or +(failing this) for @code{NSAppVersion}. If all fails, @code{"Unknown"} +is used. + +@code{FullVersionID}: A string with the full version of the application +(eg, @code{@@"0.1.2b"} or @code{@@"snap011100"}). If not available, +@code{Version} is used instead. If this fails, +@file{Info-gnustep.plist} is looked for @code{NSBuildVersion}. If all +fails, no full version is shown. + +@code{Authors}: An array of strings, each one with the name of an author +(eg, +@code{[NSArray arrayWithObject: @@"Nicola Pero "]}). +If not found, @file{Info-gnustep.plist} is +looked for @code{Authors}, if this fails, @code{@@"Unknown"} is +displayed. + +@code{URL}: [This field is still under work, so it might be changed] A +string with an URL (eg, @code{@@"See http://www.gnustep.org"}). + +@code{Copyright}: A string with copyright owners (eg, @code{@@"Copyright +(C) 2000 The Free Software Foundation, Inc."}). Support for multiple +line strings is planned but not yet available. If not found, +@file{Info-gnustep.plist} is searched for @code{Copyright} and then +(failing this) for @code{NSHumanReadableCopyright}. If all fails, +@code{@@"Copyright Information Not Available"} is used. + +@code{CopyrightDescription}: A string describing the kind of copyright +(eg, @code{@@"Released under the GNU General Public License 2.0"}). If +not available, @file{Info-gnustep.plist} is looked for +@code{CopyrightDescription}. If this fails, no copyright description +is shown. + +For compatibility reasons only, the following MacOSX API is also +available: + +@noindent +- (void) @b{orderFrontStandardAboutPanel:} (id)@t{sender} + +@noindent +- (void) @b{orderFrontStandardAboutPanelWithOptions:} (NSDictionary *)@t{dictionary} + +These methods do the same as the ones above, but are deprecated. + +Please note that you are free to implement your own info panel for your +app without breaking the GNUstep User Interface; the standard one is +available only as a facility -- it's not at all compulsory to use the +standard one -- you are encouraged to create your own if you like. What +is important instead is that you make your info panel available from the +@t{Info...} item in the @t{Info} menu. + +@node NSBrowserCell, NSSavePanel, NSApplication, Classes @section NSBrowserCell @menu @@ -1139,10 +1244,11 @@ argument was given. The Info-gnustep.plist file could look like this: @chapter Special Setup Instructions. @menu -* Keyboard Modifiers:: +* Keyboard Modifiers:: +* Window Manager:: @end menu -@node Keyboard Modifiers, , Setup, Setup +@node Keyboard Modifiers, Window Manager, Setup, Setup @section Keyboard Modifiers This section applies only to the xgps and the xdps backend. @@ -1280,6 +1386,16 @@ Good window managers let you change the keyboard shortcuts, so you may move the wm shortcuts that you do not use to keys which do not conflict (at least not too much) with GNUstep. +@node Window Manager, , Keyboard Modifiers, Setup +@section Window Manager Recommended Configuration + +If you are using GNUstep GUI library with the Window Maker window +manager it is recommended that you set the Window Maker option "Input +Focus Mouse" (under "Window Focus Preferences") to "Click Window To +Focus". + +If you are using another window manager, look for a similar option. + @node Contributing, Concept Index, Setup, Top @chapter Contributing diff --git a/Documentation/news.tmpl.texi b/Documentation/news.tmpl.texi index a18675b5e..a4c27e06e 100644 --- a/Documentation/news.tmpl.texi +++ b/Documentation/news.tmpl.texi @@ -9,8 +9,51 @@ The currently released version of the library is @samp{@value{GNUSTEP-GUI-VERSION}}. +@section Noteworthy changes in version @samp{0.6.5} + +Many of the basic GUI classes have been vastly improved or rewritten, thanks +to Nicola Pero @email{n.pero@@mi.flashnet.it} and many others. + +@itemize @bullet +@item New Info Panel support +@item New NSBezierPath +@item Rewrite of several classes including Cell and Button classes. +@item Rewrite of NSBrowser, NSSavePanel, menus, text classes, NSTableHeader. +@item RTF Parser +@item Implemented image caching. +@item Implemented editing in Forms, Matricies. +@item New autolayout classes GSHBox, GSTable, and GSVBox. +@item Almost all back-end classes have been removed and code incorporated +in a DPS-like graphics context structure. +@item Better keyboard handling. +@item NSHelpManager, NSComboBox, ProgressIndicator written. +@end itemize + +In addition a preliminary version of an Interface Builder (Gorm) has +been written, thanks to Richard Frith-Macdonald @email{richard@@brainstorm.co.uk} + @section Noteworthy changes in version @samp{0.6.0} +A Huge amount of progress, although a lot still needs to be done. It's +usable for a large base of moderately simple apps. Several NeXT/OpenStep +apps and libraries have been ported with little changes. + +@itemize @bullet +@item Drag and Drop support fleshed out but not completed. +@item NSText and related classes rewritten. Basic functionality but +much needs to be done to finish them off. +@item nib2gmodel app works with MacOS-X +@item Work done in minimizing the backend which allowed a lot +of functionality to move to the GNU library. +@item Menu code rewritten. +@item PopupButtons now work. +@item Many new images +@item Basic functionality for NSTabView +@item Much better lockFocus support in NSView. Flipped views handled. +@item Rewrite of NSSavePanel and NSOpenPanel +@item Several fixes that at least double the speed of the gui. +@end itemize + @section Noteworthy changes in version @samp{0.5.5} Too extensive to list. diff --git a/Documentation/readme.tmpl.texi b/Documentation/readme.tmpl.texi index 05db78d08..0205c7854 100644 --- a/Documentation/readme.tmpl.texi +++ b/Documentation/readme.tmpl.texi @@ -32,7 +32,3 @@ Give us feedback! Tell us what you like; tell us what you think could be better. Send bug reports to @email{bug-gnustep@@gnu.org}. @end itemize -@noindent -Creators rejoice!@* -Scott Christley@* -@email{scottc@@net-community.com} diff --git a/Documentation/todo.tmpl.texi b/Documentation/todo.tmpl.texi index 0e82eefa1..3e5aac0e0 100644 --- a/Documentation/todo.tmpl.texi +++ b/Documentation/todo.tmpl.texi @@ -6,17 +6,86 @@ @include version.texi @end ifset -@section Projects Looking for Volunteers - -If you think you can do one of these projects, please let me know. Your -help is greatly appreciated. Send email to @email{scottc@@net-community.com}. +@section Bugs in the GUI library @end ifclear +@subsection Windows + @itemize @bullet +@item Code to manage window decorations is not finished. +The reported frame origin of a window might be wrong. -@item Consolodate examples and tests [3, OpenStep] (980913). -Also fix or document whatever bugs are there. +@item Windows never get released. Setting isReleasedWhenClosed +does not work. -@item Need an rtf parser [6 - Objective-C, RTF] (980820). +Fixing these bugs requires touching delicate parts of the library. +This is why fixing them has been postponed after 0.6.5, to keep 0.6.5 +reasonably stable. +@end itemize + +@subsection Texts + +@itemize @bullet +@item The NSText code is particularly complex to work on and it has not +improved much since 0.6.0. Many bugs are know in the code -- it is +somewhat usable though. We hope on a big improvement of this area +for next release. +@end itemize + +@subsection Matrices + +@itemize @bullet +@item Encoding/Decoding of matrices is unimplemented. There are some minor +known bugs with handling of mouse down in matrices. +@end itemize + +@subsection Cells + +@itemize @bullet +@item Since NSText does only left alignment, when you select or edit text +in a cell it becomes automatically left aligned regardless of the original +alignment. + +@item Multi line texts are unsupported; isScrollable, wordWraps etc do nothing. +This restriction will hopefully be removed in next releases. +@end itemize + +@subsection Images anf Graphics + +@itemize @bullet +@item There are problems with alpha composing. To avoid these problems, +you may set manually the background color of your image when displaying it. + +@item Only TIFF images are supported in 0.6.5. Support at least for PNG and +JPEG images is planned for next release. + +@item alpha drawing and compositing of graphics doesn't work. @end itemize + +@subsection Alert, Info Panels + +@itemize @bullet +@item Multi line messages are generally unsupported due to the similar +restriction in the cells code. +@end itemize + +@subsection Unimplemented Classes + +The following classes are currently unimplemented or unfinished +to such a degree to be unusable. + +@itemize @bullet +@item NSColorPanel +@item NSDataLink +@item NSFontManager +@item NSFontPanel +@item NSHelpPanel +@item NSLayoutManager +@item NSPageLayout +@item NSPrintPanel +@item NSSecureTextField +@item NSSpellChecker +@item NSTableView +@item NSTextView +@end itemize diff --git a/Headers/gnustep/gui/NSBezierPath.h b/Headers/gnustep/gui/NSBezierPath.h index 4bda29240..9c7235541 100644 --- a/Headers/gnustep/gui/NSBezierPath.h +++ b/Headers/gnustep/gui/NSBezierPath.h @@ -189,6 +189,7 @@ typedef enum { // Path modifications. // - (NSBezierPath *)bezierPathByFlatteningPath; + - (NSBezierPath *)bezierPathByReversingPath; // diff --git a/Headers/gnustep/gui/NSCell.h b/Headers/gnustep/gui/NSCell.h index aaabb4f12..149b87214 100644 --- a/Headers/gnustep/gui/NSCell.h +++ b/Headers/gnustep/gui/NSCell.h @@ -99,10 +99,13 @@ enum { yDist = 2 // vertical distance between the text and image rects. }; +/* + * We try to do as in macosx. + */ enum { NSOffState = 0, NSOnState = 1, - NSMixedState = 2 + NSMixedState = -1 }; @interface NSCell : NSObject @@ -112,7 +115,7 @@ enum { NSImage *_cell_image; NSFont *_cell_font; struct GSCellFlagsType { - // total 30 bits. 2 bits left. + // total 28 bits. 4 bits left. unsigned is_highlighted:1; unsigned is_disabled:1; unsigned is_editable:1; @@ -124,7 +127,6 @@ enum { unsigned float_autorange:1; unsigned wraps:1; unsigned allows_mixed_state:1; - unsigned state:2; // 3 values; unsigned text_align:3; // 5 values unsigned image_position:4; // 7 values unsigned type:4; // 8 values (see NSButtonCell) @@ -132,6 +134,9 @@ enum { // 2 bits reserved for subclass use unsigned subclass_bool_one:1; unsigned subclass_bool_two:1; + /* This is not in the bitfield now (for simpler macosx compatibility) + but who knows in the future */ + int state; // 3 values but one negative } _cell; unsigned int _cell_float_left; unsigned int _cell_float_right; diff --git a/Headers/gnustep/gui/NSMenuItem.h b/Headers/gnustep/gui/NSMenuItem.h index b01ee9c98..46708078b 100644 --- a/Headers/gnustep/gui/NSMenuItem.h +++ b/Headers/gnustep/gui/NSMenuItem.h @@ -113,7 +113,6 @@ SEL mi_action; int mi_tag; id mi_representedObject; - BOOL mi_hasSubmenu; NSMenu *mi_submenu; BOOL mi_changesState; diff --git a/Headers/gnustep/gui/NSMenuItemCell.h b/Headers/gnustep/gui/NSMenuItemCell.h index d02aa8474..ef1d871e8 100644 --- a/Headers/gnustep/gui/NSMenuItemCell.h +++ b/Headers/gnustep/gui/NSMenuItemCell.h @@ -54,6 +54,10 @@ typedef void (*DrawingIMP)(id, SEL, NSRect, NSView*); NSString *mcell_titleToDisplay; NSSize mcell_imageSize; + /* If we belong to a popupbutton, we display image on the extreme + right */ + BOOL _mcell_belongs_to_popupbutton; + @private NSColor *_backgroundColor; } diff --git a/Headers/gnustep/gui/config.h.in b/Headers/gnustep/gui/config.h.in index b322e5b72..286f40d0c 100644 --- a/Headers/gnustep/gui/config.h.in +++ b/Headers/gnustep/gui/config.h.in @@ -42,4 +42,7 @@ if (pointer) free(pointer) #endif +/* Define if you have the rintf function. */ +#undef HAVE_RINTF + #endif /* _GNUstep_H_config */ diff --git a/INSTALL b/INSTALL index 608d2ac90..33e0c14ba 100644 --- a/INSTALL +++ b/INSTALL @@ -6,7 +6,7 @@ This file documents the installation of the GNUstep GUI Library, may copy, distribute, and modify it freely as long as you preserve this copyright notice and permission notice. - This is version 0.6.0 of the GNUstep GUI library. + This is version 0.6.5 of the GNUstep GUI library. Installing `gnustep-gui' ======================== diff --git a/Model/GMAppKit.m b/Model/GMAppKit.m index 24390e29a..08afbfc5b 100644 --- a/Model/GMAppKit.m +++ b/Model/GMAppKit.m @@ -723,18 +723,25 @@ void __dummy_GMAppKit_functionForLinking() {} - (void)encodeWithModelArchiver:(GMArchiver*)archiver { [archiver encodeString:[self title] withName:@"title"]; - [archiver encodeObject:[self image] withName:@"image"]; - [archiver encodeObject:[self onStateImage] withName:@"onStateImage"]; - [archiver encodeObject:[self offStateImage] withName:@"offStateImage"]; - [archiver encodeObject:[self mixedStateImage] withName:@"mixedStateImage"]; + if ([self respondsToSelector: @selector(image)]) + [archiver encodeObject:[self image] withName:@"image"]; + if ([self respondsToSelector: @selector(onStateImage)]) + [archiver encodeObject:[self onStateImage] withName:@"onStateImage"]; + if ([self respondsToSelector: @selector(offStateImage)]) + [archiver encodeObject:[self offStateImage] withName:@"offStateImage"]; + if ([self respondsToSelector: @selector(mixedStateImage)]) + [archiver encodeObject:[self mixedStateImage] withName:@"mixedStateImage"]; [archiver encodeString:[self keyEquivalent] withName:@"keyEquivalent"]; - [archiver encodeInt:[self state] withName:@"state"]; + if ([self respondsToSelector: @selector(state)]) + [archiver encodeInt:[self state] withName:@"state"]; [archiver encodeObject:[self target] withName:@"target"]; [archiver encodeSelector:[self action] withName:@"action"]; [archiver encodeInt:[self tag] withName:@"tag"]; [archiver encodeBOOL:[self isEnabled] withName:@"isEnabled"]; - [archiver encodeBOOL:[self changesState] withName:@"changesState"]; - [archiver encodeObject:[self submenu] withName:@"submenu"]; + if ([self respondsToSelector: @selector(changesState)]) + [archiver encodeBOOL:[self changesState] withName:@"changesState"]; + if ([self respondsToSelector: @selector(submenu)]) + [archiver encodeObject:[self submenu] withName:@"submenu"]; [archiver encodeConditionalObject:[self representedObject] withName:@"representedObject"]; } @@ -759,6 +766,18 @@ void __dummy_GMAppKit_functionForLinking() {} [self setRepresentedObject:[unarchiver decodeObjectWithName:@"representedObject"]]; +#ifdef GNU_GUI_LIBRARY + /* + * Set submenu from target if not set + */ + if ([NSStringFromSelector ([self action]) + isEqualToString: @"submenuAction:"]) + { + if ([self submenu] == nil) + [self setSubmenu: [self target]]; + } +#endif + #if 0 NSLog (@"menu item %@: target = %@, isEnabled = %d", [self title], [self target], [self isEnabled]); diff --git a/NEWS b/NEWS index afab5c9dc..bfefbf64d 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,74 @@ NEWS **** -The currently released version of the library is `0.6.0'. +The currently released version of the library is `0.6.5'. + +Noteworthy changes in version `0.6.5' +===================================== + + Many of the basic GUI classes have been vastly improved or +rewritten, thanks to Nicola Pero and many +others. + + * New Info Panel support + + * New NSBezierPath + + * Rewrite of several classes including Cell and Button classes. + + * Rewrite of NSBrowser, NSSavePanel, menus, text classes, + NSTableHeader. + + * RTF Parser + + * Implemented image caching. + + * Implemented editing in Forms, Matricies. + + * New autolayout classes GSHBox, GSTable, and GSVBox. + + * Almost all back-end classes have been removed and code incorporated + in a DPS-like graphics context structure. + + * Better keyboard handling. + + * NSHelpManager, NSComboBox, ProgressIndicator written. + + In addition a preliminary version of an Interface Builder (Gorm) has +been written, thanks to Richard Frith-Macdonald + Noteworthy changes in version `0.6.0' ===================================== + A Huge amount of progress, although a lot still needs to be done. +It's usable for a large base of moderately simple apps. Several +NeXT/OpenStep apps and libraries have been ported with little changes. + + * Drag and Drop support fleshed out but not completed. + + * NSText and related classes rewritten. Basic functionality but much + needs to be done to finish them off. + + * nib2gmodel app works with MacOS-X + + * Work done in minimizing the backend which allowed a lot of + functionality to move to the GNU library. + + * Menu code rewritten. + + * PopupButtons now work. + + * Many new images + + * Basic functionality for NSTabView + + * Much better lockFocus support in NSView. Flipped views handled. + + * Rewrite of NSSavePanel and NSOpenPanel + + * Several fixes that at least double the speed of the gui. + Noteworthy changes in version `0.5.5' ===================================== @@ -14,6 +77,7 @@ Noteworthy changes in version `0.5.5' * A lot of rewritting has been done to the classes, with general cleanup of coordinate conversion code, etc. + Noteworthy changes in version `0.5.0' ===================================== @@ -63,6 +127,7 @@ Noteworthy changes in version `0.5.0' * Several cleanups and as usual, many bug fixes. + Noteworthy changes in version `0.3.0' ===================================== @@ -94,6 +159,7 @@ Noteworthy changes in version `0.3.0' retain/release policy has been fixed, the cell classes correctly implement the NSCopying protocol and many others. + Noteworthy changes in version `0.2.0' ===================================== @@ -128,6 +194,7 @@ Noteworthy changes in version `0.2.0' * Many bug fixes and minor enhancements. + Noteworthy changes in version `0.1.1' ===================================== @@ -151,6 +218,7 @@ Noteworthy changes in version `0.1.1' * Now requires the TIFF library for reading, writing, and manipulating tiff files and images. + Noteworthy changes in version `0.1.0' ===================================== diff --git a/README b/README index 7733ca7bb..d8b3a0fad 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ README ****** -This is version 0.6.0 of the GNUstep GUI library (`gnustep-gui'). +This is version 0.6.5 of the GNUstep GUI library (`gnustep-gui'). Here is some introductory info to get you started: @@ -21,7 +21,3 @@ How can you help? * Give us feedback! Tell us what you like; tell us what you think could be better. Send bug reports to . -Creators rejoice! -Scott Christley - - diff --git a/Source/NSAffineTransform.m b/Source/NSAffineTransform.m index e12cc0c03..3599445e8 100644 --- a/Source/NSAffineTransform.m +++ b/Source/NSAffineTransform.m @@ -272,8 +272,9 @@ static NSAffineTransformStruct identityTransform = { - (NSBezierPath*) transformBezierPath: (NSBezierPath*)aPath { - [self notImplemented: _cmd]; - return nil; + NSBezierPath *path = [aPath copyWithZone: [aPath zone]]; + [path transformUsingAffineTransform: self]; + return path; } - (NSPoint) transformPoint: (NSPoint)point diff --git a/Source/NSApplication.m b/Source/NSApplication.m index 558164519..19ee43332 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -1146,7 +1146,7 @@ static NSCell* tileCell = nil; { if (theEvent == null_event) { - NSDebugLog(@"Not sending the Null Event\n"); + NSDebugLLog(@"NSEvent", @"Not sending the Null Event\n"); return; } @@ -1157,7 +1157,7 @@ static NSCell* tileCell = nil; case NSKeyDown: { - NSDebugLog(@"send key down event\n"); + NSDebugLLog(@"NSEvent", @"send key down event\n"); if ([theEvent modifierFlags] & NSCommandKeyMask) { NSArray *window_list = [self windows]; @@ -1179,7 +1179,7 @@ static NSCell* tileCell = nil; case NSKeyUp: { - NSDebugLog(@"send key up event\n"); + NSDebugLLog(@"NSEvent", @"send key up event\n"); [[theEvent window] sendEvent: theEvent]; break; } @@ -1189,16 +1189,16 @@ static NSCell* tileCell = nil; NSWindow *window = [theEvent window]; if (!theEvent) - NSDebugLog(@"NSEvent is nil!\n"); - NSDebugLog(@"NSEvent type: %d", [theEvent type]); - NSDebugLog(@"send event to window"); - NSDebugLog([window description]); + NSDebugLLog(@"NSEvent", @"NSEvent is nil!\n"); + NSDebugLLog(@"NSEvent", @"NSEvent type: %d", [theEvent type]); + NSDebugLLog(@"NSEvent", @"send event to window"); + NSDebugLLog(@"NSEvent", [window description]); if (window) [window sendEvent: theEvent]; else if ([theEvent type] == NSRightMouseDown) [self rightMouseDown: theEvent]; else - NSDebugLog(@"no window"); + NSDebugLLog(@"NSEvent", @"no window"); } } } @@ -1637,22 +1637,18 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException); @"OK", NULL, NULL); } -/* infoPanel, macosx API -- 'About' in the title */ +/* infoPanel, macosx API -- Deprecated */ - (void) orderFrontStandardAboutPanel: sender { - [self orderFrontStandardAboutPanel: sender]; + [self orderFrontStandardInfoPanel: sender]; } - (void) orderFrontStandardAboutPanelWithOptions: (NSDictionary *)options { - if (_infoPanel == nil) - _infoPanel = [[GSInfoPanel alloc] initWithDictionary: options]; - - [_infoPanel setTitle: @"About"]; - [_infoPanel orderFront: self]; + [self orderFrontStandardInfoPanelWithOptions: options]; } -/* infoPanel, GNUstep API -- 'Info' in the title */ +/* infoPanel, GNUstep API */ - (void) orderFrontStandardInfoPanel: sender { [self orderFrontStandardInfoPanelWithOptions: nil]; diff --git a/Source/NSBezierPath.m b/Source/NSBezierPath.m index c57b5c417..a2ef4d2be 100644 --- a/Source/NSBezierPath.m +++ b/Source/NSBezierPath.m @@ -58,7 +58,7 @@ void subdiv(int degree, float coeff[], float t, float bleft[], float bright[]); NSPoint rotatePoint(NSPoint p, NSPoint centre, float angle); -@interface PathElement : NSObject +@interface PathElement : NSObject { NSPoint p[3]; NSBezierPathElement type; @@ -140,6 +140,39 @@ NSPoint rotatePoint(NSPoint p, NSPoint centre, float angle); return AUTORELEASE(element); } +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + [super encodeWithCoder: aCoder]; + [aCoder encodeValueOfObjCType: @encode(NSBezierPathElement) at: &type]; + [aCoder encodeValueOfObjCType: @encode(NSPoint *) at: &p]; +} + +- (id)initWithCoder:(NSCoder *)aCoder +{ + self = [super initWithCoder: aCoder]; + [aCoder decodeValueOfObjCType: @encode(NSBezierPathElement) at: &type]; + [aCoder decodeValueOfObjCType: @encode(NSPoint *) at: &p]; + return self; +} + +- (id)copyWithZone:(NSZone *)zone +{ + PathElement *element = [[PathElement allocWithZone: zone] init]; + element->type = type; + if(type == NSMoveToBezierPathElement || type == NSLineToBezierPathElement) { + element->p[0].x = p[0].x; + element->p[0].y = p[0].y; + } else if(type == NSCurveToBezierPathElement) { + element->p[0].x = p[0].x; + element->p[0].y = p[0].y; + element->p[1].x = p[1].x; + element->p[1].y = p[1].y; + element->p[2].x = p[2].x; + element->p[2].y = p[2].y; + } + return AUTORELEASE(element); +} + - (void)setType:(NSBezierPathElement)t { type = t; @@ -491,7 +524,7 @@ static Class NSBezierPath_concrete_class = nil; // - (void)transformUsingAffineTransform:(NSAffineTransform *)transform { - + [self subclassResponsibility:_cmd]; } // @@ -636,23 +669,24 @@ static Class NSBezierPath_concrete_class = nil; // // NSCoding protocol // -- (void)encodeWithCoder:(NSCoder*)aCoder +- (void)encodeWithCoder:(NSCoder *)aCoder { - [super encodeWithCoder: aCoder]; + [self subclassResponsibility:_cmd]; } -- (id)initWithCoder:(NSCoder*)aCoder +- (id)initWithCoder:(NSCoder *)aCoder { - [super initWithCoder: aCoder]; + [self subclassResponsibility:_cmd]; return self; } // // NSCopying Protocol // -- (id)copyWithZone:(NSZone*)zone +- (id)copyWithZone:(NSZone *)zone { - return self; + [self subclassResponsibility:_cmd]; + return self; } @end @@ -686,6 +720,9 @@ static Class NSBezierPath_concrete_class = nil; if(self) { pathElements = [[NSMutableArray alloc] initWithCapacity: 1]; subPaths = [[NSMutableArray alloc] initWithCapacity: 1]; + [self setLineWidth: 1]; + [self setLineCapStyle: NSButtLineCapStyle]; + [self setLineJoinStyle: NSMiterLineJoinStyle]; [self setWindingRule: NSNonZeroWindingRule]; [self setBounds: NSZeroRect]; [self setControlPointBounds: NSZeroRect]; @@ -831,7 +868,6 @@ static Class NSBezierPath_concrete_class = nil; PathElement *elm; NSBezierPathElement t; NSPoint *pts, origin; - float r, g, b, w; int i; if(cachesBezierPath) { @@ -842,12 +878,10 @@ static Class NSBezierPath_concrete_class = nil; cacheimg = [[NSImage alloc] initWithSize: [self bounds].size]; [self movePathToPoint: NSMakePoint(0, 0)]; - PScurrentrgbcolor(&r, &g, &b); - PScurrentlinewidth(&w); - [cacheimg lockFocus]; - PSsetrgbcolor(r, g, b); - PSsetlinewidth(w); + PSsetlinewidth([self lineWidth]); + PSsetlinejoin([self lineJoinStyle]); + PSsetlinecap([self lineCapStyle]); for(i = 0; i < [pathElements count]; i++) { elm = [pathElements objectAtIndex: i]; pts = [elm points]; @@ -874,6 +908,9 @@ static Class NSBezierPath_concrete_class = nil; } [cacheimg compositeToPoint: origin operation: NSCompositeCopy]; } else { + PSsetlinewidth([self lineWidth]); + PSsetlinejoin([self lineJoinStyle]); + PSsetlinecap([self lineCapStyle]); for(i = 0; i < [pathElements count]; i++) { elm = [pathElements objectAtIndex: i]; pts = [elm points]; @@ -904,7 +941,6 @@ static Class NSBezierPath_concrete_class = nil; PathElement *elm; NSBezierPathElement t; NSPoint *pts, origin; - float r, g, b; int i; if(cachesBezierPath) { @@ -914,10 +950,8 @@ static Class NSBezierPath_concrete_class = nil; [cacheimg release]; cacheimg = [[NSImage alloc] initWithSize: [self bounds].size]; [self movePathToPoint: NSMakePoint(0, 0)]; - PScurrentrgbcolor(&r, &g, &b); [cacheimg lockFocus]; - PSsetrgbcolor(r, g, b); for(i = 0; i < [pathElements count]; i++) { elm = [pathElements objectAtIndex: i]; pts = [elm points]; @@ -985,6 +1019,36 @@ static Class NSBezierPath_concrete_class = nil; } +// +// Applying transformations. +// +- (void)transformUsingAffineTransform:(NSAffineTransform *)transform +{ + PathElement *elm; + NSBezierPathElement t; + NSPoint p, *pts; + int i; + + for(i = 0; i < [pathElements count]; i++) { + elm = [pathElements objectAtIndex: i]; + pts = [elm points]; + t = [elm type]; + if(t == NSCurveToBezierPathElement) { + p = [transform transformPoint: pts[0]]; + [elm setPointAtIndex: 0 toPoint: p]; + p = [transform transformPoint: pts[1]]; + [elm setPointAtIndex: 1 toPoint: p]; + p = [transform transformPoint: pts[2]]; + [elm setPointAtIndex: 2 toPoint: p]; + } else { + p = [transform transformPoint: pts[0]]; + [elm setPointAtIndex: 0 toPoint: p]; + } + } + + [self calculateDraftPolygon]; +} + // // Path info // @@ -1229,6 +1293,83 @@ static Class NSBezierPath_concrete_class = nil; [self calculateDraftPolygon]; } +// +// NSCoding protocol +// +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + float f; + int i; + NSRect r; + + [aCoder encodeValueOfObjCType: @encode(NSMutableArray) at: &pathElements]; + [aCoder encodeValueOfObjCType: @encode(NSMutableArray) at: &subPaths]; + r = [self bounds]; + [aCoder encodeValueOfObjCType: @encode(NSRect) at: &r]; + r = [self controlPointBounds]; + [aCoder encodeValueOfObjCType: @encode(NSRect) at: &r]; + f = [self lineWidth]; + [aCoder encodeValueOfObjCType: @encode(float) at: &f]; + i = [self lineCapStyle]; + [aCoder encodeValueOfObjCType: @encode(int) at: &i]; + i = [self lineJoinStyle]; + [aCoder encodeValueOfObjCType: @encode(int) at: &i]; + i = [self windingRule]; + [aCoder encodeValueOfObjCType: @encode(int) at: &i]; + [aCoder encodeValueOfObjCType: @encode(BOOL) at: &cachesBezierPath]; + [aCoder encodeValueOfObjCType: @encode(NSImage) at: &cacheimg]; +} + +- (id)initWithCoder:(NSCoder *)aCoder +{ + float f; + int i; + NSRect r; + + self = [super init]; + if(self) { + [aCoder decodeValueOfObjCType: @encode(NSMutableArray) at: &pathElements]; + [aCoder decodeValueOfObjCType: @encode(NSMutableArray) at: &subPaths]; + [aCoder decodeValueOfObjCType: @encode(NSRect) at: &r]; + [self setBounds: r]; + [aCoder decodeValueOfObjCType: @encode(NSRect) at: &r]; + [self setControlPointBounds: r]; + [aCoder decodeValueOfObjCType: @encode(float) at: &f]; + [self setLineWidth: f]; + [aCoder decodeValueOfObjCType: @encode(int) at: &i]; + [self setLineCapStyle: i]; + [aCoder decodeValueOfObjCType: @encode(int) at: &i]; + [self setLineJoinStyle: i]; + [aCoder decodeValueOfObjCType: @encode(int) at: &i]; + [self setWindingRule: i]; + [aCoder decodeValueOfObjCType: @encode(BOOL) at: &cachesBezierPath]; + [aCoder decodeValueOfObjCType: @encode(NSImage) at: &cacheimg]; + isValid = NO; + } + return self; +} + +// +// NSCopying Protocol +// +- (id)copyWithZone:(NSZone *)zone +{ + GSBezierPath *path = [[GSBezierPath allocWithZone: zone] init]; + + path->pathElements = [[pathElements copy] retain]; + path->subPaths = [[subPaths copy] retain]; + path->cachesBezierPath = cachesBezierPath; + if(cachesBezierPath && cacheimg) + path->cacheimg = [[cacheimg copy] retain]; + [path setLineWidth: [self lineWidth]]; + [path setLineCapStyle: [self lineCapStyle]]; + [path setLineJoinStyle: [self lineJoinStyle]]; + [path setWindingRule: [self windingRule]]; + [path setBounds: [self bounds]]; + [path setControlPointBounds: [self controlPointBounds]]; + + return path; +} // // Private Methods @@ -1238,7 +1379,7 @@ static Class NSBezierPath_concrete_class = nil; PathElement *elm; NSBezierPathElement bpt; NSPoint p, *pts; - double x, y, t, k = 0.025; + double x, y, t, k = 0.25; float maxx, minx, maxy, miny; float cpmaxx, cpminx, cpmaxy, cpminy; int i; diff --git a/Source/NSBrowser.m b/Source/NSBrowser.m index 33cf851f5..69c1476d0 100644 --- a/Source/NSBrowser.m +++ b/Source/NSBrowser.m @@ -47,6 +47,10 @@ #include #include +#ifndef HAVE_RINTF +#define rintf rint +#endif + #define NSBR_COLUMN_SEP 6 #define NSBR_VOFFSET 3 @@ -951,6 +955,7 @@ // load column 0 [self _performLoadOfColumn: 0]; + [self _adjustMatrixOfColumn: 0]; _isLoaded = YES; @@ -984,6 +989,7 @@ // Perform the data load [self _performLoadOfColumn: column]; + [self _adjustMatrixOfColumn: column]; // set last column loaded [self setLastColumn: column]; @@ -2592,7 +2598,6 @@ [matrix setDoubleAction: @selector(doDoubleClick:)]; // set new col matrix and release old - [[bc columnMatrix] release]; [bc setColumnMatrix: matrix]; [sc setDocumentView: matrix]; diff --git a/Source/NSButtonCell.m b/Source/NSButtonCell.m index 49b83cb4e..4842883b2 100644 --- a/Source/NSButtonCell.m +++ b/Source/NSButtonCell.m @@ -408,8 +408,10 @@ NSString *titleToDisplay; NSRect titleRect; NSSize imageSize = {0, 0}; + NSSize titleSize = {0, 0}; NSColor *backgroundColor = nil; BOOL flippedView = [controlView isFlipped]; + NSCellImagePosition ipos = _cell.image_position; // transparent buttons never draw if (_buttoncell_is_transparent) @@ -484,11 +486,29 @@ if (imageToDisplay) { - imageSize = [imageToDisplay size]; [imageToDisplay setBackgroundColor: backgroundColor]; + imageSize = [imageToDisplay size]; } - switch (_cell.image_position) + if (titleToDisplay && (ipos == NSImageAbove || ipos == NSImageBelow)) + { + titleSize = NSMakeSize([_cell_font widthOfString: titleToDisplay], + [_cell_font boundingRectForFont].size.height); + } + + if (flippedView == YES) + { + if (ipos == NSImageAbove) + { + ipos = NSImageBelow; + } + else if (ipos == NSImageBelow) + { + ipos = NSImageAbove; + } + } + + switch (ipos) { case NSNoImage: imageToDisplay = nil; @@ -541,44 +561,56 @@ break; case NSImageAbove: - imageRect.origin.x = cellFrame.origin.x; - imageRect.size.width = cellFrame.size.width; - imageRect.size.height = imageSize.height; + /* In this case, imageRect is all the space we can allocate above the text. + The drawing code below will then center the image in imageRect. */ titleRect.origin.x = cellFrame.origin.x; + titleRect.origin.y = cellFrame.origin.y; titleRect.size.width = cellFrame.size.width; - titleRect.size.height = cellFrame.size.height - imageSize.height - - yDist; - // TODO: Add distance from border if needed - if (flippedView) + titleRect.size.height = titleSize.height; + + imageRect.origin.x = cellFrame.origin.x; + imageRect.origin.y = cellFrame.origin.y; + imageRect.origin.y += titleRect.size.height + yDist; + imageRect.size.width = cellFrame.size.width; + imageRect.size.height = cellFrame.size.height; + imageRect.size.height -= titleSize.height + yDist; + + if (_cell.is_bordered || _cell.is_bezeled) { - imageRect.origin.y = NSMinY(cellFrame); - titleRect.origin.y = NSMaxY(cellFrame) - titleRect.size.height; - } - else - { - imageRect.origin.y = NSMaxY(cellFrame) - imageRect.size.height; - titleRect.origin.y = NSMinY(cellFrame); + imageRect.size.width -= 6; + imageRect.origin.x += 3; + titleRect.size.width -= 6; + titleRect.origin.x += 3; + imageRect.size.height -= 1; + titleRect.size.height -= 1; + titleRect.origin.y += 1; } break; case NSImageBelow: - imageRect.origin.x = cellFrame.origin.x; - imageRect.size.width = cellFrame.size.width; - imageRect.size.height = imageSize.height; + /* In this case, imageRect is all the space we can allocate below the text. + The drawing code below will then center the image in imageRect. */ titleRect.origin.x = cellFrame.origin.x; + titleRect.origin.y = cellFrame.origin.y + cellFrame.size.height; + titleRect.origin.y -= titleSize.height; titleRect.size.width = cellFrame.size.width; - titleRect.size.height = cellFrame.size.height - imageSize.height - - yDist; - // TODO: Add distance from border if needed - if (flippedView) + titleRect.size.height = titleSize.height; + + imageRect.origin.x = cellFrame.origin.x; + imageRect.origin.y = cellFrame.origin.y; + imageRect.size.width = cellFrame.size.width; + imageRect.size.height = cellFrame.size.height; + imageRect.size.height -= titleSize.height + yDist; + + if (_cell.is_bordered || _cell.is_bezeled) { - imageRect.origin.y = NSMaxY(cellFrame) - imageRect.size.height; - titleRect.origin.y = NSMinY(cellFrame); - } - else - { - imageRect.origin.y = NSMinY(cellFrame); - titleRect.origin.y = NSMaxY(cellFrame) - titleRect.size.height; + imageRect.size.width -= 6; + imageRect.origin.x += 3; + titleRect.size.width -= 6; + titleRect.origin.x += 3; + imageRect.size.height -= 1; + imageRect.origin.y += 1; + titleRect.size.height -= 1; } break; @@ -683,7 +715,7 @@ case NSImageBelow: case NSImageAbove: if (imageSize.width > titleSize.width) - s.height = imageSize.width; + s.width = imageSize.width; else s.width = titleSize.width; s.height = imageSize.height + titleSize.height; // + yDist ?? @@ -720,7 +752,7 @@ // Add border size s.width += 2 * borderSize.width; s.height += 2 * borderSize.height; - + return s; } diff --git a/Source/NSCell.m b/Source/NSCell.m index 7dd5339b0..ae2734713 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -346,8 +346,18 @@ static NSColor *shadowCol; */ - (void) setState: (int)value { - // FIXME - _cell.state = value; + /* We do exactly as in macosx when value is not NSOnState, + * NSOffState, NSMixedState, even if their behaviour (value < 0 ==> + * NSMixedState) is a bit strange. We could decide to do + * differently in the future, so please use always symbolic + * constants when calling this method, this way your code won't be + * broken by changes. */ + if (value > 0) + _cell.state = NSOnState; + else if (value == 0 || (_cell.allows_mixed_state == NO)) + _cell.state = NSOffState; + else + _cell.state = NSMixedState; } - (int) state diff --git a/Source/NSGraphicsContext.m b/Source/NSGraphicsContext.m index 50ed68586..c4d1711c8 100644 --- a/Source/NSGraphicsContext.m +++ b/Source/NSGraphicsContext.m @@ -129,7 +129,7 @@ NSGraphicsContext *GSCurrentContext() */ NSThread *th = GSCurrentThread(); - th->_gcontext = context; + ASSIGN(th->_gcontext, context); #else NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; diff --git a/Source/NSLayoutManager.m b/Source/NSLayoutManager.m index cb091ac56..b4a37654f 100644 --- a/Source/NSLayoutManager.m +++ b/Source/NSLayoutManager.m @@ -29,6 +29,24 @@ */ #include +/* + * A little utility function to determine the range of characters in a scanner + * that are present in a specified character set. + */ +static inline NSRange +scanRange(NSScanner *scanner, NSCharacterSet* aSet) +{ + unsigned start = [scanner scanLocation]; + unsigned end = start; + + if ([scanner scanCharactersFromSet: aSet intoString: 0] == YES) + { + end = [scanner scanLocation]; + } + return NSMakeRange(start, end - start); +} + + // _GSRunSearchKey is an internal class which serves as the foundation for // all our searching. This may not be an elegant way to go about this, so // if someone wants to optimize this out, please do. @@ -41,7 +59,7 @@ @end @implementation _GSRunSearchKey -- (id)init +- (id) init { return [super init]; } @@ -60,7 +78,7 @@ @end @implementation GSGlyphLocation -- (id)init +- (id) init { return [super init]; } @@ -80,7 +98,7 @@ @end @implementation GSLineLayoutInfo -- (id)init +- (id) init { return [super init]; } @@ -94,13 +112,13 @@ @interface GSTextContainerLayoutInfo : _GSRunSearchKey { @public - NSTextContainer *textContainer; - NSString *testString; + NSTextContainer *textContainer; + NSString *testString; } @end @implementation GSTextContainerLayoutInfo -- (id)init +- (id) init { return [super init]; } @@ -120,11 +138,11 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) { - if (((_GSRunSearchKey *)(i0.obj))->glyphRange.location - < ((_GSRunSearchKey *)(i1.obj))->glyphRange.location) + if (((_GSRunSearchKey*)(i0.obj))->glyphRange.location + < ((_GSRunSearchKey*)(i1.obj))->glyphRange.location) return NSOrderedAscending; - else if (((_GSRunSearchKey *)(i0.obj))->glyphRange.location - >= NSMaxRange(((_GSRunSearchKey *)(i1.obj))->glyphRange)) + else if (((_GSRunSearchKey*)(i0.obj))->glyphRange.location + >= NSMaxRange(((_GSRunSearchKey*)(i1.obj))->glyphRange)) return NSOrderedDescending; else return NSOrderedSame; @@ -135,17 +153,17 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) unsigned int _count; void *_runs; } -- (void)insertObject:(id)anObject; -- (void)insertObject:(id)anObject atIndex:(unsigned)theIndex; -- (id)objectAtIndex:(unsigned)theIndex; -- (unsigned)indexOfObject:(id)anObject; -- (unsigned)indexOfObjectContainingLocation:(unsigned)aLocation; -- (id)objectContainingLocation:(unsigned)aLocation; -- (int)count; +- (void) insertObject: (id)anObject; +- (void) insertObject: (id)anObject atIndex: (unsigned)theIndex; +- (id) objectAtIndex: (unsigned)theIndex; +- (unsigned) indexOfObject: (id)anObject; +- (unsigned) indexOfObjectContainingLocation: (unsigned)aLocation; +- (id) objectContainingLocation: (unsigned)aLocation; +- (int) count; @end @implementation GSRunStorage -- (id)init +- (id) init { NSZone *z; @@ -159,10 +177,10 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) return self; } -- (void)insertObject:(id)anObject +- (void) insertObject: (id)anObject { _GSRunSearchKey *aKey = [_GSRunSearchKey new]; - _GSRunSearchKey *aObject = (_GSRunSearchKey *)anObject; + _GSRunSearchKey *aObject = (_GSRunSearchKey*)anObject; int position; aKey->glyphRange.location = aObject->glyphRange.location; @@ -193,7 +211,7 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) // NSLog(@"=========> first item (zero index)."); GSIArrayInsertItem(_runs, (GSIArrayItem)anObject, position); // GSIArrayInsertSorted(_runs, (GSIArrayItem)anObject, aSort); -// [self insertObject:anObject atIndex:position]; +// [self insertObject: anObject atIndex: position]; } else NSLog(@"dead. VERY DEAD DEAD DEAD DEAD."); @@ -201,31 +219,31 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) // NSLog(@"==> %d item(s)", GSIArrayCount(_runs)); } -- (void)insertObject:(id)anObject - atIndex:(unsigned)theIndex +- (void) insertObject: (id)anObject + atIndex: (unsigned)theIndex { - NSLog(@"insertObject:atIndex: called. %d item(s)", GSIArrayCount(_runs)); + NSLog(@"insertObject: atIndex: called. %d item(s)", GSIArrayCount(_runs)); GSIArrayInsertSorted(_runs, (GSIArrayItem)anObject, aSort); // GSIArrayInsertItem(_runs, (GSIArrayItem)anObject, theIndex); - NSLog(@"insertObject:atIndex: ended. %d item(s)", GSIArrayCount(_runs)); + NSLog(@"insertObject: atIndex: ended. %d item(s)", GSIArrayCount(_runs)); } -- (void)removeObjectAtIndex:(int)theIndex +- (void) removeObjectAtIndex: (int)theIndex { GSIArrayRemoveItemAtIndex(_runs, theIndex); } -- (id)objectAtIndex:(unsigned)theIndex +- (id) objectAtIndex: (unsigned)theIndex { return GSIArrayItemAtIndex(_runs, (unsigned)theIndex).obj; } -- (unsigned)indexOfObject:(id)anObject +- (unsigned) indexOfObject: (id)anObject { return NSNotFound; } -- (unsigned)indexOfObjectContainingLocation:(unsigned)aLocation +- (unsigned) indexOfObjectContainingLocation: (unsigned)aLocation { _GSRunSearchKey *aKey = [_GSRunSearchKey new]; int position; @@ -247,7 +265,7 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) return -1; } -- (id)objectContainingLocation:(unsigned)aLocation +- (id) objectContainingLocation: (unsigned)aLocation { _GSRunSearchKey *aKey = [_GSRunSearchKey new]; int position; @@ -269,12 +287,12 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) return nil; } -- (id)lastObject +- (id) lastObject { return GSIArrayItemAtIndex(_runs, GSIArrayCount(_runs) - 1).obj; } -- (int)count +- (int) count { return GSIArrayCount(_runs); } @@ -300,17 +318,17 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) // // Setting the text storage // -- (void)setTextStorage: (NSTextStorage *)aTextStorage +- (void) setTextStorage: (NSTextStorage*)aTextStorage { ASSIGN(_textStorage, aTextStorage); } -- (NSTextStorage *)textStorage +- (NSTextStorage*) textStorage { return _textStorage; } -- (void)replaceTextStorage: (NSTextStorage *)newTextStorage +- (void) replaceTextStorage: (NSTextStorage*)newTextStorage { NSArray *layoutManagers = [_textStorage layoutManagers]; NSEnumerator *enumerator = [layoutManagers objectEnumerator]; @@ -320,7 +338,7 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) // new one. NSTextStorage's addLayoutManager invokes NSLayoutManager's // setTextStorage method automatically, and that includes self. - while( (object = (NSLayoutManager *)[enumerator nextObject]) ) + while( (object = (NSLayoutManager*)[enumerator nextObject]) ) { [_textStorage removeLayoutManager: object]; [newTextStorage addLayoutManager: object]; @@ -330,27 +348,27 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) // // Setting text containers // -- (NSArray *)textContainers +- (NSArray*) textContainers { return _textContainers; } -- (void)addTextContainer: (NSTextContainer *)obj +- (void) addTextContainer: (NSTextContainer*)obj { - if( [_textContainers indexOfObjectIdenticalTo: obj] == NSNotFound ) + if ( [_textContainers indexOfObjectIdenticalTo: obj] == NSNotFound ) { [_textContainers addObject: obj]; [obj setLayoutManager: self]; } } -- (void)insertTextContainer: (NSTextContainer *)aTextContainer - atIndex: (unsigned)index +- (void) insertTextContainer: (NSTextContainer*)aTextContainer + atIndex: (unsigned)index { [_textContainers insertObject: aTextContainer atIndex: index]; } -- (void)removeTextContainerAtIndex: (unsigned)index +- (void) removeTextContainerAtIndex: (unsigned)index { [_textContainers removeObjectAtIndex: index]; } @@ -358,39 +376,39 @@ static NSComparisonResult aSort(GSIArrayItem i0, GSIArrayItem i1) // // Invalidating glyphs and layout // -- (void)invalidateGlyphsForCharacterRange: (NSRange)aRange - changeInLength: (int)lengthChange - actualCharacterRange: (NSRange *)actualRange +- (void) invalidateGlyphsForCharacterRange: (NSRange)aRange + changeInLength: (int)lengthChange + actualCharacterRange: (NSRange*)actualRange { } -- (void)invalidateLayoutForCharacterRange: (NSRange)aRange - isSoft: (BOOL)flag - actualCharacterRange: (NSRange *)actualRange +- (void) invalidateLayoutForCharacterRange: (NSRange)aRange + isSoft: (BOOL)flag + actualCharacterRange: (NSRange*)actualRange { } -- (void)invalidateDisplayForCharacterRange: (NSRange)aRange +- (void) invalidateDisplayForCharacterRange: (NSRange)aRange { } -- (void)invalidateDisplayForGlyphRange: (NSRange)aRange +- (void) invalidateDisplayForGlyphRange: (NSRange)aRange { } -- (void)textContainerChangedGeometry: (NSTextContainer *)aContainer +- (void) textContainerChangedGeometry: (NSTextContainer*)aContainer { } -- (void)textContainerChangedTextView: (NSTextContainer *)aContainer +- (void) textContainerChangedTextView: (NSTextContainer*)aContainer { } -- (void)textStorage: (NSTextStorage *)aTextStorage - edited: (unsigned)mask - range: (NSRange)range - changeInLength: (int)lengthChange - invalidatedRange: (NSRange)invalidatedRange +- (void) textStorage: (NSTextStorage*)aTextStorage + edited: (unsigned)mask + range: (NSRange)range + changeInLength: (int)lengthChange + invalidatedRange: (NSRange)invalidatedRange { NSLog(@"NSLayoutManager was just notified that a change in the text storage occured."); @@ -402,7 +420,7 @@ invalidatedRange.length); if (mask == NSTextStorageEditedCharacters) { aLayoutHole = [[NSLayoutHole alloc] -initWithCharacterRange:invalidatedRange isSoft:NO]; +initWithCharacterRange: invalidatedRange isSoft: NO]; } else if (mask == NSTextStorageEditedAttributes) { @@ -420,12 +438,12 @@ initWithCharacterRange:invalidatedRange isSoft:NO]; // Turning on/off background layout // -- (void)setBackgroundLayoutEnabled: (BOOL)flag +- (void) setBackgroundLayoutEnabled: (BOOL)flag { _backgroundLayout = flag; } -- (BOOL)backgroundLayoutEnabled +- (BOOL) backgroundLayoutEnabled { return _backgroundLayout; } @@ -433,40 +451,40 @@ initWithCharacterRange:invalidatedRange isSoft:NO]; // // Accessing glyphs // -- (void)insertGlyph: (NSGlyph)aGlyph - atGlyphIndex: (unsigned)glyphIndex - characterIndex: (unsigned)charIndex +- (void) insertGlyph: (NSGlyph)aGlyph + atGlyphIndex: (unsigned)glyphIndex + characterIndex: (unsigned)charIndex { } -- (NSGlyph)glyphAtIndex: (unsigned)index +- (NSGlyph) glyphAtIndex: (unsigned)index { return NSNullGlyph; } -- (NSGlyph)glyphAtIndex: (unsigned)index - isValidIndex: (BOOL *)flag +- (NSGlyph) glyphAtIndex: (unsigned)index + isValidIndex: (BOOL*)flag { *flag = NO; return NSNullGlyph; } -- (void)replaceGlyphAtIndex: (unsigned)index - withGlyph: (NSGlyph)newGlyph +- (void) replaceGlyphAtIndex: (unsigned)index + withGlyph: (NSGlyph)newGlyph { } -- (unsigned)getGlyphs: (NSGlyph *)glyphArray - range: (NSRange)glyphRange +- (unsigned) getGlyphs: (NSGlyph*)glyphArray + range: (NSRange)glyphRange { return (unsigned)0; } -- (void)deleteGlyphsInRange: (NSRange)aRange +- (void) deleteGlyphsInRange: (NSRange)aRange { } -- (unsigned)numberOfGlyphs +- (unsigned) numberOfGlyphs { return 0; } @@ -474,24 +492,24 @@ initWithCharacterRange:invalidatedRange isSoft:NO]; // // Mapping characters to glyphs // -- (void)setCharacterIndex: (unsigned)charIndex - forGlyphAtIndex: (unsigned)glyphIndex +- (void) setCharacterIndex: (unsigned)charIndex + forGlyphAtIndex: (unsigned)glyphIndex { } -- (unsigned)characterIndexForGlyphAtIndex: (unsigned)glyphIndex +- (unsigned) characterIndexForGlyphAtIndex: (unsigned)glyphIndex { return 0; } -- (NSRange)characterRangeForGlyphRange: (NSRange)glyphRange - actualGlyphRange: (NSRange *)actualGlyphRange +- (NSRange) characterRangeForGlyphRange: (NSRange)glyphRange + actualGlyphRange: (NSRange*)actualGlyphRange { return NSMakeRange(0, 0); } -- (NSRange)glyphRangeForCharacterRange: (NSRange)charRange - actualCharacterRange: (NSRange *)actualCharRange +- (NSRange) glyphRangeForCharacterRange: (NSRange)charRange + actualCharacterRange: (NSRange*)actualCharRange { return NSMakeRange(0, 0); } @@ -502,14 +520,14 @@ initWithCharacterRange:invalidatedRange isSoft:NO]; // Each NSGlyph has an attribute field, yes? -- (void)setIntAttribute: (int)attribute - value: (int)anInt - forGlyphAtIndex: (unsigned)glyphIndex +- (void) setIntAttribute: (int)attribute + value: (int)anInt + forGlyphAtIndex: (unsigned)glyphIndex { } -- (int)intAttribute: (int)attribute - forGlyphAtIndex: (unsigned)glyphIndex +- (int) intAttribute: (int)attribute + forGlyphAtIndex: (unsigned)glyphIndex { return 0; } @@ -517,18 +535,18 @@ initWithCharacterRange:invalidatedRange isSoft:NO]; // // Handling layout for text containers // -- (void)setTextContainer: (NSTextContainer *)aTextContainer - forGlyphRange: (NSRange)glyphRange +- (void) setTextContainer: (NSTextContainer*)aTextContainer + forGlyphRange: (NSRange)glyphRange { - GSTextContainerLayoutInfo *theLine = [GSTextContainerLayoutInfo new]; + GSTextContainerLayoutInfo *theLine = [GSTextContainerLayoutInfo new]; theLine->glyphRange = glyphRange; ASSIGN(theLine->textContainer, aTextContainer); - [containerRuns insertObject:theLine]; + [containerRuns insertObject: theLine]; } -- (NSRange)glyphRangeForTextContainer: (NSTextContainer *)aTextContainer +- (NSRange) glyphRangeForTextContainer: (NSTextContainer*)aTextContainer { int i; @@ -537,7 +555,7 @@ textContainer(s) in containerRuns.", [containerRuns count]); for (i=0;i<[containerRuns count];i++) { - GSTextContainerLayoutInfo *aNewLine = [containerRuns objectAtIndex:i]; + GSTextContainerLayoutInfo *aNewLine = [containerRuns objectAtIndex: i]; /* NSLog(@"glyphRangeForTextContainer: (%d, %d)", @@ -545,7 +563,7 @@ aNewLine->glyphRange.location, aNewLine->glyphRange.length); */ - if ([aNewLine->textContainer isEqual:aTextContainer]) + if ([aNewLine->textContainer isEqual: aTextContainer]) { /* NSLog(@"glyphRangeForWantedTextContainer: (%d, %d)", @@ -559,27 +577,28 @@ aNewLine->glyphRange.length); return NSMakeRange(NSNotFound, 0); } -- (NSTextContainer *)textContainerForGlyphAtIndex: (unsigned)glyphIndex - effectiveRange: (NSRange *)effectiveRange +- (NSTextContainer*) textContainerForGlyphAtIndex: (unsigned)glyphIndex + effectiveRange: (NSRange*)effectiveRange { - GSTextContainerLayoutInfo *theLine = [containerRuns objectContainingLocation:glyphIndex]; + GSTextContainerLayoutInfo *theLine; - if(theLine) + theLine = [containerRuns objectContainingLocation: glyphIndex]; + if (theLine) { - (NSRange *)effectiveRange = &theLine->glyphRange; + (NSRange*)effectiveRange = &theLine->glyphRange; return theLine->textContainer; } - (NSRange *)effectiveRange = NULL; + (NSRange*)effectiveRange = NULL; return nil; } // // Handling line fragment rectangles // -- (void)setLineFragmentRect: (NSRect)fragmentRect - forGlyphRange: (NSRange)glyphRange - usedRect: (NSRect)usedRect +- (void) setLineFragmentRect: (NSRect)fragmentRect + forGlyphRange: (NSRange)glyphRange + usedRect: (NSRect)usedRect { GSLineLayoutInfo *aNewLine = [GSLineLayoutInfo new]; @@ -587,66 +606,68 @@ aNewLine->glyphRange.length); aNewLine->lineFragmentRect = fragmentRect; aNewLine->usedRect = usedRect; - [fragmentRuns insertObject:aNewLine]; + [fragmentRuns insertObject: aNewLine]; } -- (NSRect)lineFragmentRectForGlyphAtIndex: (unsigned)glyphIndex - effectiveRange: (NSRange *)lineFragmentRange +- (NSRect) lineFragmentRectForGlyphAtIndex: (unsigned)glyphIndex + effectiveRange: (NSRange*)lineFragmentRange { - GSLineLayoutInfo *theLine = [fragmentRuns objectContainingLocation:glyphIndex]; + GSLineLayoutInfo *theLine; + theLine = [fragmentRuns objectContainingLocation: glyphIndex]; if (theLine) { - (NSRange *)lineFragmentRange = &theLine->glyphRange; + (NSRange*)lineFragmentRange = &theLine->glyphRange; return theLine->lineFragmentRect; } - (NSRange *)lineFragmentRange = NULL; + (NSRange*)lineFragmentRange = NULL; return NSZeroRect; } -- (NSRect)lineFragmentUsedRectForGlyphAtIndex: (unsigned)glyphIndex - effectiveRange: (NSRange *)lineFragmentRange +- (NSRect) lineFragmentUsedRectForGlyphAtIndex: (unsigned)glyphIndex + effectiveRange: (NSRange*)lineFragmentRange { - GSLineLayoutInfo *theLine = [fragmentRuns objectContainingLocation:glyphIndex]; + GSLineLayoutInfo *theLine; + theLine = [fragmentRuns objectContainingLocation: glyphIndex]; if (theLine) { - (NSRange *)lineFragmentRange = &theLine->glyphRange; + (NSRange*)lineFragmentRange = &theLine->glyphRange; return theLine->usedRect; } - (NSRange *)lineFragmentRange = NULL; + (NSRange*)lineFragmentRange = NULL; return NSZeroRect; } -- (void)setExtraLineFragmentRect: (NSRect)aRect - usedRect: (NSRect)usedRect - textContainer: (NSTextContainer *)aTextContainer +- (void) setExtraLineFragmentRect: (NSRect)aRect + usedRect: (NSRect)usedRect + textContainer: (NSTextContainer*)aTextContainer { } -- (NSRect)extraLineFragmentRect +- (NSRect) extraLineFragmentRect { return NSZeroRect; } -- (NSRect)extraLineFragmentUsedRect +- (NSRect) extraLineFragmentUsedRect { return NSZeroRect; } -- (NSTextContainer *)extraLineFragmentTextContainer +- (NSTextContainer*) extraLineFragmentTextContainer { return nil; } -- (void)setDrawsOutsideLineFragment: (BOOL)flag - forGlyphAtIndex: (unsigned)glyphIndex +- (void) setDrawsOutsideLineFragment: (BOOL)flag + forGlyphAtIndex: (unsigned)glyphIndex { } -- (BOOL)drawsOutsideLineFragmentForGlyphAtIndex: (unsigned)glyphIndex +- (BOOL) drawsOutsideLineFragmentForGlyphAtIndex: (unsigned)glyphIndex { return NO; } @@ -655,25 +676,27 @@ aNewLine->glyphRange.length); // Layout of glyphs // -- (void)setLocation: (NSPoint)aPoint - forStartOfGlyphRange: (NSRange)glyphRange +- (void) setLocation: (NSPoint)aPoint +forStartOfGlyphRange: (NSRange)glyphRange { GSGlyphLocation *aNewLine = [GSGlyphLocation new]; aNewLine->glyphRange = glyphRange; aNewLine->point = aPoint; - [locationRuns insertObject:aNewLine]; + [locationRuns insertObject: aNewLine]; } -- (NSPoint)locationForGlyphAtIndex: (unsigned)glyphIndex +- (NSPoint) locationForGlyphAtIndex: (unsigned)glyphIndex { return NSZeroPoint; } -- (NSRange)rangeOfNominallySpacedGlyphsContainingIndex: (unsigned)glyphIndex +- (NSRange) rangeOfNominallySpacedGlyphsContainingIndex: (unsigned)glyphIndex { - GSLineLayoutInfo *theLine = [locationRuns objectContainingLocation:glyphIndex]; + GSLineLayoutInfo *theLine; + + theLine = [locationRuns objectContainingLocation: glyphIndex]; if (theLine) { @@ -683,10 +706,10 @@ aNewLine->glyphRange.length); return NSMakeRange(NSNotFound, 0); } -- (NSRect *)rectArrayForCharacterRange: (NSRange)charRange +- (NSRect*) rectArrayForCharacterRange: (NSRange)charRange withinSelectedCharacterRange: (NSRange)selChareRange - inTextContainer: (NSTextContainer *)aTextContainer - rectCount: (unsigned *)rectCount + inTextContainer: (NSTextContainer*)aTextContainer + rectCount: (unsigned*)rectCount { /* GSLineLayoutInfo *theLine = [GSLineLayoutInfo new]; @@ -727,16 +750,16 @@ aNewLine->glyphRange.length); */ } -- (NSRect *)rectArrayForGlyphRange: (NSRange)glyphRange +- (NSRect*) rectArrayForGlyphRange: (NSRange)glyphRange withinSelectedGlyphRange: (NSRange)selectedGlyphRange - inTextContainer: (NSTextContainer *)aTextContainer - rectCount: (unsigned *)rectCount + inTextContainer: (NSTextContainer*)aTextContainer + rectCount: (unsigned*)rectCount { return _cachedRectArray; } -- (NSRect)boundingRectForGlyphRange: (NSRange)glyphRange - inTextContainer: (NSTextContainer *)aTextContainer +- (NSRect) boundingRectForGlyphRange: (NSRange)glyphRange + inTextContainer: (NSTextContainer*)aTextContainer { /* Returns a single bounding rectangle enclosing all glyphs and other @@ -746,7 +769,7 @@ underlining. This method is useful for determining the area that needs to be redrawn when a range of glyphs changes. */ /* unsigned rectCount; - NSRect *rects = [self rectArrayForCharacterRange: [self glyphRangeForTextContainer:aTextContainer] + NSRect *rects = [self rectArrayForCharacterRange: [self glyphRangeForTextContainer: aTextContainer] withinSelectedCharacterRange: NSMakeRange(0,0) inTextContainer: aTextContainer rectCount: &rectCount]; @@ -770,21 +793,21 @@ be redrawn when a range of glyphs changes. */ return NSZeroRect; } -- (NSRange)glyphRangeForBoundingRect: (NSRect)aRect - inTextContainer: (NSTextContainer *)aTextContainer +- (NSRange) glyphRangeForBoundingRect: (NSRect)aRect + inTextContainer: (NSTextContainer*)aTextContainer { return NSMakeRange(0, 0); } -- (NSRange)glyphRangeForBoundingRectWithoutAdditionalLayout: (NSRect)bounds - inTextContainer: (NSTextContainer *)aTextContainer +- (NSRange) glyphRangeForBoundingRectWithoutAdditionalLayout: (NSRect)bounds + inTextContainer: (NSTextContainer*)aTextContainer { return NSMakeRange(0, 0); } -- (unsigned)glyphIndexForPoint: (NSPoint)aPoint - inTextContainer: (NSTextContainer *)aTextContainer -fractionOfDistanceThroughGlyph: (float *)partialFraction +- (unsigned) glyphIndexForPoint: (NSPoint)aPoint + inTextContainer: (NSTextContainer*)aTextContainer + fractionOfDistanceThroughGlyph: (float*)partialFraction { return 0; } @@ -792,32 +815,32 @@ fractionOfDistanceThroughGlyph: (float *)partialFraction // // Display of special glyphs // -- (void)setNotShownAttribute: (BOOL)flag - forGlyphAtIndex: (unsigned)glyphIndex +- (void) setNotShownAttribute: (BOOL)flag + forGlyphAtIndex: (unsigned)glyphIndex { } -- (BOOL)notShownAttributeForGlyphAtIndex: (unsigned)glyphIndex +- (BOOL) notShownAttributeForGlyphAtIndex: (unsigned)glyphIndex { return YES; } -- (void)setShowsInvisibleCharacters: (BOOL)flag +- (void) setShowsInvisibleCharacters: (BOOL)flag { _showsInvisibleChars = flag; } -- (BOOL)showsInvisibleCharacters +- (BOOL) showsInvisibleCharacters { return _showsInvisibleChars; } -- (void)setShowsControlCharacters: (BOOL)flag +- (void) setShowsControlCharacters: (BOOL)flag { _showsControlChars = flag; } -- (BOOL)showsControlCharacters +- (BOOL) showsControlCharacters { return _showsControlChars; } @@ -825,12 +848,12 @@ fractionOfDistanceThroughGlyph: (float *)partialFraction // // Controlling hyphenation // -- (void)setHyphenationFactor: (float)factor +- (void) setHyphenationFactor: (float)factor { _hyphenationFactor = factor; } -- (float)hyphenationFactor +- (float) hyphenationFactor { return _hyphenationFactor; } @@ -838,12 +861,12 @@ fractionOfDistanceThroughGlyph: (float *)partialFraction // // Finding unlaid characters/glyphs // -- (void)getFirstUnlaidCharacterIndex: (unsigned *)charIndex - glyphIndex: (unsigned *)glyphIndex +- (void) getFirstUnlaidCharacterIndex: (unsigned*)charIndex + glyphIndex: (unsigned*)glyphIndex { } -- (unsigned int)firstUnlaidCharacterIndex +- (unsigned int) firstUnlaidCharacterIndex { return 0; } @@ -851,17 +874,17 @@ fractionOfDistanceThroughGlyph: (float *)partialFraction // // Using screen fonts // -- (void)setUsesScreenFonts: (BOOL)flag +- (void) setUsesScreenFonts: (BOOL)flag { _usesScreenFonts = flag; } -- (BOOL)usesScreenFonts +- (BOOL) usesScreenFonts { return _usesScreenFonts; } -- (NSFont *)substituteFontForFont: (NSFont *)originalFont +- (NSFont*) substituteFontForFont: (NSFont*)originalFont { return originalFont; } @@ -869,17 +892,17 @@ fractionOfDistanceThroughGlyph: (float *)partialFraction // // Handling rulers // -- (NSView *)rulerAccessoryViewForTextView: (NSTextView *)aTextView - paragraphStyle: (NSParagraphStyle *)paragraphStyle - ruler: (NSRulerView *)aRulerView +- (NSView*) rulerAccessoryViewForTextView: (NSTextView*)aTextView + paragraphStyle: (NSParagraphStyle*)paragraphStyle + ruler: (NSRulerView*)aRulerView enabled: (BOOL)flag { return NULL; } -- (NSArray *)rulerMarkersForTextView: (NSTextView *)aTextView - paragraphStyle: (NSParagraphStyle *)paragraphStyle - ruler: (NSRulerView *)aRulerView +- (NSArray*) rulerMarkersForTextView: (NSTextView*)aTextView + paragraphStyle: (NSParagraphStyle*)paragraphStyle + ruler: (NSRulerView*)aRulerView { return NULL; } @@ -887,17 +910,17 @@ fractionOfDistanceThroughGlyph: (float *)partialFraction // // Managing the responder chain // -- (BOOL)layoutManagerOwnsFirstResponderInWindow: (NSWindow *)aWindow +- (BOOL) layoutManagerOwnsFirstResponderInWindow: (NSWindow*)aWindow { return NO; } -- (NSTextView *)firstTextView +- (NSTextView*) firstTextView { return NULL; } -- (NSTextView *)textViewForBeginningOfSelection +- (NSTextView*) textViewForBeginningOfSelection { return NULL; } @@ -905,19 +928,19 @@ fractionOfDistanceThroughGlyph: (float *)partialFraction // // Drawing // -- (void)drawBackgroundForGlyphRange: (NSRange)glyphRange - atPoint: (NSPoint)containerOrigin +- (void) drawBackgroundForGlyphRange: (NSRange)glyphRange + atPoint: (NSPoint)containerOrigin { } -- (void)drawGlyphsForGlyphRange: (NSRange)glyphRange - atPoint: (NSPoint)containerOrigin +- (void) drawGlyphsForGlyphRange: (NSRange)glyphRange + atPoint: (NSPoint)containerOrigin { int firstPosition, lastPosition, i; for (i=0;i<[fragmentRuns count];i++) { - GSLineLayoutInfo *info = [fragmentRuns objectAtIndex:i]; + GSLineLayoutInfo *info = [fragmentRuns objectAtIndex: i]; /* NSLog(@"i: %d glyphRange: (%d, %d) lineFragmentRect: (%f, %f) (%f, %f)", @@ -931,9 +954,9 @@ info->lineFragmentRect.size.height); */ } - firstPosition = [fragmentRuns indexOfObjectContainingLocation:glyphRange.location]; + firstPosition = [fragmentRuns indexOfObjectContainingLocation: glyphRange.location]; lastPosition = [fragmentRuns -indexOfObjectContainingLocation:(glyphRange.location+glyphRange.length-3)]; +indexOfObjectContainingLocation: (glyphRange.location+glyphRange.length-3)]; NSLog(@"glyphRange: (%d, %d) position1: %d position2: %d", glyphRange.location, glyphRange.length, firstPosition, lastPosition); @@ -948,7 +971,7 @@ glyphRange.location, glyphRange.length, firstPosition, lastPosition); for (i = firstPosition; i <= lastPosition; i++) { - GSLineLayoutInfo *aLine = [fragmentRuns objectAtIndex:i]; + GSLineLayoutInfo *aLine = [fragmentRuns objectAtIndex: i]; NSRect aRect = aLine->lineFragmentRect; aRect.size.height -= 4; @@ -963,74 +986,58 @@ aLine->lineFragmentRect.size.height); */ NSEraseRect (aRect); - [_textStorage drawRange:aLine->glyphRange inRect:aLine->lineFragmentRect]; + [_textStorage drawRange: aLine->glyphRange inRect: aLine->lineFragmentRect]; } } } -- (void)drawUnderlineForGlyphRange: (NSRange)glyphRange - underlineType: (int)underlineType - baselineOffset: (float)baselineOffset - lineFragmentRect: (NSRect)lineRect - lineFragmentGlyphRange: (NSRange)lineGlyphRange - containerOrigin: (NSPoint)containerOrigin +- (void) drawUnderlineForGlyphRange: (NSRange)glyphRange + underlineType: (int)underlineType + baselineOffset: (float)baselineOffset + lineFragmentRect: (NSRect)lineRect + lineFragmentGlyphRange: (NSRange)lineGlyphRange + containerOrigin: (NSPoint)containerOrigin { } -- (void)underlineGlyphRange: (NSRange)glyphRange - underlineType: (int)underlineType - lineFragmentRect: (NSRect)lineRect - lineFragmentGlyphRange: (NSRange)lineGlyphRange - containerOrigin: (NSPoint)containerOrigin +- (void) underlineGlyphRange: (NSRange)glyphRange + underlineType: (int)underlineType + lineFragmentRect: (NSRect)lineRect + lineFragmentGlyphRange: (NSRange)lineGlyphRange + containerOrigin: (NSPoint)containerOrigin { } // // Setting the delegate // -- (void)setDelegate: (id)aDelegate +- (void) setDelegate: (id)aDelegate { _delegate = aDelegate; } -- (id)delegate +- (id) delegate { return _delegate; } @end /* NSLayoutManager */ -/* Thew methods laid out here are not correct, however the code they +/* The methods laid out here are not correct, however the code they contain for the most part is. Therefore, my country and a handsome gift of -Ghiradelli chocolate to he who puts all the pieces together :) */ - -@interface _GNUTextScanner:NSObject -{ NSString *string; - NSCharacterSet *set,*iSet; - unsigned stringLength; - NSRange activeRange; -} -+(_GNUTextScanner*) scannerWithString:(NSString*) aStr set:(NSCharacterSet*) aSet invertedSet:(NSCharacterSet*) anInvSet; --(void) setString:(NSString*) aString set:(NSCharacterSet*) aSet invertedSet:(NSCharacterSet*) anInvSet; --(NSRange) _scanCharactersInverted:(BOOL) inverted; --(NSRange) scanSetCharacters; --(NSRange) scanNonSetCharacters; --(BOOL) isAtEnd; --(unsigned) scanLocation; --(void) setScanLocation:(unsigned) aLoc; -@end +Ghiradelli chocolate to he who puts all the pieces together : ) */ @implementation NSLayoutManager (Private) -- (int)_rebuildLayoutForTextContainer:(NSTextContainer *)aContainer - startingAtGlyphIndex:(int)glyphIndex +- (int) _rebuildLayoutForTextContainer: (NSTextContainer*)aContainer + startingAtGlyphIndex: (int)glyphIndex { NSSize cSize = [aContainer containerSize]; float i = 0.0; NSMutableArray *lineStarts = [NSMutableArray new]; NSMutableArray *lineEnds = [NSMutableArray new]; int indexToAdd; - _GNUTextScanner *lineScanner; - _GNUTextScanner *paragraphScanner; + NSScanner *lineScanner; + NSScanner *paragraphScanner; BOOL lastLineForContainerReached = NO; NSString *aString; int previousScanLocation; @@ -1042,8 +1049,8 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ NSFont *default_font = [NSFont systemFontOfSize: 12.0]; int widthOfString; NSSize rSize; - NSCharacterSet *selectionParagraphGranularitySet = [NSCharacterSet characterSetWithCharactersInString:@"\n"]; - NSCharacterSet *selectionWordGranularitySet = [NSCharacterSet characterSetWithCharactersInString:@" "]; + NSCharacterSet *selectionParagraphGranularitySet = [NSCharacterSet characterSetWithCharactersInString: @"\n"]; + NSCharacterSet *selectionWordGranularitySet = [NSCharacterSet characterSetWithCharactersInString: @" "]; NSCharacterSet *invSelectionWordGranularitySet = [selectionWordGranularitySet invertedSet]; NSCharacterSet *invSelectionParagraphGranularitySet = [selectionParagraphGranularitySet invertedSet]; NSRange paragraphRange; @@ -1073,30 +1080,32 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ startIndex = glyphIndex; -// lineScanner = [NSScanner scannerWithString:[_textStorage string]]; + paragraphScanner = [NSScanner scannerWithString: [_textStorage string]]; + [paragraphScanner setCharactersToBeSkipped: nil]; - paragraphScanner = [_GNUTextScanner scannerWithString:[_textStorage string] - set:selectionParagraphGranularitySet invertedSet:invSelectionParagraphGranularitySet]; - - [paragraphScanner setScanLocation:startIndex]; + [paragraphScanner setScanLocation: startIndex]; NSLog(@"length of textStorage: %d", [[_textStorage string] length]); // NSLog(@"buffer: %@", [_textStorage string]); - // This scanner eats one word at a time, we should have it imbeded in - // another scanner that snacks on paragraphs (i.e. lines that end with - // \n). Look in NSText. - + /* + * This scanner eats one word at a time, we should have it imbeded in + * another scanner that snacks on paragraphs (i.e. lines that end with + * \n). Look in NSText. + */ while (![paragraphScanner isAtEnd]) { previousParagraphLocation = [paragraphScanner scanLocation]; beginLineIndex = previousParagraphLocation; lineWidth = 0.0; - leadingNlRange=[paragraphScanner scanSetCharacters]; - paragraphRange = [paragraphScanner scanNonSetCharacters]; - trailingNlRange=[paragraphScanner scanSetCharacters]; + leadingNlRange + = scanRange(paragraphScanner, selectionParagraphGranularitySet); + paragraphRange + = scanRange(paragraphScanner, invSelectionParagraphGranularitySet); + trailingNlRange + = scanRange(paragraphScanner, selectionParagraphGranularitySet); // NSLog(@"leadingNlRange: (%d, %d)", leadingNlRange.location, leadingNlRange.length); @@ -1107,26 +1116,30 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ NSLog(@"paragraphRange: (%d, %d)", paragraphRange.location, paragraphRange.length); - lineScanner = [_GNUTextScanner scannerWithString:[[_textStorage string] substringWithRange:paragraphRange] - set:selectionWordGranularitySet invertedSet:invSelectionWordGranularitySet]; + lineScanner = [NSScanner scannerWithString: + [[_textStorage string] substringWithRange: paragraphRange]]; + [lineScanner setCharactersToBeSkipped: nil]; - while(![lineScanner isAtEnd]) + while (![lineScanner isAtEnd]) { previousScanLocation = [lineScanner scanLocation]; // snack next word - leadingSpacesRange = [lineScanner scanSetCharacters]; // leading spaces: only first time - currentStringRange = [lineScanner scanNonSetCharacters]; - trailingSpacesRange= [lineScanner scanSetCharacters]; + leadingSpacesRange + = scanRange(lineScanner, selectionWordGranularitySet); + currentStringRange + = scanRange(lineScanner, invSelectionWordGranularitySet); + trailingSpacesRange + = scanRange(lineScanner, selectionWordGranularitySet); if (leadingSpacesRange.length) - currentStringRange = NSUnionRange (leadingSpacesRange,currentStringRange); + currentStringRange = NSUnionRange(leadingSpacesRange,currentStringRange); if (trailingSpacesRange.length) - currentStringRange = NSUnionRange (trailingSpacesRange,currentStringRange); + currentStringRange = NSUnionRange(trailingSpacesRange,currentStringRange); - lSize = [_textStorage sizeRange:currentStringRange]; + lSize = [_textStorage sizeRange: currentStringRange]; -// lSize = [_textStorage sizeRange: +// lSize = [_textStorage sizeRange: //NSMakeRange(currentStringRange.location+paragraphRange.location+startIndex, //currentStringRange.length)]; @@ -1140,9 +1153,9 @@ Ghiradelli chocolate to he who puts all the pieces together :) */ previousParagraphLocation, beginLineIndex); [lineStarts addObject: [NSNumber -numberWithInt:beginLineIndex]]; +numberWithInt: beginLineIndex]]; [lineEnds addObject: [NSNumber -numberWithInt:(int)[lineScanner scanLocation] + previousParagraphLocation - (beginLineIndex)]]; +numberWithInt: (int)[lineScanner scanLocation] + previousParagraphLocation - (beginLineIndex)]]; lineWidth = 0.0; } @@ -1157,7 +1170,7 @@ numberWithInt:(int)[lineScanner scanLocation] + previousParagraphLocation - (beg break; } - [lineScanner setScanLocation:previousScanLocation]; + [lineScanner setScanLocation: previousScanLocation]; indexToAdd = previousScanLocation + previousParagraphLocation - (beginLineIndex); @@ -1171,8 +1184,8 @@ indexToAdd); lineWidth = 0.0; [lineStarts addObject: [NSNumber -numberWithInt:beginLineIndex]]; - [lineEnds addObject:[NSNumber numberWithInt:indexToAdd]]; +numberWithInt: beginLineIndex]]; + [lineEnds addObject: [NSNumber numberWithInt: indexToAdd]]; beginLineIndex = previousScanLocation + previousParagraphLocation; } } @@ -1187,20 +1200,20 @@ numberWithInt:beginLineIndex]]; // set this container for that glyphrange - [self setTextContainer:aContainer - forGlyphRange:NSMakeRange(startIndex, endScanLocation - startIndex)]; + [self setTextContainer: aContainer + forGlyphRange: NSMakeRange(startIndex, endScanLocation - startIndex)]; NSLog(@"ok, move on to step 2."); // step 2. break the lines up and assign rects to them. - for (i=0;i<[lineStarts count];i++) + for (i=0; i < [lineStarts count]; i++) { NSRect aRect, bRect; float padding = [aContainer lineFragmentPadding]; NSRange ourRange; -// NSLog(@"\t\t===> %d", [[lines objectAtIndex:i] intValue]); +// NSLog(@"\t\t===> %d", [[lines objectAtIndex: i] intValue]); ourRange = NSMakeRange ([[lineStarts objectAtIndex: i] intValue], [[lineEnds objectAtIndex: i] intValue]); @@ -1209,17 +1222,17 @@ numberWithInt:beginLineIndex]]; if (i == 0) { ourRange = NSMakeRange (startIndex, - [[lines objectAtIndex:i] intValue] - startIndex); + [[lines objectAtIndex: i] intValue] - startIndex); } else { - ourRange = NSMakeRange ([[lines objectAtIndex:i-1] intValue], -[[lines objectAtIndex:i] intValue] - [[lines objectAtIndex:i-1] + ourRange = NSMakeRange ([[lines objectAtIndex: i-1] intValue], +[[lines objectAtIndex: i] intValue] - [[lines objectAtIndex: i-1] intValue]); } */ NSLog(@"line: %@|", [[_textStorage string] -substringWithRange:ourRange]); +substringWithRange: ourRange]); firstProposedRect = NSMakeRect (0, i * 14, cSize.width, 14); @@ -1239,20 +1252,20 @@ substringWithRange:ourRange]); // set the location for this string to be 'show'ed. - [self setLocation:NSMakePoint(secondProposedRect.origin.x + padding, + [self setLocation: NSMakePoint(secondProposedRect.origin.x + padding, secondProposedRect.origin.y + padding) forStartOfGlyphRange: ourRange]; } // bloody hack. // if (moreText) -// [delegate layoutManager:self -// didCompleteLayoutForTextContainer:[textContainers objectAtIndex:i] -// atEnd:NO]; +// [delegate layoutManager: self +// didCompleteLayoutForTextContainer: [textContainers objectAtIndex: i] +// atEnd: NO]; // else -// [delegate layoutManager:self -// didCompleteLayoutForTextContainer:[textContainers objectAtIndex:i] -// atEnd:YES]; +// [delegate layoutManager: self +// didCompleteLayoutForTextContainer: [textContainers objectAtIndex: i] +// atEnd: YES]; [lineStarts release]; [lineEnds release]; @@ -1260,18 +1273,19 @@ substringWithRange:ourRange]); return endScanLocation; } -- (void)_doLayout +- (void) _doLayout { - int i; - BOOL moreText; - int gIndex = 0; + NSEnumerator *enumerator; + NSTextContainer *container; + int gIndex = 0; NSLog(@"doLayout called.\n"); - for (i=0;i<[_textContainers count];i++) + enumerator = [_textContainers objectEnumerator]; + while ((container = [enumerator nextObject]) != nil) { - gIndex = [self _rebuildLayoutForTextContainer:[_textContainers objectAtIndex:i] - startingAtGlyphIndex:gIndex]; + gIndex = [self _rebuildLayoutForTextContainer: container + startingAtGlyphIndex: gIndex]; } } @end diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index 453b013b8..470c5926a 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -348,6 +348,8 @@ static SEL getSel = @selector(objectAtIndex:); cells[i][column] = old; selectedCells[i][column] = NO; } + if (_selectedCell && (_selectedColumn >= column)) + _selectedColumn++; } /* @@ -425,6 +427,8 @@ static SEL getSel = @selector(objectAtIndex:); } cells[row] = oldr; selectedCells[row] = olds; + if (_selectedCell && (_selectedRow >= row)) + _selectedRow++; } /* @@ -501,7 +505,13 @@ static SEL getSel = @selector(objectAtIndex:); [NSException raise: NSRangeException format: @"attempt to put cell outside matrix bounds"]; } + + if ((row == _selectedRow) && (column == _selectedColumn) + && (_selectedCell != nil)) + _selectedCell = newCell; + ASSIGN(cells[row][column], newCell); + [self setNeedsDisplayInRect: [self cellFrameAtRow: row column: column]]; } @@ -1780,6 +1790,15 @@ static SEL getSel = @selector(objectAtIndex:); static MPoint anchor = {0, 0}; int clickCount; + /* + * Pathological case -- ignore mouse down + */ + if ((numRows == 0) || (numCols == 0)) + { + [super mouseDown: theEvent]; + return; + } + // Manage multi-click events clickCount = [theEvent clickCount]; diff --git a/Source/NSMenu.m b/Source/NSMenu.m index 46c889b5f..6d79307c6 100644 --- a/Source/NSMenu.m +++ b/Source/NSMenu.m @@ -496,16 +496,16 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; // Managing Submenus. // - (void) setSubmenu: (NSMenu *)aMenu - forItem: (id ) anItem + forItem: (id )anItem { [(NSMenuItem *)anItem setSubmenu: aMenu]; [anItem setTarget: self]; [anItem setAction: @selector(submenuAction:)]; - if (aMenu) - aMenu->menu_supermenu = self; - - ASSIGN(aMenu->menu_title, [anItem title]); - + if (aMenu != nil) + { + aMenu->menu_supermenu = self; + ASSIGN(aMenu->menu_title, [anItem title]); + } [self itemChanged: anItem]; } @@ -856,66 +856,37 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; { [encoder encodeObject: menu_title]; [encoder encodeObject: menu_items]; - [encoder encodeObject: menu_view]; - [encoder encodeConditionalObject: menu_supermenu]; - [encoder encodeConditionalObject: menu_popb]; [encoder encodeValueOfObjCType: @encode(BOOL) at: &menu_autoenable]; - [encoder encodeValueOfObjCType: @encode(BOOL) at: &menu_is_tornoff]; - [encoder encodeValueOfObjCType: @encode(BOOL) - at: &menu_is_beholdenToPopUpButton]; } - (id) initWithCoder: (NSCoder*)decoder { - NSNotificationCenter *theCenter = [NSNotificationCenter defaultCenter]; - NSRect winRect = {{0,0},{20,23}}; + NSString *dTitle; + NSArray *dItems; + BOOL dAuto; + unsigned i; - [decoder decodeValueOfObjCType: @encode(id) at: &menu_title]; - [decoder decodeValueOfObjCType: @encode(id) at: &menu_items]; - [decoder decodeValueOfObjCType: @encode(id) at: &menu_view]; - [menu_view setMenu: self]; // Sets notifications up - menu_supermenu = [decoder decodeObject]; - menu_popb = [decoder decodeObject]; - [decoder decodeValueOfObjCType: @encode(BOOL) at: &menu_autoenable]; - [decoder decodeValueOfObjCType: @encode(BOOL) at: &menu_is_tornoff]; - [decoder decodeValueOfObjCType: @encode(BOOL) - at: &menu_is_beholdenToPopUpButton]; + dTitle = [decoder decodeObject]; + dItems = [decoder decodeObject]; + [decoder decodeValueOfObjCType: @encode(BOOL) at: &dAuto]; - menu_attachedMenu = nil; - menu_changedMessagesEnabled = YES; - menu_notifications = [NSMutableArray new]; - menu_follow_transient = NO; - menu_is_visible = NO; + self = [self initWithTitle: dTitle]; + [self setAutoenablesItems: dAuto]; - // Mark the menu as changed in order to get it resized. - menu_changed = YES; + /* + * Make sure that items and submenus are set correctly. + */ + for (i = 0; i < [dItems count]; i++) + { + NSMenuItem *item = [dItems objectAtIndex: i]; + NSMenu *sub = [item submenu]; - // Transient windows private stuff. - _oldAttachedMenu = nil; - - // Create the windows that will display the menu. - aWindow = [[NSMenuWindow alloc] initWithContentRect: winRect - styleMask: NSBorderlessWindowMask - backing: NSBackingStoreRetained - defer: NO]; - bWindow = [[NSMenuWindow alloc] initWithContentRect: winRect - styleMask: NSBorderlessWindowMask - backing: NSBackingStoreRetained - defer: NO]; - - titleView = [NSMenuWindowTitleView new]; - [titleView setFrameOrigin: NSMakePoint(0, winRect.size.height - 23)]; - [titleView setFrameSize: NSMakeSize (winRect.size.width, 23)]; - [[aWindow contentView] addSubview: menu_view]; - [[aWindow contentView] addSubview: titleView]; - [titleView setMenu: self]; - - // Set up the notification to start the process of redisplaying - // the menus where the user left them the last time. - [theCenter addObserver: self - selector: @selector(_showTornOffMenuIfAny:) - name: NSApplicationWillFinishLaunchingNotification - object: NSApp]; + [self addItem: item]; + if (sub != nil) + { + [self setSubmenu: sub forItem: item]; + } + } return self; } @@ -1010,7 +981,10 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; defaults = [NSUserDefaults standardUserDefaults]; menuLocations = [[defaults objectForKey: NSMenuLocationsKey] mutableCopy]; [menuLocations removeObjectForKey: key]; - [defaults setObject: menuLocations forKey: NSMenuLocationsKey]; + if ([menuLocations count] > 0) + [defaults setObject: menuLocations forKey: NSMenuLocationsKey]; + else + [defaults removeObjectForKey: NSMenuLocationsKey]; RELEASE(menuLocations); [defaults synchronize]; } @@ -1448,7 +1422,9 @@ static NSString *NSMenuLocationsKey = @"NSMenuLocations"; defaults = [NSUserDefaults standardUserDefaults]; menuLocations = [[defaults objectForKey: NSMenuLocationsKey] mutableCopy]; if (menuLocations == nil) - menuLocations = [NSMutableDictionary dictionaryWithCapacity: 2]; + { + menuLocations = [[NSMutableDictionary alloc] initWithCapacity: 2]; + } locString = [[menu window] stringWithSavedFrame]; [menuLocations setObject: locString forKey: key]; [defaults setObject: menuLocations forKey: NSMenuLocationsKey]; diff --git a/Source/NSMenuItem.m b/Source/NSMenuItem.m index 59e988570..8e76bb2f3 100644 --- a/Source/NSMenuItem.m +++ b/Source/NSMenuItem.m @@ -70,7 +70,6 @@ static Class imageClass; - (id) init { self = [super init]; - mi_hasSubmenu = NO; mi_target = nil; mi_menu = nil; mi_mnemonicLocation = 255; // No mnemonic @@ -395,7 +394,6 @@ static Class imageClass; - (void) encodeWithCoder: (NSCoder*)aCoder { [super encodeWithCoder: aCoder]; - [aCoder encodeConditionalObject: mi_menu]; [aCoder encodeObject: mi_title]; [aCoder encodeObject: mi_keyEquivalent]; [aCoder encodeValueOfObjCType: "I" at: &mi_keyEquivalentModifierMask]; @@ -417,7 +415,6 @@ static Class imageClass; - (id) initWithCoder: (NSCoder*)aDecoder { self = [super initWithCoder: aDecoder]; - mi_menu = [aDecoder decodeObject]; [aDecoder decodeValueOfObjCType: @encode(id) at: &mi_title]; [aDecoder decodeValueOfObjCType: @encode(id) at: &mi_keyEquivalent]; [aDecoder decodeValueOfObjCType: "I" at: &mi_keyEquivalentModifierMask]; diff --git a/Source/NSMenuItemCell.m b/Source/NSMenuItemCell.m index 2b7e47cf0..57e8febe0 100644 --- a/Source/NSMenuItemCell.m +++ b/Source/NSMenuItemCell.m @@ -159,9 +159,11 @@ static NSImage *arrowImageH = nil; } // Image - if ((anImage = [mcell_item image])) + if ((anImage = [mcell_item image]) && _cell.image_position == NSNoImage) [self setImagePosition: NSImageLeft]; - componentSize = [anImage size]; + componentSize = NSMakeSize(0,0); + if (anImage) + componentSize = [anImage size]; mcell_imageWidth = componentSize.width; if (componentSize.height > neededMenuItemHeight) neededMenuItemHeight = componentSize.height; @@ -245,6 +247,13 @@ static NSImage *arrowImageH = nil; // - (NSRect) imageRectForBounds:(NSRect)cellFrame { + if (_mcell_belongs_to_popupbutton && _cell.image_position) + { + /* Special case: draw image on the extreme right [FIXME check the distance]*/ + cellFrame.origin.x += cellFrame.size.width - mcell_imageWidth - 2; + cellFrame.size.width = mcell_imageWidth; + return cellFrame; + } // Calculate the image part of cell frame from NSMenuView cellFrame.origin.x += [mcell_menuView imageAndTitleOffset]; cellFrame.size.width = [mcell_menuView imageAndTitleWidth]; diff --git a/Source/NSMenuView.m b/Source/NSMenuView.m index 574973a86..c37103cc0 100644 --- a/Source/NSMenuView.m +++ b/Source/NSMenuView.m @@ -228,8 +228,18 @@ static float GSMenuBarHeight = 25.0; // A wild guess. - (void) setMenuItemCell: (NSMenuItemCell *)cell forItemAtIndex: (int)index { + NSMenuItem *anItem = [menuv_items_link objectAtIndex: index]; + [menuv_itemCells replaceObjectAtIndex: index withObject: cell]; + [cell setMenuItem: anItem]; + [cell setMenuView: self]; + + if ([self highlightedItemIndex] == index) + [cell setHighlighted: YES]; + else + [cell setHighlighted: NO]; + // Mark the new cell and the menu view as needing resizing. [cell setNeedsSizing: YES]; [self setNeedsSizing: YES]; diff --git a/Source/NSPopUpButton.m b/Source/NSPopUpButton.m index 3b3131808..a197a7022 100644 --- a/Source/NSPopUpButton.m +++ b/Source/NSPopUpButton.m @@ -195,16 +195,19 @@ Class _nspopupbuttonCellClass = 0; - (void) selectItem: (id )anObject { [_cell selectItem: anObject]; + [self synchronizeTitleAndSelectedItem]; } - (void) selectItemAtIndex: (int)index { [_cell selectItemAtIndex: index]; + [self synchronizeTitleAndSelectedItem]; } - (void) selectItemWithTitle: (NSString*)title { [_cell selectItemWithTitle: title]; + [self synchronizeTitleAndSelectedItem]; } - (int) numberOfItems @@ -302,7 +305,8 @@ Class _nspopupbuttonCellClass = 0; NSMenuView *mr = [[_cell menu] menuRepresentation]; NSEvent *e; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - + NSPoint p; + if ([self isEnabled] == NO) return; @@ -313,12 +317,23 @@ Class _nspopupbuttonCellClass = 0; [_cell attachPopUpWithFrame: _bounds inView: self]; + { + // Hack, function in NSPopUpButtonCell + extern NSPoint + _convertBaseToScreen_with_fix (NSRect frame, NSWindow *window, + NSPoint point); + + p = [[mr window] + convertScreenToBase: + _convertBaseToScreen_with_fix ([self convertRect:_bounds + toView: nil], _window, + [theEvent locationInWindow])]; + } + // Process events; we start menu events processing by converting // this event to the menu window, and sending it there. e = [NSEvent mouseEventWithType: [theEvent type] - location: [[mr window] convertScreenToBase: - [_window convertBaseToScreen: - [theEvent locationInWindow]]] + location: p modifierFlags: [theEvent modifierFlags] timestamp: [theEvent timestamp] windowNumber: [[mr window] windowNumber] @@ -336,8 +351,7 @@ Class _nspopupbuttonCellClass = 0; // Send action to target [super sendAction: [self action] - to: [self target]]; - + to: [self target]]; } /* @@ -345,30 +359,58 @@ Class _nspopupbuttonCellClass = 0; */ - (void) encodeWithCoder: (NSCoder*)aCoder { + int i; + BOOL f; + id c; + + /* + * Don't encode all the cell information! + */ + c = RETAIN([self cell]); [super encodeWithCoder: aCoder]; -/* - [aCoder encodeObject: list_items]; - [aCoder encodeRect: list_rect]; - [aCoder encodeValueOfObjCType: @encode(int) at: &selected_item]; - [aCoder encodeConditionalObject: pub_target]; - [aCoder encodeValueOfObjCType: @encode(SEL) at: &pub_action]; - [aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_up]; - [aCoder encodeValueOfObjCType: @encode(BOOL) at: &pulls_down]; -*/ + [self setCell: c]; + RELEASE(c); + f = [self pullsDown]; + [aCoder encodeValueOfObjCType: @encode(BOOL) at: &f]; + [aCoder encodeObject: [self itemArray]]; + i = [self indexOfSelectedItem]; + [aCoder encodeValueOfObjCType: @encode(int) at: &i]; } - (id) initWithCoder: (NSCoder*)aDecoder { + NSArray *dItems; + int dSelected; + BOOL dPull; + unsigned i; + id aCell; + [super initWithCoder: aDecoder]; -/* - [aDecoder decodeValueOfObjCType: @encode(id) at: &list_items]; - list_rect = [aDecoder decodeRect]; - [aDecoder decodeValueOfObjCType: @encode(int) at: &selected_item]; - pub_target = [aDecoder decodeObject]; - [aDecoder decodeValueOfObjCType: @encode(SEL) at: &pub_action]; - [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_up]; - [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &pulls_down]; -*/ + /* + * Set a newly created cell. + */ + aCell = [[[self class] cellClass] new]; + [self setCell: aCell]; + RELEASE(aCell); + [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &dPull]; + [self setPullsDown: dPull]; + dItems = [aDecoder decodeObject]; + for (i = 0; i < [dItems count]; i++) + { + NSMenuItem *dItem = [dItems objectAtIndex: i]; + NSMenuItem *item; + + [self addItemWithTitle: [dItem title]]; + item = [self itemAtIndex: i]; + [item setTarget: [dItem target]]; + [item setAction: [dItem action]]; + [item setEnabled: [dItem isEnabled]]; + [item setTag: [dItem tag]]; + [item setKeyEquivalent: [dItem keyEquivalent]]; + } + [aDecoder decodeValueOfObjCType: @encode(int) at: &dSelected]; + [self selectItemAtIndex: dSelected]; + [self synchronizeTitleAndSelectedItem]; return self; } diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m index b9e12e677..cf4756a18 100644 --- a/Source/NSPopUpButtonCell.m +++ b/Source/NSPopUpButtonCell.m @@ -36,7 +36,75 @@ #include #include +@interface NSMenuItemCell (GNUStepPrivate) +- (void) setBelongsToPopUpButton: (BOOL)flag; +@end +@implementation NSMenuItemCell (GNUStepPrivate) +- (void) setBelongsToPopUpButton: (BOOL)flag +{ + _mcell_belongs_to_popupbutton = flag; +} +@end + +/* Same as [NSWindow -convertBaseToScreen:] with the difference + that detects and fixes at run time bugs in the window frame management */ +/* frame is a frame where the mouse is supposed to be. + If the mouse is out of that frame, it means the window code has got the + window origin wrong -- presumably by a decoration height. + Looking if mouse is upper or lower than the given frame we determine + if decoration window size need to be added or subtracted. */ +NSPoint +_convertBaseToScreen_with_fix(NSRect frame, NSWindow *window, NSPoint point) +{ + /* We get mouse position */ + NSPoint mouse = [window mouseLocationOutsideOfEventStream]; + float l, r, b; + float t = 0; + NSPoint ret; + + /* If the reported mouse position is not in frame + this means that the window frame origin is broken. */ + if (mouse.y > frame.origin.y + frame.size.height) + { + NSLog (@"Window Frame Origin Bug Detected: point reported higher"); + NSLog (@"Workaround enabled."); + DPSstyleoffsets (GSCurrentContext (), &l, &r, &t, &b, + [window styleMask]); + } + else if (mouse.y < frame.origin. y) + { + NSLog (@"Window Frame Origin Bug Detected: point reported lower"); + NSLog (@"Workaround enabled."); + DPSstyleoffsets (GSCurrentContext (), &l, &r, &t, &b, + [window styleMask]); + t = -t; + } + + /* Convert the origin */ + ret = [window convertBaseToScreen: point]; + + /* Add the bug correction */ + ret.y += t; + + return ret; +} + +/* The image to use in a specific popupbutton is + * _pbc_image[_pbcFlags.pullsDown]; that is, _pbc_image[0] if it is a + * popup menu, _pbc_image[1] if it is a pulls down list. */ +static NSImage *_pbc_image[2]; + @implementation NSPopUpButtonCell ++ (void) initialize +{ + if (self == [NSPopUpButtonCell class]) + { + [self setVersion: 1]; + ASSIGN(_pbc_image[0], [NSImage imageNamed: @"common_Nibble"]); + ASSIGN(_pbc_image[1], [NSImage imageNamed: @"common_3DArrowDown"]); + } +} + - (void) dealloc { RELEASE(_menu); @@ -146,15 +214,8 @@ // Adding and removing items - (void) addItemWithTitle: (NSString *)title { - NSMenuItem *anItem = [NSMenuItem new]; - - [anItem setTitle: title]; - // Not bad as defaults: - [anItem setTarget: nil]; - [anItem setAction: NULL]; - - [_menu insertItem: anItem atIndex: [_menu numberOfItems]]; - RELEASE(anItem); + [self insertItemWithTitle: title + atIndex: [_menu numberOfItems]]; } - (void) addItemsWithTitles: (NSArray *)itemTitles @@ -171,19 +232,25 @@ - (void) insertItemWithTitle: (NSString *)title atIndex: (int)index { NSMenuItem *anItem = [NSMenuItem new]; + NSMenuItemCell *aCell; + int count = [_menu numberOfItems]; if (index < 0) index = 0; - if (index > [_menu numberOfItems]) - index = [_menu numberOfItems]; + if (index > count) + index = count; [anItem setTitle: title]; - // Not bad as defaults: [anItem setTarget: nil]; [anItem setAction: NULL]; [_menu insertItem: anItem atIndex: index]; + RELEASE(anItem); + + aCell = [[_menu menuRepresentation] menuItemCellForItemAtIndex: index]; + [aCell setBelongsToPopUpButton: YES]; + [aCell setImagePosition: NSImageRight]; } - (void) removeItemWithTitle: (NSString *)title @@ -265,8 +332,11 @@ if (!item) { if (_pbcFlags.altersStateOfSelectedItem) - [_selectedItem setState: NSOffState]; - + { + [_selectedItem setState: NSOffState]; + [_selectedItem setChangesState: NO]; + } + [_selectedItem setImage: nil]; _selectedItem = nil; } else @@ -274,18 +344,32 @@ if (_pbcFlags.altersStateOfSelectedItem) { [_selectedItem setState: NSOffState]; - } + [_selectedItem setChangesState: NO]; + } + [_selectedItem setImage: nil]; + _selectedItem = item; + if (_pbcFlags.altersStateOfSelectedItem) { - [_selectedItem setState: NSOnState]; + [_selectedItem setState: NSOnState]; + [_selectedItem setChangesState: NO]; } + [_selectedItem setImage: _pbc_image[_pbcFlags.pullsDown]]; } + /* Set the item in the menu */ + [(NSMenuView *)[_menu menuRepresentation] setHighlightedItemIndex: + [_menu indexOfItem: _selectedItem]]; } - (void) selectItemAtIndex: (int)index { - NSMenuItem *anItem = (index == -1) ? nil : [self itemAtIndex: index]; + NSMenuItem *anItem; + + if (index < 0) + anItem = nil; + else + anItem = [self itemAtIndex: index]; [self selectItem: anItem]; } @@ -349,8 +433,8 @@ } else { - int index = [[_menu menuRepresentation] highlightedItemIndex]; - + int index = [[_menu menuRepresentation] highlightedItemIndex]; + if (index < 0) index = 0; [self selectItemAtIndex: index]; @@ -393,6 +477,8 @@ NSWindow *cvWin = [controlView window]; NSMenuView *mr = [_menu menuRepresentation]; int items; + NSRect origCellFrame = [controlView convertRect: cellFrame + toView: nil]; [nc postNotificationName: NSPopUpButtonCellWillPopUpNotification object: self]; @@ -417,10 +503,14 @@ } // Convert to Screen Coordinates + + /* Convert to content view */ cellFrame = [controlView convertRect: cellFrame toView: nil]; - cellFrame.origin = [cvWin convertBaseToScreen: cellFrame.origin]; - + + cellFrame.origin = _convertBaseToScreen_with_fix (origCellFrame, cvWin, + cellFrame.origin); + // Ask the MenuView to attach the menu to this rect if (_pbcFlags.pullsDown) { @@ -464,17 +554,6 @@ // This method is not executed upon mouse down; rather, it should // simulate what would happen upon mouse down. It should not start // any real mouse tracking. - - /* - int indexToClick; - [self attachPopUpWithFrame: frame - inView: controlView]; - indexToClick = [[_menu menuRepresentation] indexOfItemAtPoint: - [[_menu window] mouseLocationOutsideOfEventStream]]; - [[_menu menuRepresentation] mouseDown: [NSApp currentEvent]]; - - [[[_menu menuRepresentation] menuItemCellForItemAtIndex: indexToClick] - performClick: nil];*/ } // Arrow position for bezel style and borderless popups. @@ -483,18 +562,26 @@ return _pbcFlags.arrowPosition; } +/* + * Does nothing for now. + */ - (void) setArrowPosition: (NSPopUpArrowPosition)position { _pbcFlags.arrowPosition = position; } +/* + * What would be nice and natural is to make this drawing using the same code + * that is used to draw cells in the menu. + * This looks like a mess to do in this framework. + */ - (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)view { NSSize size; NSPoint position; - NSImage *aImage; - + NSImage *anImage; + // Save last view drawn to if (_control_view != view) _control_view = view; @@ -508,17 +595,13 @@ cellFrame.size.width -= 5; [self _drawText: [self titleOfSelectedItem] inFrame: cellFrame]; + + anImage = _pbc_image[_pbcFlags.pullsDown]; - if (_pbcFlags.pullsDown) - { - aImage = [NSImage imageNamed: @"common_3DArrowDown"]; - } - else - { - aImage = [NSImage imageNamed: @"common_Nibble"]; - } + /* NB: If we are drawing here, then the control can't be selected */ + [anImage setBackgroundColor: [NSColor controlBackgroundColor]]; - size = [aImage size]; + size = [anImage size]; position.x = cellFrame.origin.x + cellFrame.size.width - size.width - 4; position.y = MAX(NSMidY(cellFrame) - (size.height/2.), 0.); /* @@ -527,9 +610,8 @@ */ if ([view isFlipped]) position.y += size.height; - [aImage compositeToPoint: position operation: NSCompositeCopy]; + [anImage compositeToPoint: position operation: NSCompositeCopy]; [view unlockFocus]; } - @end diff --git a/Source/NSText.m b/Source/NSText.m index 1271e01fb..e929bcafd 100644 --- a/Source/NSText.m +++ b/Source/NSText.m @@ -37,10 +37,6 @@ // - optimization: 3.paragraph made one less line due to delition // of single char [opti hook 1; diff from 1.] -#if !defined(ABS) - #define ABS(A) ({ typeof(A) __a = (A); __a < 0 ? - __a : __a; }) -#endif // the definition in gstep-base produces warnings FIX ME FAR - #include #include #include @@ -68,6 +64,23 @@ #define HUGE 1e99 +/* + * A little utility function to determine the range of characters in a scanner + * that are present in a specified character set. + */ +static inline NSRange +scanRange(NSScanner *scanner, NSCharacterSet* aSet) +{ + unsigned start = [scanner scanLocation]; + unsigned end = start; + + if ([scanner scanCharactersFromSet: aSet intoString: 0] == YES) + { + end = [scanner scanLocation]; + } + return NSMakeRange(start, end - start); +} + enum { NSBackspaceKey = 8, NSCarriageReturnKey = 13, @@ -82,7 +95,6 @@ enum { float drawingOffset; BOOL dontDisplay; unsigned type; - NSString *fingerprintString; // obsolete, unused } typedef enum @@ -106,8 +118,6 @@ typedef enum - (void) setDrawingOffset: (float) anOffset; - (void) setDontDisplay: (BOOL) flag; - (void) setType: (unsigned) aType; -- (NSString*) fingerprintString; -- (void) setFingerprintString: (NSString*) aString; - (BOOL) isLineTerminatingParagraph; - (NSString*) description; @@ -151,11 +161,6 @@ typedef enum return drawingOffset; } -- (NSString*) fingerprintString -{ - return fingerprintString; -} - - (void) setLineRange: (NSRange) aRange { lineRange = aRange; @@ -184,17 +189,11 @@ typedef enum type = aType; } -- (void) setFingerprintString: (NSString*) aString -{ - ASSIGN (fingerprintString, aString); -} - - (NSString*) description { return [[NSDictionary dictionaryWithObjectsAndKeys: NSStringFromRange(lineRange), @"LineRange", NSStringFromRect(lineRect), @"LineRect", - fingerprintString, @"fingerprint", nil] description]; } @@ -204,13 +203,6 @@ typedef enum // sort of hackish return type == LineLayoutInfoType_Paragraph && lineRect.origin.x> 0; } - -- (void) dealloc -{ - if (fingerprintString) - [fingerprintString release]; - [super dealloc]; -} @end static NSRange MakeRangeFromAbs (int a1,int a2) // not the same as NSMakeRange! @@ -233,118 +225,6 @@ static NSRange MakeRangeFromAbs(int a1,int a2) */ // end: _GNULineLayoutInfo------------------------------------------------------------------------------------------ -// NeXT's NSScanner's scanCharactersFromSet and friends seem to be -// a bit sluggish on whitespaces and newlines -// (have not tried GNUstep - base implementation though). -// so here is a more pedantic (and faster) implementation: - -// this class should be considered private since it is not polished at all! - - -@interface _GNUTextScanner: NSObject -{ - NSString *string; - NSCharacterSet *set,*iSet; - unsigned stringLength; - NSRange activeRange; -} -+ (_GNUTextScanner*) scannerWithString: (NSString*) aStr - set: (NSCharacterSet*) aSet - invertedSet: (NSCharacterSet*) anInvSet; -- (void) setString: (NSString*) aString set: (NSCharacterSet*) - aSet invertedSet: (NSCharacterSet*) anInvSet; -- (NSRange) _scanCharactersInverted: (BOOL) inverted; -- (NSRange) scanSetCharacters; -- (NSRange) scanNonSetCharacters; -- (BOOL) isAtEnd; -- (unsigned) scanLocation; -- (void) setScanLocation: (unsigned) aLoc; -@end - -@implementation _GNUTextScanner -+ (_GNUTextScanner*) scannerWithString: (NSString*) aStr - set: (NSCharacterSet*) aSet - invertedSet: (NSCharacterSet*) anInvSet -{ - _GNUTextScanner *ret = [[self alloc] init]; - [ret setString: aStr set: aSet invertedSet: anInvSet]; - return [ret autorelease]; -} - -- (void) setString: (NSString*) aString set: (NSCharacterSet*) aSet - invertedSet: (NSCharacterSet*) anInvSet -{ - ASSIGN (string, aString); - stringLength = [string length]; - activeRange = NSMakeRange (0, stringLength); - ASSIGN (set, aSet); - ASSIGN (iSet, anInvSet); -} - -- (NSRange) _scanCharactersInverted: (BOOL) inverted -{ - NSRange range = NSMakeRange (activeRange.location, 0); - NSCharacterSet *currentSet = inverted? iSet: set; - NSCharacterSet *currentISet = inverted? set: iSet; - - if (activeRange.location >= stringLength) - return range; - - if ([currentSet characterIsMember: [string characterAtIndex: - activeRange.location]]) - { - range = [string rangeOfCharacterFromSet: currentSet options: 0 - range: activeRange]; - } - - if (range.length) - { - NSRange iRange = range; - iRange = [string rangeOfCharacterFromSet: currentISet options: 0 - range: MakeRangeFromAbs (NSMaxRange (range), - stringLength)]; - if (iRange.length) - range = MakeRangeFromAbs (range.location, iRange.location); - else - range = MakeRangeFromAbs (range.location, stringLength); - - activeRange = MakeRangeFromAbs (NSMaxRange(range), stringLength); - } - return range; -} - -- (NSRange) scanSetCharacters -{ - return [self _scanCharactersInverted: NO]; -} -- (NSRange) scanNonSetCharacters -{ - return [self _scanCharactersInverted: YES]; -} - -- (BOOL) isAtEnd -{ - return activeRange.location >= stringLength; -} -- (unsigned) scanLocation -{ - return activeRange.location; -} -- (void) setScanLocation: (unsigned) aLoc -{ - activeRange = MakeRangeFromAbs (aLoc, stringLength); -} -- (void) dealloc -{ - [string release]; - [set release]; - [iSet release]; - [super dealloc]; -} -@end - -// end: _GNUTextScanner implementation-------------------------------------- - /* @interface NSAttributedString(DrawingAddition) - (NSSize) sizeRange: (NSRange) aRange; @@ -602,7 +482,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) if ((!sendType || [sendType isEqual: NSStringPboardType]) && (!returnType || [returnType isEqual: NSStringPboardType])) { - if (([self selectedRange].length || !sendType) + if ((selected_range.length || !sendType) && ([self isEditable] || !returnType)) { return self; @@ -617,7 +497,6 @@ static NSRange MakeRangeFromAbs(int a1,int a2) types: (NSArray*)sendTypes { NSArray *types; - NSRange range; NSString *string; if ([sendTypes containsObject: NSStringPboardType] == NO) @@ -626,9 +505,8 @@ static NSRange MakeRangeFromAbs(int a1,int a2) } types = [NSArray arrayWithObjects: NSStringPboardType, nil]; [pb declareTypes: types owner: nil]; - range = [self selectedRange]; string = [self string]; - string = [string substringWithRange: range]; + string = [string substringWithRange: selected_range]; return [pb setString: string forType: NSStringPboardType]; } @@ -645,7 +523,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) if ([self isRichText]) { - [self setTextColor: color range: [self selectedRange]]; + [self setTextColor: color range: selected_range]; } else [self setTextColor: color]; @@ -788,7 +666,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) return NSMakeRange(0,0); } - switch(granularity) + switch (granularity) { case NSSelectByCharacter: return NSIntersectionRange (proposedCharRange, @@ -1033,12 +911,11 @@ static NSRange MakeRangeFromAbs(int a1,int a2) { if ([self isRichText]) { - NSRange selectedRange = [self selectedRange]; - NSRange searchRange = selectedRange; + NSRange searchRange = selected_range; NSRange foundRange; int maxSelRange; - for (maxSelRange = NSMaxRange(selectedRange); + for (maxSelRange = NSMaxRange(selected_range); searchRange.location < maxSelRange; searchRange = NSMakeRange (NSMaxRange (foundRange), maxSelRange - NSMaxRange(foundRange))) @@ -1158,7 +1035,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) - (BOOL) shouldDrawInsertionPoint { - return ([self selectedRange].length == 0) && [self isEditable]; + return (selected_range.length == 0) && [self isEditable]; } - (void) drawInsertionPointInRect: (NSRect)rect @@ -1540,16 +1417,16 @@ static NSRange MakeRangeFromAbs(int a1,int a2) { BOOL doUnderline = YES; if ([[rtfContent attribute: NSUnderlineStyleAttributeName - atIndex: [self selectedRange].location + atIndex: selected_range.location effectiveRange: NULL] intValue]) doUnderline = NO; - if ([self selectedRange].length) + if (selected_range.length) { [rtfContent addAttribute: NSUnderlineStyleAttributeName value: [NSNumber numberWithInt: doUnderline] - range: [self selectedRange]]; - [self rebuildFromCharacterIndex: [self selectedRange].location]; + range: selected_range]; + [self rebuildFromCharacterIndex: selected_range.location]; } else // no redraw necess. [[self typingAttributes] @@ -1562,11 +1439,11 @@ static NSRange MakeRangeFromAbs(int a1,int a2) { if ([self isRichText]) { - if ([self selectedRange].length) + if (selected_range.length) { [rtfContent removeAttribute: NSUnderlineStyleAttributeName - range: [self selectedRange]]; - [self rebuildFromCharacterIndex: [self selectedRange].location]; + range: selected_range]; + [self rebuildFromCharacterIndex: selected_range.location]; } else // no redraw necess. [[self typingAttributes] @@ -1595,9 +1472,9 @@ static NSRange MakeRangeFromAbs(int a1,int a2) { [self scrollRectToVisible: NSUnionRect ([self rectForCharacterIndex: - [self selectedRange].location], + selected_range.location], [self rectForCharacterIndex: - NSMaxRange ([self selectedRange])])]; + NSMaxRange (selected_range)])]; } // @@ -1679,14 +1556,18 @@ static NSRange MakeRangeFromAbs(int a1,int a2) unsigned cursorIndex; NSPoint cursorPoint; - if ([self selectedRange].length) + /* Do nothing if we are at beginning of text */ + if (selected_range.location == 0) + return; + + if (selected_range.length) { currentCursorX = [self rectForCharacterIndex: - [self selectedRange].location].origin.x; + selected_range.location].origin.x; currentCursorY = [self rectForCharacterIndex: - [self selectedRange].location].origin.y; + selected_range.location].origin.y; } - cursorIndex = [self selectedRange].location; + cursorIndex = selected_range.location; cursorPoint = [self rectForCharacterIndex: cursorIndex].origin; cursorIndex = [self characterIndexForPoint: NSMakePoint (currentCursorX + 0.001, @@ -1703,14 +1584,18 @@ static NSRange MakeRangeFromAbs(int a1,int a2) unsigned cursorIndex; NSRect cursorRect; - if ([self selectedRange].length) + /* Do nothing if we are at end of text */ + if (selected_range.location == [self textLength]) + return; + + if (selected_range.length) { currentCursorX = [self rectForCharacterIndex: - NSMaxRange ([self selectedRange])].origin.x; + NSMaxRange (selected_range)].origin.x; currentCursorY = [self rectForCharacterIndex: - NSMaxRange ([self selectedRange])].origin.y; + NSMaxRange (selected_range)].origin.y; } - cursorIndex = [self selectedRange].location; + cursorIndex = selected_range.location; cursorRect = [self rectForCharacterIndex: cursorIndex]; cursorIndex = [self characterIndexForPoint: NSMakePoint (currentCursorX + 0.001, @@ -1723,22 +1608,30 @@ static NSRange MakeRangeFromAbs(int a1,int a2) } - (void) moveCursorLeft: sender { + /* Do nothing if we are at beginning of text */ + if (selected_range.location == 0) + return; + [self setSelectedRange: [self selectionRangeForProposedRange: - NSMakeRange ([self selectedRange].location - 1, 0) + NSMakeRange (selected_range.location - 1, 0) granularity: NSSelectByCharacter]]; currentCursorX = [self rectForCharacterIndex: - [self selectedRange].location].origin.x; + selected_range.location].origin.x; } - (void) moveCursorRight: sender { + /* Do nothing if we are at end of text */ + if (selected_range.location == [self textLength]) + return; + [self setSelectedRange: [self selectionRangeForProposedRange: - NSMakeRange (MIN (NSMaxRange ([self selectedRange]) + 1, + NSMakeRange (MIN (NSMaxRange (selected_range) + 1, [self textLength]), 0) granularity: NSSelectByCharacter]]; currentCursorX = [self rectForCharacterIndex: - [self selectedRange].location].origin.x; + selected_range.location].origin.x; } // @@ -1759,7 +1652,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) [_window makeFirstResponder: self]; - switch([theEvent clickCount]) + switch ([theEvent clickCount]) { case 1: granularity = NSSelectByCharacter; break; @@ -1780,13 +1673,13 @@ static NSRange MakeRangeFromAbs(int a1,int a2) [self lockFocus]; // clean up before doing the dragging - if ([self selectedRange].length == 0) // remove old cursor + if (selected_range.length == 0) // remove old cursor { - [self drawInsertionPointAtIndex: [self selectedRange].location + [self drawInsertionPointAtIndex: selected_range.location color: nil turnedOn: NO]; } else - [self drawSelectionAsRangeNoCaret: [self selectedRange]]; + [self drawSelectionAsRangeNoCaret: selected_range]; // make this non - blocking (or make use of timed entries) for (currentEvent = [_window @@ -1906,7 +1799,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) { [self drawPlainLinesInLineRange: redrawLineRange]; } - [self drawSelectionAsRange: [self selectedRange]]; + [self drawSelectionAsRange: selected_range]; } if ([self drawsBackground]) // clean up the remaining area under text of us @@ -1927,7 +1820,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) if (![lineLayoutInformation count] || [[lineLayoutInformation lastObject] type] == LineLayoutInfoType_Paragraph) - [self drawSelectionAsRange: [self selectedRange]]; + [self drawSelectionAsRange: selected_range]; } } @@ -1958,7 +1851,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) - (void) insertText: insertObjc { - NSRange selectedRange = [self selectedRange]; + NSRange selectedRange = selected_range; int lineIndex = [self lineLayoutIndexForCharacterIndex: selectedRange.location]; int origLineIndex = lineIndex; @@ -1986,7 +1879,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) if ([self isRichText]) { - [self replaceRange: [self selectedRange] + [self replaceRange: selected_range withAttributedString: [insertObjc isKindOfClass: [NSAttributedString class]]? insertObjc: @@ -1997,7 +1890,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) } else { - [self replaceRange: [self selectedRange] withString: insertString]; + [self replaceRange: selected_range withString: insertString]; } redrawLineRange.length = [self rebuildLineLayoutInformationStartingAtLine: redrawLineRange.location @@ -2011,14 +1904,15 @@ static NSRange MakeRangeFromAbs(int a1,int a2) // move cursor [self selectionRangeForProposedRange: ] [self setSelectedRange: - NSMakeRange ([self selectedRange].location + [insertString length], 0)]; + NSMakeRange (selected_range.location + [insertString length], 0)]; // remember x for row - stable cursor movements currentCursorX = [self rectForCharacterIndex: - [self selectedRange].location].origin.x; + selected_range.location].origin.x; + // remember x for row - stable cursor movements currentCursorY = [self rectForCharacterIndex: - [self selectedRange].location].origin.y; + selected_range.location].origin.y; redrawLineRange = NSIntersectionRange (redrawLineRange, [self lineRangeForRect: @@ -2103,10 +1997,11 @@ static NSRange MakeRangeFromAbs(int a1,int a2) // remember x for row - stable cursor movements currentCursorX = [self rectForCharacterIndex: - [self selectedRange].location].origin.x; + selected_range.location].origin.x; + // remember x for row - stable cursor movements currentCursorY = [self rectForCharacterIndex: - [self selectedRange].location].origin.y; + selected_range.location].origin.y; redrawLineRange = NSIntersectionRange (redrawLineRange, @@ -2192,7 +2087,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) } // Special Characters for generic NSText - switch(keyCode) + switch (keyCode) { case NSUpArrowFunctionKey: [self moveCursorUp: self]; @@ -2206,8 +2101,20 @@ static NSRange MakeRangeFromAbs(int a1,int a2) case NSRightArrowFunctionKey: [self moveCursorRight: self]; return; + case NSDeleteFunctionKey: + if (selected_range.location != [self textLength]) + { + /* Not at the end of text -- delete following character */ + [self deleteRange: + [self selectionRangeForProposedRange: + NSMakeRange (selected_range.location, 1) + granularity: NSSelectByCharacter] + backspace: NO]; + return; + } + /* end of text: behave the same way as NSBackspaceKey */ case NSBackspaceKey: - [self deleteRange: [self selectedRange] backspace: YES]; + [self deleteRange: selected_range backspace: YES]; return; #if 1 case 0x6d: // end - key: debugging: enforce complete re - layout @@ -2252,7 +2159,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) if ([self shouldDrawInsertionPoint]) { - [self drawInsertionPointAtIndex: [self selectedRange].location + [self drawInsertionPointAtIndex: selected_range.location color: nil turnedOn: NO]; // stop timed entry @@ -2278,7 +2185,7 @@ static NSRange MakeRangeFromAbs(int a1,int a2) //if ([self shouldDrawInsertionPoint]) // { // [self lockFocus]; - // [self drawInsertionPointAtIndex: [self selectedRange].location + // [self drawInsertionPointAtIndex: selected_range.location // color: [NSColor blackColor] turnedOn: YES]; // [self unlockFocus]; // // restart timed entry @@ -2619,13 +2526,13 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, delta: (int) insertionDelta actualLine: (int) insertionLineIndex { - NSDictionary *attributes = [self defaultTypingAttributes]; - NSPoint drawingPoint = NSZeroPoint; - _GNUTextScanner *parscanner; - float width = _frame.size.width; - unsigned startingIndex = 0,currentLineIndex; - _GNULineLayoutInfo *lastValidLineInfo = nil; - NSArray *ghostArray = nil; // for optimization detection + NSDictionary *attributes = [self defaultTypingAttributes]; + NSPoint drawingPoint = NSZeroPoint; + NSScanner *pScanner; + float width = _frame.size.width; + unsigned startingIndex = 0,currentLineIndex; + _GNULineLayoutInfo *lastValidLineInfo = nil; + NSArray *ghostArray = nil; // for optimization detection _GNUSeekableArrayEnumerator *prevArrayEnum = nil; NSCharacterSet *invSelectionWordGranularitySet = [selectionWordGranularitySet invertedSet]; @@ -2684,37 +2591,39 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, currentLineIndex = aLine; // each paragraph - for (parscanner - = [_GNUTextScanner - scannerWithString: parsedString = [[self string] - substringFromIndex: - startingIndex] - set: selectionParagraphGranularitySet - invertedSet: invSelectionParagraphGranularitySet]; - ![parscanner isAtEnd];) + + parsedString = [[self string] substringFromIndex: startingIndex]; + pScanner = [NSScanner scannerWithString: parsedString]; + [pScanner setCharactersToBeSkipped: nil]; + while ([pScanner isAtEnd] == NO) { - _GNUTextScanner *linescanner; + NSScanner *lScanner; NSString *paragraph; - NSRange paragraphRange, leadingNlRange, trailingNlRange; - unsigned startingParagraphIndex - = [parscanner scanLocation] + startingIndex; - unsigned startingLineCharIndex = startingParagraphIndex; - BOOL isBuckled = NO, inBuckling = NO; - - leadingNlRange = [parscanner scanSetCharacters]; - // add the leading newlines of current paragraph - // if any (only the first time) - if (leadingNlRange.length) - { - [self addNewlines: leadingNlRange - intoLayoutArray: lineLayoutInformation - attributes: attributes - atPoint: &drawingPoint - width: width - characterIndex: startingLineCharIndex - ghostEnumerator: prevArrayEnum - didShift: &nlDidShift - verticalDisplacement: &yDisplacement]; + NSRange paragraphRange, leadingNlRange, trailingNlRange; + unsigned currentLoc = [pScanner scanLocation]; + unsigned startingParagraphIndex = currentLoc + startingIndex; + unsigned startingLineCharIndex = startingParagraphIndex; + BOOL isBuckled = NO, inBuckling = NO; + + leadingNlRange + = scanRange(pScanner, selectionParagraphGranularitySet); + paragraphRange + = scanRange(pScanner, invSelectionParagraphGranularitySet); + trailingNlRange + = scanRange(pScanner, selectionParagraphGranularitySet); + + if (leadingNlRange.length > 0) + { + [self addNewlines: leadingNlRange + intoLayoutArray: lineLayoutInformation + attributes: attributes + atPoint: &drawingPoint + width: width + characterIndex: startingLineCharIndex + ghostEnumerator: prevArrayEnum + didShift: &nlDidShift + verticalDisplacement: &yDisplacement]; + if (nlDidShift) { if (insertionDelta == 1) @@ -2733,43 +2642,41 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, startingLineCharIndex += leadingNlRange.length; currentLineIndex += leadingNlRange.length; } - paragraphRange = [parscanner scanNonSetCharacters]; - - trailingNlRange = [parscanner scanSetCharacters]; + // each line - for (linescanner - = [_GNUTextScanner - scannerWithString: paragraph = [parsedString - substringWithRange: - paragraphRange] - set: selectionWordGranularitySet - invertedSet: invSelectionWordGranularitySet]; - ![linescanner isAtEnd];) + paragraph = [parsedString substringWithRange: paragraphRange]; + lScanner = [NSScanner scannerWithString: paragraph]; + [lScanner setCharactersToBeSkipped: nil]; + while ([lScanner isAtEnd] == NO) { - NSRect currentLineRect = NSMakeRect (0, drawingPoint.y, 0, 0); + NSRect currentLineRect = NSMakeRect (0, drawingPoint.y, 0, 0); // starts with zero, do not confuse with startingLineCharIndex - unsigned localLineStartIndex = [linescanner scanLocation]; - NSSize advanceSize = NSZeroSize; + unsigned localLineStartIndex = [lScanner scanLocation]; + NSSize advanceSize = NSZeroSize; // scan the individual words to the end of the line - for (; ![linescanner isAtEnd]; drawingPoint.x += advanceSize.width) + for (; ![lScanner isAtEnd]; drawingPoint.x += advanceSize.width) { - NSRange currentStringRange, trailingSpacesRange; - NSRange leadingSpacesRange; - unsigned scannerPosition = [linescanner scanLocation]; + NSRange currentStringRange, trailingSpacesRange; + NSRange leadingSpacesRange; + unsigned scannerPosition = [lScanner scanLocation]; // snack next word // leading spaces: only first time - leadingSpacesRange = [linescanner scanSetCharacters]; - currentStringRange = [linescanner scanNonSetCharacters]; - trailingSpacesRange = [linescanner scanSetCharacters]; + leadingSpacesRange + = scanRange(lScanner, selectionWordGranularitySet); + currentStringRange + = scanRange(lScanner, invSelectionWordGranularitySet); + trailingSpacesRange + = scanRange(lScanner, selectionWordGranularitySet); + if (leadingSpacesRange.length) - currentStringRange = NSUnionRange (leadingSpacesRange, + currentStringRange = NSUnionRange(leadingSpacesRange, currentStringRange); if (trailingSpacesRange.length) - currentStringRange = NSUnionRange (trailingSpacesRange, + currentStringRange = NSUnionRange(trailingSpacesRange, currentStringRange); // evaluate size of current word and line so far @@ -2849,7 +2756,7 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, _GNULineLayoutInfo *ghostInfo = nil, *thisInfo; // undo layout of last word - [linescanner setScanLocation: scannerPosition]; + [lScanner setScanLocation: scannerPosition]; currentLineRect.origin.x = 0; currentLineRect.origin.y = drawingPoint.y; @@ -2952,10 +2859,10 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, // newline - induced premature lineending: flush } - else if ([linescanner isAtEnd]) + else if ([lScanner isAtEnd]) { _GNULineLayoutInfo *thisInfo; - scannerPosition = [linescanner scanLocation]; + scannerPosition = [lScanner scanLocation]; [lineLayoutInformation addObject: (thisInfo = [_GNULineLayoutInfo @@ -3188,7 +3095,7 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, return; [self drawRectNoSelection: rect]; - [self drawSelectionAsRange: [self selectedRange]]; + [self drawSelectionAsRange: selected_range]; } // text lays out from top to bottom @@ -3224,15 +3131,15 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, [pboard declareTypes: types owner: self]; - [pboard setString: [[self string] substringWithRange: [self selectedRange]] + [pboard setString: [[self string] substringWithRange: selected_range] forType: NSStringPboardType]; if ([self isRichText]) - [pboard setData: [self RTFFromRange: [self selectedRange]] + [pboard setData: [self RTFFromRange: selected_range] forType: NSRTFPboardType]; if ([self importsGraphics]) - [pboard setData: [self RTFDFromRange: [self selectedRange]] + [pboard setData: [self RTFDFromRange: selected_range] forType: NSRTFDPboardType]; } @@ -3248,11 +3155,11 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, - (void) delete: sender { - [self deleteRange: [self selectedRange] backspace: NO]; + [self deleteRange: selected_range backspace: NO]; } - (void) cut: sender { - if ([self selectedRange].length) + if (selected_range.length) { [self copy: self]; [self delete: self]; @@ -3344,7 +3251,7 @@ _relocLayoutArray (NSMutableArray *lineLayoutInformation, NSRange errorRange = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString: [self string] - startingAt: NSMaxRange ([self selectedRange])]; + startingAt: NSMaxRange (selected_range)]; if (errorRange.length) [self setSelectedRange: errorRange]; diff --git a/Source/NSTextContainer.m b/Source/NSTextContainer.m index fa96a06e5..576daaa62 100644 --- a/Source/NSTextContainer.m +++ b/Source/NSTextContainer.m @@ -32,26 +32,26 @@ #import @interface NSTextContainer (TextViewObserver) -- (void) _textViewFrameChanged: (NSNotification *)aNotification; +- (void) _textViewFrameChanged: (NSNotification*)aNotification; @end @implementation NSTextContainer (TextViewObserver) -- (void) _textViewFrameChanged: (NSNotification *)aNotification +- (void) _textViewFrameChanged: (NSNotification*)aNotification { id textView; NSSize newSize; NSSize inset; - if ( _observingFrameChanges ) + if (_observingFrameChanges) { textView = [aNotification object]; newSize = [textView frame].size; inset = [textView textContainerInset]; - if ( _widthTracksTextView ) + if (_widthTracksTextView) newSize.width = MAX(newSize.width - (inset.width * 2.0), 0.0); - if ( _heightTracksTextView ) + if (_heightTracksTextView) newSize.height = MAX(newSize.height - (inset.height * 2.0), 0.0); [self setContainerSize: newSize]; @@ -64,8 +64,10 @@ + (void) initialize { - if ( self == [NSTextContainer class] ) - [self setVersion: 1]; + if (self == [NSTextContainer class]) + { + [self setVersion: 1]; + } } - (id) initWithContainerSize: (NSSize)aSize @@ -82,36 +84,43 @@ return self; } -- (void) setLayoutManager: (NSLayoutManager *)aLayoutManager +- (void) setLayoutManager: (NSLayoutManager*)aLayoutManager { ASSIGN(_layoutManager, aLayoutManager); } -- (NSLayoutManager *) layoutManager +- (NSLayoutManager*) layoutManager { return _layoutManager; } -- (void) replaceLayoutManager: (NSLayoutManager *)newLayoutManager +- (void) replaceLayoutManager: (NSLayoutManager*)newLayoutManager { - id textStorage = [_layoutManager textStorage]; - NSArray *textContainers = [_layoutManager textContainers]; - unsigned i, count = [textContainers count]; - - [textStorage removeLayoutManager: _layoutManager]; - [textStorage addLayoutManager: newLayoutManager]; - [_layoutManager setTextStorage: nil]; - - for ( i = 0; i < count; i++ ) + if (newLayoutManager != _layoutManager) { - [newLayoutManager addTextContainer: [textContainers objectAtIndex: i]]; - [_layoutManager removeTextContainerAtIndex: i]; + id textStorage = [_layoutManager textStorage]; + NSArray *textContainers = [_layoutManager textContainers]; + unsigned i, count = [textContainers count]; + + [textStorage removeLayoutManager: _layoutManager]; + [textStorage addLayoutManager: newLayoutManager]; + [_layoutManager setTextStorage: nil]; + + for (i = 0; i < count; i++) + { + NSTextContainer *container; + + container = RETAIN([textContainers objectAtIndex: i]); + [_layoutManager removeTextContainerAtIndex: i]; + [newLayoutManager addTextContainer: container]; + RELEASE(container); + } } } -- (void) setTextView: (NSTextView *)aTextView +- (void) setTextView: (NSTextView*)aTextView { - if ( _textView ) + if (_textView) { [_textView setTextContainer: nil]; [[NSNotificationCenter defaultCenter] removeObserver: self]; @@ -119,17 +128,17 @@ ASSIGN(_textView, aTextView); - if ( aTextView ) + if (aTextView) { [_textView setTextContainer: self]; [[NSNotificationCenter defaultCenter] addObserver: self - selector: @selector(_textViewFrameChanged: ) + selector: @selector(_textViewFrameChanged:) name: NSViewFrameDidChangeNotification object: _textView]; } } -- (NSTextView *) textView +- (NSTextView*) textView { return _textView; } @@ -138,7 +147,7 @@ { _containerRect = NSMakeRect(0, 0, aSize.width, aSize.height); - if ( _layoutManager ) + if (_layoutManager) [_layoutManager textContainerChangedGeometry: self]; } @@ -173,7 +182,7 @@ { _lineFragmentPadding = aFloat; - if ( _layoutManager ) + if (_layoutManager) [_layoutManager textContainerChangedGeometry: self]; } @@ -185,7 +194,7 @@ - (NSRect) lineFragmentRectForProposedRect: (NSRect)proposedRect sweepDirection: (NSLineSweepDirection)sweepDir movementDirection: (NSLineMovementDirection)moveDir - remainingRect: (NSRect *)remainingRect; + remainingRect: (NSRect*)remainingRect; { // line fragment rectangle simply must fit within the container rectangle *remainingRect = NSZeroRect; diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 685625772..a7d69dd61 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -1,3 +1,27 @@ +/* + NSTextView.m + + Copyright (C) 1999 Free Software Foundation, Inc. + + 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 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, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + #include #include #include @@ -24,79 +48,90 @@ /* Class methods */ -+ (void)initialize ++ (void) initialize { [super initialize]; - if([self class] == [NSTextView class]) + if ([self class] == [NSTextView class]) { - [self setVersion:1]; + [self setVersion: 1]; [self registerForServices]; } } -+ (void)registerForServices ++ (void) registerForServices { - // Talk to Richard about how to do this properly. + NSArray *r; + NSArray *s; + + /* + * FIXME - should register for all types of data we support, not just string. + */ + r = [NSArray arrayWithObjects: NSStringPboardType, nil]; + s = [NSArray arrayWithObjects: NSStringPboardType, nil]; + + [[NSApplication sharedApplication] registerServicesMenuSendTypes: s + returnTypes: r]; } /* Initializing Methods */ -- (id)initWithFrame:(NSRect)frameRect - textContainer:(NSTextContainer *)aTextContainer +- (id) initWithFrame: (NSRect)frameRect + textContainer: (NSTextContainer*)aTextContainer { - self = [super initWithFrame:frameRect]; + self = [super initWithFrame: frameRect]; - [self setTextContainer:aTextContainer]; - [self setEditable:YES]; + [self setTextContainer: aTextContainer]; + [self setEditable: YES]; return self; } -- (id)initWithFrame:(NSRect)frameRect +- (id) initWithFrame: (NSRect)frameRect { textStorage = [[NSTextStorage alloc] init]; layoutManager = [[NSLayoutManager alloc] init]; - [textStorage addLayoutManager:layoutManager]; - [layoutManager release]; + [textStorage addLayoutManager: layoutManager]; + RELEASE(layoutManager); - textContainer = [[NSTextContainer alloc] initWithContainerSize:frameRect.size]; - [layoutManager addTextContainer:textContainer]; - [textContainer release]; + textContainer + = [[NSTextContainer alloc] initWithContainerSize: frameRect.size]; + [layoutManager addTextContainer: textContainer]; + RELEASE(textContainer); - return [self initWithFrame:frameRect textContainer:textContainer]; + return [self initWithFrame: frameRect textContainer: textContainer]; } -- (void)setTextContainer:(NSTextContainer *)aTextContainer +- (void) setTextContainer: (NSTextContainer*)aTextContainer { ASSIGN(textContainer, aTextContainer); } -- (NSTextContainer *)textContainer +- (NSTextContainer*) textContainer { return textContainer; } -- (void)replaceTextContainer:(NSTextContainer *)aTextContainer +- (void) replaceTextContainer: (NSTextContainer*)aTextContainer { // Notify layoutManager of change? ASSIGN(textContainer, aTextContainer); } -- (void)setTextContainerInset:(NSSize)inset +- (void) setTextContainerInset: (NSSize)inset { textContainerInset = inset; } -- (NSSize)textContainerInset +- (NSSize) textContainerInset { return textContainerInset; } -- (NSPoint)textContainerOrigin +- (NSPoint) textContainerOrigin { // use bounds, inset, and used rect. NSRect bRect = [self bounds]; @@ -104,70 +139,70 @@ return NSZeroPoint; } -- (void)invalidateTextContainerOrigin +- (void) invalidateTextContainerOrigin { tv_resetTextContainerOrigin = YES; } -- (NSLayoutManager *)layoutManager +- (NSLayoutManager*) layoutManager { return [textContainer layoutManager]; } -- (NSTextStorage *)textStorage +- (NSTextStorage*) textStorage { return textStorage; } -- (void)setBackgroundColor:(NSColor *)aColor +- (void) setBackgroundColor: (NSColor*)aColor { ASSIGN(tv_backGroundColor, aColor); } -- (NSColor *)backgroundColor +- (NSColor*) backgroundColor { return tv_backGroundColor; } -- (void)setDrawsBackground:(BOOL)flag +- (void) setDrawsBackground: (BOOL)flag { tv_drawsBackground = flag; } -- (BOOL)drawsBackground +- (BOOL) drawsBackground { return tv_drawsBackground; } -- (void)setNeedsDisplayInRect:(NSRect)aRect - avoidAdditionalLayout:(BOOL)flag +- (void) setNeedsDisplayInRect: (NSRect)aRect + avoidAdditionalLayout: (BOOL)flag { /* - NSRange glyphsToDraw = [layoutManager -glyphRangeForTextContainer:textContainer]; + NSRange glyphsToDraw; + glyphsToDraw = [layoutManager glyphRangeForTextContainer: textContainer]; [self lockFocus]; - [layoutManager drawGlyphsForGlyphRange:glyphsToDraw - atPoint:[self frame].origin]; + [layoutManager drawGlyphsForGlyphRange: glyphsToDraw + atPoint: [self frame].origin]; [self unlockFocus]; */ } /* We override NSView's setNeedsDisplayInRect: */ -- (void)setNeedsDisplayInRect:(NSRect)aRect +- (void) setNeedsDisplayInRect: (NSRect)aRect { - [self setNeedsDisplayInRect:aRect avoidAdditionalLayout:NO]; + [self setNeedsDisplayInRect: aRect avoidAdditionalLayout: NO]; } -- (BOOL)shouldDrawInsertionPoint +- (BOOL) shouldDrawInsertionPoint { return tv_shouldDrawInsertionPoint; } -- (void)drawInsertionPointInRect:(NSRect)aRect - color:(NSColor *)aColor - turnedOn:(BOOL)flag +- (void) drawInsertionPointInRect: (NSRect)aRect + color: (NSColor*)aColor + turnedOn: (BOOL)flag { [self lockFocus]; @@ -191,18 +226,18 @@ glyphRangeForTextContainer:textContainer]; [_window flushWindow]; } -- (void)setConstrainedFrameSize:(NSSize)desiredSize +- (void) setConstrainedFrameSize: (NSSize)desiredSize { // some black magic here. - [self setFrameSize:desiredSize]; + [self setFrameSize: desiredSize]; } -- (void)cleanUpAfterDragOperation +- (void) cleanUpAfterDragOperation { // release drag information } -- (void)setEditable:(BOOL)flag +- (void) setEditable: (BOOL)flag { if (flag) tv_selectable = flag; @@ -210,32 +245,32 @@ glyphRangeForTextContainer:textContainer]; tv_editable = flag; } -- (BOOL)isEditable +- (BOOL) isEditable { return tv_editable; } -- (void)setSelectable:(BOOL)flag +- (void) setSelectable: (BOOL)flag { tv_selectable = flag; } -- (BOOL)isSelectable +- (BOOL) isSelectable { return tv_selectable; } -- (void)setFieldEditor:(BOOL)flag +- (void) setFieldEditor: (BOOL)flag { tv_fieldEditor = flag; } -- (BOOL)isFieldEditor +- (BOOL) isFieldEditor { return tv_fieldEditor; } -- (void)setRichText:(BOOL)flag +- (void) setRichText: (BOOL)flag { if (!flag) tv_acceptDraggedFiles = flag; @@ -243,12 +278,12 @@ glyphRangeForTextContainer:textContainer]; tv_richText = flag; } -- (BOOL)isRichText +- (BOOL) isRichText { return tv_richText; } -- (void)setImportsGraphics:(BOOL)flag +- (void) setImportsGraphics: (BOOL)flag { if (flag) tv_richText = flag; @@ -256,155 +291,155 @@ glyphRangeForTextContainer:textContainer]; tv_acceptDraggedFiles = flag; } -- (BOOL)importsGraphics +- (BOOL) importsGraphics { return tv_acceptDraggedFiles; } -- (void)setUsesFontPanel:(BOOL)flag +- (void) setUsesFontPanel: (BOOL)flag { tv_usesFontPanel = flag; } -- (BOOL)usesFontPanel +- (BOOL) usesFontPanel { return tv_usesFontPanel; } -- (void)setUsesRuler:(BOOL)flag +- (void) setUsesRuler: (BOOL)flag { tv_usesRuler = flag; } -- (BOOL)usesRuler +- (BOOL) usesRuler { return tv_usesRuler; } -- (void)setRulerVisible:(BOOL)flag +- (void) setRulerVisible: (BOOL)flag { tv_rulerVisible = flag; } -- (BOOL)isRulerVisible +- (BOOL) isRulerVisible { return tv_rulerVisible; } -- (void)setSelectedRange:(NSRange)charRange +- (void) setSelectedRange: (NSRange)charRange { NSLog(@"setSelectedRange (%d, %d)", charRange.location, charRange.length); /* [[NSNotificationCenter defaultCenter] - postNotificationName:NSTextViewDidChangeSelectionNotification - object:self]; + postNotificationName: NSTextViewDidChangeSelectionNotification + object: self]; */ tv_selectedRange = charRange; - [self setSelectionGranularity:NSSelectByCharacter]; + [self setSelectionGranularity: NSSelectByCharacter]; // Also removes the marking from // marked text if the new selection is greater than the marked region. } -- (NSRange)selectedRange +- (NSRange) selectedRange { return tv_selectedRange; } -- (void)setSelectedRange:(NSRange)charRange - affinity:(NSSelectionAffinity)affinity - stillSelecting:(BOOL)flag +- (void) setSelectedRange: (NSRange)charRange + affinity: (NSSelectionAffinity)affinity + stillSelecting: (BOOL)flag { NSDebugLLog(@"NSText", @"setSelectedRange stillSelecting."); tv_selectedRange = charRange; - [self setSelectionGranularity:NSSelectByCharacter]; + [self setSelectionGranularity: NSSelectByCharacter]; // FIXME, more. } -- (NSSelectionAffinity)selectionAffinity +- (NSSelectionAffinity) selectionAffinity { return tv_selectionAffinity; } -- (void)setSelectionGranularity:(NSSelectionGranularity)granularity +- (void) setSelectionGranularity: (NSSelectionGranularity)granularity { tv_selectionGranularity = granularity; } -- (NSSelectionGranularity)selectionGranularity +- (NSSelectionGranularity) selectionGranularity { return tv_selectionGranularity; } -- (void)setInsertionPointColor:(NSColor *)aColor +- (void) setInsertionPointColor: (NSColor*)aColor { ASSIGN(tv_caretColor, aColor); } -- (NSColor *)insertionPointColor +- (NSColor*) insertionPointColor { return tv_caretColor; } -- (void)updateInsertionPointStateAndRestartTimer:(BOOL)flag +- (void) updateInsertionPointStateAndRestartTimer: (BOOL)flag { // tv_caretLocation = // restart blinking timer. } -- (void)setSelectedTextAttributes:(NSDictionary *)attributes +- (void) setSelectedTextAttributes: (NSDictionary*)attributes { ASSIGN(tv_selectedTextAttributes, attributes); } -- (NSDictionary *)selectedTextAttributes +- (NSDictionary*) selectedTextAttributes { return tv_selectedTextAttributes; } -- (NSRange)markedRange +- (NSRange) markedRange { // calculate return NSMakeRange(NSNotFound, 0); } -- (void)setMarkedTextAttributes:(NSDictionary *)attributes +- (void) setMarkedTextAttributes: (NSDictionary*)attributes { ASSIGN(tv_markedTextAttributes, attributes); } -- (NSDictionary *)markedTextAttributes +- (NSDictionary*) markedTextAttributes { return tv_markedTextAttributes; } -- (NSString *)preferredPasteboardTypeFromArray:(NSArray *)availableTypes - restrictedToTypesFromArray:(NSArray *)allowedTypes +- (NSString*) preferredPasteboardTypeFromArray: (NSArray*)availableTypes + restrictedToTypesFromArray: (NSArray*)allowedTypes { // No idea. } -- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard +- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard { /* Reads the text view's preferred type of data from the pasteboard specified by the pboard parameter. This method -invokes the preferredPasteboardTypeFromArray:restrictedToTypesFromArray: +invokes the preferredPasteboardTypeFromArray: restrictedToTypesFromArray: method to determine the text view's preferred type of data and then reads the data using the -readSelectionFromPasteboard:type: method. Returns YES if the +readSelectionFromPasteboard: type: method. Returns YES if the data was successfully read. */ return NO; } -- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard - type:(NSString *)type +- (BOOL) readSelectionFromPasteboard: (NSPasteboard*)pboard + type: (NSString*)type { /* Reads data of the given type from pboard. The new data is placed at the @@ -419,18 +454,18 @@ of characters (if any) to be replaced by the new data. return NO; } -- (NSArray *)readablePasteboardTypes +- (NSArray*) readablePasteboardTypes { // get default types, what are they? } -- (NSArray *)writablePasteboardTypes +- (NSArray*) writablePasteboardTypes { // the selected text can be written to the pasteboard with which types. } -- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard - type:(NSString *)type +- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard + type: (NSString*)type { /* Writes the current selection to pboard using the given type. Returns YES @@ -443,8 +478,8 @@ overridden version does not. return NO; } -- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard - types:(NSArray *)types +- (BOOL) writeSelectionToPasteboard: (NSPasteboard*)pboard + types: (NSArray*)types { /* Writes the current selection to pboard under each type in the types @@ -458,7 +493,7 @@ other than copy/paste or dragging. */ return NO; } -- (void)alignJustified:(id)sender +- (void) alignJustified: (id)sender { /* if (!tv_richText) @@ -468,19 +503,19 @@ other than copy/paste or dragging. */ */ } -- (void)changeColor:(id)sender +- (void) changeColor: (id)sender { // NSColor *aColor = [sender color]; // sets the color for the selected range. } -- (void)setAlignment:(NSTextAlignment)alignment - range:(NSRange)aRange +- (void) setAlignment: (NSTextAlignment)alignment + range: (NSRange)aRange { /* Sets the alignment of the paragraphs containing characters in aRange to -alignment. alignment is one of: +alignment. alignment is one of: NSLeftTextAlignment NSRightTextAlignment @@ -490,24 +525,24 @@ alignment. alignment is one of: */ } -- (void)setTypingAttributes:(NSDictionary *)attributes +- (void) setTypingAttributes: (NSDictionary*)attributes { // more? ASSIGN(tv_typingAttributes, attributes); } -- (NSDictionary *)typingAttributes +- (NSDictionary*) typingAttributes { return tv_typingAttributes; } -- (void)useStandardKerning:(id)sender +- (void) useStandardKerning: (id)sender { // rekern for selected range if rich text, else rekern entire document. } -- (void)lowerBaseline:(id)sender +- (void) lowerBaseline: (id)sender { /* if (tv_richText) @@ -517,7 +552,7 @@ alignment. alignment is one of: */ } -- (void)raiseBaseline:(id)sender +- (void) raiseBaseline: (id)sender { /* if (tv_richText) @@ -527,7 +562,7 @@ alignment. alignment is one of: */ } -- (void)turnOffKerning:(id)sender +- (void) turnOffKerning: (id)sender { /* if (tv_richText) @@ -537,7 +572,7 @@ alignment. alignment is one of: */ } -- (void)loosenKerning:(id)sender +- (void) loosenKerning: (id)sender { /* if (tv_richText) @@ -547,7 +582,7 @@ alignment. alignment is one of: */ } -- (void)tightenKerning:(id)sender +- (void) tightenKerning: (id)sender { /* if (tv_richText) @@ -557,31 +592,31 @@ alignment. alignment is one of: */ } -- (void)useStandardLigatures:(id)sender +- (void) useStandardLigatures: (id)sender { // well. } -- (void)turnOffLigatures:(id)sender +- (void) turnOffLigatures: (id)sender { // sure. } -- (void)useAllLigatures:(id)sender +- (void) useAllLigatures: (id)sender { // as you say. } -- (void)clickedOnLink:(id)link - atIndex:(unsigned int)charIndex +- (void) clickedOnLink: (id)link + atIndex: (unsigned int)charIndex { /* Notifies the delegate that the user clicked in a link at the specified charIndex. The delegate may take any appropriate actions to handle the -click in its textView:clickedOnLink:atIndex: method.Notifies the delegate +click in its textView: clickedOnLink: atIndex: method.Notifies the delegate that the user clicked in a link at the specified charIndex. The delegate may take any appropriate actions to handle the click in its -textView:clickedOnLink:atIndex: method. */ +textView: clickedOnLink: atIndex: method. */ } @@ -590,55 +625,55 @@ The text is inserted at the insertion point if there is one, otherwise replacing the selection. */ -- (void)pasteAsPlainText:(id)sender +- (void) pasteAsPlainText: (id)sender { - [self insertText:[sender string]]; + [self insertText: [sender string]]; } -- (void)pasteAsRichText:(id)sender +- (void) pasteAsRichText: (id)sender { - [self insertText:[sender string]]; + [self insertText: [sender string]]; } -- (void)updateFontPanel +- (void) updateFontPanel { - // [fontPanel setFont:[self fontFromRange]]; + // [fontPanel setFont: [self fontFromRange]]; } -- (void)updateRuler +- (void) updateRuler { // ruler! } -- (NSArray *)acceptableDragTypes +- (NSArray*) acceptableDragTypes { } -- (void)updateDragTypeRegistration +- (void) updateDragTypeRegistration { } -- (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange - granularity:(NSSelectionGranularity)granularity +- (NSRange) selectionRangeForProposedRange: (NSRange)proposedSelRange + granularity: (NSSelectionGranularity)granularity { NSRange retRange; switch (granularity) { - case NSSelectByParagraph: + case NSSelectByParagraph: // we need to: 1, find how far to end of paragraph; 2, increase // range. - case NSSelectByWord: + case NSSelectByWord: // we need to: 1, find how far to end of word; 2, increase range. - case NSSelectByCharacter: - default: + case NSSelectByCharacter: + default: retRange = proposedSelRange; } return retRange; } -- (NSRange)rangeForUserCharacterAttributeChange +- (NSRange) rangeForUserCharacterAttributeChange { if (!tv_editable || !tv_usesFontPanel) return NSMakeRange(NSNotFound, 0); @@ -649,19 +684,19 @@ replacing the selection. return NSMakeRange(NSNotFound, 0); // should be entire contents. } -- (NSRange)rangeForUserParagraphAttributeChange +- (NSRange) rangeForUserParagraphAttributeChange { if (!tv_editable) return NSMakeRange(NSNotFound, 0); if (tv_richText) - return [self selectionRangeForProposedRange:tv_selectedRange - granularity:NSSelectByParagraph]; + return [self selectionRangeForProposedRange: tv_selectedRange + granularity: NSSelectByParagraph]; else return NSMakeRange(NSNotFound, 0); // should be entire contents. } -- (NSRange)rangeForUserTextChange +- (NSRange) rangeForUserTextChange { if (!tv_editable || !tv_usesRuler) return NSMakeRange(NSNotFound, 0); @@ -669,13 +704,13 @@ replacing the selection. return tv_selectedRange; } -- (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange - replacementString:(NSString *)replacementString +- (BOOL) shouldChangeTextInRange: (NSRange)affectedCharRange + replacementString: (NSString*)replacementString { /* This method checks with the delegate as needed using textShouldBeginEditing: and -textView:shouldChangeTextInRange:replacementString:, returning YES to +textView: shouldChangeTextInRange: replacementString: , returning YES to allow the change, and NO to prohibit it. This method must be invoked at the start of any sequence of user-initiated @@ -690,32 +725,32 @@ the affected range or replacement string before beginning changes, pass return NO; } -- (void)didChangeText +- (void) didChangeText { [[NSNotificationCenter defaultCenter] - postNotificationName:NSTextDidChangeNotification object:self]; + postNotificationName: NSTextDidChangeNotification object: self]; } -- (void)setSmartInsertDeleteEnabled:(BOOL)flag +- (void) setSmartInsertDeleteEnabled: (BOOL)flag { tv_smartInsertDelete = flag; } -- (BOOL)smartInsertDeleteEnabled +- (BOOL) smartInsertDeleteEnabled { return tv_smartInsertDelete; } -- (NSRange)smartDeleteRangeForProposedRange:(NSRange)proposedCharRange +- (NSRange) smartDeleteRangeForProposedRange: (NSRange)proposedCharRange { // FIXME. return proposedCharRange; } -- (void)smartInsertForString:(NSString *)aString - replacingRange:(NSRange)charRange - beforeString:(NSString *)beforeString - afterString:(NSString *)afterString +- (void) smartInsertForString: (NSString*)aString + replacingRange: (NSRange)charRange + beforeString: (NSString*)beforeString + afterString: (NSString*)afterString { /* Determines whether whitespace needs to be added around aString to @@ -726,8 +761,8 @@ nil. Both are returned as nil if aString is nil or if smart insertion and deletion is disabled. As part of its implementation, this method calls -smartInsertAfterStringForString:replacingRange: and -smartInsertBeforeStringForString:replacingRange:.To change this method's +smartInsertAfterStringForString: replacingRange: and +smartInsertBeforeStringForString: replacingRange: .To change this method's behavior, override those two methods instead of this one. NSTextView uses this method as necessary. You can also use it in @@ -737,7 +772,7 @@ afterString in order over charRange. */ } -- (BOOL)resignFirstResponder +- (BOOL) resignFirstResponder { /* if (nextRsponder == NSTextView_in_NSLayoutManager) @@ -749,7 +784,7 @@ afterString in order over charRange. */ else { [[NSNotificationCenter defaultCenter] - postNotificationName:NSTextDidEndEditingNotification object:self]; + postNotificationName: NSTextDidEndEditingNotification object: self]; // [self hideSelection]; return YES; } @@ -758,7 +793,7 @@ afterString in order over charRange. */ return YES; } -- (BOOL)becomeFirstResponder +- (BOOL) becomeFirstResponder { /* if (!nextRsponder == NSTextView_in_NSLayoutManager) @@ -770,8 +805,8 @@ afterString in order over charRange. */ return YES; } -- (id)validRequestorForSendType:(NSString *)sendType - returnType:(NSString *)returnType +- (id) validRequestorForSendType: (NSString*)sendType + returnType: (NSString*)returnType { /* Returns self if sendType specifies a type of data the text view can put on @@ -782,7 +817,7 @@ read from the pasteboard; otherwise returns nil. return nil; } -- (int)spellCheckerDocumentTag +- (int) spellCheckerDocumentTag { /* if (!tv_spellTag) @@ -791,13 +826,13 @@ read from the pasteboard; otherwise returns nil. return tv_spellTag; } -- (void)rulerView:(NSRulerView *)aRulerView - didMoveMarker:(NSRulerMarker *)aMarker +- (void) rulerView: (NSRulerView*)aRulerView + didMoveMarker: (NSRulerMarker*)aMarker { /* NSTextView checks for permission to make the change in its -rulerView:shouldMoveMarker: method, which invokes -shouldChangeTextInRange:replacementString: to send out the proper request +rulerView: shouldMoveMarker: method, which invokes +shouldChangeTextInRange: replacementString: to send out the proper request and notifications, and only invokes this method if permission is granted. @@ -805,19 +840,19 @@ method if permission is granted. */ } -- (void)rulerView:(NSRulerView *)aRulerView - didRemoveMarker:(NSRulerMarker *)aMarker +- (void) rulerView: (NSRulerView*)aRulerView + didRemoveMarker: (NSRulerMarker*)aMarker { /* NSTextView checks for permission to move or remove a tab stop in its -rulerView:shouldMoveMarker: method, which invokes -shouldChangeTextInRange:replacementString: to send out the proper request +rulerView: shouldMoveMarker: method, which invokes +shouldChangeTextInRange: replacementString: to send out the proper request and notifications, and only invokes this method if permission is granted. */ } -- (void)rulerView:(NSRulerView *)aRulerView - handleMouseDown:(NSEvent *)theEvent +- (void) rulerView: (NSRulerView*)aRulerView + handleMouseDown: (NSEvent*)theEvent { /* This NSRulerView client method adds a left tab marker to the ruler, but a @@ -828,34 +863,34 @@ NSRulerView class specification. */ } -- (BOOL)rulerView:(NSRulerView *)aRulerView - shouldAddMarker:(NSRulerMarker *)aMarker +- (BOOL) rulerView: (NSRulerView*)aRulerView + shouldAddMarker: (NSRulerMarker*)aMarker { /* This NSRulerView client method controls whether a new tab stop can be added. The receiver checks for permission to make the change by invoking -shouldChangeTextInRange:replacementString: and returning the return value +shouldChangeTextInRange: replacementString: and returning the return value of that message. If the change is allowed, the receiver is then sent a -rulerView:didAddMarker: message. */ +rulerView: didAddMarker: message. */ return NO; } -- (BOOL)rulerView:(NSRulerView *)aRulerView - shouldMoveMarker:(NSRulerMarker *)aMarker +- (BOOL) rulerView: (NSRulerView*)aRulerView + shouldMoveMarker: (NSRulerMarker*)aMarker { /* This NSRulerView client method controls whether an existing tab stop can be moved. The receiver checks for permission to make the change by -invoking shouldChangeTextInRange:replacementString: and returning the +invoking shouldChangeTextInRange: replacementString: and returning the return value of that message. If the change is allowed, the receiver is -then sent a rulerView:didAddMarker: message. */ +then sent a rulerView: didAddMarker: message. */ return NO; } -- (BOOL)rulerView:(NSRulerView *)aRulerView - shouldRemoveMarker:(NSRulerMarker *)aMarker +- (BOOL) rulerView: (NSRulerView*)aRulerView +shouldRemoveMarker: (NSRulerMarker*)aMarker { /* This NSRulerView client method controls whether an existing tab stop @@ -863,14 +898,14 @@ can be removed. Returns YES if aMarker represents an NSTextTab, NO otherwise. Because this method can be invoked repeatedly as the user drags a ruler marker, it returns that value immediately. If the change is allows and the user actually removes the marker, the receiver is also sent a -rulerView:didRemoveMarker: message. */ +rulerView: didRemoveMarker: message. */ return NO; } -- (float)rulerView:(NSRulerView *)aRulerView - willAddMarker:(NSRulerMarker *)aMarker - atLocation:(float)location +- (float) rulerView: (NSRulerView*)aRulerView + willAddMarker: (NSRulerMarker*)aMarker + atLocation: (float)location { /* This NSRulerView client method ensures that the proposed location of @@ -880,9 +915,9 @@ container, returning the modified location. */ return 0.0; } -- (float)rulerView:(NSRulerView *)aRulerView - willMoveMarker:(NSRulerMarker *)aMarker - toLocation:(float)location +- (float) rulerView: (NSRulerView*)aRulerView + willMoveMarker: (NSRulerMarker*)aMarker + toLocation: (float)location { /* This NSRulerView client method ensures that the proposed location of @@ -899,9 +934,9 @@ container, returning the modified location. */ [super setDelegate: anObject]; #define SET_DELEGATE_NOTIFICATION(notif_name) \ - if ([delegate respondsToSelector: @selector(textView##notif_name:)]) \ + if ([delegate respondsToSelector: @selector(textView##notif_name: )]) \ [nc addObserver: delegate \ - selector: @selector(textView##notif_name:) \ + selector: @selector(textView##notif_name: ) \ name: NSTextView##notif_name##Notification \ object: self] @@ -909,69 +944,79 @@ container, returning the modified location. */ SET_DELEGATE_NOTIFICATION(WillChangeNotifyingTextView); } --(void) setString:(NSString *)string +- (void) setString: (NSString*)string { - NSAttributedString *aString = [[[NSAttributedString alloc] - initWithString: string - attributes: [self typingAttributes]] autorelease]; + NSAttributedString *aString; -// [textStorage replaceRange:NSMakeRange(0, [string length]) -// withString:aString]; + aString = [NSAttributedString alloc]; + aString = [aString initWithString: string + attributes: [self typingAttributes]]; + AUTORELEASE(aString); + +// [textStorage replaceRange: NSMakeRange(0, [string length]) +// withString: aString]; [textStorage setAttributedString: aString]; -//replaceCharactersInRange:NSMakeRange(0, [string length]) +//replaceCharactersInRange: NSMakeRange(0, [string length]) // withAttributedString: aString]; -// [textStorage insertAttributedString:aString atIndex:0]; +// [textStorage insertAttributedString: aString atIndex: 0]; } --(void) setText:(NSString *)string {[self setString:string];} +- (void) setText: (NSString*)string +{ + [self setString: string]; +} -- (void)insertText:(NSString *)aString +- (void) insertText: (NSString*)aString { NSDebugLLog(@"NSText", @"%@", aString); - if (![aString isKindOfClass:[NSAttributedString class]]) - aString = [[NSAttributedString alloc] initWithString:aString - attributes:[self typingAttributes]]; + if (![aString isKindOfClass: [NSAttributedString class]]) + aString = [[NSAttributedString alloc] initWithString: aString + attributes: [self typingAttributes]]; - [textStorage replaceCharactersInRange:[self selectedRange] - withAttributedString:(NSAttributedString *)aString]; + [textStorage replaceCharactersInRange: [self selectedRange] + withAttributedString: (NSAttributedString*)aString]; [self sizeToFit]; // ScrollView interaction - [self setSelectedRange:NSMakeRange([self + [self setSelectedRange: NSMakeRange([self selectedRange].location+[aString length],0)]; [self display]; [_window update]; - [self textDidChange: nil]; // broadcast notification NSLog(@"%@", [textStorage string]); + /* + * broadcast notification + */ + [[NSNotificationCenter defaultCenter] + postNotificationName: NSTextDidChangeNotification + object: self]; } -- (void)sizeToFit +- (void) sizeToFit { NSLog(@"sizeToFit called.\n"); } -- (void)drawRect:(NSRect)aRect +- (void) drawRect: (NSRect)aRect { - if(tv_backGroundColor) + NSRange glyphRange; + + if (tv_backGroundColor) { [tv_backGroundColor set]; - NSRectFill (aRect); + NSRectFill(aRect); + } + glyphRange = [layoutManager glyphRangeForTextContainer: textContainer]; + if (glyphRange.length > 0) + { + [layoutManager drawGlyphsForGlyphRange: glyphRange + atPoint: [self frame].origin]; } - - [layoutManager drawGlyphsForGlyphRange:[layoutManager glyphRangeForTextContainer: textContainer] - atPoint: [self frame].origin]; } -/* -- (void)mouseDown:(NSEvent *)aEvent -{ - NSLog(@"mouseDown:"); -} -*/ @end diff --git a/Source/NSView.m b/Source/NSView.m index 4b7073d20..c80b9b176 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -372,6 +372,10 @@ GSSetDragTypes(NSView* obj, NSArray *types) - (void) removeFromSuperviewWithoutNeedingDisplay { + /* This must be first because it invokes -resignFirstResponder:, + which assumes the view is still in the view hierarchy */ + if ([_window firstResponder] == self) + [_window makeFirstResponder: _window]; /* * We MUST make sure that coordinates are invalidated even if we have * no superview - cos they may have been rebuilt since we lost the @@ -400,6 +404,10 @@ GSSetDragTypes(NSView* obj, NSArray *types) - (void) removeFromSuperview { + /* This must be first because it invokes -resignFirstResponder:, + which assumes the view is still in the view hierarchy */ + if ([_window firstResponder] == self) + [_window makeFirstResponder: _window]; /* * We MUST make sure that coordinates are invalidated even if we have * no superview - cos they may have been rebuilt since we lost the @@ -1703,6 +1711,8 @@ GSSetDragTypes(NSView* obj, NSArray *types) - (void) setNeedsDisplayInRect: (NSRect)rect { + NSView *currentView = _super_view; + /* * Limit to bounds, combine with old _invalidRect, and then check to see * if the result is the same as the old _invalidRect - if it isn't then @@ -1713,7 +1723,6 @@ GSSetDragTypes(NSView* obj, NSArray *types) if (NSEqualRects(rect, _invalidRect) == NO) { NSView *firstOpaque = [self opaqueAncestor]; - NSView *currentView = _super_view; _rFlags.needs_display = YES; _invalidRect = rect; @@ -1726,12 +1735,16 @@ GSSetDragTypes(NSView* obj, NSArray *types) rect = [firstOpaque convertRect: _invalidRect fromView: self]; [firstOpaque setNeedsDisplayInRect: rect]; } - - while (currentView) - { - currentView->_rFlags.needs_display = YES; - currentView = currentView->_super_view; - } + } + /* + * Must make sure that superviews know that we need display. + * NB. we may have been marked as needing display and then moved to another + * parent, so we can't assume that our parent is marked simply because we are. + */ + while (currentView) + { + currentView->_rFlags.needs_display = YES; + currentView = currentView->_super_view; } } diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 04b1ba53b..41d579ef0 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -344,9 +344,12 @@ static NSMapTable* windowmaps = NULL; [content_view removeFromSuperview]; } content_view = aView; - [content_view setFrame: [_wv frame]]; // Resize to fill window. - [content_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; - [_wv addSubview: content_view]; // Add to our window view + [content_view setAutoresizingMask: (NSViewWidthSizable + | NSViewHeightSizable)]; + [_wv addSubview: content_view]; + [content_view resizeWithOldSuperviewSize: [content_view frame].size]; + [content_view setFrameOrigin: [_wv bounds].origin]; + NSAssert1 ([[_wv subviews] count] == 1, @"window's view has %d subviews!", [[_wv subviews] count]); @@ -679,18 +682,25 @@ static NSMapTable* windowmaps = NULL; if ([self isKeyWindow]) { [self resignKeyWindow]; - for (i = pos + 1; i != pos; i++) + i = pos + 1; + if (i == c) + { + i = 0; + } + while (i != pos) { - if (i == c) - { - i = 0; - } w = [windowList objectAtIndex: i]; if ([w isVisible] && [w canBecomeKeyWindow]) { [w makeKeyWindow]; break; } + + i++; + if (i == c) + { + i = 0; + } } /* * if we didn't find a possible key window - use the app icon or, @@ -720,18 +730,25 @@ static NSMapTable* windowmaps = NULL; } else { - for (i = pos + 1; i != pos; i++) + i = pos + 1; + if (i == c) + { + i = 0; + } + while (i != pos) { - if (i == c) - { - i = 0; - } w = [windowList objectAtIndex: i]; if ([w isVisible] && [w canBecomeMainWindow]) { [w makeMainWindow]; break; } + + i++; + if (i == c) + { + i = 0; + } } } } diff --git a/Version b/Version index 84217e280..d5ef7a1ce 100644 --- a/Version +++ b/Version @@ -5,7 +5,7 @@ GNUSTEP_GUI_GCC=2.8.0 # Versions for libraries that gnustep-gui is dependent upon -GNUSTEP_GUI_BASE=0.6.0 +GNUSTEP_GUI_BASE=0.6.5 LIB_FOUNDATION=0.8.1 GNUSTEP_GUI_LIBTIFF=3.4 GNUSTEP_GUI_DGS=0.5.7 @@ -14,7 +14,7 @@ GNUSTEP_GUI_DPSCLIENT=6.1 # The version number of this release. GNUSTEP_GUI_MAJOR_VERSION=0 GNUSTEP_GUI_MINOR_VERSION=6 -GNUSTEP_GUI_SUBMINOR_VERSION=0 +GNUSTEP_GUI_SUBMINOR_VERSION=5 GNUSTEP_GUI_VERSION=${GNUSTEP_GUI_MAJOR_VERSION}.${GNUSTEP_GUI_MINOR_VERSION}.${GNUSTEP_GUI_SUBMINOR_VERSION} VERSION=${GNUSTEP_GUI_VERSION} diff --git a/configure b/configure index cb51e9d9e..3cae3277d 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -49,6 +49,7 @@ mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -332,7 +333,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12" + echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) @@ -502,9 +503,11 @@ ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -521,6 +524,105 @@ fi +echo $ac_n "checking for main in -lm""... $ac_c" 1>&6 +echo "configure:529: checking for main in -lm" >&5 +ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lm $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + +for ac_func in rintf +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:574: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:602: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + + trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure @@ -544,7 +646,7 @@ EOF # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -611,7 +713,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -630,9 +732,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF $ac_vpsub $extrasub +s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g diff --git a/configure.in b/configure.in index a83749f11..c349d61be 100644 --- a/configure.in +++ b/configure.in @@ -27,6 +27,9 @@ AC_INIT(Source/NSApplication.m) AC_CONFIG_HEADER(Headers/gnustep/gui/config.h) +AC_CHECK_LIB(m, main) +AC_CHECK_FUNCS(rintf) + AC_OUTPUT() diff --git a/gnustep-gui.spec b/gnustep-gui.spec new file mode 100644 index 000000000..f7ae6bb8e --- /dev/null +++ b/gnustep-gui.spec @@ -0,0 +1,121 @@ +# This package is not relocatable +%define ver 0.6.5 +%define date 20000217 +%define prefix /usr +%define gsr %{prefix}/GNUstep +%define libcombo gnu-gnu-gnu-xgps +Name: gnustep-gui +Version: %{ver} +Release: 1 +Source: ftp://ftp.gnustep.org/pub/gnustep/core/gstep-gui-%{ver}.tar.gz +#Source: /cvs/gnustep-gui-%{ver}-%{date}.tar.gz +Copyright: GPL +Group: Development/Tools +Summary: GNUstep GUI library package +Packager: Christopher Seawood +Distribution: Seawood's Random RPMS (%{_buildsym}) +Vendor: The Seawood Project +URL: http://www.gnustep.org/ +BuildRoot: /var/tmp/build-%{name} +Conflicts: gnustep-core +Requires: gnustep-base + +%description + It is a library of graphical user interface classes written +completely in the Objective-C language; the classes are based upon the +OpenStep specification as release by NeXT Software, Inc. The library +does not completely conform to the specification and has been enhanced +in a number of ways to take advantage of the GNU system. These classes +include graphical objects such as buttons, text fields, popup lists, +browser lists, and windows; there are also many associated classes for +handling events, colors, fonts, pasteboards and images. + +Library combo is %{libcombo}. +%{_buildblurb} + +%package devel +Summary: GNUstep GUI headers and libs. +Group: Development/Libraries +Requires: %{name} = %{ver}, gnustep-base-devel +Conflicts: gnustep-core + +%description devel +Header files required to build applications against the GNUstep GUI library. +Library combo is %{libcombo}. +%{_buildblurb} + +%prep +%setup -q -n gstep-%{ver}/gui +%patch -p2 -b .headers + +%build +if [ -z "$GNUSTEP_SYSTEM_ROOT" ]; then + . %{gsr}/Makefiles/GNUstep.sh +fi +CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{gsr} --with-library-combo=%{libcombo} +make + +%install +rm -rf $RPM_BUILD_ROOT +if [ -z "$GNUSTEP_SYSTEM_ROOT" ]; then + . %{gsr}/Makefiles/GNUstep.sh +fi +mkdir -p ${RPM_BUILD_ROOT}%{gsr}/Library/Services + +make install GNUSTEP_INSTALLATION_DIR=${RPM_BUILD_ROOT}%{gsr} + +cat > filelist.rpm.in << EOF +%defattr (-, bin, bin) +%doc ANNOUNCE COPYING* ChangeLog INSTALL NEWS NOTES README SUPPORT Version + +%dir %{gsr}/Library + +%{gsr}/Libraries/GSARCH/GSOS/%{libcombo}/lib*.so.* +%{gsr}/Libraries/Resources +%{gsr}/Library/Model +%{gsr}/Library/Services/* +%{gsr}/Tools/make_services +%{gsr}/Tools/set_show_service +# gpbs is now provided by xgps +#%{gsr}/Tools/GSARCH/GSOS/%{libcombo}/gpbs +%{gsr}/Tools/GSARCH/GSOS/%{libcombo}/make_services +%{gsr}/Tools/GSARCH/GSOS/%{libcombo}/set_show_service + +EOF + +cat > filelist-devel.rpm.in << EOF +%defattr(-, bin, bin) +%{gsr}/Headers/gnustep/gui +%{gsr}/Libraries/GSARCH/GSOS/%{libcombo}/lib*.so + +EOF + +sed -e "s|GSARCH|${GNUSTEP_HOST_CPU}|" -e "s|GSOS|${GNUSTEP_HOST_OS}|" < filelist.rpm.in > filelist.rpm +sed -e "s|GSARCH|${GNUSTEP_HOST_CPU}|" -e "s|GSOS|${GNUSTEP_HOST_OS}|" < filelist-devel.rpm.in > filelist-devel.rpm + +# Don't worry about ld.so.conf on linux as gnustep-base should take care of it. + +%ifos Linux +%post -p /sbin/ldconfig +%postun -p /sbin/ldconfig +%endif + +%clean +rm -rf $RPM_BUILD_ROOT + +%files -f filelist.rpm +%files -f filelist-devel.rpm devel + +%changelog +* Sat Sep 18 1999 Christopher Seawood +- Version 0.6.0 +- Added headers patch + +* Sat Aug 07 1999 Christopher Seawood +- Updated to cvs dawn_6 branch + +* Sat Jun 26 1999 Christopher Seawood +- Split into separate rpm from gnustep-core +- Build from cvs snapshot +- Split into -devel, -libs & -zoneinfo packages +