[Linux 3.94] Professional Toolbar - includefile -

Developed or developing a new product in PureBasic? Tell the world about it.
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

[Linux 3.94] Professional Toolbar - includefile -

Post by walker »

Hi,

here is an includefile for creating a professional looking toolbar which (maybe with 4,0) could be transformed in a UserLib (isn't possible at the moment.. (see my las post in this thread http://www.purebasic.fr/english/viewtop ... 096#152096)... maybe someone has a hint.... :roll:

Anyway, creating a toolbar on linux with builtin-gfx or your own gfx is easy as it could be. Here is a small snipet which demonstrates this:

Code: Select all

Demo-application:
IncludeFile "toolbar_pro.pb"
;the Procedures called by the Toolbarbuttons MUST be in the CDLL format!!
ProcedureCDLL meineproc()
;your code here    
EndProcedure

ProcedureCDLL meineproc1()
;your code here
EndProcedure

ProcedureCDLL meineproc2()
;your code here
End
EndProcedure
*hwnd=OpenWindow(0,0,0,700,300,#PB_Window_ScreenCentered,"Toolbar")
If CreateGadgetList(*hwnd)
    ;create a toolbar
    *tool=CreateTB(0,WindowID(),#GTK_TOOLBAR_BOTH);one of #GTK_TOOLBAR_ICONS, #GTK_TOOLBAR_TEXT or #GTK_TOOLBAR_BOTH
    
    ;the buttons
    *btn=AddTBbutton(*tool,"gtk-new",@meineproc(),"",""); a standard button with standard image and text - leave the last 2 parameter empty
    SetTBbuttonTooltip(*btn,*tooltips,"Demo tooltip")
    
    AddTBseparator(*tool,#FALSE)
    
    *btn1=AddTBbutton(*tool,"gtk-open",@meineproc1(),"",""); a standard button with standard image and text
    SetTBbuttonTooltip(*btn1,*tooltips,"another tooltip")
    
    AddTBseparator(*tool,#FALSE)
    
    *btn2=AddTBbutton(*tool,"gtk-delete",@meineproc1(),"",""); a standard button with standard image and text
    SetTBbuttonTooltip(*btn2,*tooltips,"delete something.....")
    
    *btn3=AddTBbutton(*tool,"gtk-missing-image",@meineproc1(),"Press this Button","/home/user/lin_.png"); a button with own image and own text - fill the last  2 parameter
    ;if the image doesn't exist, the named button-image will be taken, if this parameter is set to "", an empty image will be generated
    SetTBbuttonTooltip(*btn3,*tooltips,"VERY IMPRESSIVE")
    
    AddTBseparator(*tool,#True);if #true, the button(s) after this will be on the most right side of the window
    
    *btn4=AddTBbutton(*tool,"gtk-quit",@meineproc2(),"MyExit",""); a button with standard image and own text - leave only he last parameter empty
    SetTBbuttonTooltip(*btn4,*tooltips,"Exit")
    
    ; other PB-Gadgets
     PanelGadget(0,10,5,680,200)
     AddGadgetItem(0,-1,"Tab1")
    CloseGadgetList()
EndIf 

Repeat
    ev = WaitWindowEvent()
Until ev=#PB_Event_CloseWindow
End
I hope, the comments are satisfying...
There are 4 commands at the moment - CreateTB(), AddTBbutton(), AddTBseparator() and SetTBtooltip() (taken the same names as TBPro on win... but unfortunately the parameters are completely different)

You can use nearly all images known by gtk2 (even ico-format) without a coresponding Imagedcoder... 8)
The heigth of the Toolbar-buttons are always depending on the largest mage....

A Warning. NEVER use

Code: Select all

UsePNGImagexxxx()
When using the toolbar... Due to an error (i think it's one) of PB-Linux the images (predefined Stock-Images) weren't displayed any more....

At least: here is a screenshot of the demo

Image

and, of course, the includefile:
http://home.arcor.de/x-linux/pure/toolbar_pro.pb


Compile with GTK2 as subsystem

Comments, error reports (or missing functions), questions etc. are appreciated

enjoy :D
User avatar
bembulak
Enthusiast
Enthusiast
Posts: 575
Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria

Post by bembulak »

Impressive!
Please keep on working on that!
cheers,

bembulak
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Great :!:
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

sweet
Image Image
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Good stuff
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

Thanks a lot...

maybe with 4.0 it's possible to create a UserLib... and then much easier to use...
Post Reply