Panelled Internet Explorer (pie)

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.

Hi,

- Dunno if this is a good example of PB or not, but here's an alternative to IE - PIE :wink:
- You'll have to run it twice (1st time it creates a simple pie.ini file) in the current directory with default panel information in it...

Thanks for giving us the Trackbar and Web gadgets Fred :wink:

Ta - N

--------------------
Declare GoToUrl(pid)

Procedure Alert(text.s)
MessageRequester("Alert",text.s,0)
EndProcedure


Procedure BuildGui()

Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF

OpenWindow(1, 0, 0, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN), #PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget, "Nigels Panelled WWW Browser")
CreateGadgetList(WindowID())
; goImageId=LoadImage(1,".\go.bmp") ;backImageId=LoadImage(2,".\back.bmp") ;fwdImageId=LoadImage(3,".\fwd.bmp")
ButtonGadget(2,8,2,20,18,"")
TrackBarGadget(1,58,2,GetSystemMetrics_(#SM_CXSCREEN)-80,16,0,100,#PB_TrackBar_Ticks)
PanelGadget(0,8,24,GetSystemMetrics_(#SM_CXSCREEN)-20,GetSystemMetrics_(#SM_CYSCREEN)-50)
BtnX=360 : BtnW=22
INIFilename(".\pie.ini")
For x = 1 To 99


defaultUrl$="javascript:document.write('-unused-'); document.close()"
defaultUrl$="about:blank"

inisection$="Panel"+Str(x) : INISection(inisection$)
If (ReadINIString("HOME","")="")
WriteINIString("HOME",defaultUrl$)
WriteINIString("NAME",inisection$)
Else
homeUrl$=ReadINIString("HOME","")
pieName$=ReadINIString("NAME","Panel"+Str(x))
EndIf
AddGadgetItem(0,-1,pieName$)

StringGadget(200+x, 10, 5, 350, 18, homeUrl$)
defaultUrl$=GetGadgetText(URL+x)
WebGadget(100+x,10,30,GetSystemMetrics_(#SM_CXSCREEN)-40,GetSystemMetrics_(#SM_CYSCREEN)-120,defaultUrl$)

; TrackBarGadget(300+x,360,5,400,20,0,100,PB_TrackBar_Ticks)
; ButtonImageGadget(500+x,800,5,20,18,goImageId) ; ButtonImageGadget(500+x,822,5,20,18,backImageId) ; ButtonImageGadget(500+x,844,5,20,18,fwdImageId)

ButtonGadget(GO+x,BtnX,5,20,18,"GO")
ButtonGadget(BACK+x,BtnX+(BtnW*8),5,20,18,"")
; ButtonGadget(FAV+x,BtnX+(BtnW*5),5,20,18,":-)")
ButtonGadget(STOP+x,BtnX+(BtnW*10),5,20,18,"!")
ButtonGadget(REF+x,BtnX+(BtnW*11),5,20,18,"X")
StringGadget(NAME+x,BtnX+(BtnW*3),5,9*10,18,pieName$)
TextGadget(4,BtnX+(BtnW*2),7,20,18,"Title")
ButtonGadget(5,BtnX+(BtnW*14),5,20,18,"?")
Next
EndProcedure

Procedure ListFavourites(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
; SetGadgetText(URL+pid,"file://C:\Documents and Settings\gb071577\Favourites")
SetGadgetText(URL+pid,"file://C:")
GoToUrl(pid)
EndProcedure

;Procedure GoToNAME(pid)
;Shared PIE, URL, GO, BACK, FWD, FAV, STOP, REF, NAME
;Alert("NAMEor For"+Str(pid))
;EndProcedure

Procedure GoToUrl(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetText(PIE+pid,GetGadgetText(URL+pid))
inisection$="Panel"+Str(pid)
INISection(inisection$)
INIFilename(".\pie.ini")
WriteINIString("HOME",GetGadgetText(URL+pid))
WriteINIString("NAME",GetGadgetText(NAME+pid))
EndProcedure

Procedure BackHistory(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetState(PIE+pid,#PB_Web_Back)
EndProcedure

Procedure FwdHistory(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetState(PIE+pid,#PB_Web_Forward)
EndProcedure

Procedure StopUrl(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetState(PIE+pid,#PB_Web_Stop)
EndProcedure

Procedure RefUrl(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetState(PIE+pid,#PB_Web_Refresh)
EndProcedure

Procedure HelpMsg()
Alert("PIE browser (Panelled Internet Explorer :wink: v1.00 June 2002 "+Chr(13)+Chr(13)+"Nigel Wale ([url]mailto:walen@hursley.ibm.com[/url]) - Use at your own risk!"+Chr(13)+Chr(13)+"creates a pie.ini file on startup that stores default HOME URL and TITLE for each Panel & updated each time you hit the 'GO' Button"+Chr(13)+Chr(13)+"Use the Slider & '' Buttons at the top to navigate quickly between Panels (99 max) which auto load on startup..."+Chr(13)+Chr(13)+" - have fun using it...")
EndProcedure


PIE=100
URL=200
NAME=300
GO=400
BACK=500
FWD=600
FAV=700
STOP=800
REF=900
Global NAME, GO, BACK, FWD, FAV, STOP, REF

BuildGui()

QUIT=0
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Default : If MainDebug0 : Alert("FYI: Menu Item "+Str(EventMenuID())+" Not Implemented") : EndIf
EndSelect
Case #PB_EventGadget

; If (EventGadgetID()>NAME And EventGadgetID()GO And EventGadgetID()BACK And EventGadgetID()FWD And EventGadgetID()FAV And EventGadgetID()STOP And EventGadgetID()REF And EventGadgetID()<REF+100)
RefUrl(EventGadgetID()-REF)
EndIf
Select EventGadgetID()
Case 1 : SetGadgetState(0,(GetGadgetState(1)))
Case 2 : SetGadgetState(1,GetGadgetState(1)-1) : SetGadgetState(0,(GetGadgetState(1)))
Case 3 : SetGadgetState(1,GetGadgetState(1)+1) : SetGadgetState(0,(GetGadgetState(1)))
Case 5 : HelpMsg()

;Default : Alert("FYI: Gadget "+Str(EventGadgetID())+" Not Implemented")
EndSelect

Case #WM_CLOSE : QUIT=MessageRequester("Confirm","Really Quit",1)
Case #PB_EventCloseWindow : QUIT=MessageRequester("Confirm","Really, Really Quit",1)

EndSelect
Until QUIT=1

Edited by - naw on 11 June 2002 11:45:55
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

You're example is cool . Nevertheless, please don't use the INI commands anymore but 'Preferences' one, as it's the official lib for preferences files now..

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.
You're example is cool . Nevertheless, please don't use the INI commands anymore but 'Preferences' one, as it's the official lib for preferences files now..

Fred - AlphaSND
- Thanks Fred [:-D] will do INI -> PREFERENCES conversion and repost...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.
You're example is cool . Nevertheless, please don't use the INI commands anymore but 'Preferences' one, as it's the official lib for preferences files now..

Fred - AlphaSND
Fred,

I replaced Mr Skunks INI file commands with your Preferences commands, but there seems to be a problem...

I can create a new *prefs* file & I can read the contents of the same file. But I cant seem to be able to overwrite individual entries...

Here's the updated version (using *Preferences*):

-----------------

Declare GoToUrl(pid)

Procedure Alert(text.s)
MessageRequester("Alert",text.s,0)
EndProcedure


Procedure BuildGui()

Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF, WID

WID=OpenWindow(1, 0, 0, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN), #PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget, "pIE - Panelled Internet Explorer")
CreateGadgetList(WindowID())
; goImageId=LoadImage(1,".\go.bmp") ;backImageId=LoadImage(2,".\back.bmp") ;fwdImageId=LoadImage(3,".\fwd.bmp")
ButtonGadget(2,8,2,20,18,"")
TrackBarGadget(1,58,2,GetSystemMetrics_(#SM_CXSCREEN)-80,16,0,100,#PB_TrackBar_Ticks)
PanelGadget(0,8,24,GetSystemMetrics_(#SM_CXSCREEN)-20,GetSystemMetrics_(#SM_CYSCREEN)-50)
BtnX=360 : BtnW=22

If (OpenPreferences(".\pie.prefs")=0) : Alert("New Prefs") : CreatePreferences(".\pie.prefs") : EndIf

For x = 1 To 99


defaultUrl$="javascript:document.write('-unused-'); document.close()"
defaultUrl$="about:blank"

PreferenceGroup$="Panel"+Str(x) : PreferenceGroup(PreferenceGroup$)
If (ReadPreferenceString("HOME","")="")
WritePreferenceString("HOME",defaultUrl$)
WritePreferenceString("NAME",PreferenceGroup$)
Else
homeUrl$=ReadPreferenceString("HOME","")
pieName$=ReadPreferenceString("NAME","Panel"+Str(x))
EndIf
AddGadgetItem(0,-1,pieName$)

StringGadget(200+x, 10, 5, 350, 18, homeUrl$)
defaultUrl$=GetGadgetText(URL+x)
WebGadget(100+x,10,30,GetSystemMetrics_(#SM_CXSCREEN)-40,GetSystemMetrics_(#SM_CYSCREEN)-120,defaultUrl$)

; TrackBarGadget(300+x,360,5,400,20,0,100,PB_TrackBar_Ticks)
; ButtonImageGadget(500+x,800,5,20,18,goImageId) ; ButtonImageGadget(500+x,822,5,20,18,backImageId) ; ButtonImageGadget(500+x,844,5,20,18,fwdImageId)

ButtonGadget(GO+x,BtnX,5,20,18,"GO")
ButtonGadget(BACK+x,BtnX+(BtnW*8),5,20,18,"")
; ButtonGadget(FAV+x,BtnX+(BtnW*5),5,20,18,":-)")
ButtonGadget(STOP+x,BtnX+(BtnW*10),5,20,18,"!")
ButtonGadget(REF+x,BtnX+(BtnW*11),5,20,18,"@")
StringGadget(NAME+x,BtnX+(BtnW*3),5,9*10,18,pieName$)
TextGadget(4,BtnX+(BtnW*2),7,20,18,"Title")
ButtonGadget(5,BtnX+(BtnW*14),5,20,18,"?")
Next
ClosePreferences()
EndProcedure

Procedure ListFavourites(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
; SetGadgetText(URL+pid,"file://C:\Documents and Settings\gb071577\Favourites")
SetGadgetText(URL+pid,"file://C:")
GoToUrl(pid)
EndProcedure

;Procedure GoToNAME(pid)
;Shared PIE, URL, GO, BACK, FWD, FAV, STOP, REF, NAME
;Alert("NAMEor For"+Str(pid))
;EndProcedure

Procedure GoToUrl(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetText(PIE+pid,GetGadgetText(URL+pid))
Alert("Updating .\pie.prefs file to show new URL & Title")
OpenPreferences(".\pie.prefs")
PreferenceGroup("Panel"+Str(pid))
WritePreferenceString ("ItemX","ValueY")
WritePreferenceString ("HOME",GetGadgetText(URL+pid))
WritePreferenceString ("NAME",GetGadgetText(NAME+pid))
ClosePreferences()
;
; DEBUG BIT
;
OpenPreferences(".\pie.prefs")
PreferenceGroup("Panel"+Str(pid))
HOME$=ReadPreferenceString("HOME","")
NAME$=ReadPreferenceString("NAME","")
Alert("Prefs File says: Panel"+Str(pid)+" HOME="+HOME$+" NAME="+NAME$+Chr(13)+"Should be: "+GetGadgetText(URL+pid)+" & "+GetGadgetText(NAME+pid))
ClosePreferences()
EndProcedure

Procedure BackHistory(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetState(PIE+pid,#PB_Web_Back)
EndProcedure

Procedure FwdHistory(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetState(PIE+pid,#PB_Web_Forward)
EndProcedure

Procedure StopUrl(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetState(PIE+pid,#PB_Web_Stop)
EndProcedure

Procedure RefUrl(pid)
Shared PIE, URL, NAME, GO, BACK, FWD, FAV, STOP, REF
SetGadgetState(PIE+pid,#PB_Web_Refresh)
EndProcedure

Procedure HelpMsg()
Alert("PIE browser (Panelled Internet Explorer :wink: v1.00 June 2002 "+Chr(13)+Chr(13)+"Nigel Wale ([url]mailto:walen@hursley.ibm.com[/url]) - Use at your own risk!"+Chr(13)+Chr(13)+"creates a pie.prefs file on startup that stores default HOME URL and TITLE for each Panel & updated each time you hit the 'GO' Button"+Chr(13)+Chr(13)+"Use the Slider & '' Buttons at the top to navigate quickly between Panels (99 max) which auto load on startup..."+Chr(13)+Chr(13)+" - have fun using it...")
EndProcedure


PIE=100
URL=200
NAME=300
GO=400
BACK=500
FWD=600
FAV=700
STOP=800
REF=900
WID=1
Global NAME, GO, BACK, FWD, FAV, STOP, REF, WID

BuildGui()

QUIT=0
Repeat
Select WaitWindowEvent()
Case #PB_EventMenu
Select EventMenuID()
Default : If MainDebug0 : Alert("FYI: Menu Item "+Str(EventMenuID())+" Not Implemented") : EndIf
EndSelect
Case #PB_EventGadget

; If (EventGadgetID()>NAME And EventGadgetID()GO And EventGadgetID()BACK And EventGadgetID()FWD And EventGadgetID()FAV And EventGadgetID()STOP And EventGadgetID()REF And EventGadgetID()<REF+100)
RefUrl(EventGadgetID()-REF)
EndIf
Select EventGadgetID()
Case 1 : SetGadgetState(0,(GetGadgetState(1)))
Case 2 : SetGadgetState(1,GetGadgetState(1)-1) : SetGadgetState(0,(GetGadgetState(1)))
Case 3 : SetGadgetState(1,GetGadgetState(1)+1) : SetGadgetState(0,(GetGadgetState(1)))
Case 5 : HelpMsg()

;Default : Alert("FYI: Gadget "+Str(EventGadgetID())+" Not Implemented")
EndSelect

Case #WM_CLOSE : QUIT=MessageRequester("Confirm","Really Quit",1)
Case #PB_EventCloseWindow : QUIT=MessageRequester("Confirm","Really, Really Quit",1)

EndSelect
Until QUIT=1
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Hi Naw, nice work.
This is so cool that it normally must be under Tips&Tricks instead of Beginners...

BTW your line:

WID=OpenWindow(1, 0, 0, GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN), #PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget, "pIE - Panelled Internet Explorer")

has a bad result, because the Window is BIGGER (X and Y) than my Desktop.
You probably overlooked that the SIZE in OpenWindow is the Client Area not the overall Window dimension.
To adjust this, you can't use ResizeWindow because it resizes the Client Area of a Window.
The explanation:

ResizeWindow(Width, Height)
Resize the current window to the given dimensions.

in the help file is wrong!

This would be more appropriate:

ResizeWindow(InnerWidth, InnerHeight)
Resize the current window to the given dimensions.
'InnerWidth' and 'InnerHeight' specify the requiered client area (without borders and window decorations), for Windows XP, AmigaOS and Linux skinning compatibility.

--------------------

Anyway, to use a fixed number to adjust this, like -4 for X and -28 for Y, doesn't work either because of WinXP's new skinning stuff.

Here is a procedure that I use for PureGUI as a built-in command:

Code: Select all

Procedure PG_ResizeWindow(PureGUI_SizeX,PureGUI_SizeY)
  PureGUI_Pos.RECT : GetWindowRect_(WindowID(),PureGUI_Pos)
  SetWindowPos_(WindowID(),0,PureGUI_Pos\left,PureGUI_Pos\top,PureGUI_SizeX,PureGUI_SizeY,0)
EndProcedure

Hope this helps...




Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by naw.
You probably overlooked that the SIZE in OpenWindow is the Client Area not the overall Window dimension.
Hi Franco,
Wow! praise indeed :wink:
Trying to incorporate your suggestions, but Resizing the Window is tricky...
Ta - N
BTW NAW=Nigel :wink:
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Hi Nigel,
Trying to incorporate your suggestions, but Resizing the Window is tricky...

just put my Procedure on top of your code and put this line after the OpenWindow call:

PG_ResizeWindow(GetSystemMetrics_(#SM_CXSCREEN), GetSystemMetrics_(#SM_CYSCREEN))

That's it.

BTW: The best would be if you put ALL procedures on TOP of your code.
And after that build your gui. You can call the procedures everytime you need it.



Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
Post Reply