Does Shoes have a list view control? - ruby

I was taking a look at Shoes which seems like a very nice tool for quick GUI applications. The common elements/controls, however, don't seem to include the equivalent of a list/report view (e.g., ListView in Windows, NSTableView in OS X).
Did I just miss this, or does it not (yet) exist?

If you mean output a large quantity of textual data such as a report or table then there's a nice simple app in the shoebox called the Simple Table Class which works very nicely. Before I found it i was ready to give shoes up - but this class solved my problem in minutes.
Looking for it i stumbled across laces which includes a class called The Tablie. I haven't tried it but I am suddenly intrigued....

There doesn't seem to be. Shoes Classes doesn't seem to mention anything similar.
I guess it shouldn't be too difficult to manually create something similar. The good-vjot.rb sample script is probably the closest I can think of, although it's hardly identical..
Martin DeMello's Gooey Challenge
(Using Shoes widgets to build custom Shoes controls) may be of some help

Shoes.app do
stack do
#l = list_box :items => ["YES", "NO"] do
alert #l.text
end
end
end

Related

How to make my program to behave like Dictionary in iBooks?

When I use iBooks on Mac, and highlight a word with a mouse, English Thesaurus is shown:
I'd like my program to do similar thing - to appear like this Thesaurus in iBooks. How can it be reached?
The simplest idea is recognizing that some text is selected, but maybe iBooks has some API (nothing useful at https://developer.apple.com/ibooks/). Or maybe Mac OS has event "single word selected", and I can subscribe for it.
What kind of app is best suited for that: Cocoa App or some extension/plugin?
I'm not interested in "long way" (context menu):
Any advices will be highly appreciated, because I don't know anything about that.:)
What I think you are looking for is NSView's showDefinitionForAttributedString:atPoint: method or one of its siblings. HTH

Looking for a spreadsheet-like control for Cocoa

I'm looking for a grid view / table view / spreadsheet-type control for Cocoa and can't seem to find anything that's in any reasonable state.
I've tried using NSTableView but it's not really meant to be a single cell control.
NSCollectionView doesn't seem to be right either.
Any ideas?
While Matt Ball's spreadsheet view (https://github.com/mattball/mbtablegrid/, mentioned above) is several years old, it does still compile on El Capitan. It must be easier as a starting point than working from scratch. There are several forks of the repository, most notable this one that does seem to be actively developed:
https://github.com/pixelspark/mbtablegrid
It seems like it would be better for those interested to pool contributions than create something new!
We now have NSGridView, which is most likely what any future person reading this will want to use.

Equivalent of .Net Data Repeater in Cocoa

I'm a total noob to Xcode and Interface builder. I'm on version 3.2.3 and OSX 10.6.4.
What I'd like to know, and haven't been able to find out, is how to display a list of n items. Using .Net, I'd probably use a Data Repeater control and then use that to repeatedly populate the controls I'd like to display.
Is there an equivalent or am I going about things in the wrong way? I don't see anything in the IB controls library that is quite what I'm looking for.
Any help is much appreciated, even a direction to a relevant tutorial or something.
Regards,
Iain
I guess you are looking for NSTableView with it's DataSource (ArrayController or equivalent) and it's delegate (for defining N items)?
The most common view for displaying lists is NSTableView. There are many, many tutorials on the web... Just google 'nstableview tutorial' and take your pick. :-)

What is the benefit of Xcode's seemingly over-complicated control/outlet workflow?

I'm new to Objective-C, Cocoa, Xcode and Interface Builder. I've got some C background in the past, as well as a fair amount of RealBASIC experience.
I'm working through Mark and LaMarche's iPhone 3 Dev book and I'm really just sort of stunned about how tedious some things are. Maybe someone can shed some light on this for me. My question really is, why does the process for seemingly simple actions involve such a complicated number of steps? Is there a benefit to the complexity which I'll come to love later? Or is it just a brute fact that is unavoidable?
For example, in RealBASIC, if I want a slider's value displayed in a text box, I simply add:
myTextBox.text = mySlider.value
to the slider's Changed event. I can program this in well under 1 minute.
In Xcode/Interface Builder, I have to physically type a declaration for both the text box and the slider, then type a property/outlet declaration for each as well, then create a method declaration and implementation for the ValueChanged even, then set up a (relatively) complicated typecast of the slider's integer value into an NSString using initWithFormat. I then have to return to Interface Builder to link up the controls with the control and method outlets I typed in. I don't see how this can be done in much less than 10 minutes. Maybe 5.
So, what's the benefit of this? Why doesn't Interface Builder automatically create, or at least suggest, control declarations and #property statements, as well as method declarations and implementations? Why can't double-clicking a slider in IB offer you a list of events and offer to automatically insert a skeleton method into your .h and .m file? And why does IB even have to be a separate application?
I'm willing to accept that some of this is my unfamiliarity with all things Xcode, but is this really as efficient as the development environment can be?
My apologies if this is a dead-horse, flame-bait topic with opposing sides on full aggro. If so, please just say "yes, that it is" and move on.
Thanks,
-Rob
A lot of the reasons behind the way IB works will become more clear as you get used to the MVC paradigm.
Once you start using Cocoa Bindings, which update your model when the UI changes and vice versa, you should see an enormous productivity improvement.
I too used to think that Xcode and Interface Builder were unnecessarily complicated, until I worked through a book on both (specifically, Beginning iPhone Development: Exploring the iPhone SDK).
If you're serious about working with Xcode and Interface Builder and are as confused as I was when I started, I highly recommend picking up a book like the one I used. Granted, that was for iPhone development, but I think there is another book by the same publisher (or author) that is straight Mac programming.
Once you work through it and understand what is going on behind the scenes it starts to make a lot more sense. In some ways I prefer IB to things like Expression Blend or XAML for WPF programming in .NET.
Give a book a try and see if it helps :-)
Good luck!

Is there a simple way to combine a text and icon in an NSCell in Cocoa?

I'm trying to create a very simple selection list widget based on NSOutlineView. However, I'm having a hard time figuring out how to display an icon and a label right next to it, which is really the expected behavior in all the mainstream implementations of that kind of widget out there (iTunes, mail, Finder,...).
So far I am just binding two separate cells, but then when I'm expanding the tree, the icon cell grows larger and a gap appears between the icon and its accompanying label. I know I can probably overcome this problem by extending NSCell and provide a custom class, but as what I'm trying to achieve is really the standard thing, I can't be resigned to accept that there isn't a simpler solution.
Candide
Sadly, there isn't a 'text and icon' cell that you can just use, fresh out of the box as you would like. However, when I was working on a project, I found that Apple released some sample code that implements this, since it is such a common idiom.
This can be found here, specifically ImageAndTextCell.h/m
It can help teach you about UI customization by reading through this example, but scratching that, just dropping the ImageAndTextCell straight into your project should do just fine.
You need to create ImageAndTextcell to combine text and icon..
you can create ImageAndTextcell like this Sample Project

Resources