Re: Embedding resources in Static Cocoa Library

2012-10-08 Thread Alexander Bokovikov

On Oct 9, 2012, at 1:00 AM, Simone Tellini wrote:

 
 this is way overkill. You can simply write a simple utility to dump the 
 content of your resource in a C file:
 
 static char foo[] = {
0x01, 0x02, 0x03, 
 ...
 };
 
 You don't need to use assembly nor to create bogus functions to get the 
 address of foo.

Oops… You haven't caught the idea… Everybody knows how to create a _data_ but 
I've described, how to _embed_ data into the _code_ segment. This way can be 
used if it's necessary to hide some data against patching.
This code sample is related to software protection area.

Best regards,
Alexander
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Embedding resources in Static Cocoa Library

2012-10-07 Thread Alexander Bokovikov

On Oct 7, 2012, at 1:00 AM, koko k...@highrolls.net wrote:

 I want to make a static cocoa library that is an NSTableView and allots data 
 is contained in the library.
 I want images in the rows of the table.
 Where would one get these images as their is no bundle where that can be 
 stored?
 Or the question is where are resources for a static coco library stored?

All suggestions here are reduced to an external file (bundle) usage. Just for a 
case, if you really wish to store any data (non-executable code, like images, 
etc.) within the executable (regardless of the type: the main project, a static 
library, a dynamic library) there is a way to do it. But you'll need to know 
how to use assembler in the Cocoa project. If you know it, this way is for you. 
I used it in my Windows project, but never in Cocoa.

AFAIK, you need to create a .s file and add it to your Xcode sources. Then 
Xcode will know what to do with this file. And you need to write something like 
this within the .s file:

.text
.globl  _MyFunc
pushl   %ebx
callL1
jmp L2
.align  1
.byte   0x0,0x1,0x2,0x3,0x4
.byte   0x5,0x6,0x7,0x8,0x9
L1:
popl%eax
movleax, ebx
pushl   %eax
ret
L2:
addl5, %ebx
movl%ebx,%eax
popl%ebx
ret

As a result, you'll have the address of the embedded information in the eax 
register. I.e. you just need to create the function declaration like this one:

(void *) myFunc(void); 

and call it. Hope this code is close to correct one, as I never dealt with Mac 
OS assembler. And please take it into account, that 5, mentioned in the code 
above, means the size of the jmp L2 instruction, which is five in 32-bit 
assembler, but it will take nine bytes in the 64-bit one. And of course, I'm 
talking only about x86/64 assembler. Don't know anything about PowerPC one.

The only what is left out is how to fill out the .byte with a useful 
information. Personally I used a specially written simple utility, transcoding 
any binary file into the fixed length lines of .byte  hex codes. You can use 
decimal or octal codes too. as far as the assembler allows it.

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Embedding resources in Static Cocoa Library

2012-10-07 Thread Alexander Bokovikov

On Oct 7, 2012, at 1:00 AM, koko k...@highrolls.net wrote:

 I want to make a static cocoa library that is an NSTableView and allots data 
 is contained in the library.
 I want images in the rows of the table.
 Where would one get these images as their is no bundle where that can be 
 stored?
 Or the question is where are resources for a static coco library stored?

All suggestions here are reduced to an external file (bundle) usage. Just for a 
case, if you really wish to store any data (non-executable code, like images, 
etc.) within the executable (regardless of the type: the main project, a static 
library, a dynamic library) there is a way to do it. But you'll need to know 
how to use assembler in the Cocoa project. If you know it, this way is for you. 
I used it in my Windows project, but never in Cocoa.

AFAIK, you need to create a .s file and add it to your Xcode sources. Then 
Xcode will know what to do with this file. And you need to write something like 
this within the .s file:

.text
.globl  _MyFunc
pushl   %ebx
callL1
jmp L2
.align  1
.byte   0x0,0x1,0x2,0x3,0x4
.byte   0x5,0x6,0x7,0x8,0x9
L1:
popl%eax
movleax, ebx
pushl   %eax
ret
L2:
addl5, %ebx
movl%ebx,%eax
popl%ebx
ret

As a result, you'll have the address of the embedded information in the eax 
register. I.e. you just need to create the function declaration like this one:

(void *) myFunc(void); 

and call it. Hope this code is close to correct one, as I never dealt with Mac 
OS assembler. And please take it into account, that 5, mentioned in the code 
above, means the size of the jmp L2 instruction, which is five in 32-bit 
assembler, but it will take nine bytes in the 64-bit one. And of course, I'm 
talking only about x86/64 assembler. Don't know anything about PowerPC one.

The only what is left out is how to fill out the .byte with a useful 
information. Personally I used a specially written simple utility, transcoding 
any binary file into the fixed length lines of .byte  hex codes. You can use 
decimal or octal codes too. as far as the assembler allows it.

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSFileHandle readInBackground vs threading?

2011-11-13 Thread Alexander Bokovikov


On 09.11.2011, at 19:25, Scott Ribe wrote:

I'm not arguing the OP isn't seeing data lost, just that it cannot  
be happening the way he thinks it is if he's using any normal  
networking calls.


Thanks to everybody for your useful comments!
My local socket is opened in the client process just as

socket(AF_LOCAL, SOCK_STREAM, 0)

I'm getting the socket file handle, and use it for writing to the host  
process. I've tested the write process and as far as I can see, the  
data are written completely. The socket is never blocked by host  
process. So, I believe I need to dig the sending side.


Thank you.
___

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 arch...@mail-archive.com


Files DragDrop - target file icon problems

2011-11-13 Thread Alexander Bokovikov

Hi, Everyone,

In my Cocoa app, I use file saving by dragdrop into Finder window  
(Desktop is one particular case). I'm trying to do it just as docs  
tell me: I use namesOfPromisedFilesDroppedAtDestination message to  
create a list of files being saved (one file at least) then I create  
and write real files in the draggedImage:endedAt: just as docs tell me  
to do it.


Files are saved, but the problem is that the file icon is created at  
the default location but not at the mouse pointer location, when the  
mouse is released. I've noticed that everything goes correctly, when I  
save files in the namesOfPromisedFilesDroppedAtDestination message  
handler. But my files are large and I can't do file saving there,  
because target Finder window is blocked.


Now I create a zero length file (if it not exists) in the  
namesOfPromisedFilesDroppedAtDestination message handler then save the  
real file in the draggedImage:endedAt: message. The problem with icon  
location is resolved now, but another problem appears: Finder somehow  
remembers the zero-sized state of the file, so its icon is not changed  
into thumbnail for example for MP4 or MOV files. Standard QuickTime  
icon is shown instead.


Is there any really correct solution to avoid such problems?

Thanks in advance.
___

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 arch...@mail-archive.com


NSFileHandle readInBackground vs threading?

2011-11-08 Thread Alexander Bokovikov

Hi, All,

I have a need to read some data from a local socket, which serves for  
IPC. And data may come very quickly, so (AFAIU) inner socket buffer  
might overflow, so a portion of data might be lost. I don't see a way  
how to define an inner system buffer size, so the only I can is to do  
my best to read from the socket quickly enough. The problem is that I  
need yet to process the incoming data, not only to read them. Now I'm  
doing the next:


- (void) readPacket:(NSNotification *)aNotification {
	[packetBuffer appendData:[[aNotification userInfo]  
objectForKey:NSFileHandleNotificationDataItem]];

[sockFileHandle readInBackgroundAndNotifyForModes:modesArray];
[self processPacket];
}

where packetBuffer is the storage for incoming data and processPacket  
is where data are processed.


My question is:

Isn't it better to do it in this way:

- (void) readPacket:(NSNotification *)aNotification {
	[packetBuffer appendData:[[aNotification userInfo]  
objectForKey:NSFileHandleNotificationDataItem]];

[sockFileHandle readInBackgroundAndNotifyForModes:modesArray];
	[self performSelector:@selector(processPacket) withObject:nil  
afterDelay:0];

}

Or is the multithreaded processing the only (or at least much better)  
solution here? If yes, then may I be sure that NSData appendData (see  
above) will never relocate the initial portion of the data buffer, but  
only will add new data to the end of buffer? My data processing  
routine looks like the next:


len = [packetBuffer length];
ptr = [packetBuffer bytes];
while (len = MIN_PACKET_SZ) {
   /// doing something with data pointed by ptr-
ptr += _some_value;
len -= _some_value;
}


So, I need be sure that once reading the ptr, then increasing it, step  
by step up to the len value, I'll always have valid data despite of  
how many times append data will be called in another thread. What  
about this?


Thanks in advance.

-Alex
___

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 arch...@mail-archive.com


Re: NSFileHandle readInBackground vs threading?

2011-11-08 Thread Alexander Bokovikov


On 09.11.2011, at 0:50, Scott Ribe wrote:


On Nov 8, 2011, at 9:54 AM, Alexander Bokovikov wrote:

I have a need to read some data from a local socket, which serves  
for IPC. And data may come very quickly, so (AFAIU) inner socket  
buffer might overflow, so a portion of data might be lost.


What makes you think that? If the buffers fill up, writes will block.


OK, then the same problem will appear at the other end of the socket.  
One way or another I need to read from the socket as fast as possible.  
And I have a real problem now. Sometimes data are lost when they come  
with high speed. Though I agree, that first I need to investigate what  
end of the socket has a bottle neck.


Thank you.
___

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 arch...@mail-archive.com


AuthorizationServices - what is wrong here?

2011-10-07 Thread Alexander Bokovikov

Hi, All,

Here is a piece of code where I'm trying to customize the password  
input box.

Nevertheless I can see nothing but generic icon and default prompt text.
The rights are assigned and my helper tool is working correctly.
The problem is just in the interface customization.
Could anybody tell me what I'm doing wrong here?

Thanks in advance.
..
lpath = [launchPath fileSystemRepresentation];
//
AuthorizationItem right = {system.privilege.root,
strlen(lpath),
(void *)lpath,
0};
AuthorizationRights rights = {1, right};
//
char *prompt = My custom prompt text;
iconFile = [[NSBundle mainBundle] bundlePath];
	iconFile = [iconFile stringByAppendingPathComponent:@Contents/ 
Resources/icon.png];

iconPath = [iconFile fileSystemRepresentation];
AuthorizationItem envItem[2];
envItem[0].name = kAuthorizationEnvironmentPrompt;
envItem[0].valueLength = strlen(prompt);
envItem[0].value = prompt;
envItem[0].flags = 0;
envItem[1].name = kAuthorizationEnvironmentIcon;
envItem[1].valueLength = strlen(iconPath),
envItem[1].value = (void *)iconPath,
envItem[1].flags = 0;
AuthorizationItemSet envItems;
envItems.count = 2;
envItems.items = envItem[0];
//
AuthorizationFlags flags = kAuthorizationFlagInteractionAllowed |
   
kAuthorizationFlagPreAuthorize |
   
kAuthorizationFlagExtendRights;
//
err = AuthorizationCreate(rights,
 envItems,
 flags,
 authorizationRef);
.

Best regards,
-Alex
___

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 arch...@mail-archive.com


Re: Strange autoreleased with no pool in place message

2010-04-18 Thread Alexander Bokovikov


On 18.04.2010, at 1:59, Ken Thomases wrote:

Run  Manage Breakpoints  Add Symbolic Breakpoint.  Type the name  
of the function to break on.


In general, you should familiarize yourself with the Xcode Debugging  
Guide:

http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeDebugging/


Thank you, though I've found the reason. A friend of mine shared this  
code snippet with me:


#ifdef DEBUG
#define NSLog( s, ... ) NSLog( @%s : (%d) %@,__FUNCTION__,  
__LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )

#else
#define NSLog( s, ... )
#endif

This macro is helpful when it is in correct hands :) I didn't take it  
into account that such redefined NSLog can't be used without a  
NSAutoReleasePool, being previously initialized. Usual NSLog can be  
used wherever you wish unless it is not using autoreleased objects.  
For example, NSLog(@Hello); can be inserted wherever you wish, right?


I've removed NSLog call from one improper location, and the problem  
has disappeared. What is interesting, this error didn't lead to crash  
in 10.5+, but leads to crash in 10.4.


Most likely you started an NSThread without putting an autorelease  
pool in the thread’s main function, or you got a callback on some  
thread and are making Cocoa calls on it without wrapping your  
callback in an autorelease pool.


Start NSThread even BEFORE main() ? Is it possible?


It is possible, with something like +load.  It's also possible log  
lines are somehow out of order.  In any case, there's no reason to  
speculate.  The debugger can show you exactly where/when this is  
happening.


As for threads, it's definitely not my case. all my threads are  
initialized in FreePascal back-end stuff, because FPC doesn't support  
Cocoa threads for some reason. Of course I'm using NSAutoReleasePool  
in all Cocoa methods, called from FPC thread procedures. Fortunately  
this part of my project works OK.


Thanks.

___

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 arch...@mail-archive.com


Strange autoreleased with no pool in place message

2010-04-17 Thread Alexander Bokovikov

Hi, All,

Am trying to debug an app, which crashes in 10.4 when I build it with  
10.5 SDK and 10.4 deployment target, but works OK when is built with  
10.4 SDK and 10.4 deployment target. All builds are performed in 10.5


I'm getting these lines in crash log:

Thread 0 Crashed:
0   libSystem.B.dylib   0x9010c812 _malloc_initialize + 992
1   libSystem.B.dylib   0x90002417 malloc + 29
2   com.apple.Foundation0x927dffbf _NSAPDataCreate + 26
3   com.apple.Foundation0x927df93d NSPushAutoreleasePool + 37
4   com.apple.AppKit0x93274621 NSApplicationMain + 62
..

AFAIU, the problem is in autoreleasing of already released object or  
something like that.


Then I'm running the same app in 10.5, where it is working OK, and  
look at the console log. I see this line:


*** _NSAutoreleaseNoPool(): Object 0x209fa0 of class NSCFString  
autoreleased with no pool in place - just leaking


OK, then I'm launching the app with leaks tool and look what is this   
0x209fa0. And what I see is this:


#	Object Address	Category	Creation Time	Size	Responsible Library	 
Responsible Caller
0	0x209fa0		CFString	00:00.235		32		Foundation			-[NSPlaceholderString  
initWithFormat:locale:arguments:]


I can't find where it is used. What is strange, this is the first  
message in the log, appearing even before main(), because I've  
inserted debug print in main() and I see it later in the log.


My OS is 10.5.8

Any ideas, please!


___

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 arch...@mail-archive.com


Re: Strange autoreleased with no pool in place message

2010-04-17 Thread Alexander Bokovikov


On 18.04.2010, at 1:30, Jens Alfke wrote:



On Apr 17, 2010, at 12:18 PM, Alexander Bokovikov wrote:

*** _NSAutoreleaseNoPool(): Object 0x209fa0 of class NSCFString  
autoreleased with no pool in place - just leaking


Set a breakpoint at _NSAutoreleaseNoPool and start the app. That  
should show you where it’s happening.


I'm sorry... but how to do it? Where can I find this line? AFAIU, it  
is out of my source code... Sorry, I'm a newbie...


Most likely you started an NSThread without putting an autorelease  
pool in the thread’s main function, or you got a callback on some  
thread and are making Cocoa calls on it without wrapping your  
callback in an autorelease pool.


Start NSThread even BEFORE main() ? Is it possible?

Thanks.___

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 arch...@mail-archive.com


Re: How to find all clipping siblings for a view?

2010-04-17 Thread Alexander Bokovikov


On 18.04.2010, at 1:29, Jonathan Hess wrote:



On Apr 16, 2010, at 10:47 AM, Kyle Sluder wrote:

On Fri, Apr 16, 2010 at 10:37 AM, Corbin Dunn corb...@apple.com  
wrote:
You can't control it in IB (short of removing the view and adding  
it back in). But in code, you can just call - 
addSubview:positioned:relativeTo: to move views around in the Z  
order.


IB has Send Forward/Backward items on its Layout menu. Whether they
work or not is another question entirely... :)


They work.

You can also change the z-order of a view-hierarchy with drag-and- 
drop in the document outline view since version 3.1.


Of course I used these features of IB. The only what I can tell -- it  
is very ugly. I'd say, IB is just fails to work with many overlapped  
objects. For example any imprudent dragging of an overlapping view  
automatically inserts it into a lower view. And there is no way to  
return it back but to drag it in the tree-shaped window view. Really  
this was designed not for overlapping objects...


Thanks.
___

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 arch...@mail-archive.com


Re: How to find all clipping siblings for a view?

2010-04-16 Thread Alexander Bokovikov

On Friday, April 16, 2010 at 2:40 PM Norbert M. Doerner wrote:


NSView *rootView;
NSArray *mySubViews
rootView = [theWindow contentView];
mySubViews = [rootView subviews];


Thanks, it looks like I've found it. The only question is why Cocoa has no 
Z-order term? I've read in the doc that it is implicitly defined by the 
sequence of objects within the [rootView subviews], but it is not the 
Z-order itself, but the order in which objects are stored in the NIB file. 
I've tried it and it is working OK for my particular case.


Best regards,
Alexander 


___

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 arch...@mail-archive.com


How to find all clipping siblings for a view?

2010-04-15 Thread Alexander Bokovikov

Hi, All,

For some reason I need to do a job which NSWindow usually does, when  
it redraws itself (AFAIU) - I need to find all its views, which have z- 
order higher than my view, then get their bounding rectangles, unite  
them, subtract from the window content view bounding rectangle and  
sect the result with my view bounding rectangle. This is because my  
view uses QuickDraw to redraw itself, but those functions draw on  
screen directly (AFAIU) and don't take into account other views,  
located above current view.


Could anybody show the right way to go?

Thanks in advance. 
___


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 arch...@mail-archive.com


Re: How to catch modal window appearance?

2010-03-29 Thread Alexander Bokovikov


On 30.03.2010, at 2:27, Lee Ann Rucker wrote:

Well, if you're using runModalForWindow: and relying on it to show  
the window, it goes away before the method returns, so there is no  
point in the code after show and before hide.


I understand it of course. I told about the window controller class  
code, not about the calling procedure code.



But you can always do makeKeyAndOrderFront: explicitly:

[myWindow makeKeyAndOrderFront:self];
// Stuff I need to do
[NSApp runModalForWindow:myWindow].


Now I understand it. Initially I believed that there is an appropriate  
notification to do it.


Thanks. 
___


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 arch...@mail-archive.com


Re: How to catch modal window appearance?

2010-03-27 Thread Alexander Bokovikov


On 26.03.2010, at 23:10, Fritz Anderson wrote:


On 26 Mar 2010, at 11:12 AM, Alexander Bokovikov wrote:

Is there any notification or NSWindow delegate method, called  
immediately after the modal window is shown on screen? It looks  
like windowDidExposed doesn't come to a modal window. Is there any  
solution?


Just to check on the obvious points:

* Have you set a delegate for the window, which would receive the  
windowDidExpose: message?


* Have you named the method windowDidExpose: (without d, with :)?


Yes, it's all done. That was just a typo in the email. I've copy/ 
pasted method declaration from the API Reference, so it's written  
correctly in the project. Nevertheless it is never called. I suppose  
that the problem is just the same as with other notifications - I need  
to do some actions to get them from a modal window message loop. But I  
have no idea of how to do it in this particular case.


Thanks.

___

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 arch...@mail-archive.com


Re: How to catch modal window appearance?

2010-03-27 Thread Alexander Bokovikov

On 27.03.2010, at 12:48, Ken Thomases wrote:

I'm not really sure what you're asking for.  A modal window being  
shown on screen is not something that happens spontaneously _to_  
your application, it's something that your application does.  So,  
whatever you want to do after the window is shown, just do it after  
the point in your code where you show it.


I tried to achieve the next effect: some automatic process should be  
started on the modal window appearance on screen. A popup panel with  
progress indicator appears, etc. My idea was not to initiate such  
process from the calling code (where modal window is called from), but  
do it asynchronously, as soon as the modal window will appear on the  
screen.


Of course, I've solved the problem by calling this process from the  
calling code just before [NSApp runModalForWindow:] call. But it is  
not pretty correct from the OOP philosophy point of view, at least as  
I understand it.


What is over my mind is why Apple split main loop and modal loop. I  
see none of benefits but headaches.. There may be only one modal  
window at a time, isn't it?


Thanks.
___

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 arch...@mail-archive.com


Re: How to catch modal window appearance?

2010-03-27 Thread Alexander Bokovikov

On 27.03.2010, at 1:59 PM, Ken Thomases wrote:


I can't see how this is either correct or incorrect
from the point of view of OOP philosophy.
OOP involves encapsulation, separation of concerns,
polymorphism, etc.


separation of concerns is just the case.


I would say it's the other way around: the window's appearance
should be in response to the initiation of the process.


My modal window's purpose is not just to show this initial process. It's a 
dialog, which does something more complicated, but this initial process 
should be completed to activate its subsequent functionality. Of course, we 
could show this progress before the modal window appearance. But I don't 
like it.



Well, first, you should consider whether a modal window
is the best design of your GUI.  I would say there's a mild
recommendation that they be avoided in favor of
document-modal sheets and the like.


It's not a document-based app. This dialogue does some thing which can't be 
shared in time with other functionality. It's just like Save File As... but 
more complex


In MustDie all messages, addressed to the application, go through the window 
procedure of the modal window. Modal window is the key window, the main 
window, and whatever you do you do within it. Therefore I don't understand 
why notifications should be queued in the main loop while they can't be 
processed by the modal window messages loop.


Thanks. 


___

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 arch...@mail-archive.com


Re: How to catch modal window appearance?

2010-03-27 Thread Alexander Bokovikov


On 27.03.2010, at 16:57, Ken Thomases wrote:


separation of concerns is just the case.


Except the timing does not impact on separation of concerns.


I'm not about timing. I'm just about code separation. Initialization  
is a part of dialogue, so its window controller is the right place,  
where this code should be located and where it should be called. But  
now it is called from the main AppController, where the dialogue is  
created and where runModalForWindow sits. Usually only initialization  
methods, using some data from the calling object, should be called  
from the calling object. At least we must do our best to minimize  
their number. In my case I have to call  a pure inner, I'd even say,  
private object method from outside of the object code. In my opinion  
it's not correct, though it's not so meaningful in this particular  
case. I'm just about a good style.


The controller, the C in MVC, should be responsible for the process,  
whether it is initiated before the window is show or after.


Is C the window controller in my case? I believe, it is.

If the modal event loop processed all of the same events as the main  
event loop, then it wouldn't be modal -- the user would be able to  
do things outside of the modal window, like clicking on buttons in  
another window, or selecting menus not related to the modal window.   
So, I don't know how you expect that to work differently.  But this  
has _nothing_ to do with notifications.


Of course, I had in mind all events, related to the modal window. All  
other events should be ignored. But windowDidExpose: notification is  
related to the window, and it is called after I call  
runModalForWindow: Isn't it? Then why it doesn't reach my window  
controller, which is set as a window delegate? Where is the logic? It  
looks as a bug rather than as a feature...


As we saw with NSFileHandle, where necessary it is usually quite  
easy to ask for an event or runloop source to operate in the modal  
runloop mode. It's just not a big problem.  It seems like you're  
inventing aggravation for yourself.


There was an explicit method how to call a notification, when we  
talked about NSFileHandle. But In the case of windowDidExpose: I don't  
see any way how to tell it to Cocoa that I'd like to get this  
notification.


Thanks.

___

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 arch...@mail-archive.com


Re: How to catch modal window appearance?

2010-03-27 Thread Alexander Bokovikov


On 27.03.2010, at 19:39, Joanna Carter wrote:

Every window is managed by a Controller and it is from this  
Controller that you can run any process you want, as well as  
creating and showing a window.


This is correct of course, and this was just what I tried to reach  
for. But I had to call this private code from the main  
AppController, rather than from a window controller of the modal  
window. Probably I was not too clear with my terms.


I think you are used to Windows programming. Cocoa modal sheets are  
modal to the owning form, not the whole app.


Modal sheet is not so suitable here. Modal sheet is located within  
the window which owns it. In my case popup window may be larger than  
parent window. Therefore I've chosen a real modal window.


Thanks.

___

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 arch...@mail-archive.com


Re: How to catch modal window appearance?

2010-03-27 Thread Alexander Bokovikov


On 27.03.2010, at 20:36, Ken Thomases wrote:

The app controller should just send a message to the window  
controller asking it to do the whole thing.  Then, the window  
controller can create the window, initiate the process, and invoke - 
runModalForWindow:, in whichever order it prefers.


There's no need to expose the inner/private stuff to the app  
controller, if you think it doesn't belong there.


OK, Finally I've come to some understanding.

Finally, one extra question. When modal window runloop starts? Does it  
start after the window is shown on screen or before that? If it starts  
after window showing then I'd use  
performSelector:withObject:afterDelay: to be sure that my procedure  
will start to execute itself when window is already visible.


Thank you!
___

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 arch...@mail-archive.com


How to catch modal window appearance?

2010-03-26 Thread Alexander Bokovikov

Hi, All,

Is there any notification or NSWindow delegate method, called  
immediately after the modal window is shown on screen? It looks like  
windowDidExposed doesn't come to a modal window. Is there any solution?


Thanks.
___

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 arch...@mail-archive.com


NSNotificationCenter and a modal window - a problem

2010-03-24 Thread Alexander Bokovikov

Hi, All,

I have a project where a progress of NSTask is indicated through this  
code:


if ([self  popup] != nil)
anObj = [self popup];
else
anObj = self;
[[NSNotificationCenter defaultCenter] addObserver:anObj

 selector:@selector(getData:)

 name:NSFileHandleReadCompletionNotification

   object:[[mytask standardError] fileHandleForReading]];
[[NSNotificationCenter defaultCenter] addObserver:anObj

 selector:@selector(taskTerminated:)

 name:NSTaskDidTerminateNotification

   object:mytask];
[[[mytask standardError] fileHandleForReading]  
readInBackgroundAndNotify];



All is going OK when I have a progress bar in the main window, so  
anObj  = self. But I'd like to use just the same code to show a  
progress of the same NSTask by a NSProgressIndicator, placed in a  
modal NSPanel, opened through [NSApp runModalForWindow:]. In this case  
NSTask is launched and is executed OK, And it does what it should. But  
none of notifications are going to my popup modal window.At least  
getData method is never called, as debugger shows it.


self is AppController, popup is a subclass of NSWindowController.

What is the problem reason? Is it possible to receive notifications in  
a modal window?


Thanks.

___

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 arch...@mail-archive.com


Re: NSNotificationCenter and a modal window - a problem [solved]

2010-03-24 Thread Alexander Bokovikov


On 24.03.2010, at 12:48, Ken Thomases wrote:

You need to invoke -readInBackgroundAndNotifyForModes: and pass an  
array of modes which includes NSModalPanelRunLoopMode (or  
NSRunLoopCommonModes, which includes NSModalPanelRunLoopMode by  
default).


Many thanks! Really I should look at that method, but I looked at the  
notification center, which has minimum of methods. Don't know why but  
I decided that this aspect should be taken into account when an  
observer is added. Now it's obvious for me, that I should look at the  
notification generator too.


NSTask termination is caught without any problems. The problem was  
just in reading from pipe.


Thanks.
___

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 arch...@mail-archive.com


Re: Cocoa-dev Digest, Vol 7, Issue 307

2010-03-14 Thread Alexander Bokovikov


On Sat, 13 Mar 2010 at 20:23:40 -0800 Quincey Morris wrote:

You might want to choose a different run loop mode, if you have  
special requirements. NSEventTrackingRunLoopMode is sufficient to  
allow keystrokes and mouse clicks to be processed, so that you can  
have a UI (say, Esc key or button) to cancel the procedure if you  
want.



What is the difference between different modes? Is it performance or  
whatever else?


On Sat, 13 Mar 2010 at 22:49:45 -0600 Ken Thomases wrote:

You should also see if -beginModalSessionForWindow:/- 
runModalSession:/-endModalSession: makes sense for your situation.   
It does require that you can do the time-consuming task in discrete  
chunks.


Do you have in mind that user can close a modal window while this task  
is executed? OK. I'll disable the Close button of the window and  
leave Cancel button active.  Clicking on Cancel my time-consuming  
task will be aborted after the nearest iteration. Hope it will be  
enough.


Thanks.
___

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 arch...@mail-archive.com


How to show a progress without multithreading?

2010-03-13 Thread Alexander Bokovikov

Hi, All,

I have a time-consuming procedure, and I'd like to show its progress. 
I can't use multi-threading for some technical reason.

I'm looking for a way to update a progress indicator from this procedure,
As far as I understand my task is to cause message loop processing.
And my question is - how to do it?

Thanks.

___

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 arch...@mail-archive.com


performSelector doesn't work for modal window

2010-03-12 Thread Alexander Bokovikov

Hi, All,

Unfortunately NSButton click is called when button is pressed, but not  
when it is released. Therefore any timeconsumming process, executed on  
the button click, will keep the button pressed. To avoid it I've  
decided to use performSelector:withObject:afterDelay: message. This  
approach works OK for main window, but it doesn't work for a modal  
popup panel. More exactly, this message is sent only when modal window  
is closed and NSApplication is returned to the main messages loop.


It looks like this is a fundamental Cocoa specifics, though I don't  
understand it. So, how to send a message to a modal window messages  
loop? I don't like to use multithreading here, though I will do it if  
I'll can't find another solution.


Any ideas?

Thanks.
___

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 arch...@mail-archive.com


NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Alexander Bokovikov

Hi, All.

I have a table view in the main window, where it works fine. And  
have yet another very similar table view in a popup modal panel. where  
it fails immediately after panel is closed. Debugger shows subj, as  
the failure point. In both cases dataSource for table view is assigned  
in the IB statically.


The problem disappears if I clear dataSource assignment in the IB and  
include this assignment into awakeFromNib of the window controller.  
Also I include [myTableView setDataSource:nil] into -windowWillClose  
event handler of the same window controller. I tried to manipulate  
with release when closed option of the window - no effect.


What it could be?

Thanks.
___

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 arch...@mail-archive.com


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Alexander Bokovikov

On Thursday, March 11, 2010 at 10:11 PM Fritz Anderson wrote:


1. You don't say what fail means. A crash?
What error code? What stack trace?


EXC_BAD_ACCESS. Assembler call stack view shows line next to the subj call.

OS X 10.5.8 Never tried it in 10.6.X


2. This is all moot, because, as the leading underscore shows,
_dataSourceValueForColumn:row: is a private method.
It is not meant to be called by anyone but Apple. It is likely
that only Apple knows what the preconditions and postconditions
for calling it are; and they can change those conditions at any time.


Of couse, I never called it directly. I never implemented it. I just _use_ 
NSTableView. Nothing more. The fact is that it is working nice in the main 
app, where it is never destroyed explicitly. But it doesn't work correctly 
in a modal window, which I create and then release. As I've described the 
only way I've found is to assign the datasource explicitly in awakeFromNib 
and set it to nil explicitly in windowWillClose handler.


Really my question was - is this a known bug, a feature or my mistake?

Thanks. 


___

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 arch...@mail-archive.com


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Alexander Bokovikov


On Thursday, March 11, 2010 at 10:29 PM Corbin Dunn wrote:


Break on objc_exception_throw.


Could you explain it? What does it mean?

Thanks.
___

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 arch...@mail-archive.com


Re: NSTableView _dataSourceValueForColumn:row: failure

2010-03-11 Thread Alexander Bokovikov


On 11.03.2010, at 23:25, Corbin Dunn wrote:


http://www.corbinstreehouse.com/blog/2008/08/your-most-important-breakpoint-in-cocoa/


I've done what was told there. No difference. I just get  
EXC_BAD_ACCESS in XCode status line and debugger's call stack list  
shows:


objc_msgSend
- [NSTableView _dataSourceValueForColumn:row: ]


and a long chain is below, but there are no my project lines there.  
All lines are from Cocoa itself. It looks like the window requires for  
update after dataSource is already released.


This is how I call the modal window:

- (void) doModalWnd{
MyWnd *wnd = [[MyWnd alloc] init];
[[NSApplication sharedApplication] runModalForWindow:[wnd window]];
[wnd release];
}

- (IBAction) myBtnClick:(NSButton *)sender {
[self performSelector:@selector(doModalWnd)
   withObject:nil
   afterDelay:0];
}

There is such code within MyWnd.m:

- (void)windowWillClose:(NSNotification *)notification {
[[NSApplication sharedApplication] stopModalWithCode:NSCancelButton];
}

Is there anything criminal here?

Thanks.

___

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 arch...@mail-archive.com


Transparent background for controls - some problems

2010-03-07 Thread Alexander Bokovikov

Hi, All,

I'm trying to create a NSView descendent which could draw a custom  
bitmap background and which could contain other subviews (like labels  
and buttons) . The problem that all goes perfectly unless controls  
will change their state or any another event will cause my view  
redrawing.


When any control changes its state (e.g. label changes its caption)  
its background is drawn in some incorrect way, which you can see here:


http://68.178.246.102/etc/cocoa/test.png

Here an empty label is shown after its caption was changed to . I've  
created a special striped background with holes, randomly set to  
visualize this effect.


Please note, that initially (on startup) all looks just perfectly.

Here is my code (its essential part) of my custom view, drawing the  
background:


Here buf is a temporary NSImage, where rectangular piece is created,
and bg is the original background of the whole NSView in size.

- (void)drawRect:(NSRect)rect {
..
	rep = [[[NSBitmapImageRep alloc]  
initWithBitmapDataPlanes:nil  

reps = [buf representations];
if (reps != nil  [reps count]  0)
[buf removeRepresentation:[reps objectAtIndex:0]];
[buf setSize:NSZeroSize];
[buf addRepresentation:rep];
r = rect;
r.origin.x = 0;
r.origin.y = 0;
[buf lockFocus];
[bg drawInRect:r
  fromRect:rect
 operation:NSCompositeCopy
  fraction:1.0];
[buf unlockFocus];
ctx = [NSGraphicsContext currentContext];
[ctx saveGraphicsState];
[ctx setShouldAntialias:YES];
[ctx setPatternPhase:NSMakePoint(0, 0)];
[[NSColor colorWithPatternImage:buf] set];
NSRectFill(rect);
[ctx restoreGraphicsState];
}

I've tried to save both buf and bg as TIFF's and apply buf on bg in  
PhotoShop with appropriate shift - all looks exactly, as it should be.  
The problem is that some controls, like labels, checkboxes and  
buttons, are drawn somehow outside of this procedure. At least I could  
not find their rectangles, when I logged rect parameter.


Any help would be appreciated.

Thanks

-Alexander

___

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 arch...@mail-archive.com


Re: NSWindow - makeKeyAndOrderFront problem

2010-03-01 Thread Alexander Bokovikov

Hi, All,

I'm sorry for an offtopic, so I'm writing just to close the thread.

On 02.03.2010, at 7:37, Andy Lee wrote:

If I feel my app should come forward in both cases I do think it  
should be okay to implement it that way, but there *is* precedent  
for not activating the app.


I'd even say, there were no precedents (I could not find them at  
least) of doing anything else. Though I can't explain it for myself...


On 02.03.2010, at 7:37, Matthew Lindfield Seager wrote:


For more guidance see what other popular or Apple apps do (e.g.
QuickTime Player, etc) or do some usability testing with some target
users.


On 02.03.2010, at 7:37, Andreas Mayer wrote:


Dragging something onto an application icon - either in the Finder or
in the Dock - is an explicit request to bring that application to the
front.

Dragging something inside another application's window is not.


As for something, I could agree, moreover, I'd hate it if iTunes  
would activate itself each time I drop a link into the playlist. But  
as for my case, when we can expect nothing but the only result - a  
playback beginning, it looks as surprise for me, when ALL video  
players, I saw, behave in the same silent manner -- they do not  
activate themself.



or do some usability testing with some target users.


If you do that, please make sure they are actually Mac users, not
Windows users sitting in front of a Mac. :P


Perhaps I'm still a Windows user :(


And as this is rather off-topic for cocoa-dev, I'll leave it at that.
I just tried to give some advice. Do what you think is best.


It looks like the best modus operandi here is:

Lord, grant me the serenity to accept the things I cannot change

Thanks to all who answered!

Best regards,
Alex

___

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 arch...@mail-archive.com


NSWindow - makeKeyAndOrderFront problem

2010-02-28 Thread Alexander Bokovikov

Hi, All,

Perhaps it's my misunderstanding, but I can't activate window title  
when I apply


[mainWindow makeKeyAndOrderFront:nil]

to main app window in the performDragOperation dragdrop handler.  
The content is dropped into the window, and window goes to the top of  
screen, but its title bar remains to be inactive. I need yet click it  
to activate it.


What is strange, the same message produces required result at some  
another place of code, where a popup window is closed, and this method  
is called to activate the same main app window.


Any help would be appreciated!

Thanks.
___

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 arch...@mail-archive.com


Re: NSWindow - makeKeyAndOrderFront problem

2010-02-28 Thread Alexander Bokovikov


On 28.02.2010, at 17:48, jonat...@mugginsoft.com wrote:


Try scheduling it for the next iteration of the run loop.

[mainWindow performSelector:@selector(makeKeyAndOrderFront:)  
withObject:nil afterDelay:0.0];


I tried it too as well as

performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg  
waitUntilDone:(BOOL)wait


Also I tried to insert these lines into concludeDragOperation:  handler.

No effect. The window goes to the top, but the title is still inactive  
and I need to click it to activate it. I believe the problem is  
covered just in the dragdrop process, as I had no problems with this  
message at some another place.


Thanks.
___

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 arch...@mail-archive.com


Re: NSWindow - makeKeyAndOrderFront problem

2010-02-28 Thread Alexander Bokovikov


On 28.02.2010, at 17:48, jonat...@mugginsoft.com wrote:


Try scheduling it for the next iteration of the run loop.

[mainWindow performSelector:@selector(makeKeyAndOrderFront:)  
withObject:nil afterDelay:0.0];


It looks like I've understood why it is not working. Here is the  
message description:


his action method moves the receiver to the front of the screen list,  
within its level, and makes it the key window; that is, it shows the  
window.


What is within its level? What is the level? Does it mean that this  
message brings a window to front within the same application/process  
only? If yes, then how to do the same when the process (application is  
not the active (hasn't keyboard input)?


For example, in my case I have Finder's window and my app's window.  
Finder's window is active. I drop a file into my app's window. And the  
question is how to switch the global system focus to my app? Then I  
believe I'll see my app's window in active state, as it's the only  
window in the application at that moment.


Any ideas?

Thanks.
___

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 arch...@mail-archive.com


Re: NSWindow - makeKeyAndOrderFront problem - solved

2010-02-28 Thread Alexander Bokovikov


On 28.02.2010, at 17:48, jonat...@mugginsoft.com wrote:


Try scheduling it for the next iteration of the run loop.

[mainWindow performSelector:@selector(makeKeyAndOrderFront:)  
withObject:nil afterDelay:0.0];


Really the problem was not in the scheduling but just in the scope of  
the message - it works only within the same process. Therefore what we  
need to do is to activate the process itself. To do it we must use  
activateIgnoringOtherApps: message of the NSApplication class. In my  
case this is the only what is required, as I have only one window,  
when I drop a file into it.


Thanks. 
___


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 arch...@mail-archive.com


Re: NSWindow - makeKeyAndOrderFront problem

2010-02-28 Thread Alexander Bokovikov


On 28.02.2010, at 22:38, Andreas Mayer wrote:


Hm. You don't?

Just dragging should not switch the focus to another application.


What do you have in mind? Is it incorrect to create such behavior? My  
app is a player. Dropping file into it I'd expect its activation. Am I  
wrong? Without activation all visual controls are not reachable unless  
you'll click the window. This is not a case when user could drop file- 
by-file into the same window, as I believe. Therefore my app should  
activate itself after every single file drop. Am I wrong?


Thanks.

___

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 arch...@mail-archive.com


Re: NSWindow - how to resize it keeping aspect ratio?

2010-02-25 Thread Alexander Bokovikov


On 25.02.2010, at 15:17, Ariel Feinerman wrote:

there is of the matter is that -setAspectRatio: sets the window`s  
aspect ratio, but when window has been loaded from nib and not  
resized yet, its size is taken from content size that was written  
in IB with it own aspect. Then when window has been resized it  
instantly get size to conform aspect. Can you suggest something?


In general I don't care about IB settings overriding, as my window  
initially has correct aspect ratio. The only my care was about its  
manual resizing at runtime. Don't know if this a correct solution or  
not, but I've written this code:


- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize {
NSRect r;

	r = NSMakeRect([sender frame].origin.x, [sender frame].origin.y,  
frameSize.width, frameSize.height);

r = [sender contentRectForFrameRect:r];
r.size.height = r.size.width * 422 / 674;
r = [sender frameRectForContentRect:r];
return r.size;
}

And it works perfectly for me. 674 x 422 - is my original content view  
size, defined in IB. Unfortunately IB operates by window's content  
view size, whereas the message above operates by window's frame size,  
which is not the same. Therefore it's required to recalculate the size  
between window frame and content view sizes, if we have a care about  
content view aspect ratio keeping.


Thanks.
___

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 arch...@mail-archive.com


Re: NSWindow - how to resize it keeping aspect ratio?

2010-02-25 Thread Alexander Bokovikov

On Thursday, February 25, 2010 at 5:57 PM Ariel Feinerman wrote:


You calculate view`s aspect from it size, but I mean content frame (not
window frame) from constant aspect, for example 4/3, then set size.


I don't understand what is the problem. Isn't my 422/674 ratio not a 
constant? What is a principal difference between it and yours 4/3? Just 
substitute my digits to whatever you need. You'll get just the same result.


This constant, used in the message, will keep the aspect ratio. Now you can 
(if you wish to) set an initial width of the window (e.g. in the 
awakeFromNib), and window height will be adjusted respectively. You don't 
need to store both width and height in the preferences. Just save width. 
Height will be adjusted automatically. At least it works for me.


Thanks.

___

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 arch...@mail-archive.com


NSWindow - how to resize it keeping aspect ratio?

2010-02-18 Thread Alexander Bokovikov

Hi, All,

I'm sorry if this is a stupid question, but I don't see an evident answer... 
I need the subj, but don't see appropriate NSWindow method... Am I missing 
something?


Any help would be appreciated.

Best regards,
Alexander 


___

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 arch...@mail-archive.com


NSView : Background bitmap drawing issue

2010-02-15 Thread Alexander Bokovikov
I've written a subclass of NSView, which draws a NSImage, as the  
background. All is working, but the only problem is in different  
behavior on different Macs / OS versions. Here is the drawing code:


@interface BGSkinView : NSView {
NSImage *bg;
BOOL isLeo, isSnowLeo;
}
..
- (void)drawRect:(NSRect)rect {
NSGraphicsContext *ctx;
CGFloat y;

ctx = [NSGraphicsContext currentContext];
[ctx saveGraphicsState];
y = [self bounds].size.height;

///
if (!isLeo)
y++;

///
[ctx setPatternPhase:NSMakePoint(0, y)];
//
[[NSColor colorWithPatternImage:bg] set];
NSRectFill([self bounds]);
//
[ctx restoreGraphicsState];
}

isLeo is true on 10.5 and isSnowLeo is true on 10.6

I tested this code on my Mac with both 10.4, 10.5 and 10.6 and have  
got a shift of the image for one pixel down on 10.4 and 10.6.  
Therefore I've added the condition, selected above. But now I've got a  
report from another 10.6 Mac, where my code shifts the background for  
one pixel up. Thus, my patch with y++ should be disabled there.


As far as I understand, this effect is caused not by OS version, but  
by some graphic subsystem feature. Could anybody tell me, what is this  
one-pixel shift? Maybe it's some border, drawn outside of my view,  
which I don't see?


Any help would be appreciated.

Thanks.

___

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 arch...@mail-archive.com


Re: NSView : Background bitmap drawing issue

2010-02-15 Thread Alexander Bokovikov

On Monday, February 15, 2010 at 11:50 PM Steve Christensen wrote:

While there could be a drawing but in the OS, it's probably best to  rule 
out issues with your code first. How do you determine the OS  version?


I've used a code from the Net, which adds a category to NSApplication. This 
code was tested in both 10.4, 10.5 and 10.6 and works perfectly. No problems 
here. Moreover, I've changed the drawing code to make it to be more clear. 
My initial goal was just to draw the upper part of background image (the 
same for several windows), whereas windows have different height. Therefore 
I calculate an offset value, which is used in setPatternPhase, as


[myView bounds].size.height - [myBgImage size].height

And I've tried to exclude version checking from the code. A person, who 
reported a bug in 10.6, now tells that all is OK. But I've tested this 
version in 10.6 and in 10.4 and in both versions there is a shift for 1 
pixel down. It looks like my NSView is shifted for 1 pixel. But its frame 
top is zero. Its height is the same in every OS... Just a weird problem...


Best regards,
Alexander



- Original Message - 
From: Steve Christensen puns...@mac.com

To: Alexander Bokovikov openwo...@uralweb.ru
Cc: cocoa-dev@lists.apple.com
Sent: Monday, February 15, 2010 11:50 PM
Subject: Re: NSView : Background bitmap drawing issue


While there could be a drawing but in the OS, it's probably best to  rule 
out issues with your code first. How do you determine the OS  version? I 
ask because that's the only version-specific test in your  drawing code. I 
would do something like this to initialize the  variables:


double majorOSVersionNumber = floor(NSAppKitVersionNumber);

isLeo = NO;
isSnowLeo = NO;
if (majorOSVersionNumber  NSAppKitVersionNumber10_4)
{
if (majorOSVersionNumber  NSAppKitVersionNumber10_5)
isSnowLeo = YES;
else
isLeo = YES;
}

You should not being doing tests like if (NSAppKitVersionNumber == 
NSAppKitVersionNumber10_5) since that will only be true for 10.5.0,  but 
will fail for 10.5.1, 10.5.2, etc. The value of  NSAppKitVersionNumber is 
incremented by an integer amount for 10.x  releases and by a fractional 
amount for 10.x.x releases.



On Feb 15, 2010, at 1:26 AM, Alexander Bokovikov wrote:

I've written a subclass of NSView, which draws a NSImage, as the 
background. All is working, but the only problem is in different 
behavior on different Macs / OS versions. Here is the drawing code:


@interface BGSkinView : NSView {
NSImage *bg;
BOOL isLeo, isSnowLeo;
}
..
- (void)drawRect:(NSRect)rect {
NSGraphicsContext *ctx;
CGFloat y;

ctx = [NSGraphicsContext currentContext];
[ctx saveGraphicsState];
y = [self bounds].size.height;
///
   if (!isLeo)
y++;
///
[ctx setPatternPhase:NSMakePoint(0, y)];
//
[[NSColor colorWithPatternImage:bg] set];
NSRectFill([self bounds]);
//
[ctx restoreGraphicsState];
}

isLeo is true on 10.5 and isSnowLeo is true on 10.6

I tested this code on my Mac with both 10.4, 10.5 and 10.6 and have  got 
a shift of the image for one pixel down on 10.4 and 10.6.  Therefore I've 
added the condition, selected above. But now I've got  a report from 
another 10.6 Mac, where my code shifts the background  for one pixel up. 
Thus, my patch with y++ should be disabled there.


As far as I understand, this effect is caused not by OS version, but  by 
some graphic subsystem feature. Could anybody tell me, what is  this 
one-pixel shift? Maybe it's some border, drawn outside of my  view, which 
I don't see?




___

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 arch...@mail-archive.com


Re: Weird exception

2010-01-25 Thread Alexander Bokovikov


On 24.01.2010, at 14:08, vincent habchi wrote:


Under XCode, you select 'run with performance tool' - 'zombies'.
This will launch your app with the 'zombie instrument' attached,  
that will signal you if you app tries to message a released entity.


I'm sorry, but I don't see zombies item within Start with  
Performance Tool menu. I'm using XCode 3.1.4. Also it's not clear how  
to launch the app. Is it enough to set the target SDK to 10.4 or  
should I transfer my project into 10.4 system completely, then build  
it and run?


Thanks for your 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 arch...@mail-archive.com


Re: Cocoa-dev Digest, Vol 7, Issue 107

2010-01-25 Thread Alexander Bokovikov


On 25.01.2010, at 19:14, James Montgomerie wrote:

I think you're on a wild goose chase here - the most likely  
explanation to me is that something somewhere is deliberately  
calling -[NSString boolValue] (and it may not be 'your' code - I  
wouldn't put it out of the realms of possibility that a call to it  
sneaked into Sparkle), which didn't exist until 10.5.


I believe you're right. I've commented some lines related to Sparkle,  
and now the same call occurs in a more clear location, definitely  
related to Sparkle.


If this is the problem, and you want to target Tiger, the best  
solution would be to find the use of boolValue in the code base and  
replace it with something that will work on 10.4.


I don't know how to do it, as I have no sources for Sparkle. I could  
make a post at the Sparkle bug tracker, indeed.


The category method you made on NSString is not the right solution -  
it almost certainly does less than the 10.5+ framework  
implementation, and it'll replace that method when system frameworks  
call it, which could cause all sorts of problems (this hit me in the  
past - the SYCK YAML parsing framework implemented -[NSString  
boolValue], and it caused problems with, of all things, the iPhone  
keyboard in iPhone OS 3.0).


As far as I've checked now, all calls go with the same true value.  
Therefore there is a chance that my simple patch will fix the issue.  
Of course, I understand that it would be better to replace this code  
with the full implementation of this method.


Best,
Alex
___

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 arch...@mail-archive.com


Re: Weird exception

2010-01-23 Thread Alexander Bokovikov


On 22.01.2010, at 20:50, Keary Suska wrote:

I would put my money on bindings. It shouldn't be too difficult to  
isolate the issue with the debugger.


I've created a category and set a breakpoint within this method. Call  
stack leads me to NSApplication applicationWillFinishLaunching method,  
but what can I do with it? Really, I'm using this delegate method, but  
I don't use any boolValue calls there.


Now I've written this one:

@implementation NSString (MissingMethods)

-(BOOL) boolValue {
return [self value] == @true;
}

@end

Because debugger shows just true value, when this method is called.

I have no idea how to switch between OS versions, because this  
category is useless (if not worse) in 10.5+, but it does something  
useful in 10.4. I can build release with 10.4 SDK, but it will be not  
correct, as I believe.


Any ideas?

___

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 arch...@mail-archive.com


Re: Weird exception

2010-01-23 Thread Alexander Bokovikov


On 24.01.2010, at 1:12, Kyle Sluder wrote:


You should turn on zombies and run your app in the debugger on 10.4.


Could you please describe it more particularly, as it's not clear for  
me what should I do exactly. Should I transfer all my sources into  
10.4 OS? Or should I use Terminal to run gdb then launch my app? And  
how to turn zombies on?


Thanks in advance.

P.S. Now I've fixed this issue as follows:

@implementation NSString (MissingMethods)
-(BOOL) boolValue {
return strcmp([self UTF8String], true) == 0;
}
@end

and I don't see any exceptions now. Doesn't it mean the problem is  
fixed?


-Alex
___

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 arch...@mail-archive.com


Weird exception

2010-01-22 Thread Alexander Bokovikov

Hi, All,

Browsing the console log I've found that my app raises an exception,  
when it is launched in Mac OS X 10.4. I built it in 10.5 with 10.4 as  
a target setting. I didn't see any problems there. The exception is  
caused by unsupported selector calling [NSString boolValue]. I've  
scanned all my project but couldn't find any reference to boolValue.  
What could cause the problem?


Visually my app is working nice in 10.4.

BTW, I'm using Sparkle framework, but AFAIK it is compatible with 10.4.

Any ideas?

-Thanks
___

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 arch...@mail-archive.com


Application help window size

2010-01-13 Thread Alexander Bokovikov

Hi, All,

Does anybody know how could I define default help window width?
I've created a navigation menu, which is too wide for default window,  
so horizontal scrollbar appears.


Or should I adjust my help design to the existing help window default  
size?


Thanks,
Alexander
___

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 arch...@mail-archive.com


AppController dealloc is never called. Why?

2010-01-12 Thread Alexander Bokovikov

Hi, All,

Perhaps my question is stupid, but this is my first Cocoa project, so  
I'll try to ask. I've noticed that my main window controller (usually  
named AppController) is never freed. I don't know where it is  
allocated, but suppose it happens somewhere within NSApplication. All  
other windows, used in the program, are freed OK, as I'm doing it  
explicitly, as well as their initialization.


On the other hand, I'm getting BAD_ACCESS exception, if I insert [self  
release] within applicationWillTerminate delegate method of my  
AppController. So, what is the correct way to free AppController?


Thanks,
Alexander
___

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 arch...@mail-archive.com


NSWindow delegate messages question

2009-12-18 Thread Alexander Bokovikov

Hi, All,

I'm rather new in Cocoa development, so I have some misunderstanding after 
API manuals reading. In particular I have a popup panel, opened by a button 
click in the main window:


- (IBAction) btnClick:(id)sender {
 [popupPanel showWindow];
}

I'd like to launch some process (no matter what exactly, it will work in 
different thread) as soon  this popup panel will appear on screen. Of 
course, I could launch this process from within the same click handler 
above, but I believe it will be better to do it all in the 
WindowController's module, related to the popup panel. My question is: what 
window delegate message should I use? Will it be OK to use 
windowDidBecomeKey message or should I use windowDidExposed? Or whatever 
else?


Another question is what notification could I use to display an alert box, 
appearing _after_ this popup window will disappear from screen? For example, 
I have a Cancel button on this popup panel, which should terminate the 
launched process and (as a result of NSTask termination notification) panel 
should be closed. For the sake of simplicity let's imagin, we're closing the 
panel by button directly:


- (IBAction) btnCancelClick:(id)sender {
 [[self window] close];
}

My question is: what window delegate message should I use to show an 
NSAlert, in order my alert box would appear on screen already _after_ hiding 
of the popup panel? As far as I can see, there is no windowDidClosed 
message, but there is only windowWillClose. Is there any easy solution here?


Thanks in advance.

Best regards,
Alexander 


___

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 arch...@mail-archive.com


Re: [IB] - can't assign keyboard shortcut to a menu item - closed

2009-08-04 Thread Alexander Bokovikov


On 04.08.2009, at 12:43, Graham Cox wrote:

The shortcut item always does look grey however - you have to select  
it and type the desired shortcut - it's not a normal text field.


Understood!  My thumbdown to whom designed that screen... Probably I  
could yet find a way how to do it if I wouldn't see those grayed up/ 
down arrows... Choosing such grey design could they at least use a  
simple input box without any arrows? A hint below the control, where  
we can see a lot of free space, also would help...


Thanks.
___

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 arch...@mail-archive.com


NSPathControl + PopUp style - is it a bug or feature?

2009-08-04 Thread Alexander Bokovikov

Hi, All,

I'm using NSPathControl with Popup style. The question is - why can't  
I change the path by selecting existing paths in the popup paths list  
panel? I click the control, panel appears with the target path and all  
its parent paths below. I click on any of parent paths and have no  
result - panel disappears and the same path is shown, as the  
destination, as it was before.


I walked across all properties I can see in the Inspector, but can't  
see anything suitable to resolve the problem.


Is this popup panel selectable? If not, then what it appears for?

Thanks.
___

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 arch...@mail-archive.com


[IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alexander Bokovikov

Hi, All,

It's my first attempt to assign a popup menu to a view, so perhaps my  
question is stupid, but I can't find an explanation in the Apple's  
docs... The Key Equiv. field is grayed, and don't see any obvious  
solution to activate it. I've created a menu, associated it with a  
view, associated a menu item with action, but this field is still gray.


Where is the problem?

Thanks.
 
___


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 arch...@mail-archive.com


Re: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alexander Bokovikov


On 03.08.2009, at 17:45, Graham Cox wrote:

the view may have many objects any of which could be the menu's  
target - only the click location can tell you which one,


Can't agree. If we setup a control, as capable to have keyboard focus,  
then, activating this control, we activate all hierarchy of its  
parents, and we definitely can apply the lowest level parent's popup  
menu (if any) with its shortcuts.  Of course, we can't do it, if we  
have no focusable controls, so we can work by mouse only in this case.  
But in this case we even can't speak about keyboard shortcuts. In any  
other cases we can.


Thanks.
___

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 arch...@mail-archive.com


NSPathControl - popup panel doesn't work

2009-08-03 Thread Alexander Bokovikov

Hi, All,

I can't understand why, but target path is not changed when I click on  
NSPathControl's popup panel. The control shows the same path, as was  
chosen earlier. I can click Choose... item and NSOpenPanel will  
appear, where I can choose a new directory, and these changes will be  
saved. But none of other items in the popup panel work. Why? I don't  
see any options in the Inspector, which could help here. NSPathControl  
has style set to PopUp. Please help.


Thanks.
___

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 arch...@mail-archive.com


Re: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alexander Bokovikov


On 03.08.2009, at 19:00, Graham Cox wrote:


There's much more to life than controls.


Completely agree. But I don't like to say that _every_ popup menu  
_must_ have keyboard shortcuts. I'd just like to say, that it would be  
good to give such possibility to the coder.


But back to your question - feel free to implement it if you feel it  
does make sense in your app.


But it would be _not_ a _popup_menu_ shortcuts, but just a keyboard  
events handling by the view, if I understand it correctly. In any case  
we can close this discussion unless it will not transform itself into  
a pure flood... :)


Thanks.

___

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 arch...@mail-archive.com


Re: [IB] - can't assign keyboard shortcut to a menu item

2009-08-03 Thread Alexander Bokovikov


On 03.08.2009, at 20:58, Alastair Houghton wrote:

If the options in question are useful enough to merit a keyboard  
shortcut, then they're useful enough to appear in the application's  
main menu hierarchy.  If not, then they aren't.


I'm sorry, but as I can see now, main menu shortcuts are also gray...  
I can delete them but I can't assign them. Why? I've created  
controller actions and have connected actions of menu items with the  
controller.


Thanks.
___

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 arch...@mail-archive.com


Re: How to change focus ring color?

2009-08-01 Thread Alexander Bokovikov


On 01.08.2009, at 4:42, Joel Norvell wrote:

You didn't say what objects you are drawing, so I should add this  
caveat:  I'm not sure what variations, if any, would be induced by  
generalizing my approach to NSCell objects.


OK, maybe I provided not so clear problem description. I have  
_standard_ NSPathControl. It's style is set to PopUp. And I see a  
light blue rounded rectangle around the control. I'm not sure exactly,  
if it's a focus ring, because this border does not disappear, if I'm  
selecting (by mouse) other controls on the same panel. At least this  
border disappears if choose none in IB properties inspector for the  
Focus Ring.


My question was exactly can I subclass NSPathControl to override this  
border drawing procedure to change the color of the border? If yes,  
then what method should I override?


I'm not so skilled yet in controls inner structure yet, so I don't  
know if there is a special procedure, drawing the border, or it's  
drawn within the same method, which draws the control itself.


It looks like your code really draws focus ring, related to keyboard  
focus. But I'm not sure, if it's what I need for my case. Please  
advise if you can.


Another related problem is that checkbox has the same light-blue  
background in the checked state. And I don't see what property could  
change it. I'd like to change it to some grayscale value.


Thanks.

___

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 arch...@mail-archive.com


Re: How to set the name of open-with application for a specific file?

2009-08-01 Thread Alexander Bokovikov


On 31.07.2009, at 21:41, MATSUMOTO Satoshi sato...@mac.com wrote:


I want to do this programmatically.


The direct answer to this question is very easy - it's impossible.  
Why? Take a look here:


http://developer.apple.com/technotes/tn/tn2017.html#Section3

Nevertheless, if I understand it correctly, you need to create a  
situation, when your app will be shown within the Open With menu for  
appropriate file type, after user has installed your app on his/her  
computer. If this is the case, then all what you need to do is the next:


- provide appropriate info.plist with your app bundle;
- place your app into Applications folder (with app installer's help).

I did it manually (the second part) and it works without any problems.

Going ahead, a question raises, how to make our great app to be the  
default application for this file type? First of all read the topic,  
next to the above mentioned. Then... really I never did it yet. As I  
believe, a specific API function is required here. I never tried it  
yet, though I will need to resolve the same problem soon. Therefore  
I'd like to ask you to let me know, if you'll have any success here.


Thanks.
___

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 arch...@mail-archive.com


Re: How to change focus ring color?

2009-08-01 Thread Alexander Bokovikov


On 02.08.2009, at 0:14, Joel Norvell framewor...@yahoo.com wrote:

If your object is always the First Responder, that would account for  
its focus ring always being redrawn.


As I've tested it with the code samples from your links, it's NOT the  
first resonder. I don't see any drawings if I surround the drawing  
code by if ([self showsFirstResponder]) operator.


There's a lot of good information available, but you have to look  
around a bit to find it.


I've checked the links. Thanks. At least I see the way now.  
Nevertheless my main problem is still unresolved - I can't change the  
color of the focus ring. I used this code:


- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {

[super drawWithFrame:cellFrame inView:controlView];

//if ([self showsFirstResponder]) {

		// showsFirstResponder is set for us by the NSControl that is  
drawing  us.


NSRect focusRingFrame = cellFrame;

focusRingFrame.size.height -= 2.0;

[NSGraphicsContext saveGraphicsState];

NSSetFocusRingStyle(NSFocusRingOnly);

[[NSColor brownColor] setStroke];

   [[NSBezierPath bezierPathWithRect: NSInsetRect(focusRingFrame, 
4,4)] stroke];
^ 
^ 
^ 
^ 
^ 
^ 
^^		

//[[self focusRingPath] stroke];


[NSGraphicsContext restoreGraphicsState];

//}

// other stuff might happen here

}

I don't see any ring if I comment the line above, marked with ^.  
And I see just the same blue ring, if I uncomment it. I tried NSColor  
set, NSColor setFill, NSBezierPath fill - all with the same result. I  
can't set another color. What is wrong in my code?


Thanks.
___

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 arch...@mail-archive.com


Re: NSURL fileURLWithPath doesn't produce a valid URL

2009-07-31 Thread Alexander Bokovikov


On 31.07.2009, at 11:51, Dave Keck wrote:


Check out CFURLCreateStringByAddingPercentEscapes(), and note that
CFURL is toll-free bridged with NSURL.


Just have tried it. No difference. I've used:

surl = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,

   spath,

   NULL,

   NULL,

   kCFStringEncodingUTF8);
where spath was the source string with + signs. I've set NULL's, as  
it was described (at least as I've understood what was written) to  
escape any possible characters. Is + sign not considered by Apple,  
as a character, which requires escaping?


In my opinion, all codes since 0x20 to 0x2F require escaping. Am I  
incorrect?


Thanks.

___

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 arch...@mail-archive.com


Re: NSURL fileURLWithPath doesn't produce a valid URL

2009-07-31 Thread Alexander Bokovikov


On 31.07.2009, at 14:02, Richard Frith-Macdonald wrote:


Why do you think that's not a valid URL?


It's because another code (Flash plugin) doesn't want to work if I  
provide a path (as a part of URL), containing +  characters. At  
least I don't see other reasons, why the same function work for path  
with my home directory, and doesn't work with path, provided by  
_CS_DARWIN_USER_DIR.


 If you look at RFC1738 you will see it explicitly says that a '+'  
is allowed.


Say it to Macromedia... or to Adobe?... Though I work with Flash  
directly (not by WebKit), so maybe the error is within my code, I  
leave such chance. Nevertheless, even in that case the error is just  
in the need of URL encoding, as I believe.


I suspect what you are actually looking for is a mechanism to encode  
a string for use as a field name or field value in a form encoded as  
the query string of a URL.  If thats the case, you need to encode  
the '+' '=' and '' characters yourself.


I was just about that. I've created a simple function, encoding  
necessary characters - blanks, pluses, etc., but I just would like to  
know if there is a standard way to do it by API usage. But you say -  
do it yourself. Therefore I believe, the question is closed. Isn't it?


Thanks.

___

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 arch...@mail-archive.com


Re: NSURL fileURLWithPath doesn't produce a valid URL

2009-07-31 Thread Alexander Bokovikov


On 31.07.2009, at 14:57, Dave Keck wrote:


I'm confused:

NSLog(@%@, CFURLCreateStringByAddingPercentEscapes(nil,
CFSTR(http://www.example.com?a+b  c = d), nil, CFSTR(+=),
kCFStringEncodingUTF8));

That doesn't do what you want?


I've misunderstood. It was said do it yourself in the previous  
answer, but not use CFURLCreateStringByAddingPercentEscapes with the  
necessary characters, included into the fourth argument, so I thought  
this function doesn't do what I need. Of course, I was not too careful  
when I read its description, where it was said, that fourth argument  
is just for my case.


Thanks.

___

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 arch...@mail-archive.com


Application Preferences - a general question

2009-07-31 Thread Alexander Bokovikov

Hi, All,

Hope this is not an offtopic here...

I'm quite new in Mac world, and one of essential differences from  
Windows, which I've noticed, is how Preferences changes are applied.  
Unlike to usual Windows GUI, preferences are applied instantly on Mac,  
i.e. just as user changes a value. There is no Cancel button  
resetting values to the state, which they had at the moment, when  
Preferences panel was opened. Though there is Restore Defaults  
button, but it does just what it says - it restores so called factory  
defaults, which are not the same, as previously saved values.


I'm reading Cocoa Programming by Aaron Hillegass, now, and he  
describes just the same Preferences functionality, as above.


Am I missing something? Or is this the general user interface building  
strategy for Cocoa applications or for Mac OS? Is it assumed that user  
will never wish to return to previously saved values?


Thanks.
___

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 arch...@mail-archive.com


Re: Application Preferences - a general question

2009-07-31 Thread Alexander Bokovikov


On 31.07.2009, at 23:09, Daniel DeCovnick wrote:

Correct in practice, although the principle is more that preferences  
shouldn't be that onerous to change back to how they were. The lack  
of needing to click Apply helps here too: since each change is  
reflected instantly, if something goes horribly wrong, the user  
knows EXACTLY what made it go horribly wrong. Feel free to implement  
the Windows way (just keep an NSMutableDictionary in your app  
delegate that updates whenever the preferences window is opened, and  
syncs back to the user defaults when cancel is clicked) if your  
preferences are extensive enough or changes to them destructive  
enough that you need it.


OK, understood it. I just would like to know what is the usual  
approach here. I believe I know it now.


Thanks.

___

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 arch...@mail-archive.com


How to change focus ring color?

2009-07-31 Thread Alexander Bokovikov

Hi, All,

I can't find how I could change the focus ring color, for example, of  
NSPathControl. The IB only lets me disable it. Is the color defined by  
the color scheme hardly?


Thanks.
___

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 arch...@mail-archive.com


NSURL fileURLWithPath doesn't produce a valid URL

2009-07-30 Thread Alexander Bokovikov

Hi, All,

I've found that [NSURL fileURLWithPath] doesn't convert such symbols  
as + into URL-encoded format. It only converts blanks into %20. As a  
result, such path, as _CS_DARWIN_USER_DIR, will not be converted into  
a valid URL. Is there any method or function here to produce a valid  
URL-encoded strings? Of course, I can do it by hands, but I'd just  
like to know if there is a correct standard way.


Thanks.

___

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 arch...@mail-archive.com


DragDrop to desktop - file icons layout problem

2009-07-29 Thread Alexander Bokovikov

Hi, All,

Maybe it's a stupid question, but I can't find a solution... I'm  
dragging files from my app to desktop. All goes OK, but file icons are  
located one exactly above another if I'm dragging many items. As a  
result, few extra clicks on desktop are required to be able to split  
these icons.


The question is, how could I assign icons location for dropped items?  
I believe, though didn't yet tested it, that similar problem will be  
with Finder window, when it is in icons mode. The only point where I  
could get such information (as I believe) could be   
tableView::namesOfPromisedFilesDroppedAtDestination: method, but it  
doesn't contain any information about icons location.


Any ideas?

Thanks.

___

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 arch...@mail-archive.com


Re: NSTableView cell editing begin / end notifications?

2009-07-28 Thread Alexander Bokovikov

Hi, All,

As soon as I have no replies, I will try to reduce my problem scope...

As far as I can see now, there are no suitable messages/notifications  
in standard Cocoa classes, which could serve, as notifiers of the cell  
editor session start/stop. I've found a code snipped, showing, how to  
create my own cell editor subclass:
-(id) windowWillReturnFieldEditor:(NSWindow *)sender toObject: 
(id)anObject {

if ([anObject isKindOfClass:[NSTextField class]]) {
return [[[myCustomFieldEditor alloc] init] autorelease];
}
return nil;
}
I've assigned my AppController, as the main window delegate, then  
created my own cell editor, as a derivative from NSTextView, and am  
trying to create it, as it is shown above.
There is a problem - if operator, shown above, is never true. So, my  
cell editor is never created and the result of this method is always  
nil.

Am I missing something?
Thanks.

___

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 arch...@mail-archive.com


Re: NSTableView cell editing begin / end notifications?

2009-07-28 Thread Alexander Bokovikov

Hi, All,

I'm sorry for flood, it's all is pretty new for me, therefore I do too  
many mistakes...


Here is, what I'm trying to do:

- (id) windowWillReturnFieldEditor:(NSWindow *)sender toObject: 
(id)anObject {

MyTitleEditor *ed;

if ([anObject isKindOfClass:[NSTextField class]]) {
ed = [[[MyTitleEditor alloc] init] autorelease];
[ed setDelegate:self];
return ed;
   }
   return nil;  
}

As far as debugger shows it, this procedure is called for every  
control in my main window. I don't understand it why, but it is called  
twice for every control, if I understand it correctly.


OK, the IF operator is true for some objects like text field (a  
label), but not only for the NSTableView cell editor. So, first of all  
I need to distinguish somehow, when this procedure is called for the  
table cell editor. How to do it? What is the TextField object at the  
moment, when this method is called for the table cell editor?


Another question is that my approach with the NSTextView subclassing  
seems to be not working. What I wrote, is this:


in .h file:

..
@interface MyTitleEditor : NSTextView {

}

- (BOOL)acceptsFirstResponder;
- (BOOL)becomeFirstResponder;
- (BOOL)resignFirstResponder;

@end

in .m file:
.

- (BOOL)acceptsFirstResponder {
return [super acceptsFirstResponder];
}

- (BOOL)becomeFirstResponder {
if(([self delegate] != nil) 
	   ([[self delegate]  
respondsToSelector:@selector(cellEditorWasActivated:)]))

[[self delegate] cellEditorWasActivated:self];
return [super becomeFirstResponder];
}

- (BOOL)resignFirstResponder {
if(([self delegate] != nil) 
	   ([[self delegate]  
respondsToSelector:@selector(cellEditorWasDeactivated:)]))

[[self delegate] cellEditorWasActivated:self];
return [super resignFirstResponder];
}

None of these methods is called when I click in the NSTableView cell.  
Editor appears, but I suppose, it's somehow not my customized editor,  
but just generic cell text editor.


Where is my mistake?

Thanks.

___

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 arch...@mail-archive.com


Re: NSTableView cell editing begin / end notifications - solved (?)

2009-07-28 Thread Alexander Bokovikov

Hi, All,

To whom is may be interesting:

As I wrote initially, my problem is that the table is updated on a  
timer, so cell editor was cancelled automatically, as the timer fires.  
First I started to seek for a solution to learn about cell editor  
appearing / hiding events. And that was very hard way. Occasionally,  
walking through NSView methods I've found currentEditor method,  
resolving all my problem. Really, what I need to know, is whether cell  
editor is active or not. And the method, pointed above just shows it.


Nevertheless I'd be just happy to learn about how to detect cell  
editor appearing / hiding. Though this question comes into a  
theoretical plane now.


Thanks.

___

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 arch...@mail-archive.com


NSTableView - strange behaviour after cell text color assignment

2009-07-27 Thread Alexander Bokovikov

Hi, All,

I'm trying to color my table's rows depending on some value, returning  
from a function like this:


int GetState(int rowIndex);

I've searched around the Net and the only clear way I've found is to  
set my AppController, as a tableView delegate and respond to the message


- (void)tableView:(NSTableView *)aTableView
  willDisplayCell:(id)aCell
   forTableColumn:(NSTableColumn *)aTableColumn
  row:(int)rowIndex;

I've created this method as the next:

if (rowIndex == selRow)
color = [NSColor selectedTextColor];
else
switch (st = GetState(rowIndex)) {
case 1 : { color = [NSColor colorWithCalibratedRed:0

 green:0

  blue:0.5

 alpha:1.0]; break; }
case 2 : { color = [NSColor colorWithCalibratedRed:0

 green:0.5

  blue:0

 alpha:1.0]; break; }
case 3 : { color = [NSColor colorWithCalibratedRed:0.5

 green:0

  blue:0

 alpha:1.0]; break; }
}
[aCell  setTextColor:color];

I've got a strange effect: a new row is selected OK, when I change  
selection in the tableview, but the row, which was selected, remains  
being drawn with the same selected color unless reloadData will  
appear. Therefore, changing selection quickly I can change color of  
many rows to selected color, unless update will come. Selection bar  
itself looks OK, and selected row background and text color changes  
immediately, but how to update the row, which was previously selected?  
I believed it will be done by my delegate method. It looks like this  
method is called at some not appropriate time. Is there a solution?


Thanks.



___

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 arch...@mail-archive.com


Re: NSTableView - strange behaviour after cell text color assignment

2009-07-27 Thread Alexander Bokovikov

Replying to myself:


- (void)tableView:(NSTableView *)aTableView
  willDisplayCell:(id)aCell
   forTableColumn:(NSTableColumn *)aTableColumn
  row:(int)rowIndex;


The function above works perfectly, but the problem reason was in the  
incorrect receiving of the selected row index. I wrongly assigned it,  
as a global variable, within a function, which updated my table data  
on timer. therefore the selected row index value was changed on timer,  
but not on real selection change. why didn't 5 set the assignment in  
the tableViewSelected: action, going from tableView? Really, I did it.  
But unfortunately this action raises on the mouse clicks only.  
Keyboard clicks are passing by this action.


Fortunately I've found a solution, that really works. I've registered  
an observer for NSTableViewSelectionDidChangeNotification  
notification, and now every change of selection is processed.


I believe, the question is closed.

Thanks.
___

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 arch...@mail-archive.com


NSTableView cell editing begin / end notifications?

2009-07-27 Thread Alexander Bokovikov

Hi, All,

In my app I have a table, populated by some periodic procedure,  
working on a timer. At the same time I need to add a cell editing  
capability. But periodic updating procedure calls [tableView  
reloadData], which resets the cell editor, if it is active.


Therefore I need to stop this update procedure for a time, when cell  
editor is active. I've searched over the Net, but can't find any  
simple solution or description, how to catch editor appearance and  
hiding. Could anybody point me any sample or at least what  
notifications should I use? I don't like the idea to subclass a cell  
editor, but of course I'll do it (though don't know how to do it yet)  
if there will no other simpler solutions.


Thanks.
___

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 arch...@mail-archive.com


NSButton setImage in runtime : where is template image?

2009-07-26 Thread Alexander Bokovikov

Hi, All,

I'm trying to create a simple switch button, showing something like  
Show blablabla  /  Hide blablabla depending on the state of  
blablabla. I've found that it would be most suitable to use rounded  
textrured button and change its title, image and image position in the  
onClick: handler. Everything is OK, but I can't find how to set an  
image from template, which we can see in the IB. We can choose several  
images there, in particular, I've chosen NSCoLeftTemplate and  
NSCoRightTemplate for button states. But how to change them in  
runtime? As far as I can understand, I should write something like this:


[myButton setImage:[NSImage .]]

but the question is what messages to use here and how to reach those  
templates, as we can see in the IB?


I tried imageNamed, but it does not find an image. I tried to search  
in Google for NSCoLeftTemplate / NSCoRightTemplate, but they're not  
found.


Thanks.
___

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 arch...@mail-archive.com


Re: NSButton setImage in runtime : where is template image?

2009-07-26 Thread Alexander Bokovikov


On 26.07.2009, at 16:31, Brandon Walkin wrote:

There's a typo in your image names. Use NSGoLeftTemplate and  
NSGoRightTemplate (Go instead of Co).


I'm so sorry! I was just blind and used Cmd+C too often... sorry.

Thanks.

___

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 arch...@mail-archive.com


How to use NSTimer correctly?

2009-07-25 Thread Alexander Bokovikov

Hi, All,

In my app I have a timer, created in the awakeFromNib and living until  
the app terminates. And I have some problem when I close the  
application. Here are my code snippets:


- (void) awakeFromNib {
...
processingTimer = YES;
timer = [NSTimer scheduledTimerWithTimeInterval:0.5

 target:self

   selector:@selector(onTimer:)

   userInfo:nil

repeats:YES];
...
}

As I believe, everything is OK here...

- (void) dealloc {
processingTimer = NO;
[timer invalidate];
..
}

I'm not sure, if I must invalidate the timer, but think I should do it.

- (void)onTimer:(NSTimer*)timer {
...
//
if (!processingTimer) return;
//
 some procedure is going here, which updates the data for NSTableView
//
if (!processingTimer) return;
//
// Update results list in the NSTableView
[fileView reloadData];
^
here we had an exception within obc_msg_send()

}

Here is the onTimer: procedure, where I had an exception after I  
closed the application. I tried to remove timer invalidation from the  
dealloc, but nothing helped unless I've inserted a boolean var  
processingTimer, which should indicate whether our app still lives or  
it is slosing now. First I've added this var check only at the top of  
onTimer procedure, yet before the main calculating procedure call.  
That didn't helped. Then I've added yet another check right before the  
call of [NSTable reloadData]. And this helped. At least I've tried to  
run and close my app several times and I didn't see an exception.


Also I tried to change timer interval, believing that my main  
procedure runs too slowly, so overlapped onTimer calls occur. But it  
makes no sense.


So, what is the _correct_ way to do all that?

Thanks.

___

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 arch...@mail-archive.com


Re: How to use NSTimer correctly?

2009-07-25 Thread Alexander Bokovikov


On 25.07.2009, at 18:48, Dave Keck wrote:


First off, your object's -dealloc is never going to get called,
because NSTimers retain their targets.


If so, then where should I dealloc everything, I created in the  
awakeFromNib? I believed that dealloc will be called when my  
AppController will be released. But you say it is never released. Then  
what should I do?


Is your suggestion about applicationWillTerminate etc. the correct  
way to go in this case? And where my AppController will be released?  
As far as I can understand I can't release it within  
applicationWillTerminate handler. Am I wrong? Should I write [self  
release] there?


Thanks.

___

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 arch...@mail-archive.com


Re: How to use NSTimer correctly?

2009-07-25 Thread Alexander Bokovikov


On 25.07.2009, at 19:56, Scott Ribe wrote:


If so, then where should I dealloc everything, I created in the
awakeFromNib? I believed that dealloc will be called when my
AppController will be released. But you say it is never released.  
Then

what should I do?


In dealloc, as you do now. But you need to arrange for dealloc to be  
called,

by making sure nothing (the timer) still retains you.


Could you explain it, how should I make the [dealloc] to be called?  
I've described, how I create a timer, so how should I free it to call  
dealloc? Should I explicitly call [self release] somewhere or should I  
do whatever else?


Thanks.

___

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 arch...@mail-archive.com


Re: NSTableView - populating from C procedure

2009-07-23 Thread Alexander Bokovikov


On 23.07.2009, at 11:52, Graham Cox wrote:

BTW, watch out for a potential buffer overflow in getString(...),  
this is the sort of thing viruses readily exploit.


OK, thanks, though I'd like to ask, if it's not a big offtopic, how  
viruses can exploit my internal function? I can it understand, when  
viruses send something illegal to a webserver, which has flaws in the  
request processing routine, but in my case it's an internal function,  
which, of course, should check the buffer size, but how it could be  
accessible for a virus?


Thanks to all others, who replied.

___

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 arch...@mail-archive.com


Re: NSTableView - populating from C procedure

2009-07-23 Thread Alexander Bokovikov


On 23.07.2009, at 12:55, Marco S Hyman wrote:


On Jul 22, 2009, at 11:38 PM, Graham Cox wrote:

My warning was of a very general nature, and may not apply to your  
app. But every time you declare buffer space as a stack array, you  
should mentally consider whether a buffer exploit might be possible  
there.


It was a good warning.


Agree completely with all you said below! Indeed, I'm doing a check.


Since the author can rarely guarantee that some data field will
not be filled from an untrusted source *forever* it is always
best to check for and not allow overflow.   The function
getString in the sample code might be safe today, but will
it be safe after the nth code change in the future?  Does it
get or generate its code as a result of user action?  Will it
always be that way?

Easier to ensure that an overflow can't cause harm today
then to worry about all future failures.  Remember, most
security problems stem from abuse of simple bugs.

/\/\arc



___

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 arch...@mail-archive.com


NSTableView is not updated on [reloadData]

2009-07-23 Thread Alexander Bokovikov

Hi, All,

So, I'm continuing :)
I've connected my NSTableView with AppController (in IB) setting  
AppController, as NSTableView's datasource. Then I've added a couple  
of methods to the AppController to implement NSTableDataSource protocol:


- (int)numberOfRowsInTableView:(NSTableView *)tableView;

- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row;

Also I have a timer in my app, which should recalculate something from  
time to time and, as a result of this procedure, table row count (as  
well as values) should be updated. onTimer: method is like this one:


- (void)onTimer:(NSTimer*)timer {
//
// here we do some actions, leading to actual changes in the table  
content.

//
[myTable reloadData];
}

It all is correct for the first look. Isn't it? Now what is  
happening.  numberOfRowsInTableView: is called only once, yet before  
AppController's awakeFromNib is called. At that moment nothing yet is  
initialized (initialization goes in awakeFromNib), so  
numberOfRowsInTableView: returns zero.


Nothing happens when [myTable reloadData] is called within onTimer:  
procedure. None of delegated methods are called, so my table is always  
empty, though new data (of nonzero length) are created.


So, my question is - how to make table view to change its row count  
and update the data?


Thanks.

___

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 arch...@mail-archive.com


Re: closed - NSTableView is not updated on [reloadData]

2009-07-23 Thread Alexander Bokovikov


On 23.07.2009, at 21:25, I. Savant wrote:


 Is your myTable outlet connected to the table view?


I'm fool... :( sorry... I was pretty sure it is, but really it isn't.   
Also I was sure that BAD_ACCESS exception should occur if not  
initialized outlet is used to send a message to.


Fixed it.

Thanks for so quick reply!

___

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 arch...@mail-archive.com


NSTableView - populating from C procedure

2009-07-22 Thread Alexander Bokovikov

Hi, All,

This is my first attempt to deal with Cocoa container class, so I have  
some unclear points. I've found one of many tutorials here:


http://www.cocoadev.com/index.pl?NSTableViewDataSource

where it is said, among other, that NSTableView items may be filled  
out like this:


- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex {

return [[myTableViewArray objectAtIndex: rowIndex] objectForKey: 
[aTableColumn identifier]]


}

My specifics is that the data (strings)  are delivered by an external  
procedure, located out of ObjC stuff, and returning C-style strings.  
My table has only one column. My question is, as usual, about memory  
manager: May I write something like this:


exern void getString(int row, char *s, int *len);

- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex {

char buf[255];
int len;

getString(rowIndex, buf, len);
return [NSString stringWithCString:buf length:len  
encoding:NSUTF8StringEncoding];


}

I.e. is it possible to return a NSString without its preliminary  
retaining?

Or should I add [... retain]  to the returning string?

All examples operate by some values, stored in retained structures,  
like NSArray. Here my question originates from.


Thanks.
___

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 arch...@mail-archive.com


Re: [IB] - possible bug [was: how to delete action or outlet?]

2009-07-21 Thread Alexander Bokovikov


On 21.07.2009, at 4:07, Kelly Keenan wrote:

Have you figured out what is going on here?  If not, can you please  
file a bug and send me the bug number?  If possible, it would be  
really handy to have a very simple project with this same problem.


OK, I've found a time to recall what and how I did it. Finally I've  
discovered the reason. Here is the actions sequence, leading to the bug.


- create a new project; I used Cocoa-FPC template, recently created by  
Jonas Maebe (see the list for the link) though I don't think the  
template itself does a matter.


- click BuildGo to compile, though I don't think it does a matter  
too. I'm just too lazy to repeat it all again without that step. I  
just remember that I did it earlier.


- open Interface Builder;

- select Object Controller in the Library and drag it into Main  
Menu.XIB window;


- PRINCIPAL STEPS ARE HERE:

- rename the Object Controller instance, i.e. click on the Object  
name label below the blue cube, causing its inline editor appearance,  
and type something. I used AppController name.


- DO NOT change NSObject class name at the top of Info page of the  
Inspector.


- add a new action in the Actions panel of the Info page, and call it  
onClick:.


- drag a push button from Library to the Window

- connect (Ctrl+Mouse Down) the push button instance with  
AppController object in the XIB window; a popup list appears, where we  
choose onClick: action.


- CHANGE the AppController object instance CLASS NAME to  
AppController (was NSObject) in the Object Inspector; the action, we  
just created DISAPPEARS, so Actions panel is EMPTY.


- right-click on the AppController object instance in the XIB window  
and look at the actions list - we can see, that onClick: action still  
exists and it's still connected to the push button; screenshot is here:


http://home.bokovikov.com/etc/mac/xcode/IB-bug_01.png

- click on the cross and disconnect this action from button; now it's  
empty


- add new onClick: action in the Actions panel of Object Info page.

- we can see, that AppController popup window has two actions, but  
Info page now contains only one action.


http://home.bokovikov.com/etc/mac/xcode/IB-bug_02.png

That's all, what I did now. Earlier I yet created appropriate code in  
the AppController.m file. Finally I came to the situation, when  
Actions page in the Inspector contained one onClick: action  
(though AppController's popup shew two actions) and Minus button was  
grayed. Now I did not reproduce it, but I believe the problem reason  
is revealed pretty enough. I demonstrated it all for object actions,  
though the same situation is with object outlets.


Fixing this bug I'd suggest to save all existing actions and outlets,  
rather than remove them completely, because initial class is NSObject,  
which is the base one, so any actions, added to NSObject definitely  
can be added to any of its descendants. Indeed, it would be more  
advanced solution, when a warning will be generated, when object class  
is downgraded. Though I can't provide an exact sample, as I'm not so  
skilled yet in XCode/Cocoa.


Thanks.

___

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 arch...@mail-archive.com


Re: [IB] - possible bug [was: how to delete action or outlet?]

2009-07-21 Thread Alexander Bokovikov


On 21.07.2009, at 12:20, Graham Cox wrote:

Setting the name automatically when you set the class is a  
convenience, but equally you can change the name to make it clear to  
you what the object is. The name has no effect on anything.


I can agree, but the bug is, that I can't correctly change the class  
name _after_ I've added some actions/outlets. I definitely would like  
to have such ability. Adding a new object I could name its class by  
mistake then add a couple of tens actions/outlets, then discover my  
mistake in class naming (remember, all this we do in IB, so none of  
code files could yet be created!), and come face to face with the  
problem.


This is a sort of problem similar to inability of XCode project  
renaming. It's not clear why not to add such feature?


Thanks.
___

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 arch...@mail-archive.com


Re: [IB] - possible bug [was: how to delete action or outlet?]

2009-07-21 Thread Alexander Bokovikov


On 21.07.2009, at 13:19, Graham Cox wrote:

I don't make up controllers as I go along in IB - they always pre- 
exist in code and I just use IB to, er, build the interface.


I'm not against of the above. I can agree with your approach,  
moreover, it's an approach, described in Cocoa classic books. In most  
of cases authors just suggest to create classes (at least their  
skeletons) in code and then open IB for the first time. Though it may  
be not so usual for a newbie to write these magic clauses like  
(IBAction) and IBOutlet, but it is not so fearful.


I only would like to say, that really good and stable software should  
at least be stable to some more or less incorrect user's actions. Is  
it not allowed to change class name after actions/outlets have been  
added? OK, just say that! Or, if it's allowed, just fix a bug. Nothing  
more.


Thanks.
___

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 arch...@mail-archive.com


Open Recent menu - how to populate it?

2009-07-20 Thread Alexander Bokovikov

Hi, All,

I'm writing a simple (in GUI) application, where NSDocument is not  
used. I use NSOpenPanel to get a file name, then process file and  
close it. There is no UI, related to file, where NSDocument could help  
significantly. At least I believe so.


My problem is that Recent menu is empty, because in Cocoa (AFAIK) it  
is maintained automatically by NSDocumentController, which is absent  
in my app. So, my question is - how to create and update the Open  
Recent menu manually? Where to store its items? How to populate this  
submenu when my app is loaded?


Or should I use NSDocumentController anyway?

Thanks.
___

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 arch...@mail-archive.com


Re: Open Recent menu - how to populate it?

2009-07-20 Thread Alexander Bokovikov


On 20.07.2009, at 21:47, Graham Cox wrote:


... and use a menu delegate to update the menu from this.


This is just what is unclear for me, as I'm still learning Cocoa :)

Do you have in mind that I must:

1 - create an outlet, pointing to Open Recent menu item
2 - create an outlet, pointing to the Main Menu itself (or is there  
any ready-to-use one?)
3 - set my AppController, as a Main Menu delegate (e.g. in  
awaikFromNib, using outlet, created in #2)
4 - add some delegate message to my AppController class (what message  
should I intercept?)
5 - write some code like populating submenu of the menu item  
referenced by outlet, created in #1


If the sequence above is correct, then, OK, I'll try to do it, though  
I have one unclear point - will newly created menu items respond to  
onClick: action automatically, or should I assign onClick: action for  
each dynamically created item? If I should, then how to do it?


For extra credit, check the validity/existence of the file when  
updating the menu and remove bad ones and disambiguate duplicates.  
Someone might have written a class to do this already.


This is obvious, but my problem is in the menu dynamic creation.

On 20.07.2009, at 21:55, Tony S. Wu wrote:

i'd store the plist file in Library/Application support folder, and  
just process the file upon startup.


Am I correct in my understanding, that my application can create a  
subdirectory within /Library/Application Support/ directory? Or should  
it be done through an installer, where Administrator's password is  
asked?


Thanks.
___

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 arch...@mail-archive.com


Re: Open Recent menu - how to populate it?

2009-07-20 Thread Alexander Bokovikov


On 20.07.2009, at 23:13, Ali Ozer wrote:

You probably want to call this when you open a doc, or revert, or do  
save as... (if you have any of these commands in your app, of  
course).


Das ist fantastisch... 8-(  )

[[NSDocumentController sharedDocumentController]  
noteNewRecentDocumentURL:[NSURL URLWithString:filename]];


Just one line of code

Thank you very much!
___

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 arch...@mail-archive.com


Re: [IB] - how to delete action or outlet?

2009-07-19 Thread Alexander Bokovikov


On 19.07.2009, at 18:05, Graham Cox wrote:

Delete the actions/outlets from the source file, save, and in IB  
they'll show up with a yellow colour and a 'x' in the list views  
(right-click on the target object to show the HUD view of the  
connections). Then clicking the yellow x deletes the phantom  
connection.


Thanks to all, who replied, but nothing helps :( I tried to reload  
(synchronize) IB with sources, but without luck. All what I have now  
is illustrated at screenshots:


http://home.bokovikov.com/etc/mac/xcode/Picture1.png
http://home.bokovikov.com/etc/mac/xcode/Picture2.png

 As you can see, bindings panel has four outlets, two of which are  
connected and other two are free. At the same time Outlets panel at  
Info page shows only two outlets. AppController's popup menu also  
shows four outlets. And I don't see any way to delete two free  
outlets. Moreover, I don't understand, how it could happen, that IB  
allows existence of more than one object's outlet with the same name.  
I don't like the idea to clear the XIB and create it all again, but  
definitely I will be more careful next time I'll have a deal with it!


Thanks.
___

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 arch...@mail-archive.com


How to intercept/reroute API call in loaded plugin?

2009-07-19 Thread Alexander Bokovikov
I'm sorry, if it's offtopic here, then please tell me, what should be  
correct list.


The problem is the next. I'm working on a Cocoa app, playing Flash  
content from a specially structured files. The problem with SWF  
playback is (as I believe) is resolved by movie loading from memory  
rather than from file. There is no problems here. But what is the  
problem is FLV (Flash video) playback. It looks like its opening goes  
despite to all rules directly from a file, but not through  
plugin=host app communication interface. At least I can't detect  
any public plugin functions calls, when FLV file is loaded. So, the  
task is - how to intercept this I/O call and patch it by my own  
procedure, providing a file handle, as well as file pointer navigation.


I'm walking around Apple's sample of mach-o module manual launching:
http://developer.apple.com/SampleCode/MemoryBasedBundle/index.html

It is more or less clear, how to do it, but I can't find a way to  
intercept the process of import table loading of the loaded module.


Did anybody similar things ever?
Any help would be appreciated.

Thanks.
___

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 arch...@mail-archive.com


Re: [IB] - how to delete action or outlet?

2009-07-19 Thread Alexander Bokovikov


On 19.07.2009, at 19:11, Graham Cox wrote:


So, have you tried what I suggested?

Right-click on the target object that you've changed *in the main  
view*. In the HUD window that pops up, look for yellow text with a  
'x' button. Click it to delete. This should update what you are  
seeing in the bindings panel. It may not be possible to do the same  
thing directly in the bindings panel's list, but I do know the above  
does work, I use it frequently.


I'm sorry, I don't know what is HUD window, but it is what is shown  
in this screenshot:

http://home.bokovikov.com/etc/mac/xcode/Picture3.png

If so, I don't see any yellow text here. Could you please provide a  
similar screenshot? You could email it to me directly, but not to the  
public list.


Thanks.
___

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 arch...@mail-archive.com


Re: [IB] - how to delete action or outlet?

2009-07-18 Thread Alexander Bokovikov


On 18.07.2009, at 11:51, Chase Meadors wrote:

IB should sync with it's relative Xcode project if they are both  
open. Are you actually saving changes to the AppController source  
files after you edit them?




As I wrote, when I opened IB for the first time, Actions panel  
already had AppController.h title and contained my previously  
declared action. Therefore I thought IB was synchronized with the  
source file. Am I incorrect?


On a second note, the - button is gray because you can only remove  
actions in IB that you've added in IB.




Nice! And how to remove that action or at least how to rename it? For  
example I've done it by mistake, for testing or similar purposes. Now  
I can't remove such action or outlet, though I've closed IB, removed  
the action from the source file, then opened IB again. The action (or  
outlet) still exists in the object properties list.


I think the only way to remove it is to edit XIB file manually - not a  
simple way, isn't it?


Thanks.
___

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 arch...@mail-archive.com


[IB] - how to delete action or outlet?

2009-07-17 Thread Alexander Bokovikov

Hi, All,

I have no idea of how to remove an action or an outlet from  
AppController object, once added. For example, I've created  
appropriate modules AppController.h and .m, then wrote necessary code  
lines to declare an action stub and/or outlet. Then I open IB and drag  
necessary objects, like AppController, a text field or label or  
whatever else, connect them with AppController and look at the  
AppController's Info page. I see a header AppController.h and action  
(as well as outlet), I just created for it.


OK. Now I'd like to remove that action and/or outlet. But I can't do  
it from IB, because - button is always gray unless I'll add a new  
(yet another) action or outlet. What to do now? I close IB, go to  
AppController.h and .m and remove the code. Then I open IB again,  
expecting to see previous action being disappeared... Oops... They're  
still in place, connected to nothing, but - button in appropriate  
panel is still gray. I can add a new action or outlet, but those,  
initially created, will be stay unremovable.


Recently I've upgraded XCode to 3.1.3, but have still the same problem.

Is this a bug or just my misunderstanding?

Thanks.

___

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 arch...@mail-archive.com


10.4 vs 10.5 SDK - some problems in compilation

2009-07-15 Thread Alexander Bokovikov

Hi, All,

I'm rather new in XCode and Cocoa, so maybe it's my misunderstanding. Am I 
correct in my understanding, that I need to select 10.4 SDK in XCode project 
menu to create an application, compatible with both Tiger and Leo? I've got 
few errors in compilation when I choose 10.4 SDK.


Some of these errors, like NSUInteger and CGFloat missing, I've fixed by 
appropriate basic types substituting. Nevertheless I still have one 
uresolved problem - kVK_ constants are not found in 10.4 SDK, though 
they're OK with 10.5. I've tried to search in Google, but the only I've 
found was some FAQ, where it was suggested to use absolute path to the 
header file. I've tried it, but without luck. Though I use 
#import/System/Library/.../Events.h (what is shown in Get Info for 
that header in Finder) I still get the same error.


What is strange for me, all works OK even without this #import clause when 
I'm using 10.5 SDK.


Any help would be appreciated.

Thanks. 


___

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 arch...@mail-archive.com


How to share Cocoa classes?

2009-07-06 Thread Alexander Bokovikov

Hi, All,

Maybe it's a dummy question, but I can't find a way to share some ObjC 
classes with several XCode projects. I've created a set of Cocoa classes (.h 
and .m files) What I'd like to get is the ability to write something like 
this:


#import MyDir/MyClass.h

I don't want to distribute these classes, as a framework, but I would like 
just to link them directly into every executable, which refers them. As I 
heard, a static library, having ObjC classes inside, may cause some problems 
in linking. Therefore I yet didn't try this way.


My question is: can I copy these shared files (.h + .m) into some system 
directory to make them being visible for any Cocoa project through the 
import directive, like above?


If no, then what is the correct way to go besides manual inclusion of the 
same files into every XCode project?


-Thanks. 


___

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 arch...@mail-archive.com


Subject: Re: How to share Cocoa classes?

2009-07-06 Thread Alexander Bokovikov

Thank you, Jesse, but just a couple of points to clarify:


Static library linking with ObjC class, most likely could be done

successfully by only adding -ObjC and -all_load to the Other Linker
Flags in the build configuration.

Is this option applicable to library project settings or to a project where 
this library is called from?



To be able to use

#import MyDir/MyClass.h,
you need to add a header search path, that refers to that global
directory (or system directory, if you prefer) in your project
settings.

Could you please give an example of particular directories, where I could 
put headers as well as the library? All directories at root level are 
write-protected. What is the correct location to put my own libraries?


Also what particular settings are responsible for headers (and libraries) 
search path?


Thank you!

___

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 arch...@mail-archive.com


Re: How to share Cocoa classes?

2009-07-06 Thread Alexander Bokovikov

Thank you for the reply,

It looks like your case is just what I'd like to have, though my situation 
is simpler, as my shared code is the same for different projects (though 
different projects may include other different pieces). Therefore the 
problem of code stripping (which you described) should not appear for me.


Nevertheless, I'd appreciate it highly, if you'll guide me through the XCode 
project settings adjustment, as it sounds foggy for me, how to make static 
library to rebuild itself when main project is built. What particular 
settings should I add to the main project?


Also it's not clear, where to put that common header file? What is the 
correct location for that? Am I correct in my understanding, that placing 
this .h file into the right place I'll have the ability to include my 
classes (stored in static library) by single #importmysubdir/myincfile.h ? 
If yes, then it is just, what I'd like to get! The same question is about 
static library itseklf -- where it should be located? Should I create my own 
directory system or is it better to use some standard (system) directories 
for that? If I must use my own directories, then where should I add a path 
to them to avoid the necessarity to add this path to every new XCode project 
manually?


Thank you.


- Original Message - 
From: Steve Christensen puns...@mac.com

To: Alexander Bokovikov openwo...@uralweb.ru
Cc: cocoa-dev@lists.apple.com
Sent: Monday, July 06, 2009 9:30 PM
Subject: Re: How to share Cocoa classes?


I build a number of plugins and ended up with a lot of shared code so  I 
ended up creating a project that builds a static library with all  those 
pieces, then make all my plugin targets dependent on it so that  it gets 
[re-]built first. I created a common include file that  includes all the 
headers for the code in the static library and then  include that header in 
all my plugins. That keeps the included  headers list in the various 
plugins neat, plus makes it easy to add  new stuff to the library without 
having to update headers all over.


As for linking, so far I haven't had any problems. The only issue  I've 
ever run into is the case where I have a custom NSView class  that doesn't 
get directly referenced in the code because it's being  managed from the 
nib via bindings. In that case I've just added a if  ([MyViewClass class] 
!= NULL)... to a window controller's  +initialize method to force that 
code not to be stripped, since I do  want any classes in the library that 
I'm not using for a particular  plugin to be stripped out.


steve


On Jul 6, 2009, at 1:23 AM, Alexander Bokovikov wrote:

Maybe it's a dummy question, but I can't find a way to share some  ObjC 
classes with several XCode projects. I've created a set of  Cocoa classes 
(.h and .m files) What I'd like to get is the ability  to write something 
like this:


#import MyDir/MyClass.h

I don't want to distribute these classes, as a framework, but I  would 
like just to link them directly into every executable, which  refers 
them. As I heard, a static library, having ObjC classes  inside, may 
cause some problems in linking. Therefore I yet didn't  try this way.


My question is: can I copy these shared files (.h + .m) into some  system 
directory to make them being visible for any Cocoa project  through the 
import directive, like above?


If no, then what is the correct way to go besides manual inclusion  of 
the same files into every XCode project?




___

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 arch...@mail-archive.com


  1   2   >