It is currently Sat May 18, 2013 7:44 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: ZOOM IN\OUT ListIcon Gadget [Windows]
PostPosted: Wed Apr 25, 2012 8:37 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 1467
Tested with PB 4.6 x84 Win 7 x64

Code:
  LoadFont(0,"Arial",10)
  LoadFont(1,"Broadway",14)

  If OpenWindow(0, 0, 0, 640, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
    ListIconGadget(0,  10,  10, 620, 280, "Column 0", 200,#PB_ListIcon_GridLines)
      For x = 1 To 9
        AddGadgetColumn(0, x, "Column " + Str(x), 300)
      Next
      For x = 0 To 8
        AddGadgetItem(0, x, "Item 0"+Chr(10)+"Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4"+Chr(10)+"Item 5"+Chr(10))
      Next
      header = SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0)
      SendMessage_(GadgetID(0),#WM_SETFONT,FontID(0),1)
      SendMessage_(header,#WM_SETFONT,FontID(1),1)     
           
      FSize_1 = 10
      FSize_2 = 14
      Col_No = 9
           
      Global Dim width(Col_No)
Repeat
  Select WaitWindowEvent()
     
      Case #PB_Event_CloseWindow
            Quit = 1
       
     
      Case #PB_Event_Gadget
            Select EventGadget()
             Case 0           
            EndSelect
           
           
      Case #WM_SIZE
            ResizeGadget(0,10,10,WindowWidth(0)-20,WindowHeight(0)-20)
           
         
      Case #WM_ENTERSIZEMOVE           
            HSpos.d = GetScrollPos_(GadgetID(0),#SB_HORZ)           
            WWidth.d = WindowWidth(0)
            For i = 0 To Col_No
                width(i) = GetGadgetItemAttribute(0, 0, #PB_ListIcon_ColumnWidth ,i)
            Next
         
      Case #WM_EXITSIZEMOVE
            Scale.d = WindowWidth(0)/WWidth
            FSize_1 = Int(Round((FSize_1 * Scale),1))
            FSize_2 = Int(Round((FSize_2 * Scale),1))         
            For i = 0 To Col_No
                SetGadgetItemAttribute(0, 0, #PB_ListIcon_ColumnWidth ,Round(Scale*width(i),#PB_Round_Up),i)
            Next

            LoadFont(0,"Arial",FSize_1)
            LoadFont(1,"Broadway",FSize_2)
           
            SendMessage_(GadgetID(0),#WM_SETFONT,FontID(0),1)
            SendMessage_(header,#WM_SETFONT,FontID(1),1)
           
            SendMessage_(GadgetID(0), #LVM_SCROLL,- GetScrollPos_(GadgetID(0),#SB_HORZ), 0)
            SendMessage_(GadgetID(0), #LVM_SCROLL,Scale*HSpos, 0)
     
  EndSelect
Until Quit = 1
EndIf

_________________
Egypt my love


Top
 Profile  
 
 Post subject: Re: ZOOM IN\OUT ListIcon Gadget [Windows]
PostPosted: Wed Apr 25, 2012 9:54 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Apr 30, 2003 8:15 am
Posts: 710
Location: Germany
@Rashad: could you explain pls, how to use it? What is the initial action to enter
the #WM_ENTERSIZEMOVE?

I mean are there others actions than change the size of the window...

_________________
"Daddy, I'll run faster, then it is not so far..."


Top
 Profile  
 
 Post subject: Re: ZOOM IN\OUT ListIcon Gadget [Windows]
PostPosted: Wed Apr 25, 2012 10:06 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 1467
Hi dige
The main purpose is to change the size of the ListIcon proportional to the initial size
And at the same time keep the Hal. scrollbar at the previous position
Let us start by setting the Hal. scrollbar between Column 3 and Column 4 for example
Then resize the window to see what I mean
So you can read what you want easily

_________________
Egypt my love


Top
 Profile  
 
 Post subject: Re: ZOOM IN\OUT ListIcon Gadget [Windows]
PostPosted: Wed Apr 25, 2012 10:30 am 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2852
Location: Wales, UK
Hi Rashad - it's working really nicely on WinXP 32bit :)

The crème de la crème would be to zoom in-out on the gadget via middle-mouse drag or scroll (without necessarily changing window size).

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: ZOOM IN\OUT ListIcon Gadget [Windows]
PostPosted: Wed Apr 25, 2012 1:30 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 1467
Hi IdeasVacuum
It is your idea after all
Take it as a start
Code:
  LoadFont(0,"Arial",10)
  LoadFont(1,"Broadway",14)

  If OpenWindow(0, 0, 0, 800, 500, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ListIconGadget(0,  10,  10, 780, 480, "Column 0", 200,#PB_ListIcon_GridLines)
      For x = 1 To 9
        AddGadgetColumn(0, x, "Column " + Str(x), 300)
      Next
      For x = 0 To 8
        AddGadgetItem(0, x, "Item 0"+Chr(10)+"Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4"+Chr(10)+"Item 5"+Chr(10))
      Next
      header = SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0)
      ;
      SendMessage_(GadgetID(0),#WM_SETFONT,FontID(0),1)      ;
      SendMessage_(header,#WM_SETFONT,FontID(1),1)
     
      Col_No = 9           
      Global Dim width(Col_No)
Repeat
  Select WaitWindowEvent()
     
      Case #PB_Event_CloseWindow
            Quit = 1
       
     
      Case #PB_Event_Gadget
            Select EventGadget()
             Case 0           
            EndSelect
           
           
      Case #WM_MOUSEWHEEL
          HSpos.d = GetScrollPos_(GadgetID(0),#SB_HORZ)
          For i = 0 To Col_No
                width(i) = SendMessage_(GadgetID(0), #LVM_GETCOLUMNWIDTH, i, 0)
          Next
          Scale.d = 1
          If EventwParam() < 0
               Scale = Scale * 1.1
          Else
               Scale = Scale * 0.9
          EndIf
         
          For i = 0 To Col_No
                SendMessage_(GadgetID(0), #LVM_SETCOLUMNWIDTH, i,Round(Scale*width(i),#PB_Round_Up))
          Next
           SendMessage_(GadgetID(0), #LVM_SCROLL,- GetScrollPos_(GadgetID(0),#SB_HORZ), 0)
           SendMessage_(GadgetID(0), #LVM_SCROLL,Scale*HSpos, 0)
     
  EndSelect
Until Quit = 1
EndIf


_________________
Egypt my love


Top
 Profile  
 
 Post subject: Re: ZOOM IN\OUT ListIcon Gadget [Windows]
PostPosted: Wed Apr 25, 2012 9:00 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 2505
Location: Lyon - France
The first code is like usually splendid :shock:
Thanks a lot for sharing and for this amazing new behaviour of the ListIcon 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
 
 Post subject: Re: ZOOM IN\OUT ListIcon Gadget [Windows]
PostPosted: Thu Apr 26, 2012 12:17 am 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2852
Location: Wales, UK
Clever stuff :mrgreen:

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: ZOOM IN\OUT ListIcon Gadget [Windows]
PostPosted: Sun May 06, 2012 10:17 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:51 pm
Posts: 2715
Location: Portugal, Lisbon
LOL!

I like it! Nice idea :mrgreen:

_________________
Software: http://xipa.org
Elevator Maintenance: http://central-elevadores.pt
Good web hosting!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye