Page 6 of 7
Re: [PB Cocoa] Cocoa companion library
Posted: Thu Mar 20, 2014 8:14 pm
by wilbert
metalos wrote:I have wanted to know if it was possible to move in a ToolBar 1 Boutton the oposite of the other and if so how.
I've read your question multiple times but I still don't understand what you are exactly asking.
Can you try to explain a bit more ?
Re: [PB Cocoa] Cocoa companion library
Posted: Fri Mar 21, 2014 8:57 am
by metalos
Sorry for my English but I use Google Translate.
Using an example of the documentation for your library I get this result for the ToolBar.
Code: Select all
If OpenWindow(0, 0, 0, 600, 200, "ToolBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(0, 0, 0, 96, 32, "")
CreateImage(0, 32, 32)
StartDrawing(ImageOutput(0))
Box(0,0,32,32,RGB(255,255,255))
Box(4,4,24,24,RGB(255,0,0))
StopDrawing()
CreateToolBar(0, WindowID(0))
TB_ID = ToolBarID(0)
ToolBar_SetMode(TB_ID, 1, 1)
ToolBarImageButton(0, ImageID(0))
Item = ToolBar_ItemAtIndex(TB_ID, 0)
ToolBar_SetItemLabel(Item, "Button")
ToolBarImageButton(1, ImageID(0))
Item = ToolBar_ItemAtIndex(TB_ID, 1)
ToolBar_SetItemLabel(Item, "String gadget")
ToolBar_SetItemGadget(Item, GadgetID(0))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
I would like to place the StringGadget the oposite of BouttonImage like this:
My request is can not be possible with your library and if this is the case do you add this option in the future? Thank you for your help.
Re: [PB Cocoa] Cocoa companion library
Posted: Fri Mar 21, 2014 9:42 am
by wilbert
It's a bit complicated since I don't know the PureBasic internals.
What you need to get what you want is a flexible space item.
You can insert one after you create the toolbar like this
Code: Select all
CocoaMessage(0, ToolBarID(0), "insertItemWithItemIdentifier:$", @"NSToolbarFlexibleSpaceItem", "atIndex:", 1)
The problem is that there seem to be additional items on the toolbar that mess up the way things look and I don't know if there is a reason these items are there.
On my system there seem to be two and once I remove those things look fine
Code: Select all
CocoaMessage(0, ToolBarID(0), "removeItemAtIndex:", 2)
CocoaMessage(0, ToolBarID(0), "removeItemAtIndex:", 2)
CocoaMessage(0, ToolBarID(0), "insertItemWithItemIdentifier:$", @"NSToolbarFlexibleSpaceItem", "atIndex:", 1)
I just can't guarantee it is the same on every OSX version, if it will stay this way and if these additional items have any reason to be there.
So without any confirmation on this from Fred it's not really a safe option.
Re: [PB Cocoa] Cocoa companion library
Posted: Fri Mar 21, 2014 12:51 pm
by metalos
I'll try anyway, thanks;-)
Re: [PB Cocoa] Cocoa companion library
Posted: Fri Mar 21, 2014 3:40 pm
by Shardik
As Wilbert correctly describes it, it's really a bit complicated because of PureBasic's internal toolbar implementation. PureBasic always adds a flexible space, a space and a separator (on Snow Leopard but not on Mavericks!) behind the last visible toolbar button. You may inspect this by executing the following code which enables you to customize your toolbar and by the way see all visible and invisible items which PureBasic always adds to your toolbar:
Code: Select all
#SilkThemePath = #PB_Compiler_Home + "Themes/"
#IconNameList = "disk.png+delete.png+arrow_left.png+arrow_right.png"
UsePNGImageDecoder()
UseZipPacker()
OpenWindow(0, 270, 100, 290, 50, "Customizable toolbar")
CreateToolBar(0, WindowID(0))
If OpenPack(0, #SilkThemePath + "SilkTheme.zip")
*ImageBuffer = AllocateMemory(1024)
If ExaminePack(0)
For i = 0 To CountString(#IconNameList, "+")
ImageSize = UncompressPackMemory(0, *ImageBuffer, MemorySize(*ImageBuffer),
StringField(#IconNameList, i + 1, "+"))
If ImageSize > 0
If CatchImage(i, *ImageBuffer, ImageSize)
ToolBarImageButton(i, ImageID(i))
If i = 2
ToolBarSeparator()
EndIf
EndIf
EndIf
Next i
EndIf
FreeMemory(*ImageBuffer)
EndIf
; ----- Display dialog to customize toolbar
CocoaMessage(0, ToolBarID(0), "runCustomizationPalette:", ToolBarID(0))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Also keep in mind that these PureBasic internals may change with new releases, so please use the following hackish solution with care:
Code: Select all
#NSToolbarSizeModeRegular = 1
OpenWindow(0, 270, 100, 350, 200, "ToolBar with button at right end")
CreateImage(0, 24, 24)
StartDrawing(ImageOutput(0))
Box(0, 0, 24, 24, $FF0000)
Box(4, 4, 16, 16, $FFFF)
StopDrawing()
CreateImage(1, 24, 24)
StartDrawing(ImageOutput(1))
Box(0, 0, 24, 24, $FF)
Box(4, 4, 16, 16, $FFFF)
StopDrawing()
CreateToolBar(0, WindowID(0))
CocoaMessage(0, ToolBarID(0), "setSizeMode:", #NSToolbarSizeModeRegular)
ToolBarImageButton(0, ImageID(0))
ToolBarImageButton(1, ImageID(1))
; ----- Count visible and invisible toolbar items
ItemCount = CocoaMessage(0, CocoaMessage(0, ToolBarID(0), "items"), "count")
If OSVersion() <= #PB_OS_MacOSX_10_6
; ----- Remove rightmost separator
CocoaMessage(0, ToolBarID(0), "removeItemAtIndex:", ItemCount - 1)
ItemCount - 1
EndIf
; ----- Remove rightmost space
CocoaMessage(0, ToolBarID(0), "removeItemAtIndex:", ItemCount - 1)
ItemCount - 1
; ----- Remove rightmost flexible space
CocoaMessage(0, ToolBarID(0), "removeItemAtIndex:", ItemCount - 1)
ItemCount - 1
; ----- Insert flexible space between 1st and 2nd button
CocoaMessage(0, ToolBarID(0),
"insertItemWithItemIdentifier:$", @"NSToolbarFlexibleSpaceItem",
"atIndex:", 1)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: [PB Cocoa] Cocoa companion library
Posted: Fri Mar 21, 2014 3:56 pm
by wilbert
Another option might be to create a Toolbar yourself from the NSToolbar class but that also means defining all the required delegate methods.
Re: [PB Cocoa] Cocoa companion library
Posted: Mon Mar 24, 2014 9:21 pm
by metalos
Ok thanks
Re: [PB Cocoa] Cocoa companion library
Posted: Thu Apr 17, 2014 12:39 am
by J. Baker
Could someone sticky this? I think it's a must have for OS X users.
Re: [PB Cocoa] Cocoa companion library
Posted: Thu May 15, 2014 9:49 am
by metalos
Hello,
I returned to you because when I add the parameter # PB_ToolBar_Toggle my ToolBarImageButton () it does not seem to work. Do you have an idea of the problem? Thank you in advance.
Code: Select all
If OpenWindow(0, 0, 0, 600, 200, "ToolBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(0, 0, 0, 96, 32, "")
CreateImage(0, 32, 32)
StartDrawing(ImageOutput(0))
Box(0,0,32,32,RGB(255,255,255))
Box(4,4,24,24,RGB(255,0,0))
StopDrawing()
CreateToolBar(0, WindowID(0))
TB_ID = ToolBarID(0)
ToolBar_SetMode(TB_ID, 1, 1)
ToolBarImageButton(0, ImageID(0), #PB_ToolBar_Toggle)
Item = ToolBar_ItemAtIndex(TB_ID, 0)
ToolBar_SetItemLabel(Item, "Button")
ToolBarImageButton(1, ImageID(0))
Item = ToolBar_ItemAtIndex(TB_ID, 1)
ToolBar_SetItemLabel(Item, "String gadget")
ToolBar_SetItemGadget(Item, GadgetID(0))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: [PB Cocoa] Cocoa companion library
Posted: Fri May 16, 2014 5:48 am
by wilbert
metalos wrote:when I add the parameter # PB_ToolBar_Toggle my ToolBarImageButton () it does not seem to work.
It looks like this is a PureBasic bug.
The optional #PB_ToolBar_Toggle doesn't seem to do anything.
You could post a bug report in the bugs section of the forum.
Re: [PB Cocoa] Cocoa companion library
Posted: Fri May 16, 2014 2:58 pm
by metalos
I just mentioned. Thank you.
Re: [PB Cocoa] Cocoa companion library
Posted: Mon Jun 09, 2014 10:43 pm
by J. Baker
Missing a couple of files on build...
Code: Select all
Last login: Mon Jun 9 17:34:56 on ttys000
Joseph-Bakers-MacBook-Air:~ jbaker$ /Users/jbaker/Documents/Cocoa/PBCocoa64/PBUserlib/build.command ; exit;
cp: /Users/jbaker/Documents/Cocoa/PBCocoa64/build/PBCocoa.build/Release/PBCocoa.build/Objects-normal/i386/libPBCocoa.a: No such file or directory
cp: /Users/jbaker/Documents/Cocoa/PBCocoa64/build/PBCocoa.build/Release/PBCocoa.build/Objects-normal/x86_64/libPBCocoa.a: No such file or directory
Can't open the main file: libPBCocoa_x86.a
Can't open the main file: libPBCocoa_x64.a
rm: *.zip: No such file or directory
adding: libPBCocoa_x64 (deflated 66%)
adding: libPBCocoa_x86 (deflated 66%)
logout
[Process completed]
Re: [PB Cocoa] Cocoa companion library
Posted: Tue Jun 10, 2014 5:19 am
by wilbert
J. Baker wrote:Missing a couple of files on build...
Do you also have this problem with other user libraries Joe ?
Maybe it is related to using Yosemite.
Re: [PB Cocoa] Cocoa companion library
Posted: Tue Jun 10, 2014 5:32 am
by J. Baker
wilbert wrote:J. Baker wrote:Missing a couple of files on build...
Do you also have this problem with other user libraries Joe ?
Maybe it is related to using Yosemite.
The last lib I tried was with TailBite. That's been a while. I'm actually on Snow Leopard. I thought that maybe those directories and files were missing from the source? Or is there something else I'm missing or should be doing?
Re: [PB Cocoa] Cocoa companion library
Posted: Tue Jun 10, 2014 6:32 pm
by J. Baker
removed
EDIT: I got it. I had to remove the fullscreen code as I'm using an earlier version of xcode.
