Re: Getting a list of all classes, etc...

2008-03-27 Thread Chris Suter


On 27/03/2008, at 4:59 PM, Graham Cox wrote:

This worked well (after a little tweaking!) thanks - got the whole  
caboodle running now. I note that NSObject's superclass is NULL, so  
I had to switch the order of the while() test in order to correctly  
detect plain NSObjects (admittedly this will probably never be  
needed in practice).


Here's my implementation (including objective C 2.0 variant), for  
anyone's further use:

[snip]

You could probably implement classIsSubclassOfClass as:

BOOL classIsSubclassOfClass (const Class aClass, const Class subclass)
{
  return class_getClassMethod (aClass, @selector (isSubclassOfClass:))
? [aClass isSubclassOfClass:subclass] : NO;
}

- Chris

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Writing a preference pane that configures hotkeys?

2008-03-27 Thread Nathan Day
You probable have, try downloading it again from my site, you also  
might want to download my Popup Dock application 
and look at how the views are set up for the IB file within the  
preference pane, it use the NDHotKeyControl in a cooler way than the  
example that comes with NDHotKeyEvent, I will have to update the  
example app to show this when I get a chance.


On 27/03/2008, at 17:18 , Brian Kendall wrote:



It doesn't look like NDHotKeyControl implements a  
setReadyForHotKeyEvent: method.  Do I perhaps have an older version  
of the NDHotKeyControl source code?  Surely there is something I'm  
missing here.  I figure I can take your word for it on this, since  
you wrote the class and all. ;-)


- Brian

On Wed, 26 Mar 2008 09:56:01 -0400, Nathan Day <[EMAIL PROTECTED]>  
wrote:


I use those classes myself in a preference pane (Popup Dock) and  
they work fine. You need to have a NDHotKeyControl to capture the  
event, you can create an input field in IB and change its class to  
NDHotKeyControl. You then need to tell the NDHotKeyControl to wait  
for a HotKey combination event by calling setReadyForHotKeyEvent:,  
you can alternativly set up a button to send a  
readyForHotKeyEventChanged: action.


On 26/03/2008, at 12:38 AM, Brian Kendall wrote:

On Mon, 24 Mar 2008 01:46:27 -0400, Jens Alfke  
<[EMAIL PROTECTED]> wrote:



Take a look at Nathan Day's "NDHotKeyEvent" utility code:
http://homepage.mac.com/nathan_day/pages/source.xml



I tried to use this in my preference pane, but I can't get the  
control to receive hot key events.  There could be something I'm  
doing wrong when setting up or working with the NDHotKeyControl  
class, but is there any reason it wouldn't be able to receive  
events in a preference pane?


- Brian
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/nathan_day 
%40mac.com


This email sent to [EMAIL PROTECTED]




Nathan Day
[EMAIL PROTECTED]
http://homepage.mac.com/nathan_day/






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Key icons?

2008-03-27 Thread Rick Mann
I'd like to implement something like Xcode's accelerator key- 
assignment prefs pane. Are there standard icons representing all the  
special keys on the keyboard? If so, how do I get at them?


TIA,
--
Rick

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Programmatically invoking Exposé?

2008-03-27 Thread Rick Mann

Is there any way to programmatically invoke Exposé?

TIA,
--
Rick

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Key icons?

2008-03-27 Thread Andrew Farmer

On 27 Mar 08, at 01:11, Rick Mann wrote:
I'd like to implement something like Xcode's accelerator key- 
assignment prefs pane. Are there standard icons representing all the  
special keys on the keyboard? If so, how do I get at them?


They're all Unicode characters. ⌘ is one of them; the rest are all  
nearby.___


Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


A Tab after 4 SPACEs

2008-03-27 Thread Gerriet M. Denkmann
I would like to put an NSLeftTabStopType after every 4 blanks (' '  
Unicode: SPACE) into my NSTextField.


So I do:
NSFont *usedFont = [ layoutManager substituteFontForFont: font ];
float widthOfTab = [usedFont advancementForGlyph:(NSGlyph)' '].width  
* 4;

and so on.

Works perfectly for Monaco or Courier.
Does not work at all for almost all other fonts.

Monaco 10.00 pt. S ... spc=6.00
advancementForGlyph = 6.00  -- Note: same as spc above

Monaco 11.00 pt. P ... spc=6.60
advancementForGlyph =  6.601074	-- Note: printer font has (almost)  
same as spc


LucidaGrande 14.00 pt. P ... spc=4.43
advancementForGlyph = 11.128906	-- looks like the real width of a  
blank is more like 4.43


Times-Roman 14.00 pt. S ... spc=4.00
advancementForGlyph = 8.00  -- 4.0 works much better.

Thonburi 10.00 pt. S ... spc=1.00
advancementForGlyph = 6.00		-- huge difference. 1.0 is probably  
correct


So I have the strong feeling that the real width of a blank (SPACE)  
is the value reported by [font description] as spc=n.nn and that  
either advancementForGlyph or my usage of it is somehow crooked.


How can I get the width of a SPACE in a given font?


Kind regards,

Gerriet.

P.S. Currently I am parsing [font description] but this really does  
not seem the correct way.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Programmatically invoking Exposé?

2008-03-27 Thread Jonathon Mah

Hi Rick,

On 2008-03-27, at 18:47, Rick Mann wrote:


Is there any way to programmatically invoke Exposé?



You could open /Applications/Expose.app, depending on the level of  
flexibility you need.




Jonathon Mah
[EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Ephemeral Changes

2008-03-27 Thread Jens Miltner


Am 26.03.2008 um 11:26 schrieb Gerriet M. Denkmann:
I also can use Edit  ► Undo Set (or Paste) Font but now the  
document gets dirty. Very bad. Also: the complete text gets selected.
So what else do I have to implement? I tried setFont: and  
setFont:range:, but these seem never to be called.

How does the NSUndoManager undo my font changes?


Hmmh - how about completely disabling the built-in undo support for  
these functions (as was proposed before), and manually add undo actions?
That way you'd have control over the undo action yourself and could  
once again mark the document as unchanged after the undo


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: A Tab after 4 SPACEs

2008-03-27 Thread Uli Kusterer

On 27.03.2008, at 09:32, Gerriet M. Denkmann wrote:
float widthOfTab = [usedFont advancementForGlyph:(NSGlyph)' '].width  
* 4;



 I'm pretty new to the text engine myself, but I don't think an  
NSGlyph can be generated by typecasting a char. Since Monaco or  
Courier are monospaced, it just so happens that you get the same width  
as the space would be. But the glyph with number 0x20 is probably a  
completely different width than the glyph corresponding to a space in  
other languages.


 Have you tried asking the glyph storage (I think that's a category  
that the layout manager adheres to, or maybe it was the text storage)  
for the correct glyph for the character ' ' ?


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Core Data/IB questions

2008-03-27 Thread Ian Jackson
If I may be so bold, I'd like to jump in on this question. I have a  
similar situation, but I want to have a table representing a to-many  
relationship for entity1, which the user can populate by choosing any  
number of entries from a entity2.


e.g. entity2 has 50 entries.

entity1 1st entry refers to entries 1, 4, and 9 of entity 2.
entity1 2nd entry refers to entries 4, 8 and 26 of entity 2.

So I envisage that the table in entity1 should have add and remove  
buttons. When you click add, a new row is added to the table. The  
first column in the table is a NSCombobox, which can be used to select  
from the entries in entity 2.


The employee/department tutorial seems to come close to doing this,  
but as seems to be more the norm, it assumes that all entries in the  
relationship are wanted, which is not the case here.


So, I set up the interface as above (table with NSCombobox, and +/-  
buttons). I created a special array controller just for this to-many  
relationship, and bound its contentset to the relevant relationship in  
entity1.
The first column in the table is bound to the specially created array  
controller, arrangedObjects, but this is a dead end. I can't see how  
to make the combobox choose the entry. The combo box doesn't have the  
same binding options as a popup menu.


Any advice as to how to approach this would be great.

Ian.


On 27/03/2008, at 7:34 PM, Adam Gerson wrote:


I think that internally when you create a to-many core-data
relationship the group of objects is stored as an NSSet as opposed to
an array.


http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/CntrlContent.html#/ 
/apple_ref/doc/uid/TP40002147-181724


http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ 
/apple_ref/doc/uid/20002174-178830-BAJEDEFB



On Thu, Mar 27, 2008 at 2:10 AM, Rick Mann <[EMAIL PROTECTED]>  
wrote:


On Mar 26, 2008, at 11:06 PM, Adam Gerson wrote:

Each table should have its own ArrayController if the two tables
represent the data from two different entities. Since you entities  
are

related I am assuming one entity has a property that is a to-many
relationship to the other entity. Set the ContentSet bindings for
ArrayController2 to be the selection of ArrayController1.

ArrayController2 ContentSet
Bind to = ArrayController1
Controller Key = selection
Model Key Path = (the name of the relationship that represents  
entity2

in entity1)

This will cause ArrayController2 to always populate the TableView  
with

the objects selected by ArrayController1

Let me know if that needs to be more clear.



Excellent! That was exactly what was missing. Thank you.

Why ContentSet, and not ContentArray or one of the other ContentXXX
things?

--
Rick



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/bianface%40gmail.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Getting a list of all classes, etc...

2008-03-27 Thread Graham Cox
Actually I did try it this way at one point, and it worked OK with one  
small kink. It caused the +initialize method of the classes being  
tested to get called, which for some classes (bearing in mind that  
it's going through a list of EVERY class in the runtime), triggered  
some warnings about deprecated classes, for example from  
NSATSGlyphRenderer (I think it was). The advantage of this way is that  
it doesn't invoke any methods on the class being tested itself, so  
works very stealthily ;-)


--
S.O.S.




On 27 Mar 2008, at 5:59 pm, Chris Suter wrote:


On 27/03/2008, at 4:59 PM, Graham Cox wrote:
This worked well (after a little tweaking!) thanks - got the whole  
caboodle running now. I note that NSObject's superclass is NULL, so  
I had to switch the order of the while() test in order to correctly  
detect plain NSObjects (admittedly this will probably never be  
needed in practice).


Here's my implementation (including objective C 2.0 variant), for  
anyone's further use:

[snip]

You could probably implement classIsSubclassOfClass as:

BOOL classIsSubclassOfClass (const Class aClass, const Class subclass)
{
  return class_getClassMethod (aClass, @selector (isSubclassOfClass:))
? [aClass isSubclassOfClass:subclass] : NO;
}

- Chris



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Ephemeral Changes

2008-03-27 Thread Gerriet M. Denkmann


On 26 Mar 2008, at 22:56, Graham Cox wrote:
The undo manager will directly change the data in the text view  
using an invocation or target/action - it doesn't go back through  
changeFont: normally, which is really a "high level" method.


Maybe the solution to this is to subclass NSUndoManager so that you  
can hook into the undo and redo methods and use those opportunities  
to modify the change count of the document.


So I implement in MyUndoManager:
- (void)undo
{
NSString *action = [self undoActionName];
[ super undo ];
	if ( action contains "Font" ) [myDocument  
updateChangeCount:NSChangeUndone];

}

But: If the language is switched to German, this does no longer work.  
Now one would have to look for "Schrift" instead.


What I really want is:
NSInvocation *i = [ self invocationOnTopOfUndoStack]; But such a  
method I cannot find.


Or: +[NSTextView undoActionNameToBeUsedForSettingFonts] which would  
return "Schrift wählen" if the language currently is set to German.

Again - cannot find such a method.

So - what can I do?


You can switch the document's undo manager early in the document  
creation sequence.


Yes. I did in MyDocument init:
MyUndoManager *undoManager = [ [ MyUndoManager alloc ]  
initForDocument: self ];	

[ self setUndoManager: undoManager ];   
[ undoManager release ];


Kind regards,

Gerriet.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Getting other application window reference

2008-03-27 Thread Apparao Mulpuri
Hi,

   I am developing a Cocoa based application, which will access other
application's window and do some resize  operations.

   In Cocoa, is there any way to get other applications(includes
non-scriptable ) window references?

Thanks,
- Apparao.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Master-Slave Display Exception - Cannot remove an observer

2008-03-27 Thread Steve Steinitz

Hello,

I sent this just before the Easter break but didn't receive a 
reply.  I thought I'd try again now that we're all back at work.


I have what, in WebObjects, we used to call a master-slave 
display.  I show a list of specific Products based on the 
selected Product Model, hereafter referred to as the 'Model'. So 
when a user picks a certain Model of sunglasses in the master 
list, she sees all the different size/color/lens combinations 
(Products) in the slave list.  It works nicely.


I use a contentSet binding (programmatically-generated if that 
makes a difference) to filter the slave list ie. bind it to the 
to-many relationship from Model to Products. **


In the slave (Product) list, I have a popup that allows the user 
to change a Product's Model.  The popup is usually only used to 
fix data entry errors - e.g. specifying the wrong Model for a Product.


Here is my problem.  I noticed that changing the Model results 
in two exception:


NSRangeException -- Cannot remove an observer 
 for the key path "currentCost" 
from  because it is not registered as an observer.


and

NSInternalInconsistencyException -- Cannot remove an observer 
 for the key 
path "model.currentCost" from , most likely 
because the value for the key "model" has changed without an 
appropriate KVO notification being sent. Check the 
KVO-compliance of the Product class.


Googling, I found some other developers who have experienced 
this but no answers were offered.


Note that the exceptions are complaining about one of the 
Model's attributes: currentCost.  At other times, the exception 
complains about another attribute: 'active' -- its unclear 
whether that refers to the Model's 'active' attribute or the 
Product's 'active' attribute.


Should I be reporting a bug?

Thanks,

Steve


** this likely has little to do with my question, but for the 
curious: I programmatically bind a contentSet based on the 
setting of a radio button with two choices: 'All' and "Model".  
"All" means show all products, "Model" means show just the 
Products for the selected Model. I only have the problem in 
"Model" mode.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


method declaration error

2008-03-27 Thread Nick Rogers

i'm declaring the following method:

- (BOOL)searchNodeTarget:(const ItemType)target
location:(int &)location;

with error: "parse error before '&' token".

can we not use (int &) this way?

Thanks,
Nick

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Rép : method declaration error

2008-03-27 Thread Allison Newman
Um, I'm more of a C girl than Objective-C, but I think this holds true for the 
two languages:  the ampersand is an operator used to get the address of a 
variable.  What you need is an asterix - this is the symbol used to denote that 
you want a pointer to a type rather than the type itself.

Alli
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: method declaration error

2008-03-27 Thread Jonathan del Strother
On Thu, Mar 27, 2008 at 12:21 PM, Nick Rogers <[EMAIL PROTECTED]> wrote:
> i'm declaring the following method:
>
>  - (BOOL)searchNodeTarget:(const ItemType)target
> location:(int &)location;
>
>  with error: "parse error before '&' token".
>
>  can we not use (int &) this way?


Reference parameters are a C++ feature.  You can either use
(int*)location, or compile as Objective-C++ by changing your header
extension to .hh
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


to include a C++ class in proj

2008-03-27 Thread Nick Rogers

are we allowed to do that in a cocoa proj.
if so how do we declare the class.

Is it like?

class MyClass
{

}

this is throwing error at the first line:  parse error before  
'MyClass' token

what headers do i need to include for a C++ class?

Thanks,
Nick

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Ephemeral Changes

2008-03-27 Thread Jens Miltner


Am 27.03.2008 um 11:57 schrieb Gerriet M. Denkmann:

On 26 Mar 2008, at 22:56, Graham Cox wrote:
The undo manager will directly change the data in the text view  
using an invocation or target/action - it doesn't go back through  
changeFont: normally, which is really a "high level" method.


Maybe the solution to this is to subclass NSUndoManager so that you  
can hook into the undo and redo methods and use those opportunities  
to modify the change count of the document.


So I implement in MyUndoManager:
- (void)undo
{
NSString *action = [self undoActionName];
[ super undo ];
	if ( action contains "Font" ) [myDocument  
updateChangeCount:NSChangeUndone];

}



Maybe there's a way to trigger on the action selector instead of the  
action name? However, even the action selector _might_ change in  
future AppKit versions, so even this would be a somewhat fragile  
solution.


I'd still think that it might be easier to register you own undo  
action for the font changes instead of trying to hijack the automatic  
undo...


just my €.02,


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: to include a C++ class in proj

2008-03-27 Thread Jens Miltner


Am 27.03.2008 um 14:44 schrieb Nick Rogers:

are we allowed to do that in a cocoa proj.
if so how do we declare the class.

Is it like?

class MyClass
{

}

this is throwing error at the first line:  parse error before  
'MyClass' token

what headers do i need to include for a C++ class?


Make sure your source file is compiled as Objective-C++. The easiest  
way is to give the file a '.mm' extension. Alternatively, you can  
change the file type in the inspector panel for the source file, but I  
prefer to indicate the language by file extension - it saves me a lot  
of headaches why things work different than expected ;-)


Also, your declaration above is missing a trailing semicolon - I guess  
that's not the issue here, but I have seen strange apparently out-of- 
location error messages when gcc gets confused due to missing  
semicolons...


HTH,



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: to include a C++ class in proj

2008-03-27 Thread Sherm Pendley
On Thu, Mar 27, 2008 at 9:44 AM, Nick Rogers <[EMAIL PROTECTED]> wrote:

> are we allowed to do that in a cocoa proj.
> if so how do we declare the class.
>
> Is it like?
>
> class MyClass
> {
>
> }
>
> this is throwing error at the first line:  parse error before
> 'MyClass' token


To compile a file as Objective-C++, you need to give it a .mm extension
instead of .m.

See also:
<
http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_12_section_3.html
>

sherm--
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Getting other application window reference

2008-03-27 Thread Brian Kendall


I would recommend the accessibility API, since that can be used to find  
all the windows on screen as well as change their position and size.   
(URL:  
http://developer.apple.com/documentation/Cocoa/Conceptual/Accessibility/cocoaAXIntro/cocoaAXintro.html)
Unfortunately, that won't let you use any of the normal cocoa methods for  
manipulating windows, but unless something has been added to Leopard that  
I wasn't aware of, this might be your only option.


- Brian


On Thu, 27 Mar 2008 07:32:47 -0400, Apparao Mulpuri  
<[EMAIL PROTECTED]> wrote:



Hi,

   I am developing a Cocoa based application, which will access other
application's window and do some resize  operations.

   In Cocoa, is there any way to get other applications(includes
non-scriptable ) window references?

Thanks,
- Apparao.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/guygizmo%40gmail.com

This email sent to [EMAIL PROTECTED]



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: to include a C++ class in proj

2008-03-27 Thread Nick Rogers


hi,
the semicolon is there. i've changed extension to .hh and .mm, still  
the same error.
Again what headers to include for a .hh file to be taken as a file  
declaring a C++ class?


Wishes,
Nick

On 27-Mar-08, at 7:28 PM, Jens Miltner wrote:



Am 27.03.2008 um 14:44 schrieb Nick Rogers:

are we allowed to do that in a cocoa proj.
if so how do we declare the class.

Is it like?

class MyClass
{

}

this is throwing error at the first line:  parse error before  
'MyClass' token

what headers do i need to include for a C++ class?


Make sure your source file is compiled as Objective-C++. The  
easiest way is to give the file a '.mm' extension. Alternatively,  
you can change the file type in the inspector panel for the source  
file, but I prefer to indicate the language by file extension - it  
saves me a lot of headaches why things work different than  
expected ;-)


Also, your declaration above is missing a trailing semicolon - I  
guess that's not the issue here, but I have seen strange apparently  
out-of-location error messages when gcc gets confused due to  
missing semicolons...


HTH,





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: to include a C++ class in proj

2008-03-27 Thread Scott Ribe
> Again what headers to include for a .hh file to be taken as a file
> declaring a C++ class?

None for what you posted. Headers are only needed to introduce declarations
of classes, types, etc which you will use.

-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


applicationWillTerminate and animations

2008-03-27 Thread Mitchell Livingston

Hello,

When my program quits, I would like to fade out all the windows using  
the animator. When I put this code in the applicationWillTerminate:  
method, however, it appears to be called but doesn't animate. How  
would I got about to get this to work?


Thank you,
Mitchell Livingston
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Programmatically invoking Exposé?

2008-03-27 Thread Brian Kendall


The way I've done it, and mind you this is a bit of work and it's  
certainly not ideal, is to read the contents of  
com.apple.symbolichotkeys.plist to figure out what the current hotkey for  
any of the Expose actions are, and then use CGEventCreateKeyboardEvent and  
CGEventPost to synthesize a keystroke in order to invoke it.


If you look inside com.apple.symbolichotkeys.plist you'll find all sorts  
of unlabeled entries in an array, each referring to various hotkeys.  The  
ones specifically for expose are: 32 (expose all), 33 (expose  
application), and 36 (expose desktop).  Then, inside each entry is a value  
dictionary, containing a parameters array.  In the parameters array, the  
entry with index 1 is the keycode for the hotkey, and index 2 is the  
modifier keys.


Of course, this method fails the user specifically has disabled the hotkey  
for any of the various Expose functions.  Like I said, it's a bit of work  
and it's not ideal.  It'd be nice if there was an official  
Apple-sanctioned way of invoking Expose, but I don't think there is one.   
(Other than invoking Expose.app, but that only seems to get you one of the  
three kinds of Expose.)


- Brian


On Thu, 27 Mar 2008 04:17:03 -0400, Rick Mann <[EMAIL PROTECTED]>  
wrote:



Is there any way to programmatically invoke Exposé?

TIA,



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: to include a C++ class in proj

2008-03-27 Thread Brady Duga


On Mar 27, 2008, at 7:05 AM, Nick Rogers wrote:


hi,
the semicolon is there. i've changed extension to .hh and .mm, still  
the same error.


What file did you change to .mm, the header or the source file?  
Remember, header files are not compiled (well, generally not), they  
are included in implementation files by the preprocessor, then that  
gets compiled. The file(s) that include your header must be compiled  
as C++ or Objective-C++. Try changing the extension of the source  
file(s) that include your class to .mm. There is no need to call the  
header file .hh.


--Brady

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Writing a preference pane that configures hotkeys?

2008-03-27 Thread Brian Kendall


It looks like I did have an early version.  I downloaded the one from your  
website, rebuilt my pref pane and included a call to  
setReadyForHotKeyEvent, and now it works great.


Thanks a lot for making a very cool and very useful NDHotKeyControl class!

- Brian


On Thu, 27 Mar 2008 03:21:01 -0400, Nathan Day <[EMAIL PROTECTED]> wrote:

You probable have, try downloading it again from my site, you also might  
want to download my Popup Dock application  

and look at how the views are set up for the IB file within the  
preference pane, it use the NDHotKeyControl in a cooler way than the  
example that comes with NDHotKeyEvent, I will have to update the example  
app to show this when I get a chance.


On 27/03/2008, at 17:18 , Brian Kendall wrote:



It doesn't look like NDHotKeyControl implements a  
setReadyForHotKeyEvent: method.  Do I perhaps have an older version of  
the NDHotKeyControl source code?  Surely there is something I'm missing  
here.  I figure I can take your word for it on this, since you wrote  
the class and all. ;-)


- Brian

On Wed, 26 Mar 2008 09:56:01 -0400, Nathan Day <[EMAIL PROTECTED]>  
wrote:


I use those classes myself in a preference pane (Popup Dock) and they  
work fine. You need to have a NDHotKeyControl to capture the event,  
you can create an input field in IB and change its class to  
NDHotKeyControl. You then need to tell the NDHotKeyControl to wait for  
a HotKey combination event by calling setReadyForHotKeyEvent:, you can  
alternativly set up a button to send a readyForHotKeyEventChanged:  
action.


On 26/03/2008, at 12:38 AM, Brian Kendall wrote:

On Mon, 24 Mar 2008 01:46:27 -0400, Jens Alfke <[EMAIL PROTECTED]>  
wrote:



Take a look at Nathan Day's "NDHotKeyEvent" utility code:
http://homepage.mac.com/nathan_day/pages/source.xml



I tried to use this in my preference pane, but I can't get the  
control to receive hot key events.  There could be something I'm  
doing wrong when setting up or working with the NDHotKeyControl  
class, but is there any reason it wouldn't be able to receive events  
in a preference pane?


- Brian
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/nathan_day%40mac.com

This email sent to [EMAIL PROTECTED]




Nathan Day
[EMAIL PROTECTED]
http://homepage.mac.com/nathan_day/









___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: applicationWillTerminate and animations

2008-03-27 Thread Sherm Pendley
On Thu, Mar 27, 2008 at 10:14 AM, Mitchell Livingston <[EMAIL PROTECTED]>
wrote:

> Hello,
>
> When my program quits, I would like to fade out all the windows using
> the animator. When I put this code in the applicationWillTerminate:
> method, however, it appears to be called but doesn't animate. How
> would I got about to get this to work?


I'd try putting it in applicationShouldTerminate:, and return
NSTerminateLater to give the app time to run the fade-out animation. Then,
when the animation completes, you can call [NSApp
replyToApplicationShouldTerminate:YES].

sherm--
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


NSMapTable with pointer keys ?

2008-03-27 Thread Guillaume Laurent

Hi all,

I need to build a map of NSObjects indexed by void* pointers.  
Apparently the right way to do this is to use NSMapTable with the  
appropriate options :


[NSMapTable mapTableWithKeyOptions:NSMapTableObjectPointerPersonality  
valueOptions:NSMapTableStrongMemory]


(reading the doc for NSMap, I figured these are the right options)

However, when trying to fetch an object with a void* key to check for  
its presence (using the C api as recommended)


NSMapGet(myMap, aKey);

I get an instant crash and looking at the stack trace, it's because  
aKey is being sent an ObjC message, to which it will hard time  
replying since it's not an NSObject in the first place.


What am I missing here ?

Thanks for any hints,

--
Guillaume
http://telegraph-road.org





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leopard on PPC

2008-03-27 Thread Clark Cox
On Wed, Mar 26, 2008 at 4:48 PM, Sherm Pendley <[EMAIL PROTECTED]> wrote:
> On Wed, Mar 26, 2008 at 7:04 PM, Lorenzo <[EMAIL PROTECTED]> wrote:
>
>  > Hi Laurent,
>  > I am going to debug and let you know. Right now I have found these lines.
>  > Might they cause the trouble on Leopard && PPC?
>  >
>  >number = CFNumberCreate(NULL, kCFNumberFloatType, &destSize.width);
>  >options = [NSDictionary dictionaryWithObjectsAndKeys:
>  >(id) kCFBooleanTrue,   (id) kCGImageSourceShouldCache,
>  >(id) kCFBooleanTrue,   (id)
>  >kCGImageSourceCreateThumbnailFromImageIfAbsent,
>  >(id) number,   (id)
>  > kCGImageSourceThumbnailMaxPixelSize,
>  >NULL];
>  >
>  >
>  >
>  >options = [NSDictionary dictionaryWithObjectsAndKeys:
>  >(id) kCFBooleanTrue,(id) kCGImageSourceShouldCache,
>  >(id) kCFBooleanTrue,(id) kCGImageSourceShouldAllowFloat,
>  >NULL];
>
>
>  I'm deeply suspicious of those typecast CFBoolRefs. Not every Core
>  Foundation class is toll-free bridged. CFNumber is, but I don't see any
>  indication in the CF reference that CFBoolean is. Have you tried using
>  NSNumber objects instead of those kCFBooleanTrue constants?

CFBoolean *is* toll free bridged to NSNumber.

-- 
Clark S. Cox III
[EMAIL PROTECTED]
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leopard on PPC

2008-03-27 Thread Clark Cox
On Wed, Mar 26, 2008 at 4:04 PM, Lorenzo <[EMAIL PROTECTED]> wrote:
> Hi Laurent,
>  I am going to debug and let you know. Right now I have found these lines.
>  Might they cause the trouble on Leopard && PPC?
>

No, but this line will cause problems when/if you build for 64-bit:
> number = CFNumberCreate(NULL, kCFNumberFloatType, &destSize.width);

Use kCFNumberCGFloatType instead of kCFNumberFloatType, and make sure
that you later CFRelease(number). Or just use NSNumber.

> options = [NSDictionary dictionaryWithObjectsAndKeys:
> (id) kCFBooleanTrue,   (id) kCGImageSourceShouldCache,
> (id) kCFBooleanTrue,   (id) 
> kCGImageSourceCreateThumbnailFromImageIfAbsent,
> (id) number,   (id) kCGImageSourceThumbnailMaxPixelSize,
> NULL];
>
>
>
> options = [NSDictionary dictionaryWithObjectsAndKeys:
> (id) kCFBooleanTrue,(id) kCGImageSourceShouldCache,
> (id) kCFBooleanTrue,(id) kCGImageSourceShouldAllowFloat,
> NULL];

Also, be sure that you are not releasing either of the "options"
dictionary, as they are already autoreleased for you.


-- 
Clark S. Cox III
[EMAIL PROTECTED]
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: A Tab after 4 SPACEs

2008-03-27 Thread Uli Kusterer


On 27.03.2008, at 10:08, Uli Kusterer wrote:
But the glyph with number 0x20 is probably a completely different  
width than the glyph corresponding to a space in other languages.


I meant in other *fonts*, not languages.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leopard on PPC

2008-03-27 Thread Sherm Pendley
On Thu, Mar 27, 2008 at 11:25 AM, Clark Cox <[EMAIL PROTECTED]> wrote:

> On Wed, Mar 26, 2008 at 4:48 PM, Sherm Pendley <[EMAIL PROTECTED]>
> wrote:
> > On Wed, Mar 26, 2008 at 7:04 PM, Lorenzo <[EMAIL PROTECTED]> wrote:
> >
> >  > Hi Laurent,
> >  > I am going to debug and let you know. Right now I have found these
> lines.
> >  > Might they cause the trouble on Leopard && PPC?
> >  >
> >  >number = CFNumberCreate(NULL, kCFNumberFloatType,
> &destSize.width);
> >  >options = [NSDictionary dictionaryWithObjectsAndKeys:
> >  >(id) kCFBooleanTrue,   (id) kCGImageSourceShouldCache,
> >  >(id) kCFBooleanTrue,   (id)
> >  >
>  kCGImageSourceCreateThumbnailFromImageIfAbsent,
> >  >(id) number,   (id)
> >  > kCGImageSourceThumbnailMaxPixelSize,
> >  >NULL];
> >  >
> >  >
> >  >
> >  >options = [NSDictionary dictionaryWithObjectsAndKeys:
> >  >(id) kCFBooleanTrue,(id) kCGImageSourceShouldCache,
> >  >(id) kCFBooleanTrue,(id)
> kCGImageSourceShouldAllowFloat,
> >  >NULL];
> >
> >
> >  I'm deeply suspicious of those typecast CFBoolRefs. Not every Core
> >  Foundation class is toll-free bridged. CFNumber is, but I don't see any
> >  indication in the CF reference that CFBoolean is. Have you tried using
> >  NSNumber objects instead of those kCFBooleanTrue constants?
>
> CFBoolean *is* toll free bridged to NSNumber.


OK, so where is that documented then? As I said, the CFBoolean reference
says not a word about it:

<
http://developer.apple.com/documentation/CoreFoundation/Reference/CFBooleanRef/Reference/reference.html
>

By contrast, every other toll-free bridged CF class I can think of
explicitly documents that fact.

sherm--
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Core Data/IB questions

2008-03-27 Thread Adam Gerson
Is what you are describing similar to the "To Dos" example at:

http://homepage.mac.com/mmalc/CocoaExamples/controllers.html


Adam



On Thu, Mar 27, 2008 at 5:33 AM, Ian Jackson <[EMAIL PROTECTED]> wrote:
> If I may be so bold, I'd like to jump in on this question. I have a
>  similar situation, but I want to have a table representing a to-many
>  relationship for entity1, which the user can populate by choosing any
>  number of entries from a entity2.
>
>  e.g. entity2 has 50 entries.
>
> entity1 1st entry refers to entries 1, 4, and 9 of entity 2.
> entity1 2nd entry refers to entries 4, 8 and 26 of entity 2.
>
>  So I envisage that the table in entity1 should have add and remove
>  buttons. When you click add, a new row is added to the table. The
>  first column in the table is a NSCombobox, which can be used to select
>  from the entries in entity 2.
>
>  The employee/department tutorial seems to come close to doing this,
>  but as seems to be more the norm, it assumes that all entries in the
>  relationship are wanted, which is not the case here.
>
>  So, I set up the interface as above (table with NSCombobox, and +/-
>  buttons). I created a special array controller just for this to-many
>  relationship, and bound its contentset to the relevant relationship in
>  entity1.
>  The first column in the table is bound to the specially created array
>  controller, arrangedObjects, but this is a dead end. I can't see how
>  to make the combobox choose the entry. The combo box doesn't have the
>  same binding options as a popup menu.
>
>  Any advice as to how to approach this would be great.
>
>  Ian.
>
>
>
>
>  On 27/03/2008, at 7:34 PM, Adam Gerson wrote:
>
>  > I think that internally when you create a to-many core-data
>  > relationship the group of objects is stored as an NSSet as opposed to
>  > an array.
>  >
>  >
>  > 
> http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html
>  >
>  > 
> http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/CntrlContent.html#/
>  > /apple_ref/doc/uid/TP40002147-181724
>  >
>  > 
> http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/
>  > /apple_ref/doc/uid/20002174-178830-BAJEDEFB
>  >
>  >
>  > On Thu, Mar 27, 2008 at 2:10 AM, Rick Mann <[EMAIL PROTECTED]>
>  > wrote:
>  >>
>  >> On Mar 26, 2008, at 11:06 PM, Adam Gerson wrote:
>  >>> Each table should have its own ArrayController if the two tables
>  >>> represent the data from two different entities. Since you entities
>  >>> are
>  >>> related I am assuming one entity has a property that is a to-many
>  >>> relationship to the other entity. Set the ContentSet bindings for
>  >>> ArrayController2 to be the selection of ArrayController1.
>  >>>
>  >>> ArrayController2 ContentSet
>  >>> Bind to = ArrayController1
>  >>> Controller Key = selection
>  >>> Model Key Path = (the name of the relationship that represents
>  >>> entity2
>  >>> in entity1)
>  >>>
>  >>> This will cause ArrayController2 to always populate the TableView
>  >>> with
>  >>> the objects selected by ArrayController1
>  >>>
>  >>> Let me know if that needs to be more clear.
>  >>
>  >>
>  >> Excellent! That was exactly what was missing. Thank you.
>  >>
>  >> Why ContentSet, and not ContentArray or one of the other ContentXXX
>  >> things?
>  >>
>  >> --
>  >> Rick
>  >>
>  >>
>
> > ___
>  >
>  > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>  >
>  > Please do not post admin requests or moderator comments to the list.
>  > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>  >
>  > Help/Unsubscribe/Update your Subscription:
>  > http://lists.apple.com/mailman/options/cocoa-dev/bianface%40gmail.com
>  >
>  > This email sent to [EMAIL PROTECTED]
>
>
>
>  ___
>
>  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>  Please do not post admin requests or moderator comments to the list.
>  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>  Help/Unsubscribe/Update your Subscription:
>  http://lists.apple.com/mailman/options/cocoa-dev/agersonl%40gmail.com
>
>  This email sent to [EMAIL PROTECTED]
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: A Tab after 4 SPACEs

2008-03-27 Thread Gerriet M. Denkmann


On 27 Mar 2008, at 10:08, Uli Kusterer wrote:

On 27.03.2008, at 09:32, Gerriet M. Denkmann wrote:
float widthOfTab = [usedFont advancementForGlyph:(NSGlyph)'  
'].width * 4;



 I'm pretty new to the text engine myself, but I don't think an  
NSGlyph can be generated by typecasting a char. Since Monaco or  
Courier are monospaced, it just so happens that you get the same  
width as the space would be. But the glyph with number 0x20 is  
probably a completely different width than the glyph corresponding  
to a space in other languages.


Yes. You are certainly right. Silly mistake of mine.
There should be something like: -[NSFont glyphForChar: (NSString *) 
aString ] which returns NSNotFound if the font does not contain the  
first char in aString.

But I did not find any such method.



 Have you tried asking the glyph storage (I think that's a category  
that the layout manager adheres to, or maybe it was the text  
storage) for the correct glyph for the character ' ' ?


Current I am using:

NSString *dummyString = [ NSString stringWithUTF8String: " " ];   
NSTextView *dummyTextView = [ [ NSTextView alloc ] initWithFrame:  
NSMakeRect(0,0,1e4,1e4) ];

[ dummyTextView setString: dummyString ];
[ dummyTextView setFont: usedFont ];
NSLayoutManager *dummyLayoutManager = [ dummyTextView layoutManager ];
[ dummyLayoutManager setUsesScreenFonts: useScreenFont ];
unsigned int length = [ dummyString length ];
NSRange glyphRange = 	[ dummyLayoutManager 	 
glyphRangeForCharacterRange: 	NSMakeRange(0,length)   
actualCharacterRange: NULL ];

unsigned int glyphIndex = glyphRange.location;
NSTextContainer *aTextContainer = [ dummyLayoutManager 	 
textContainerForGlyphAtIndex: 	glyphIndex  effectiveRange: NULL ];
NSRect boundingRect =	[ dummyLayoutManager 	 
boundingRectForGlyphRange: 	glyphRange inTextContainer: 	 
aTextContainer];

[dummyTextView release];
float widtOfDummyString = boundingRect.size.width;

This looks incredible clumsy. Do you know of any better way?


Kind regards,

Gerriet.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


IKImageEditPanel Effects Preview Question

2008-03-27 Thread Jamie Phelps
When I first invoke the IKImageEditPanel, the preview in the Effects  
tab reflects the image that is in my IKImageView. If I change the  
image in the image view, however, the preview in the Effects tab does  
not show the preview applied to the image currently in the image view  
but to the image that was in the view when I first invoked the  
IKImageEditPanel. I have tried calling reloadData on the edit panel to  
no apparent avail. Is this the correct behavior or is there some place  
I'm missing something that will make the edit panel display the  
preview with the currently displayed image of my image view?


Thanks,
Jamie
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leopard on PPC

2008-03-27 Thread Matt Gough



OK, so where is that documented then? As I said, the CFBoolean  
reference

says not a word about it:

   <
http://developer.apple.com/documentation/CoreFoundation/Reference/CFBooleanRef/Reference/reference.html




By contrast, every other toll-free bridged CF class I can think of
explicitly documents that fact.



This blog post has more info on the subject:

http://belkadan.com/blog/2008/01/NSNumber-CFNumber-and-CFBoolean/

Matt
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leopard on PPC

2008-03-27 Thread Jean-Daniel Dupas


Le 27 mars 08 à 16:59, Sherm Pendley a écrit :
On Thu, Mar 27, 2008 at 11:25 AM, Clark Cox <[EMAIL PROTECTED]>  
wrote:


On Wed, Mar 26, 2008 at 4:48 PM, Sherm Pendley <[EMAIL PROTECTED] 
>

wrote:

On Wed, Mar 26, 2008 at 7:04 PM, Lorenzo <[EMAIL PROTECTED]> wrote:


Hi Laurent,
I am going to debug and let you know. Right now I have found these

lines.

Might they cause the trouble on Leopard && PPC?

  number = CFNumberCreate(NULL, kCFNumberFloatType,

&destSize.width);

  options = [NSDictionary dictionaryWithObjectsAndKeys:
  (id) kCFBooleanTrue,   (id) kCGImageSourceShouldCache,
  (id) kCFBooleanTrue,   (id)


kCGImageSourceCreateThumbnailFromImageIfAbsent,

  (id) number,   (id)
kCGImageSourceThumbnailMaxPixelSize,
  NULL];



  options = [NSDictionary dictionaryWithObjectsAndKeys:
  (id) kCFBooleanTrue,(id) kCGImageSourceShouldCache,
  (id) kCFBooleanTrue,(id)

kCGImageSourceShouldAllowFloat,

  NULL];



I'm deeply suspicious of those typecast CFBoolRefs. Not every Core
Foundation class is toll-free bridged. CFNumber is, but I don't  
see any
indication in the CF reference that CFBoolean is. Have you tried  
using

NSNumber objects instead of those kCFBooleanTrue constants?


CFBoolean *is* toll free bridged to NSNumber.



OK, so where is that documented then? As I said, the CFBoolean  
reference

says not a word about it:

   <
http://developer.apple.com/documentation/CoreFoundation/Reference/CFBooleanRef/Reference/reference.html




By contrast, every other toll-free bridged CF class I can think of
explicitly documents that fact.

sherm--


I don't know but that what Apple do in the samples on ADC (http://developer.apple.com/samplecode/ImageApp/listing4.html).If 
 this is the cause of the crash, i think this sample should be change.


NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:
(id)kCFBooleanTrue, (id)kCGImageSourceShouldCache,
(id)kCFBooleanTrue,  
(id)kCGImageSourceShouldAllowFloat,

nil];


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leopard on PPC

2008-03-27 Thread glenn andreas


On Mar 27, 2008, at 10:59 AM, Sherm Pendley wrote:


CFBoolean *is* toll free bridged to NSNumber.



OK, so where is that documented then? As I said, the CFBoolean  
reference

says not a word about it:



It's more subtle than that.

CFNumber is toll-free bridged with NSNumber.

"toll-free bridged" things need to work both ways - where you can use  
one, you can use the other.


If CFBoolean were toll-free bridged with NSNumber then you can use an  
NSNumber where you can use a CFBoolean.  But since you can also use a  
CFNumber where you can use an NSNumber, this would mean that you can  
use a CFNumber where there is a CFBoolean, which you can't.


CFBoolean is instead just "partially bridged". You can use  
kCFBooleanTrue wherever you can use [NSNumber numberWithBool: YES] and  
kCFBooleanFalse wherever you can use [NSNumber numberWithBool: NO] (in  
that CFBoolean has enough scaffolding to support NSNumber routines,  
and CFBooleanGetValue understands NSNumber).


This does not imply that [NSNumber numberWithBool: YES] ==  
kCFBooleanTrue (it may be, but that's not documented as such), just  
that they are interchangeable.


For example, from 


Cocoa property lists organize data into named values and lists of  
values using these classes:


•NSArray
•NSDictionary
•NSData
•NSString (java.lang.String in Java)
•NSNumber (subclasses of java.lang.Number in Java)
•NSDate

The Core Foundation property list API, defined in CoreServices.h>, supports the following Core Foundation types:


•CFArray
•CFDictionary
•CFData
•CFString
•CFDate
•CFNumber
•CFBoolean
Because all these types can be automatically cast to and from their  
corresponding Cocoa types, you can use the Core Foundation property  
list API with Cocoa objects. In most cases, however, methods  
provided by theNSPropertyListSerialization class should provide  
enough flexibility.





So it is documented that they can be automatically cast to and from  
their corresponding Cocoa types (assuming you're willing to grant that  
NSNumber is the corresponding type for CFBoolean, but they do say  
_all_ of the types, and if it's not NSNumber, there's no clear other  
candidate).





Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next  
generation of fractal art




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Getting a list of all classes, etc...

2008-03-27 Thread Ken Thomases

On Mar 26, 2008, at 11:43 PM, Graham Cox wrote:
I have a class that can contain different objects which all derive  
from a class R. The container can accept instances of any subclass  
of R.


Each subclass of R implements a CLASS method for a particular  
feature, returning an array. The container needs to build an array  
which is the union of all the arrays returned by each subclass. Thus  
it needs to iterate through a list of all possible subclasses of R,  
combining the arrays as it goes. Problem is that not all possible  
subclasses of R are known until runtime, so I need a way to be able  
to get hold of such a list, based on the fact that they all inherit  
from R. Note that these are not instances of R, but classes. (I can  
get a list of instances I have right now, but that doesn't cover the  
possibility of another object instance derived from R being added  
after I already built the array).


Hope this makes sense - any ideas?


You seem to have solved this, but there might be a better way:

Implement +initialize on class R.  Reading the docs on +initialize,  
you'll find that it's called for subclasses of R, too, if those  
subclasses don't override +initialize.  Even if a subclass does  
override +initialize, you can make it a part of the design contract  
that they must call [super initialize].  (Yes, that goes against a  
suggestion in the docs, but in this case you're doing it with eyes  
open for a specific purpose.)


So, now you have arranged that R's +initialize is called for R and  
every one of its subclasses.  In that method, you can use "self" to  
refer to the actual (sub)class being initialized and do whatever is  
appropriate from there.


I hope that's useful,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leopard on PPC

2008-03-27 Thread Sherm Pendley
On Thu, Mar 27, 2008 at 12:22 PM, glenn andreas <[EMAIL PROTECTED]> wrote:

>
> On Mar 27, 2008, at 10:59 AM, Sherm Pendley wrote:
>
> >>> CFBoolean *is* toll free bridged to NSNumber.
> >
> >
> > OK, so where is that documented then? As I said, the CFBoolean
> > reference
> > says not a word about it:
>
> It's more subtle than that.
>

...


> CFBoolean is instead just "partially bridged".


Thanks for the detailed explanation.

I still think that there should be some mention of this in the CFBoolean
reference docs though. I'll file a bug report on that.

sherm--
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: A Tab after 4 SPACEs

2008-03-27 Thread glenn andreas


On Mar 27, 2008, at 11:12 AM, Gerriet M. Denkmann wrote:



On 27 Mar 2008, at 10:08, Uli Kusterer wrote:

On 27.03.2008, at 09:32, Gerriet M. Denkmann wrote:
float widthOfTab = [usedFont advancementForGlyph:(NSGlyph)'  
'].width * 4;



I'm pretty new to the text engine myself, but I don't think an  
NSGlyph can be generated by typecasting a char. Since Monaco or  
Courier are monospaced, it just so happens that you get the same  
width as the space would be. But the glyph with number 0x20 is  
probably a completely different width than the glyph corresponding  
to a space in other languages.


Yes. You are certainly right. Silly mistake of mine.
There should be something like: -[NSFont glyphForChar: (NSString  
*)aString ] which returns NSNotFound if the font does not contain  
the first char in aString.

But I did not find any such method.


You are assuming that there is a one-to-one correspondence between  
characters and glyphs.  There isn't.  Consider simple cases such as  
ligatures (the way that "f" and "l" may combine to a single character  
where the top of the "f" blends in with the top of the "l"), or  
degenerate cases like the way that the entire word "Zapfino" in the  
Zapfino font is a single glyph.  It gets worse once you consider  
internationalization - many languages have different glyphs depending  
on if the character is the first character of a word, in the middle,  
or at the end of the word (so if you get a glyph for a single  
character, you've got a 66% chance of getting the wrong one).




Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
Cardographer | the custom playing card designer


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


NSScroller question

2008-03-27 Thread slasktrattenator
Hi,

NSScroller has a small view, by default two pixels high, just above
the scroller and below the NSTableHeaderView's corner view. How can I
get at this view? If you look at the XCode interface you can see they
have put an icon in this view (the one that splits the editor view)
and made it larger. I would like to remove the view completely so the
scroller goes all the way up to the edge of the corner view.

This question has been addressed before in the archives, but
unfortunately the link pointing to an answer is no longer valid.

Thanks.
F.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSMapTable with pointer keys ?

2008-03-27 Thread Benjamin Stiglitz
[NSMapTable  
mapTableWithKeyOptions:NSMapTableObjectPointerPersonality  
valueOptions:NSMapTableStrongMemory]


(reading the doc for NSMap, I figured these are the right options)

However, when trying to fetch an object with a void* key to check  
for its presence (using the C api as recommended)


NSMapGet(myMap, aKey);

I get an instant crash and looking at the stack trace, it's because  
aKey is being sent an ObjC message, to which it will hard time  
replying since it's not an NSObject in the first place.


That’s because you’ve marked the keys as being object pointers; you’ve  
got your key and value pointer functions reversed.


(Also be sure you want the StrongMemory personality, and not  
OpaqueMemory.)


-Ben___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSMapTable with pointer keys ?

2008-03-27 Thread Guillaume Laurent


On Mar 27, 2008, at 17:51 , Benjamin Stiglitz wrote:

[NSMapTable  
mapTableWithKeyOptions:NSMapTableObjectPointerPersonality  
valueOptions:NSMapTableStrongMemory]


(reading the doc for NSMap, I figured these are the right options)

However, when trying to fetch an object with a void* key to check  
for its presence (using the C api as recommended)


NSMapGet(myMap, aKey);

I get an instant crash and looking at the stack trace, it's because  
aKey is being sent an ObjC message, to which it will hard time  
replying since it's not an NSObject in the first place.


That’s because you’ve marked the keys as being object pointers;  
you’ve got your key and value pointer functions reversed.


Just tried, exact same crash. :-(


(Also be sure you want the StrongMemory personality, and not  
OpaqueMemory.)



Ah, there seem to be a documentation problem here. The NSMapTable doc  
only lists the following personalities as being available :


   NSMapTableStrongMemory = 0,
   NSMapTableZeroingWeakMemory=  
NSPointerFunctionsZeroingWeakMemory,

   NSMapTableCopyIn   = NSPointerFunctionsCopyIn,
   NSMapTableObjectPointerPersonality =  
NSPointerFunctionsObjectPointerPersonality


It also says in the overview section that "only the options listed in  
“Personality Options” guarantee that the rest of the API will work  
correctly". So should I really use NSPointerFunctionsOpaqueMemory  
(which has no documentation either except that it's "Available in Mac  
OS X v10.5 and later") ?


I suppose OpaqueMemory would fit, though, since what I want is to use  
the void* values as index keys, what they are pointing to is  
irrelevant at this stage (it's a C++ object).


--
Guillaume
http://telegraph-road.org





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: outlineViewSelectionDidChange not called

2008-03-27 Thread Adam Gerson
>  Ah.. I'm not quite sure you got what I meant.  In a (document-based)
>  app set up an NSArray *selectionIndexPaths ivar, so the
>  NSTreeController then binds its @"selectionIndexPaths" binding to the
>  keypath @"File's Owner.selectionIndexPaths" where file's owner is the
>  owner of the nib containing the tree controller and the outline view.
>  The outline view then has its content bound to the tree controller's
>  @"arrangedObjects" controller key, the selectionIndexPaths to the
>  @"selectionIndexPaths" controller key and then the outline view's
>  table column's @"value" binding is set to the tree controller's
>  @"arrangedObjects.nodeName" (nodeName is just an NSString
>  representation of a file path).
>
Ok, I understand. So I bind both the OutlineView and the
TreeController to a third object that keeps them both in sync to the
same SelectionIndexPath value. However, when I tried this my
OutlineView was blank. I think the Outline Views's selectionIndexPaths
binding refers to the selectionIndexPaths of its content provider(in
this case the tree controller). I dont think and outline view has
selectionIndexPaths properties of its own.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSMapTable with pointer keys ?

2008-03-27 Thread Guillaume Laurent


On Mar 27, 2008, at 17:54 , A.M. wrote:



On Mar 27, 2008, at 11:24 AM, Guillaume Laurent wrote:


Hi all,

I need to build a map of NSObjects indexed by void* pointers.  
Apparently the right way to do this is to use NSMapTable with the  
appropriate options :


[NSMapTable  
mapTableWithKeyOptions:NSMapTableObjectPointerPersonality  
valueOptions:NSMapTableStrongMemory]


(reading the doc for NSMap, I figured these are the right options)

However, when trying to fetch an object with a void* key to check  
for its presence (using the C api as recommended)


NSMapGet(myMap, aKey);

I get an instant crash and looking at the stack trace, it's because  
aKey is being sent an ObjC message, to which it will hard time  
replying since it's not an NSObject in the first place.


What am I missing here ?


Unless those void pointers are subject to garbage collection,



I hope the void pointers aren't GC'ed - they are pointers to C++  
objects, I assume the GC handles C++ objects properly too, that is it  
won't try to free them under my feet.


 I think you would have an easier time with NSMutableDictionary and  
[NSValue valueWithPointer:&x] as the key.



Thanks, I'll try that too.

--
Guillaume
http://telegraph-road.org





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Ephemeral Changes

2008-03-27 Thread Gerriet M. Denkmann


On 27 Mar 2008, at 09:50, Jens Miltner wrote:


Am 26.03.2008 um 11:26 schrieb Gerriet M. Denkmann:
I also can use Edit  ► Undo Set (or Paste) Font but now the  
document gets dirty. Very bad. Also: the complete text gets selected.
So what else do I have to implement? I tried setFont: and  
setFont:range:, but these seem never to be called.

How does the NSUndoManager undo my font changes?


Hmmh - how about completely disabling the built-in undo support for  
these functions (as was proposed before), and manually add undo  
actions?
That way you'd have control over the undo action yourself and could  
once again mark the document as unchanged after the undo



Yes. As I do not know how to recognize the actions when overriding  
undo/redo in NSUndoManager this definitly is the best (or even the  
only) way.


Thank you very much!

Kind regards,

Gerriet.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Ephemeral Changes

2008-03-27 Thread Gerriet M. Denkmann


On 27 Mar 2008, at 14:46, Jens Miltner wrote:


Am 27.03.2008 um 11:57 schrieb Gerriet M. Denkmann:

On 26 Mar 2008, at 22:56, Graham Cox wrote:
The undo manager will directly change the data in the text view  
using an invocation or target/action - it doesn't go back through  
changeFont: normally, which is really a "high level" method.


Maybe the solution to this is to subclass NSUndoManager so that  
you can hook into the undo and redo methods and use those  
opportunities to modify the change count of the document.


So I implement in MyUndoManager:
- (void)undo
{
NSString *action = [self undoActionName];
[ super undo ];
	if ( action contains "Font" ) [myDocument  
updateChangeCount:NSChangeUndone];

}



Maybe there's a way to trigger on the action selector instead of  
the action name? However, even the action selector _might_ change  
in future AppKit versions, so even this would be a somewhat fragile  
solution.


I'd still think that it might be easier to register you own undo  
action for the font changes instead of trying to hijack the  
automatic undo...


just my €.02,


You are right. And I have just implemented your suggestions. And all  
seems to be perfect now.

Thank you again!

Kind regards,

Gerriet.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


NSToolbar doesn't add default items issue on 10.5.2

2008-03-27 Thread Martin Redington


I've got some NSToolbar code, which seems to have suddenly stopped  
working on Leopard only.


- (void) setupToolbar
{
NSLog(@"Setting up toolbar");

//[self removeObsoleteToolbarIdentifiers];

NSToolbar *toolbar = [[MMICleanerToolbar alloc]  
initWithIdentifier:@"CleanerToolbar"];


[toolbar setAllowsUserCustomization:YES];
[toolbar setAutosavesConfiguration:YES];
[toolbar setDelegate:self];

NSLog(@"Setting toolbar %@ for window %@", toolbar,  
mMainCleanerWindow);

[mMainCleanerWindow setToolbar:toolbar];
// release it as well? TODO
NSLog(@"Set up toolbar");
}

MMICleanerToolbar is a subclass of NSToolbar, but actually doesn't  
implement any methods, so it's an NSToolbar for all intents and  
purposes.


On Tiger, I can see the delegates -toolbarDefaultItemIdentifiers:  
method get called, followed by the NSToolbarItem calls, after the  
setToolbar: method.


On Leopard (10.5.2/9C31) [latest security update not installed yet],  
the delegate methods aren't getting called, and I get an empty  
toolbar, which looks to be slightly less tall than the standard  
toolbar with small items.


I rolled back over a few revisions of my app, and they all seem to be  
affected, so it doesn't seem like I've broken anything recently. The  
first user report I got for this was today (in fact I got two).


As I workaround, I'm checking [[toolbar items] count], after  
setToolbar: and manually inserting the default item set if the  
toolbar is empty.
















___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


NSTextField and IB Weirdness

2008-03-27 Thread Mike

I am using Xcode 2.5 and IB Version 2.5.6 (489).

I have a window with two NSTextFields. Both are static.

I've verified all my outlets and connections are valid.

Both outlet types are set to NSTextField in IB's inspector pallette.

However, when I generate the class files, no matter what I do, the first 
NSTextField is created as type id instead of NSTextField. When my object 
initializes in awakeFromNib, the debugger shows outlet listed as a 
NSTextField initialized, but the one created as id is nil.


Even if I change the id outlet's type to NSTextField, it still will not 
initialize. I then go back to IB and verify that my item in the window 
is still set to type NSTextField, but it won't initialize no matter what 
I do.


Both NSTextField's are identical. One works, one doesn't and it isn't 
clear why.


Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


setMenuVisible

2008-03-27 Thread Wesley Smith
I'm trying to make an NSWindow that takes up the entire screen
including the menu bar but is not actually a fullscreen window.  I
know this is possible with Carbon, but I can't figure it out with
Cocoa.  Whenever I call [NSMenu setMenuVisible:TRUE], the menubar goes
away, but so does my window.  I can't for the life of me figure out
how to hide one without the other.  The reason I want to do this is so
that the user can bring other windows on top of the window despite it
taking up the entire screen.  Any help appreciated.
thanks,
wes
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: outlineViewSelectionDidChange not called

2008-03-27 Thread Hamish Allan
On Thu, Mar 27, 2008 at 5:17 PM, Adam Gerson <[EMAIL PROTECTED]> wrote:

>  Ok, I understand. So I bind both the OutlineView and the
>  TreeController to a third object that keeps them both in sync to the
>  same SelectionIndexPath value.

No -- you bind the view to the controller and the controller to the model.

>  However, when I tried this my
>  OutlineView was blank. I think the Outline Views's selectionIndexPaths
>  binding refers to the selectionIndexPaths of its content provider (in
>  this case the tree controller). I dont think and outline view has
>  selectionIndexPaths properties of its own.

If your outline view is blank there is a problem with your
content/value bindings; this is a separate issue to the selection
index path bindings.

Basically, you need the following bindings (assuming you have
NSMutableArray properties called "content" and "selectionIndexPaths"
in your File's Owner):

(View to Controller bindings:)
NSOutlineView's Content to NSTreeController's arrangedObjects.
NSOutlineView's Selection Index Paths to NSTreeController's selectionIndexPaths
NSTableColumn's Value to NSTreeController's arrangedObjects.nodeName

(Controller to Model bindings:)
NSTreeController's Content Array to File's Owner's content
NSTreeController's Selection Index Paths to File's Owner's selectionIndexPaths

Then, if you need to "update some non controller bound GUI controls
when the selection changes", you need your secondary controller (well,
it's neither model nor view, is it?!) to observe your File's Owner's
selectionIndexPaths (using addObserver:forKeyPath:options:context:)
and update the controls accordingly.

Best wishes,
Hamish
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSToolbar doesn't add default items issue on 10.5.2

2008-03-27 Thread Peter Ammon


On Mar 27, 2008, at 10:58 AM, Martin Redington wrote:




On Tiger, I can see the delegates -toolbarDefaultItemIdentifiers:  
method get called, followed by the NSToolbarItem calls, after the  
setToolbar: method.


On Leopard (10.5.2/9C31) [latest security update not installed yet],  
the delegate methods aren't getting called, and I get an empty  
toolbar, which looks to be slightly less tall than the standard  
toolbar with small items.



Hmm. When you open up your app's preferences with Property List  
Editor, what data is there for your toolbar, as its autosaved  
configuration?


-Peter

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Core Data & IB in prefs pane

2008-03-27 Thread Rick Mann
I'm trying to use what I learned yesterday about Core Data in a System  
Prefs pane. I created an Entity data model, and then tried to add an  
NSTable and some buttons and wire them up the same way I'd seen the  
Core Data Entity tool do it in IB. But, it didn't work.


So I tried using the Core Data Entity tool to let IB do it, and it  
disables the Add and Remove buttons.


The only difference I can spot is in yesterday's project, the File's  
Owner is an NSDocument. Today, it's a PrefsPane.


Is it possible to use this stuff in a prefs pane? What am I missing?

Thanks!

--
Rick

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


programatically show NSSegmentedCell menu?

2008-03-27 Thread Jesse Grosjean
I'm trying to programatically show a NSSgetmentedCell menu, as if the  
user has clicked on that segmented cell. For normal popup buttons you  
can do this with 'performClick:', but that doesn't work for segmented  
controls, because it will always just perform the click on the middle  
cell. Is there a way to do a "targeted" performClick on a  
NSSegmentedControl? That's targeted to a specific cell?


Thanks,
Jesse
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Interface Builder

2008-03-27 Thread Thiago Rossi
Well, I tried some things at home but didn't get success. =(

I'm trying to do this: I have a controller with an array of accounts. And
these albums has a type associated to it. For example:
ACCOUNT 01 - BANK ACCOUNT
ACCOUNT 02 - BANK ACCOUNT
ACCOUNT 03 - LOAN ACCOUNT
ACCOUNT 04 - BANK ACCOUNT

I want to show, as in iPhoto hierararchy, this way:
BANK ACCOUNT
  ACCOUNT 01
  ACCOUNT 02
  ACCOUNT 04
LOAN ACCOUNT
  ACCOUNT 03

When the user clicks in any account, in the main view it shows its details.
And you can hide/show sub-items by clicking on the parent (in this example,
bank account or loan account).

I tried to find any source code as an example, but I could not find any. =(

Can anyone help me?!

Please?! Thanks!


On 3/17/08, Thiago Rossi <[EMAIL PROTECTED]> wrote:
>
> thanks for your help, robert. you helped me a lot! =)
>
> On Mon, Mar 17, 2008 at 7:43 PM, Robert Walker <
> [EMAIL PROTECTED]> wrote:
>
> > Most of what you see in this window is likely a custom view designed and
> > built by the Apple iPhoto developers. The blue sidebar is one pane of a
> > split view with what's probably a customized tree view. The photo area
> > window can now be accomplished using the new image browser from the image
> > kit. The toolbar at the bottom of the window is likely a custom view.
> >   On Mar 16, 2008, at 10:57 AM, Thiago Rossi wrote:
> >
> >
> >
> >   I would like to know how to draw a window like iPhoto.
> >
> > For example, what kind of object are the light-blue bar on the left? And
> > the dark one (main)? And the toolbar inside the dark one, on the bottom? Ok,
> > they may be easy. But how about the object that display the text LIBRARY?
> > And the other one for RECENT? And Events, Photos, Last 12 Months, Last
> > Import, Flagged, Trash, albums…?
> >
> >
> > Could you please help me?
> >
> >
> >   ___
> > Do not post admin requests to the list. They will be ignored.
> > Webobjects-dev mailing list  ([EMAIL PROTECTED])
> > Help/Unsubscribe/Update your Subscription:
> >
> > http://lists.apple.com/mailman/options/webobjects-dev/robert.walker%40bennettig.com
> >
> >
> > This email sent to [EMAIL PROTECTED]
> >
> >
> >  Robert Walker
> > [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> >
> >
> >
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: programatically show NSSegmentedCell menu?

2008-03-27 Thread Bob Clark

On Mar 27, 2008, at 1:21 PM, Jesse Grosjean wrote:
I'm trying to programatically show a NSSgetmentedCell menu, as if  
the user has clicked on that segmented cell. For normal popup  
buttons you can do this with 'performClick:', but that doesn't work  
for segmented controls, because it will always just perform the  
click on the middle cell. Is there a way to do a "targeted"  
performClick on a NSSegmentedControl? That's targeted to a specific  
cell?


Hi Jesse.

Use setSelectedSegment instead.

NSSegmentedControl* seg;
...
[seg setSelectedSegment:4];


--
Bob Clark
Lead Software Development Engineer
RealPlayer Mac/Unix
RealNetworks, Inc.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Leopard on PPC

2008-03-27 Thread Scott Thompson


On Mar 27, 2008, at 10:29 AM, Clark Cox wrote:

On Wed, Mar 26, 2008 at 4:04 PM, Lorenzo <[EMAIL PROTECTED]> wrote:

Hi Laurent,
I am going to debug and let you know. Right now I have found these  
lines.

Might they cause the trouble on Leopard && PPC?



No, but this line will cause problems when/if you build for 64-bit:
   number = CFNumberCreate(NULL, kCFNumberFloatType,  
&destSize.width);


Use kCFNumberCGFloatType instead of kCFNumberFloatType, and make sure
that you later CFRelease(number). Or just use NSNumber.


You could just use NSNumber, if it were not for the fact that NSNumber  
doesn't have any API support for CGFloat. :-)


 (rdar: //5812091)

You can add it with a category:

@implementation NSNumber (CGFloatSupport)

+ (NSNumber *) numberWithCGFloat: (CGFloat) cgFloatValue
{
	CFNumberRef cfVersion = CFNumberCreate(NULL, kCFNumberCGFloatType,  
&cgFloatValue);

return [NSMakeCollectable(cfVersion) autorelease];
}

- (CGFloat) cgFloatValue
{
CGFloat retVal = 0;

CFNumberGetValue((CFNumberRef) self, kCFNumberCGFloatType, &retVal);

return retVal;
}
@end
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: programatically show NSSegmentedCell menu?

2008-03-27 Thread Jesse Grosjean

Bob,

Thanks, but that only seems to select the cell. I want to temporarily  
highlight the cell, and show the menu, as if the user has clicked on  
it. Anyway looking into synthesizing the mouse event now.


Jesse

On Mar 27, 2008, at 4:32 PM, Bob Clark wrote:

On Mar 27, 2008, at 1:21 PM, Jesse Grosjean wrote:
I'm trying to programatically show a NSSgetmentedCell menu, as if  
the user has clicked on that segmented cell. For normal popup  
buttons you can do this with 'performClick:', but that doesn't work  
for segmented controls, because it will always just perform the  
click on the middle cell. Is there a way to do a "targeted"  
performClick on a NSSegmentedControl? That's targeted to a specific  
cell?


Hi Jesse.

Use setSelectedSegment instead.

   NSSegmentedControl* seg;
   ...
   [seg setSelectedSegment:4];


--
Bob Clark
Lead Software Development Engineer
RealPlayer Mac/Unix
RealNetworks, Inc.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Static in Subclasses

2008-03-27 Thread Justin Giboney
I need to create a series of classes that implement the Singleton  
design pattern. These classes have a lot of similar methods (I am  
trying to create a series of DAOs see: http://en.wikipedia.org/wiki/Data_Access_Object) 
.


I was thinking that it would be best to create a super class, and a  
series of subclasses to that super class. The problem I am running  
upon is that the Singleton pattern requires a static variable.


How can I get a variable that is static to each subclass, but that is  
declared in the super class?


for example I tried this.

/*-
#import 

@interface SuperClass : NSObject {
}
- (void) addToMyVar;
- (int) getMyVar;
@end

@implementation SuperClass
static int MyVar = 0;

- (void) addToMyVar {
++MyVar;
}

- (int) getMyVar {
return MyVar;
}
@end

@interface SubClass1 : SuperClass {
}
@end
@implementation SubClass1
@end

@interface SubClass2 : SuperClass {
}
@end
@implementation SubClass2
@end

int main(int argc, char *argv[])
{

SubClass1 *mySubClass1 = [[SubClass1 alloc] init];
SubClass2 *mySubClass2 = [[SubClass2 alloc] init];
NSLog(@"1 before = %i", [mySubClass1 getMyVar]);
NSLog(@"2 before = %i", [mySubClass2 getMyVar]);
[mySubClass1 addToMyVar];
NSLog(@"1 after 1 = %i", [mySubClass1 getMyVar]);
NSLog(@"2 after 1 = %i", [mySubClass2 getMyVar]);
[mySubClass2 addToMyVar];
NSLog(@"1 after 2 = %i", [mySubClass1 getMyVar]);
NSLog(@"2 after 2 = %i", [mySubClass2 getMyVar]);

return NSApplicationMain(argc,  (const char **) argv);
}


--*/

which outputs the following

2008-03-27 14:34:31.040 TimeKeeper[790:10b] 1 before = 0
2008-03-27 14:34:31.045 TimeKeeper[790:10b] 2 before = 0
2008-03-27 14:34:31.046 TimeKeeper[790:10b] 1 after 1 = 1
2008-03-27 14:34:31.047 TimeKeeper[790:10b] 2 after 1 = 1
2008-03-27 14:34:31.048 TimeKeeper[790:10b] 1 after 2 = 2
2008-03-27 14:34:31.049 TimeKeeper[790:10b] 2 after 2 = 2

I want it so that it outputs

2008-03-27 14:34:31.040 TimeKeeper[790:10b] 1 before = 0
2008-03-27 14:34:31.045 TimeKeeper[790:10b] 2 before = 0
2008-03-27 14:34:31.046 TimeKeeper[790:10b] 1 after 1 = 1
2008-03-27 14:34:31.047 TimeKeeper[790:10b] 2 after 1 = 0
2008-03-27 14:34:31.048 TimeKeeper[790:10b] 1 after 2 = 1
2008-03-27 14:34:31.049 TimeKeeper[790:10b] 2 after 2 = 1

Thank you,

Justin Giboney
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: applicationWillTerminate and animations

2008-03-27 Thread Troy Stephens

On Mar 27, 2008, at 7:14 AM, Mitchell Livingston wrote:

Hello,

When my program quits, I would like to fade out all the windows  
using the animator. When I put this code in the  
applicationWillTerminate: method, however, it appears to be called  
but doesn't animate. How would I got about to get this to work?


Thank you,
Mitchell Livingston


You'd need to do this earlier, before your windows close, and would  
also need to delay their closure to allow the fade animation time to  
complete.


I'd recommend against such a "feature" though.  Keeping an app  
responsive to the user's request to quit seems more valuable to me.


--
Troy Stephens
Cocoa Frameworks
Apple, Inc.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSScroller question

2008-03-27 Thread Troy Stephens

On Mar 27, 2008, at 9:50 AM, [EMAIL PROTECTED] wrote:

Hi,

NSScroller has a small view, by default two pixels high, just above
the scroller and below the NSTableHeaderView's corner view. How can I
get at this view? If you look at the XCode interface you can see they
have put an icon in this view (the one that splits the editor view)
and made it larger. I would like to remove the view completely so the
scroller goes all the way up to the edge of the corner view.

This question has been addressed before in the archives, but
unfortunately the link pointing to an answer is no longer valid.

Thanks.
F.


See NSTableView.h:

/* Get and set the cornerView. The cornerView is the view that appears  
directly to the right of the headerView above the vertical NSScroller.  
The scroller must be present for the cornerView to be shown. Calling - 
setCornerView: may have the side effect of tiling the  
enclosingScrollView to accomodate the size change. The default value  
is an internal class that properly fills in the corner.

 */
- (void)setCornerView:(NSView *)cornerView;
- (NSView *)cornerView;

--
Troy Stephens
Cocoa Frameworks
Apple, Inc.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Static in Subclasses

2008-03-27 Thread Ken Thomases

On Mar 27, 2008, at 3:44 PM, Justin Giboney wrote:

I need to create a series of classes that implement the Singleton  
design pattern. These classes have a lot of similar methods (I am  
trying to create a series of DAOs see: http://en.wikipedia.org/wiki/ 
Data_Access_Object).


I was thinking that it would be best to create a super class, and a  
series of subclasses to that super class. The problem I am running  
upon is that the Singleton pattern requires a static variable.


How can I get a variable that is static to each subclass, but that  
is declared in the super class?


Objective-C doesn't support the notion of class variables.  The  
convention is to use static variables, which have their usual C  
semantics.  That is, they are not "static to a class", they are  
static to the compilation unit.


You're going to need a static variable in the implementation file of  
each subclass.  It may be possible to pass a pointer to that variable  
to the superclass implementation at a strategic point so you can  
still share code, but this strikes me as more complicated than  
necessary.


Also, I'm aware that there are some implementations of the basic  
Singleton functionality in a reusable forms.  You can search the list  
archives for them. I don't remember them off-hand.  Here's one:  
http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/ 
Foundation/GTMObjectSingleton.h


You're probably familiar with this, but I thought I'd add it for  
completeness: http://developer.apple.com/documentation/Cocoa/ 
Conceptual/CocoaFundamentals/CocoaObjects/chapter_3_section_10.html


Cheers,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CoreAnimation weird problems with NSView animator

2008-03-27 Thread Troy Stephens

On Mar 26, 2008, at 9:12 AM, Milen Dzhumerov wrote:

Hi all,

I've been playing with CA today and encountered some weird problems.  
Firstly, I tested setHidden: on an animator on a NSSegmentedView and  
it worked fine - it gets faded in/out. Now, all the problems I  
encountered happen in another NIB file. I've got the following piece  
of code (in a controller):


[self.generalView setHidden:YES];
[self.window setContentView:self.generalView];
[[self.generalView animator] setHidden:NO];


This should produce a fade transition, as long as self.generalView's  
superview, or an ancestor view higher up, has wantsLayer == YES.


Does it help if you wrap the un-hide in an explicit NSAnimationContext  
begin/end?


[NSAnimationContext beginGrouping];
[[self.generalView animator] setHidden:NO];
[NSAnimationContext endGrouping];

I expect this to animate the view but it doesn't happen - no  
animation goes on. I've made sure that all NSView's want layers. I  
also noticed some other unusual problems

with the said NIB:
- Animations work on a random basis (CA animations)


A more specific example would help.

- If I attach an outlet to a particular NSPopUpButton, it  
disappears. Removing the outlet makes it appear again


The NSPopUpButton disappears?  What do you see when you look at the  
popup button's state when this has happened?  (i.e. What does - 
isHiddenOrHasHiddenAncestor report, and frame, superview, etc.?)   
Something must be collapsing it, hiding it, removing it from the view  
tree, or moving it out of its superview's visibleRect.


I think I'm missing some setup here but I cannot figure out exactly  
what it is. The NIB (saved as a XIB) was created from scratch (i.e.,  
not included in a project template) but I can't see how this can be  
a problem. Any help is greatly appreciated.


M



--
Troy Stephens
Cocoa Frameworks
Apple, Inc.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Static in Subclasses

2008-03-27 Thread Hamish Allan
On Thu, Mar 27, 2008 at 8:44 PM, Justin Giboney
<[EMAIL PROTECTED]> wrote:

>  How can I get a variable that is static to each subclass, but that is
>  declared in the super class?

In short, you can't. "static" in C means "within the scope of the
source file". Split your subclasses off into their own files, define
your static variables there, give them accessor methods, and use those
accessors in the superclass.

Hamish
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How to get current renderer for an NSOpenGLView?

2008-03-27 Thread Troy Stephens

On Mar 26, 2008, at 2:54 PM, Duncan Champney wrote:
I need to find out the amount of total VRAM and available VRAM in  
the current renderer before creating a large renderbuffer object, to  
make sure I don't choke the system in doing it.


I know how to find the current renderer for a given display, but I  
want the current renderer for my NSOpenGLView. I can get to the core  
graphics context like this:


  //code is from my NSOpenGLView object, so self refers to an  
NSOpenGLView

  NSOpenGLContext* theContext = [self openGLContext];
  void* the_CGLContext = [theContext CGLContextObj];

But that still doesn't get me to the renderer. What I want to to is  
get a handle to the current renderer's CGLRendererInfoObj, then use  
the call:


   CGLDescribeRenderer (theRendererInfoObj, theRendererInex,  
kCGLRPVideoMemory,

&deviceVRAM);

But I can't for the life of me figure out how to get from my  
NSOpenGLView to the renderer's CGLRendererInfoObj. I don't want to  
assume that the openGL view is on the main display, as all the  
example code I can find does.


Can somebody help me here? I'm going in circles with the  
documentation, and can't find an answer to this.


On 10.5, you can get the CGLContext's CGLPixelFormat using  
CGLGetPixelFormat(), and get the CGLPixelFormat's kCGLPFARendererID  
using CGLDescribePixelFormat().  From that I think you should be able  
to identify the applicable renderer from among those available.   
That's the most direct route that I'm aware of, but you may be able to  
get a better recommendation from the experts on the Mac-OpenGL list.


--
Troy Stephens
Cocoa Frameworks
Apple, Inc.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Static in Subclasses

2008-03-27 Thread Troy Stephens

On Mar 27, 2008, at 2:05 PM, Hamish Allan wrote:

On Thu, Mar 27, 2008 at 8:44 PM, Justin Giboney
<[EMAIL PROTECTED]> wrote:


How can I get a variable that is static to each subclass, but that is
declared in the super class?


In short, you can't. "static" in C means "within the scope of the
source file". Split your subclasses off into their own files, define
your static variables there, give them accessor methods, and use those
accessors in the superclass.


Alternatively, if this isn't practical for some reason, you might  
consider using an NSMapTable or similar data structure to store your  
per-class info, keyed by class.


Troy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Getting a list of all classes, etc...

2008-03-27 Thread Chris Suter


On 28/03/2008, at 3:23 AM, Ken Thomases wrote:


On Mar 26, 2008, at 11:43 PM, Graham Cox wrote:
I have a class that can contain different objects which all derive  
from a class R. The container can accept instances of any subclass  
of R.


Each subclass of R implements a CLASS method for a particular  
feature, returning an array. The container needs to build an array  
which is the union of all the arrays returned by each subclass.  
Thus it needs to iterate through a list of all possible subclasses  
of R, combining the arrays as it goes. Problem is that not all  
possible subclasses of R are known until runtime, so I need a way  
to be able to get hold of such a list, based on the fact that they  
all inherit from R. Note that these are not instances of R, but  
classes. (I can get a list of instances I have right now, but that  
doesn't cover the possibility of another object instance derived  
from R being added after I already built the array).


Hope this makes sense - any ideas?


You seem to have solved this, but there might be a better way:

Implement +initialize on class R.  Reading the docs on +initialize,  
you'll find that it's called for subclasses of R, too, if those  
subclasses don't override +initialize.  Even if a subclass does  
override +initialize, you can make it a part of the design contract  
that they must call [super initialize].  (Yes, that goes against a  
suggestion in the docs, but in this case you're doing it with eyes  
open for a specific purpose.)


So, now you have arranged that R's +initialize is called for R and  
every one of its subclasses.  In that method, you can use "self" to  
refer to the actual (sub)class being initialized and do whatever is  
appropriate from there.


The problem with using initialize is that it's only guaranteed to be  
sent just before the first message is sent to that class (which might  
not be at all if the class isn't used).


- Chris

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSMapTable with pointer keys ?

2008-03-27 Thread Guillaume Laurent


On Mar 27, 2008, at 18:17 , Guillaume Laurent wrote:



On Mar 27, 2008, at 17:54 , A.M. wrote:



I think you would have an easier time with NSMutableDictionary and  
[NSValue valueWithPointer:&x] as the key.



Thanks, I'll try that too.



Indeed, that seem to be the simplest solution. I couldn't get  
NSMapTable to work at all in that case, kinda frustrating.


--
Guillaume
http://telegraph-road.org





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Is @"constantstring" pointer equal to @"constantstring" a guarantee?

2008-03-27 Thread Nathan Vander Wilt
If I make two identical string constants
(@"samestring" and @"samestring") in my Cocoa program,
are their pointers guaranteed to be equal? I assumed
this without thinking while prototyping root objects
in an NSOutline view and it did work, however I just
realized that perhaps I shouldn't rely on this
behaviour.

The compiler documentation
(http://developer.apple.com/documentation/developertools/gcc-4.0.1/gcc/Constant-string-objects.html)
doesn't say either way. The CFString documentation
(http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFStrings/Articles/CreatingAndCopying.html)
says about the CFSTR() macro: "If there are two or
more exact instances of a constant string in an
executable, in some cases only one might be stored."
Which I'll take to mean that in some cases two or more
might be stored.

However, when I get to the documentation for the
@"..." construct
(http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/CreatingStrings.html)
it says "The compiler makes such object constants
unique on a per-module basis...".

So does that mean once I'm up at the Cocoa level, that
constant strings *are* guaranteed to have the same
pointer if their contents are the same? What is
"unique" and what is a "module" in this context?

thanks,
-natevw



  

¡Capacidad ilimitada de almacenamiento en tu correo!
No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:  

http://correo.espanol.yahoo.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSScroller question

2008-03-27 Thread slasktrattenator
Thanks, but the corner view is the right side corner of the header
view, right? I was talking about the small view just below it, on top
of the vertical slider and part of the slider itself. It's a tiny view
of about 2 pixels height. I believe it corresponds to
NSScrollerNoPart, but I'm not sure.

On Thu, Mar 27, 2008 at 9:53 PM, Troy Stephens <[EMAIL PROTECTED]> wrote:
>
> On Mar 27, 2008, at 9:50 AM, [EMAIL PROTECTED] wrote:
>  > Hi,
>  >
>  > NSScroller has a small view, by default two pixels high, just above
>  > the scroller and below the NSTableHeaderView's corner view. How can I
>  > get at this view? If you look at the XCode interface you can see they
>  > have put an icon in this view (the one that splits the editor view)
>  > and made it larger. I would like to remove the view completely so the
>  > scroller goes all the way up to the edge of the corner view.
>  >
>  > This question has been addressed before in the archives, but
>  > unfortunately the link pointing to an answer is no longer valid.
>  >
>  > Thanks.
>  > F.
>
>  See NSTableView.h:
>
>  /* Get and set the cornerView. The cornerView is the view that appears
>  directly to the right of the headerView above the vertical NSScroller.
>  The scroller must be present for the cornerView to be shown. Calling -
>  setCornerView: may have the side effect of tiling the
>  enclosingScrollView to accomodate the size change. The default value
>  is an internal class that properly fills in the corner.
>   */
>  - (void)setCornerView:(NSView *)cornerView;
>  - (NSView *)cornerView;
>
>  --
>  Troy Stephens
>  Cocoa Frameworks
>  Apple, Inc.
>
>
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?

2008-03-27 Thread Bill Bumgarner

On Mar 27, 2008, at 4:20 PM, Nathan Vander Wilt wrote:

So does that mean once I'm up at the Cocoa level, that
constant strings *are* guaranteed to have the same
pointer if their contents are the same? What is
"unique" and what is a "module" in this context?


They might be unique, they might not.  It might change over time or in  
context of usage.  And it may change if you suddenly decide that one  
of those global constant strings really needs to be configurable at  
runtime.


Best not to rely upon it.

In general, -isEqual*: methods are optimized to check for pointer  
identity equality, if it is a significant optimization. Certainly, the  
cost of a msgSend() is greater than a pointer equality test, but  
likely not in any significant fashion.


Instruments or Shark can, of course, answer whether or not it matters.

b.bum

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSScroller question

2008-03-27 Thread Troy Stephens


On Mar 27, 2008, at 4:26 PM, [EMAIL PROTECTED] wrote:

Thanks, but the corner view is the right side corner of the header
view, right? I was talking about the small view just below it, on top
of the vertical slider and part of the slider itself. It's a tiny view
of about 2 pixels height. I believe it corresponds to
NSScrollerNoPart, but I'm not sure.


(By "slider" I take it you really mean "scroller", as NSSlider is  
something else entirely. :-)


An NSScroller (currently) has no subviews, but if your aim is to add  
one or more accessory views above the scroller, that can be done by  
subclassing NSScrollView.  The key is to override NSScrollView's -tile  
method to invoke [super tile], and then adjust the layout to  
accommodate your accessory subview(s).  Figure out where you want your  
accessory subview(s) to go, set their frame(s), and change the  
ScrollView's verticalScroller's frame (shrink and move down, since  
ScrollViews are flipped) to make room for them.





On Thu, Mar 27, 2008 at 9:53 PM, Troy Stephens <[EMAIL PROTECTED]>  
wrote:


On Mar 27, 2008, at 9:50 AM, [EMAIL PROTECTED] wrote:

Hi,

NSScroller has a small view, by default two pixels high, just above
the scroller and below the NSTableHeaderView's corner view. How  
can I
get at this view? If you look at the XCode interface you can see  
they

have put an icon in this view (the one that splits the editor view)
and made it larger. I would like to remove the view completely so  
the

scroller goes all the way up to the edge of the corner view.

This question has been addressed before in the archives, but
unfortunately the link pointing to an answer is no longer valid.

Thanks.
F.


See NSTableView.h:

/* Get and set the cornerView. The cornerView is the view that  
appears
directly to the right of the headerView above the vertical  
NSScroller.
The scroller must be present for the cornerView to be shown.  
Calling -

setCornerView: may have the side effect of tiling the
enclosingScrollView to accomodate the size change. The default value
is an internal class that properly fills in the corner.
 */
- (void)setCornerView:(NSView *)cornerView;
- (NSView *)cornerView;

--
Troy Stephens
Cocoa Frameworks
Apple, Inc.







--
Troy Stephens
Cocoa Frameworks
Apple, Inc.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: A Tab after 4 SPACEs

2008-03-27 Thread Alastair Houghton

On 27 Mar 2008, at 16:12, Gerriet M. Denkmann wrote:


Current I am using:

NSString *dummyString = [ NSString stringWithUTF8String: " " ];   
NSTextView *dummyTextView = [ [ NSTextView alloc ] initWithFrame:  
NSMakeRect(0,0,1e4,1e4) ];

[ dummyTextView setString: dummyString ];
[ dummyTextView setFont: usedFont ];
NSLayoutManager *dummyLayoutManager = [ dummyTextView layoutManager ];
[ dummyLayoutManager setUsesScreenFonts: useScreenFont ];
unsigned int length = [ dummyString length ];
NSRange glyphRange = 	[ dummyLayoutManager 	 
glyphRangeForCharacterRange: 	NSMakeRange(0,length)   
actualCharacterRange: NULL ];

unsigned int glyphIndex = glyphRange.location;
NSTextContainer *aTextContainer = [ dummyLayoutManager 	 
textContainerForGlyphAtIndex: 	glyphIndex  effectiveRange: NULL ];
NSRect boundingRect =	[ dummyLayoutManager 	 
boundingRectForGlyphRange: 	glyphRange inTextContainer: 	 
aTextContainer];

[dummyTextView release];
float widtOfDummyString = boundingRect.size.width;

This looks incredible clumsy. Do you know of any better way?


How about the following (largely untested; I did check that the glyph  
returned seemed sane):


  NSGlyph glyph = [usedFont glyphWithName:@"space"];
  NSSize size;

  [usedFont getAdvancements:&size forGlyphs:&glyph count:1];

("space" is the standard PostScript name for the space glyph; see,  
e.g. )


Alternatively you could use the Core Text function  
CTFontGetGlyphsForCharacters() (but you'd need a CTFontRef rather than  
an NSFont), or you could implement a lightweight NSGlyphStorage and  
use either the shared NSGlyphGenerator or the one from your layout  
manager.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Core Data faulting and bindings: recursive KVO notifications?

2008-03-27 Thread Dennis Lorson

Hi,

I have a Core Data (single-doc) application in which I have a medium- 
complex object graph.


In this application, a main entity (Image) forms the master part (they  
are displayed in a list), and this entity has several properties.
I use an array controller to manage the Image selection, and I have a  
detail view (Inspector, if you will) displaying the properties.


The problem I'm having arises when selecting all images at once  
(Command+A), if they are fairly large in number (in my store: ~2000).   
This takes an enormous time that is definitely > O(n).
Sampler reveals nothing particular because processing time is  
generally divided between many lower-level CD operations (string  
creation, etc.)
Upon inspecting the issue closer, it seems that the stack reaches a  
large depth (trace > 20.000).  Of course, this is some kind of  
recursion.  The stack recursive pattern is:


#0  0x0002cba2 in -[ImageArrayController  
observeValueForKeyPath:ofObject:change:context:] at  
ImageArrayController.m:345

#1  0x91abb58e in NSKVONotify
#2  0x91abb58e in NSKVONotify
#3	0x91b6fdec in -[NSObject(NSKeyValueObservingPrivate)  
_didChangeValuesForKeys:]

#4  0x937d290d in _PFFaultHandlerFulfillFault
#5  0x9380bf3a in -[NSFaultHandler fulfillFault:withContext:]
#6  0x937d4102 in _sharedIMPL_pvfk_core
#7  0x937d4c3c in -[NSManagedObject valueForKey:]
#8  0x91a8c39a in -[NSObject(NSKeyValueCoding) valueForKeyPath:]
#9  0x91a8c300 in -[NSObject(NSKeyValueCoding) valueForKeyPath:]
#10 0x94de7516 in -[NSArrayController _singleValueForKeyPath:]
#11	0x0002cced in -[ImageArrayController _singleValueForKeyPath:] at  
ImageArrayController.m:370

#12 0x91a8c300 in -[NSObject(NSKeyValueCoding) valueForKeyPath:]
#13	0x94daae48 in -[NSBinder  
_valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:]
#14	0x94daaa50 in -[NSBinder  
valueForBinding:resolveMarkersToPlaceholders:]

#15 0x94ddff8c in -[NSValueBinder _referenceBindingValue]
#16	0x94ddfd57 in -[NSValueBinder  
_adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState 
:]
#17	0x94ddf9e0 in -[NSValueBinder  
_observeValueForKeyPath:ofObject:context:]
#18	0x94de10c1 in -[NSTextValueBinder  
_observeValueForKeyPath:ofObject:context:]

#19 0x91abb58e in NSKVONotify
#20	0x91a4be45 in -[NSObject(NSKeyValueObservingPrivate)  
_notifyObserversForKeyPath:change:]

#21 0x94bcd15e in -[NSController _notifyObserversForKeyPath:change:]
#22	0x94dea920 in -[NSController  
observeValueForKeyPath:ofObject:change:context:]
#23	0x94dea479 in -[NSArrayController  
observeValueForKeyPath:ofObject:change:context:]
#24	0x0002cca4 in -[ImageArrayController  
observeValueForKeyPath:ofObject:change:context:] at  
ImageArrayController.m:361

#25 0x91abb58e in NSKVONotify
#26 0x91abb58e in NSKVONotify



In which [ImageArrayController observeValue:::] is invoked every time  
with the same keypath : @"instrument.magnification", but with a  
different image as observable object.  Instrument is a NSManagedObject  
with float property magnification, and each image has one instrument  
(the inverse relationship is 1..n).


The way I interpret this (it could be wrong, I don't have unlimited  
insight in private APIs)


- the array controller observes a change in keypath  
instrument.magnification of object imageA, and calls super.  This is  
because observers are bound to the selection key of the controller.
- a NSTextField that is bound to  
controller.selection.instrument.magnification receives the  
notification. (through NSTextValueBinder)

- the text field asks for the value of the property.
- a Core Data fault fires for the magnification property.  I assume  
that here, only the properties of Instrument are loaded.  Is this  
correct?
- some object (I assume the Instrument?) invokes [self  
_didChangeValuesForKeys:] because of the fulfilled fault
- since the array controller observes the key, observeValue:::  is  
invoked again with keyPath instrument.magnification, HOWEVER the image  
object is not the same!


This recurses further with all images in the controller selection  
until the whole object graph is in-memory.  It is much slower (>1  
minute on a MBP with 2000 elements in the controller set) than loading  
the data in a normal manner, probably because of spread faulting and  
the large stack depth.


My question now is, why does this recursiveness occur?  Each  
instrument has one image relationship in the test scenario, so why is  
the same keypath triggered for another image object, if the trigger is  
caused by a property of an instrument that is only related to one of  
the two images?


Thanks for any advice,


Dennis
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subs

Re: NSToolbar doesn't add default items issue on 10.5.2

2008-03-27 Thread Martin Redington


On 27 Mar 2008, at 19:34, Peter Ammon wrote:



On Mar 27, 2008, at 10:58 AM, Martin Redington wrote:




On Tiger, I can see the delegates -toolbarDefaultItemIdentifiers:  
method get called, followed by the NSToolbarItem calls, after the  
setToolbar: method.


On Leopard (10.5.2/9C31) [latest security update not installed  
yet], the delegate methods aren't getting called, and I get an  
empty toolbar, which looks to be slightly less tall than the  
standard toolbar with small items.



Hmm. When you open up your app's preferences with Property List  
Editor, what data is there for your toolbar, as its autosaved  
configuration?


None when the problem occurs, as it only seems to hit new users, with  
no existing prefs.


After I've run the app once, I see no entries for the toolbar in the  
prefs.


When I customise the toolbar, and drag the default set in, then  
restart the app, everything works normally, and the prefs look ok.


I think this must be something I'm doing wrong somewhere, as it looks  
like some other expected keys don't make it into the prefs in the  
problem case, and presumably if this was widespread, or an underlying  
bug, it would have been reported far more widely by now, but I'm not  
really seeing any trace of it via google.


It is a bit odd that whatever I'm doing wrong (which I would guess is  
something subtle and not directly toolbar related) leads to this  
behaviour though. I'm pretty sure I'll track this down, so I'll post  
anything I uncover on this thread.










-Peter




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Subverting the first responder chain

2008-03-27 Thread John Stiles
I am implementing a custom NSView subclass (actually a simple subclass 
of NSOpenGLView) that implements -keyDown: in order to respond to user 
typing. Typically, this works great.


However, I have a few menu items which respond to atypical hotkeys (e.g. 
one responds to "space", another to "option+X"). In this case, I've 
found that the view gets a -keyDown: event, which it dutifully handles, 
and the menu hotkey is never handled. I'd prefer it if the menu action 
were triggered and no -keyDown: event were generated, and that's exactly 
what happens with more typical menu hotkeys like command+letters. But my 
view doesn't know what is in the menubar and so, without adding a lot of 
ugly special-case code, from within the view's -keyDown: handler, it 
would be difficult to know whether I need to send the event to the next 
responder or handle the key myself.


Is there any elegant solution to this problem? The last thing I want to 
do is reimplement hotkey handling on my own, but I can't think of any 
workarounds to this issue that don't involve my view taking on a lot of 
extra knowledge about what's in the menubar, or completely hacking the 
responder chain in some ugly way. It seems that I can't forward on to 
the next responder and then ask "did you handle it?"—if the responder 
chain fails to handle the event, apparently it just calls 
-noResponderFor: on the window and that is that—there's no return value 
of "YES" or "NO" or anything like that.


Help...!

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Subverting the first responder chain

2008-03-27 Thread Hamish Allan
On Fri, Mar 28, 2008 at 12:52 AM, John Stiles <[EMAIL PROTECTED]> wrote:

>  However, I have a few menu items which respond to atypical hotkeys (e.g.
>  one responds to "space", another to "option+X"). In this case, I've
>  found that the view gets a -keyDown: event, which it dutifully handles,

Perhaps the right way to look at it from the custom view's perspective
is not "should this be handled by the menu?" but "should this be
handled by me?"

If the answer to the latter question is "no", you should call "[super
keyDown:]". If the answer is "yes", you have an ambiguity in your
keyboard shortcuts.

Hamish
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


error strings in NSPropertyListSerialization

2008-03-27 Thread B.J. Buchalter


In the docs for [NSPropertyListSerialization   
propertyListFromData:mutabilityOption:format:errorDescription:] it has  
the following comment:


Special Considerations
--
Strings returned in errorString needed to be released by the caller  
prior to Mac OS X version 10.5. In Mac OS X version 10.5 and later,  
strings returned inerrorString are memory managed for the caller.




I understand this to mean that prior to 10.5, we needed to do a  
[errorString release]. But I am very unclear what this means  
practically for the code that I am writing today.


I am writing code that is linked to the 10.4u SDK. Does this mean that  
I need to release the string? What happens if my app is run under 10.5?


If I move to the 10.5 SDK, does that mean that I must NOT release the  
string?


Do I need to detect this at runtime, or can I detect this at compile  
time?


TIA,

B.J. Buchalter
Metric Halo
http://www.mhlabs.com



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Subverting the first responder chain

2008-03-27 Thread John Stiles
The view doesn't immediately have a way of knowing whether it should 
handle a key like "space" or not. The app design is predicated around 
the idea that keyboard shortcuts will be consumed before they reach the 
view, which I think is reasonable, and matches reality for standard 
command keys.


The view can be connected to other blobs of code, and I am responsible 
for passing along the message, "hey, the user pressed space!" But it 
will gleefully consume the event no matter what I tell it was pressed.



Hamish Allan wrote:

On Fri, Mar 28, 2008 at 12:52 AM, John Stiles <[EMAIL PROTECTED]> wrote:

  

 However, I have a few menu items which respond to atypical hotkeys (e.g.
 one responds to "space", another to "option+X"). In this case, I've
 found that the view gets a -keyDown: event, which it dutifully handles,



Perhaps the right way to look at it from the custom view's perspective
is not "should this be handled by the menu?" but "should this be
handled by me?"

If the answer to the latter question is "no", you should call "[super
keyDown:]". If the answer is "yes", you have an ambiguity in your
keyboard shortcuts.

Hamish
  

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?

2008-03-27 Thread Jens Alfke


On 27 Mar '08, at 4:20 PM, Nathan Vander Wilt wrote:


So does that mean once I'm up at the Cocoa level, that
constant strings *are* guaranteed to have the same
pointer if their contents are the same? What is
"unique" and what is a "module" in this context?


The linker coalesces multiple identical string constants into a single  
value in the data segment. However, you can still end up with multiple  
copies if your code was linked in separate pieces and then joined  
together. Prior to Xcode 3.0 that used to happen when using ZeroLink —  
in fact, once or twice I've had my code crash when run with ZeroLink  
because I'd inadvertently used pointer comparison instead of  
isEqualToString: somewhere. Xcode 3.0 doesn't have ZeroLink anymore,  
but the details of how your program gets linked together are not  
something you should be relying on.


If you want to use this sort of optimization, it's very easy to write  
a MakeStringUnique( ) function that returns a single unique copy of  
the given NSString; any strings that have been run through that  
function can be compared with ==. All you have to do to implement it  
is keep a global NSMutableSet of NSStrings.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: NSScroller question

2008-03-27 Thread slasktrattenator
Yes, I meant scroller, not slider. Just had a glass of wine too much :-)

Actually I don't want to add an accessory view, I want to get rid of
the one that appears to be there by default. I have attached a
screenshot showing what I'm talking about. The yellow part is the
knob, drawn by filling the rect return by calling [self
rectForPart:NSScrollerKnob]. The green part is the slot,  [self
rectForPart:NSScrollerKnobSlot]. The white part above the slot is by
default black, but here I made it white by filling the rect returned
by calling [self rectForPart:NSScrollerNoParts].

I can move the knob/slot upwards by tampering with their designated
rects ("rect.origin.y -= 5"), thus hiding the white part. But that
messes up the drawing when the view is updated.

I figured the white part was a view, but since you are telling me
NSScroller has no subviews I really don't know what to think. Maybe
there is something wrong with my implementation?

@implementation TestScroller

- (void)drawRect:(NSRect)rect
{
[self drawKnobSlot];
[self drawKnob];
}

- (void)drawKnob
{
NSRect rect = [self rectForPart:NSScrollerKnob];
[[NSColor yellowColor] set];
[NSBezierPath fillRect:rect];
}

- (void)drawKnobSlot
{
NSRect rect = [self rectForPart:NSScrollerKnobSlot];
[[NSColor greenColor] set];
[NSBezierPath fillRect:rect];
}

@end

On Fri, Mar 28, 2008 at 12:41 AM, Troy Stephens <[EMAIL PROTECTED]> wrote:
>
>  On Mar 27, 2008, at 4:26 PM, [EMAIL PROTECTED] wrote:
>  > Thanks, but the corner view is the right side corner of the header
>  > view, right? I was talking about the small view just below it, on top
>  > of the vertical slider and part of the slider itself. It's a tiny view
>  > of about 2 pixels height. I believe it corresponds to
>  > NSScrollerNoPart, but I'm not sure.
>
>  (By "slider" I take it you really mean "scroller", as NSSlider is
>  something else entirely. :-)
>
>  An NSScroller (currently) has no subviews, but if your aim is to add
>  one or more accessory views above the scroller, that can be done by
>  subclassing NSScrollView.  The key is to override NSScrollView's -tile
>  method to invoke [super tile], and then adjust the layout to
>  accommodate your accessory subview(s).  Figure out where you want your
>  accessory subview(s) to go, set their frame(s), and change the
>  ScrollView's verticalScroller's frame (shrink and move down, since
>  ScrollViews are flipped) to make room for them.
>
>
>
>  >
>  >
>  > On Thu, Mar 27, 2008 at 9:53 PM, Troy Stephens <[EMAIL PROTECTED]>
>  > wrote:
>  >>
>  >> On Mar 27, 2008, at 9:50 AM, [EMAIL PROTECTED] wrote:
>  >>> Hi,
>  >>>
>  >>> NSScroller has a small view, by default two pixels high, just above
>  >>> the scroller and below the NSTableHeaderView's corner view. How
>  >>> can I
>  >>> get at this view? If you look at the XCode interface you can see
>  >>> they
>  >>> have put an icon in this view (the one that splits the editor view)
>  >>> and made it larger. I would like to remove the view completely so
>  >>> the
>  >>> scroller goes all the way up to the edge of the corner view.
>  >>>
>  >>> This question has been addressed before in the archives, but
>  >>> unfortunately the link pointing to an answer is no longer valid.
>  >>>
>  >>> Thanks.
>  >>> F.
>  >>
>  >> See NSTableView.h:
>  >>
>  >> /* Get and set the cornerView. The cornerView is the view that
>  >> appears
>  >> directly to the right of the headerView above the vertical
>  >> NSScroller.
>  >> The scroller must be present for the cornerView to be shown.
>  >> Calling -
>  >> setCornerView: may have the side effect of tiling the
>  >> enclosingScrollView to accomodate the size change. The default value
>  >> is an internal class that properly fills in the corner.
>  >>  */
>  >> - (void)setCornerView:(NSView *)cornerView;
>  >> - (NSView *)cornerView;
>  >>
>  >> --
>  >> Troy Stephens
>  >> Cocoa Frameworks
>  >> Apple, Inc.
>  >>
>  >>
>  >>
>  >>
>
>
>  --
>  Troy Stephens
>  Cocoa Frameworks
>  Apple, Inc.
>
>
>
>
<>___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Re: error strings in NSPropertyListSerialization

2008-03-27 Thread Jens Alfke


On 27 Mar '08, at 6:10 PM, B.J. Buchalter wrote:

I am writing code that is linked to the 10.4u SDK. Does this mean  
that I need to release the string?


Yes.


What happens if my app is run under 10.5?


Cocoa detects that your code was linked with the 10.4 SDK and follows  
the old behavior. (Otherwise all apps that did do the right thing in  
the past would crash when run under 10.5.)


If I move to the 10.5 SDK, does that mean that I must NOT release  
the string?


Right. If you build your app for 10.5 then you need to start following  
the correct/new behavior.


—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

CGContextReplacePathWithStrokedPath problem?

2008-03-27 Thread Graham Cox
I'm using CGContextReplacePathWithStrokedPath to get an outline of a  
stroke, but it seems to ignore the current line cap, join and dash  
settings (it does thankfully honour the line width though, so it's not  
entirely useless). Can someone confirm that, or am I doing something  
wrong?


--
S.O.S.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Subverting the first responder chain

2008-03-27 Thread Hamish Allan
On Fri, Mar 28, 2008 at 1:14 AM, John Stiles <[EMAIL PROTECTED]> wrote:

>  The view doesn't immediately have a way of knowing whether it should handle
> a key like "space" or not. The app design is predicated around the idea that
> keyboard shortcuts will be consumed before they reach the view, which I
> think is reasonable, and matches reality for standard command keys.

I'm not sure you can make this assumption. In order to be a good
responder chain citizen, your view really needs to know whether it
should handle a given event (it may of course need to ask its own
delegates whether they wish to handle the event before it can answer
this).  However, it's not at all clear to me why your custom view
should get a go at the space bar before your menu, so perhaps someone
else knows how to fix this.

Hamish
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Static in Subclasses

2008-03-27 Thread Jon Gordon


On Mar 27, 2008, at 5:17 PM, [EMAIL PROTECTED] wrote:





Date: Thu, 27 Mar 2008 14:44:17 -0600
From: Justin Giboney <[EMAIL PROTECTED]>
Subject: Static in Subclasses
To: Cocoa Developers 
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain;   charset=US-ASCII;   format=flowed;  
delsp=yes

I need to create a series of classes that implement the Singleton
design pattern. These classes have a lot of similar methods (I am
trying to create a series of DAOs see: 
http://en.wikipedia.org/wiki/Data_Access_Object)
.

I was thinking that it would be best to create a super class, and a
series of subclasses to that super class. The problem I am running
upon is that the Singleton pattern requires a static variable.

How can I get a variable that is static to each subclass, but that is
declared in the super class?

for example I tried this.




I had a similar problem, and I addressed it by implementing a class  
cluster in which
each of the private subclasses was a singleton.  To handle the static  
variable
issue, I just created a static NSDictionary in the source file in  
which the
subclass identifier was the key, and the singleton instance was the  
value.


Justin, I'll send you my source files privately to avoid making this  
message too
long, but anyone else who wants to see what I did should feel free to  
mail me and

ask.

 -Jon

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: error strings in NSPropertyListSerialization

2008-03-27 Thread Adam R. Maxwell


On Mar 27, 2008, at 6:10 PM, B.J. Buchalter wrote:


In the docs for [NSPropertyListSerialization   
propertyListFromData:mutabilityOption:format:errorDescription:] it  
has the following comment:


Special Considerations
--
Strings returned in errorString needed to be released by the caller  
prior to Mac OS X version 10.5. In Mac OS X version 10.5 and later,  
strings returned inerrorString are memory managed for the caller.


I think the API docs are wrong here.  From the Foundation release  
notes :


NSPropertyListSerialization (Updated since WWDC 2007)
A previous release note in the Leopard Foundation release notes said  
that a leak has been fixed in the two NSPropertyListSerialization  
methods that return an NSString * error description by reference.   
This fix has been reverted, and will never be done.  As stated in the  
documentation for those methods, and as was true in 10.4 and earlier,  
it is the client's responsibility to release that string (if either  
method returns nil) in 10.5 and beyond as well.


I understand this to mean that prior to 10.5, we needed to do a  
[errorString release]. But I am very unclear what this means  
practically for the code that I am writing today.


You still need to (auto)release the returned error string if  
NSPropertyListSerialization returns nil.


--
adam
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: NSScroller question

2008-03-27 Thread Hamish Allan
On Fri, Mar 28, 2008 at 1:17 AM,  <[EMAIL PROTECTED]> wrote:

>  The white part above the slot is by
>  default black, but here I made it white by filling the rect returned
>  by calling [self rectForPart:NSScrollerNoParts].

[self rectForPart:NSScrollerNoPart] simply returns a rect in the
scroller where a click will have no effect. Those pixels are, however,
part of the slot.

Hamish
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: CGContextReplacePathWithStrokedPath problem?

2008-03-27 Thread Graham Cox
Never mind, I was doing something wrong - it does honour all of those  
settings ;-) Apologies for doubting Quartz's engineers!


(BTW, an aside: since Quartz has the ability to do this sort of bezier  
curve fitting, how about exposing more of it in the API? It would be  
great to be able to "unflatten" a bezier curve without using difficult  
curve fitting code (e.g. graphics gems), some of which is very tricky  
to get working well).


--
S.O.S.



On 28 Mar 2008, at 12:20 pm, Graham Cox wrote:
I'm using CGContextReplacePathWithStrokedPath to get an outline of a  
stroke, but it seems to ignore the current line cap, join and dash  
settings (it does thankfully honour the line width though, so it's  
not entirely useless). Can someone confirm that, or am I doing  
something wrong?


--
S.O.S.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?

2008-03-27 Thread Kyle Sluder
On Thu, Mar 27, 2008 at 9:16 PM, Jens Alfke <[EMAIL PROTECTED]> wrote:
>  The linker coalesces multiple identical string constants into a single
>  value in the data segment. However, you can still end up with multiple
>  copies if your code was linked in separate pieces and then joined
>  together. Prior to Xcode 3.0 that used to happen when using ZeroLink —
>  in fact, once or twice I've had my code crash when run with ZeroLink
>  because I'd inadvertently used pointer comparison instead of
>  isEqualToString: somewhere. Xcode 3.0 doesn't have ZeroLink anymore,
>  but the details of how your program gets linked together are not
>  something you should be relying on.

But it still makes sense to me that when I'm providing NSString
constants to be used as they are in the case of an NSError's userInfo
dictionary, for example, that pointer comparison is still valid.  Of
course I wouldn't do it for places where I expect arbitrarily-provided
strings to be passed to my method, but I typically make my string
constants opaque.

Is this just in general a Bad Idea(TM)?

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Subverting the first responder chain

2008-03-27 Thread Ken Thomases

On Mar 27, 2008, at 7:52 PM, John Stiles wrote:

I am implementing a custom NSView subclass (actually a simple  
subclass of NSOpenGLView) that implements -keyDown: in order to  
respond to user typing. Typically, this works great.


However, I have a few menu items which respond to atypical hotkeys  
(e.g. one responds to "space", another to "option+X"). In this  
case, I've found that the view gets a -keyDown: event, which it  
dutifully handles, and the menu hotkey is never handled. I'd prefer  
it if the menu action were triggered and no -keyDown: event were  
generated, and that's exactly what happens with more typical menu  
hotkeys like command+letters. But my view doesn't know what is in  
the menubar and so, without adding a lot of ugly special-case code,  
from within the view's -keyDown: handler, it would be difficult to  
know whether I need to send the event to the next responder or  
handle the key myself.


Is there any elegant solution to this problem? The last thing I  
want to do is reimplement hotkey handling on my own, but I can't  
think of any workarounds to this issue that don't involve my view  
taking on a lot of extra knowledge about what's in the menubar, or  
completely hacking the responder chain in some ugly way. It seems  
that I can't forward on to the next responder and then ask "did you  
handle it?"—if the responder chain fails to handle the event,  
apparently it just calls -noResponderFor: on the window and that is  
that—there's no return value of "YES" or "NO" or anything like that.


From :


"An application routes a key-equivalent event by sending it first  
down the view hierarchy of a window. The global NSApplication object  
dispatches events it recognizes as potential key equivalents (based  
on the presence of modifier flags) in its sendEvent: method. It sends  
a performKeyEquivalent: message to the key NSWindow object.  [...]   
If no object in the view hierarchy handles the key equivalent, NSApp  
then sends performKeyEquivalent: to the menus in the menu bar."


So, NSApplication requires modifier flags on the key event to  
recognize it as a potential key equivalent.  Unfortunately, I find no  
documented way of changing the application object's criteria for  
recognizing key equivalents.


So, I think you'll need to subclass NSApplication, override  
sendEvent:, check for key events which you think should be candidate  
key equivalents, and pass them to the key window and then the menu  
bar via performKeyEquivalent:.  If either returns YES, stop  
processing the event.  Otherwise, pass the event to [super sendEvent:].


Cheers,
Ken___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?

2008-03-27 Thread Ken Thomases

On Mar 27, 2008, at 9:41 PM, Kyle Sluder wrote:


But it still makes sense to me that when I'm providing NSString
constants to be used as they are in the case of an NSError's userInfo
dictionary, for example, that pointer comparison is still valid.  Of
course I wouldn't do it for places where I expect arbitrarily-provided
strings to be passed to my method, but I typically make my string
constants opaque.

Is this just in general a Bad Idea(TM)?


I think so.  There's no telling if somebody has copied the string on  
its way from where you stuff it in the dictionary to where you're  
comparing it.  Even if immutable string classes optimize copy...  
methods to be the equivalent of retain, there's no guarantee that  
somebody didn't do stringWithString: or whatever to circumvent that.


Cheers,
Ken
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?

2008-03-27 Thread glenn andreas


On Mar 27, 2008, at 9:41 PM, Kyle Sluder wrote:

On Thu, Mar 27, 2008 at 9:16 PM, Jens Alfke <[EMAIL PROTECTED]>  
wrote:
The linker coalesces multiple identical string constants into a  
single
value in the data segment. However, you can still end up with  
multiple

copies if your code was linked in separate pieces and then joined
together. Prior to Xcode 3.0 that used to happen when using  
ZeroLink —

in fact, once or twice I've had my code crash when run with ZeroLink
because I'd inadvertently used pointer comparison instead of
isEqualToString: somewhere. Xcode 3.0 doesn't have ZeroLink anymore,
but the details of how your program gets linked together are not
something you should be relying on.


But it still makes sense to me that when I'm providing NSString
constants to be used as they are in the case of an NSError's userInfo
dictionary, for example, that pointer comparison is still valid.  Of
course I wouldn't do it for places where I expect arbitrarily-provided
strings to be passed to my method, but I typically make my string
constants opaque.

Is this just in general a Bad Idea(TM)?



Bad Idea.

Consider that, at some point, you move your code into a framework that  
you can reuse in multiple projects.  While the linker can coalesce  
constant strings within a single binary, it obviously doesn't go  
across multiple binaries, so suddenly code that worked fine no longer  
works (and you spend days tracking it down).


You could do what Coca does and declare your keys as variables:

extern NSString *NSFontAttributeName;

In this case, if you always used NSFontAttributeName (and never  
@"NSFontAttributeName") you should be OK, because all places are  
basically referring to the same variable value.  This, of course,  
assumes that the variable is _always_ used.


Of course, I'd be paranoid and just use isEqualToString: since that  
has the fewest assumptions and is the safest (and the infinitesimal  
performance penalty is completely overwhelmed by the time not spent  
tracking down bugs by using "==").




Glenn Andreas  [EMAIL PROTECTED]
  wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next  
generation of fractal art




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?

2008-03-27 Thread Kyle Sluder
On Thu, Mar 27, 2008 at 10:52 PM, glenn andreas <[EMAIL PROTECTED]> wrote:
>  Bad Idea.
>
>  Consider that, at some point, you move your code into a framework that
>  you can reuse in multiple projects.  While the linker can coalesce
>  constant strings within a single binary, it obviously doesn't go
>  across multiple binaries, so suddenly code that worked fine no longer
>  works (and you spend days tracking it down).

That's actually the situation my question arose from.

>  You could do what Coca does and declare your keys as variables:
>
>  extern NSString *NSFontAttributeName;
>
>  In this case, if you always used NSFontAttributeName (and never
>  @"NSFontAttributeName") you should be OK, because all places are
>  basically referring to the same variable value.  This, of course,
>  assumes that the variable is _always_ used.

This is what I do.  In my header, my string constants are declared
extern, and defined in a source file.  I figured only one instance of
this symbol will exist anyway and will be resolved by dyld at runtime.
 Though I guess I shouldn't assume that dyld will actually resolve
_MyStringKey to the same place in all cases (though why would it ever
do otherwise?).

>  Of course, I'd be paranoid and just use isEqualToString: since that
>  has the fewest assumptions and is the safest (and the infinitesimal
>  performance penalty is completely overwhelmed by the time not spent
>  tracking down bugs by using "==").

Makes sense.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is @"constantstring" pointer equal to @"constantstring" aguarantee?

2008-03-27 Thread Kyle Sluder
On Thu, Mar 27, 2008 at 10:55 PM, Jeff Laing <[EMAIL PROTECTED]> wrote:
>  What confuses me is that people keep talking about @"constant" as though
>  it were a 'string constant'
>
>  Its not, it's an Objective-C object that you can send messages to.
>  [snip]
>  What is the subtlety here that I must be missing?

@"" strings are actually instances of an immutable private NSString
subclass.  I think it's called _NSConstantString or some such.  Of
course this is an implementation detail.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


embed screen sharing in a cocoa app?

2008-03-27 Thread Adam Gerson
With 10.5's new screen sharing ability is there away to embed screen
sharing into my app? I would like to pop up a window in my cocoa app
that allows a user to remote view or control the desktop of another
mac. I know I can launch the screen sharing app externally with vnc://

Thanks,
Adam
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Subverting the first responder chain

2008-03-27 Thread John Stiles

Wow, this sounds like a disaster.

Maybe in my -keyDown: call I can walk the menus in the menu bar and call 
-performKeyEquivalent on all of them. It's probably not fast :| I was in 
the process of writing code that stores the menu bar's key equivalents 
in a hash table and checks the hash table before handling -keyDown:, 
maybe I'll just keep doing that. It's gross but I guess all the 
potential solutions are gross.



Ken Thomases wrote:

On Mar 27, 2008, at 7:52 PM, John Stiles wrote:

I am implementing a custom NSView subclass (actually a simple 
subclass of NSOpenGLView) that implements -keyDown: in order to 
respond to user typing. Typically, this works great.


However, I have a few menu items which respond to atypical hotkeys 
(e.g. one responds to "space", another to "option+X"). In this case, 
I've found that the view gets a -keyDown: event, which it dutifully 
handles, and the menu hotkey is never handled. I'd prefer it if the 
menu action were triggered and no -keyDown: event were generated, and 
that's exactly what happens with more typical menu hotkeys like 
command+letters. But my view doesn't know what is in the menubar and 
so, without adding a lot of ugly special-case code, from within the 
view's -keyDown: handler, it would be difficult to know whether I 
need to send the event to the next responder or handle the key myself.


Is there any elegant solution to this problem? The last thing I want 
to do is reimplement hotkey handling on my own, but I can't think of 
any workarounds to this issue that don't involve my view taking on a 
lot of extra knowledge about what's in the menubar, or completely 
hacking the responder chain in some ugly way. It seems that I can't 
forward on to the next responder and then ask "did you handle it?"—if 
the responder chain fails to handle the event, apparently it just 
calls -noResponderFor: on the window and that is that—there's no 
return value of "YES" or "NO" or anything like that.


From 
: 



"An application routes a key-equivalent event by sending it first down 
the view hierarchy of a window. The global NSApplication object 
dispatches events it recognizes as potential key equivalents (based on 
the presence of modifier flags) in its sendEvent: method. It sends a 
performKeyEquivalent: message to the key NSWindow object.  [...]  If 
no object in the view hierarchy handles the key equivalent, NSApp then 
sends performKeyEquivalent: to the menus in the menu bar."


So, NSApplication requires modifier flags on the key event to 
recognize it as a potential key equivalent.  Unfortunately, I find no 
documented way of changing the application object's criteria for 
recognizing key equivalents.


So, I think you'll need to subclass NSApplication, override 
sendEvent:, check for key events which you think should be candidate 
key equivalents, and pass them to the key window and then the menu bar 
via performKeyEquivalent:.  If either returns YES, stop processing the 
event.  Otherwise, pass the event to [super sendEvent:].


Cheers,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is @"constantstring" pointer equal to @"constantstring" aguarantee?

2008-03-27 Thread Jens Alfke


On 27 Mar '08, at 7:59 PM, Kyle Sluder wrote:

On Thu, Mar 27, 2008 at 10:55 PM, Jeff Laing <[EMAIL PROTECTED] 
> wrote:
What confuses me is that people keep talking about @"constant" as  
though

it were a 'string constant'

Its not, it's an Objective-C object that you can send messages to.
[snip]
What is the subtlety here that I must be missing?


@"" strings are actually instances of an immutable private NSString
subclass.  I think it's called _NSConstantString or some such.


Yup. And they're not allocated on the heap; they're stored in the  
executable itself, although their memory layout is that of a "real"  
Obj-C object. The compiler tags them in such a way that the linker  
will coalesce identical ones into a single value.



 Of course this is an implementation detail.


Yup. Don't rely on this behavior.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

  1   2   >