forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Toolbar GoSub

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code
View previous topic :: View next topic  
Author Message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Mon Mar 17, 2003 7:21 pm    Post subject: Toolbar GoSub Reply with quote

Here is a sub that I made to make toolbars. I'm sure it could be refined
so please do so and post your results.

Code:

   rem Toolbar Gosub by Chris Gingerich
   rem
   rem This sub is to allow the ease of creating a toolbar
   dialog CREATE,Toolbar Sub,-1,0,400,160
   dialog SHOW
   rem Format:
   rem   The first 6 items
   rem   0 = Toolbar name
   rem   1 = Top
   rem   2 = Left
   rem   3 = Width of buttons
   rem   4 = Height of buttons
   rem   5 = Space between buttons
   rem   6 - ? are button description
   rem    Button description format
   rem     Use @tab() as the seperator
   rem     Button Name
   rem     Button butmap if needed
   rem     Button caption if needed
   rem     Button tooltip if needed
   %%toolbar = Toolbar1|0|0|48|32|0|button|Button1@tab()1.bmp@tab()@tab()Home|Button2@tab()2.bmp@tab()@tab()Open|-|Button3@tab()3.bmp@tab()@tab()Open
   gosub Create toolbar


:evloop
   wait event
   goto @event()

:close
   stop

:Create Toolbar
   if %%toolbar
      parse "%a;%b",%%toolbar
      %%tblist = %a_list
      dialog add,list,%%tblist,0,0,0,
      repeat
         parse "%a;%b",%%toolbar
         %%remainder = @substr(%%toolbar,@sum(@len(%a),2),@len(%%toolbar))
         if %a
            list add,%%tblist,%a
            %%toolbar = %%remainder
         end
      until @null(%a)
      %%tbname = @item(%%tblist,0)
      %%tbtop = @item(%%tblist,1)
      %%tbleft = @item(%%tblist,2)
      %%tbw = @item(%%tblist,3)
      %%tbh = @item(%%tblist,4)
      %%tbspace = @item(%%tblist,5)
      %%tbstyle = @item(%%tblist,6)
      %x = 7
      %%spacer = 1
      dialog add,group,%%tbname,%%tbtop,%%tbleft,0,@sum(%%tbh,6)
      option fieldsep,@tab()
      %%tbleft = @sum(%%tbleft,5)
      repeat
         %%tbi = @item(%%tblist,%x)
         if @equal(%%tbi,-)
            %%tbleft = @diff(%%tbleft,%%tbspace)
            dialog add,group,Spacer%%spacer,@sum(%%tbtop,6),@sum(%%tbleft,4),2,@diff(%%tbh,4)
            %%tbleft = @sum(%%tbleft,10)
            %%spacer = @succ(%%spacer)
            rem if @greater(%%tbspace,0)
            rem %t = @div(%%tbw,4)
            rem %%tbleft = @diff(%%tbleft,%%tbspace)
            rem dialog add,group,Spacer%%spacer,@sum(%%tbtop,6),@sum(%%tbleft,%t),2,@diff(%%tbh,4)
            rem %%tbleft = @sum(%%tbleft,@sum(%t,%t))
            rem else
            rem %t = @div(%%tbw,4)
            rem dialog add,group,Spacer%%spacer,@sum(%%tbtop,6),@sum(%%tbleft,%t),2,@diff(%%tbh,4)
            rem %%tbleft = @sum(%%tbleft,@sum(%t,%t))
            rem end
            rem %%spacer = @succ(%%spacer)
         else
            parse "%a;%b;%c;%d",%%tbi
            if @equal(%%tbstyle,button)
               dialog add,%%tbstyle,%a,@sum(%%tbtop,3),%%tbleft,%%tbw,%%tbh,%c,%d
               elsif @equal(%%tbstyle,bitbtn)
               dialog add,%%tbstyle,%a,@sum(%%tbtop,3),%%tbleft,%%tbw,%%tbh,%b,%c,%d
               elsif @equal(%%tbstyle,bitmap)
               dialog add,%%tbstyle,%a,@sum(%%tbtop,3),%%tbleft,%%tbw,%%tbh,%b,%d
            end
            %%tbleft = @sum(%%tbleft,@sum(%%tbw,%%tbspace))
         end
         %x = @succ(%x)
      until @equal(%x,@count(%%tblist))
      dialog setpos,%%tbname,,,@dlgpos(,W)
rem      dialog setpos,%%tbname,,,@sum(@dlgpos(%a,L),@sum(%%tbw,4))
      option fieldsep,|
   end
   exit


- Edit: Made it so toolbar name is also name of list with "_list" at the end and made group extend to the width of the dialog.

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ACE
Valued Newbie


Joined: 05 Sep 2002
Posts: 34

PostPosted: Mon Mar 24, 2003 4:30 pm    Post subject: Reply with quote

great code you have there LiquidCode Very Happy

I like how you make reusable code, thats the concept of efficient proggraming. Whit VDS5 it will be very useful, can be converted to fuction and put in a externally file. Great again Very Happy

But probably you want to change the line 54, where you first add the toolbar´s group, its better to first create and make the items fall inside, in this way you can have fuctions on you toolbar with only the %%tbname group, like showing or hiding, relocating, or moving with the mouse

Lioric
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group