tholland@amy.skidmore.edu (06/17/91)
Does anyone know how to get graphics into a scrolling text view in IB ? Can I get the scrolling text views to support rtf ? Anthony Holland Skidmore College next mail: tholland@pars.skidmore.edu
eps@toaster.SFSU.EDU (Eric P. Scott) (06/17/91)
In article <1157.285b7b92@amy.skidmore.edu> tholland@amy.skidmore.edu writes: >Does anyone know how to get graphics into a scrolling text view >in IB ? There are basically three ways to create ScrollViews in IB: 1) Dragging a ScrollView+Text from the fourth standard palette; 2) Dragging a CustomView from the third standard palette, and changing it into a ScrollView with the Attributes Inspector; 3) Selecting "Group in ScrollView" from the Layout menu. The easiest way to do what you want is probably (1) and perform replaceSelWithCell: on the ScrollView's docView at run time. Try this: Create a Window containing a ScrollView+Text. Drag a Format> to your main menu (maybe a Services> as well). You want to have fun with your text. :-) Create a Button containing the image you want displayed. (If you don't have one, just use something handy, like NXdefaulticon. Remember to click Title under Icon Position to change it to Icon.) Turn off its Bordered attribute, and click Disabled. Resize if necessary. Click Layout>Send To Back. Then set its Transparent attribute. Don't panic! Create an outlet for the Button ("myButton") Create an outlet for the ScrollView ("myScrollView") Create an action, which you'll connect to from some sort of trigger (such as another button or a menu item). After you've created a project and unparsed, add the code [[myScrollView docView] replaceSelWithCell: [[[myButton cell] copy] setTransparent:NO]]; to that action. Compile your test application, and play with it. This will give you a feel for how embedded graphic objects behave. N.B.: this isn't the "right" (or the best) way to do this sort of thing; I've taken a rather expedient approach. Read the documentation for the Text object before doing this in production code--I've left out a lot of subtle details. > Can I get the scrolling text views to support rtf ? Sure. In the Attributes Inspector, make sure Monofont is NOT checked. This is a prerequisite for being able to embed graphic objects. -=EPS=-
mcgredo@prism.cs.orst.edu (Don McGregor) (06/17/91)
In article <1157.285b7b92@amy.skidmore.edu> tholland@amy.skidmore.edu writes: >Does anyone know how to get graphics into a scrolling text view >in IB ? Can I get the scrolling text views to support rtf ? > That's covered in the Text object documentation. The scrolling text IS an rtf object. You can turn on the rtf capabilities with a setMonoFont:NO message sent to the text object (which is the docview of the scrollview). With that message you can do all the usual selecting and font reseting if you drag in the font menu. You can get spellchecking and an online dictionary by dragging in the services menu. You can get graphics into the text object, but that takes a little more doing. The graphic object usually is a subclass of Cell. It has to respond to several messages, specified in the docs. You place it in the Text object by sending a replaceSelWithCell: message. Don McGregor | "I too seek the light, so long as it tastes mcgredo@prism.cs.orst.edu| great and is not too filling."
eps@toaster.SFSU.EDU (Eric P. Scott) (06/19/91)
Also, look at Jayson Adams' "ImageText" in the MiniExamples (available from the usual NeXT archive sites). [My apologies.] -=EPS=-