Page 1 of 2

PureBasic 3.92 beta 1 for Windows released

Posted: Mon Oct 11, 2004 1:18 am
by freak
Hello everybody,

The new beta version is now available for download on your personal user account.
Please test it a lot, as there have been quite a few compiler changes.
This is a bug-fix release only, so there is not much new stuff (only 2 commands),
but it fixes some important bugs.

There will be a bug-fix release for the Linux version soon as well.

Timo


Changes:
- Added: CalendarGadget() and DateGadget(), thanks to Fr34k !
- Added: Doubleclick on windows background now generate an event (Thanks to Rings)
- Added: LibraryID()
- Added: SaveSprite() now have an optional 'Flags' parameter and can now save 8 bits sprite/screen

- Optimized: ListCount() and ListIndex() are now very fast (it doesn't iterate each element of the list anymore).

- Changed: DeleteElement() now always goes back to the previous element (can be outside the list if
it was the first element), to be fully compatible with ForEach. An optional flag has been added to preserve previous behaviour.
- Changed: the application current directory isn't anymore touched by any PureBasic command to conform
to Windows rules.

- Fixed: IsSound() wasn't available in NT4 mode
- Fixed: AddDate() could fail depending of the computer time zone
- Fixed: Memory leak with linkedlists, arrays and local variables when using a structure which contained strings
- Fixed: SaveSprite() default value for JPEG saving is now '7'.
- Fixed: DisplayPalette() failed on XP systems (1st and last color remained unchanged)
- Fixed: ImageGadget() now supports ToolTips and bitmap/icon live switching
- Fixed: ImageButtonGadget() now supports skinning and bitmap/icon live switching
- Fixed: SetGadgetItemText() for ListViewGadget() destroyed the item user data
- Fixed: CopyImage() failed on WinNT4 under some conditions
- Fixed: A memory leak in SendNetworkFile(). Now, it returns 1 on success or 0 on failure.
- Fixed: StatusBarText() didn't refresh the statusbar with the 'Borderless' flag
- Fixed: CatchImage() with #PB_any
- Fixed: the PNG decoder nows handle corrupted PNG safely
- Fixed: the JPEG encoder with quality value inferior to 3 could lead to a crash
- Fixed: a little TreeGadget() bug when checkboxes were activated
- Fixed: several compiler bugs
Help for the 2 new commands:
CalendarGadget()

Syntax

CalendarGadget(#Gadget, x, y, Width, Height [, Date [, Flags]])
Description

Create a calendar gadget in the current GadgetList. This gadget displays a month calendar and lets the user select a date. The dates used by this gadget and the commands for it use the same date format as the PB date library. If #PB_Any is used as '#Gadget' parameter, the new gadget identifier will be returned as 'Result'. #Gadget will be the number returned by EventGadgetID() command. The Date parameter can optionally be used to select a certain date, if not specified, the current date is selected. You can specify #PB_Calendar_Borderless in the Flags parameter if you want the gadget to be created without a border.

The following commands can be used for this gadget:

- SetGadgetState(): Set the currently displayed date.
- GetGadgetState(): Get the currently displayed date.

Example:
If OpenWindow(0, 0, 0, 220, 200, #PB_Window_SystemMenu|#PB_Window_Screencentered,"CalendarGadget()")
If CreateGadgetList(WindowID())
CalendarGadget(0, 10, 10, 200, 180)
Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndIf
DateGadget()

Syntax

Result = DateGadget(#Gadget, x, y, Width, Height [, Mask$ [, Date [, Flags]]])
Description

Creates a String gadget in the current GadgetList, in which a date and/or time can be entered. This gadget uses the same date format for its functions as used by the Date library. So you can use for example FormatDate() to display the results you get from GetGadgetState() in a proper format. If #PB_Any is used as '#Gadget' parameter, the new gadget identifier will be returned as 'Result'. #Gadget will be the numeric identifier returned by the EventGadgetID() command.

With the optional Mask$ parameter you can specify the format in which the date can be entered. See FormatDate() for the format of this mask. Important note: The gadget does not support the display of seconds, so if you specify "%ss" in the Mask$ parameter, it will simply be ignored! If you don't specify the mask or specify an empty string, a default mask will be choosen. The mask can be modified with the SetGadgetText() command. With the optional Date parameter you can set the displayed date to any date of your choise. Not specifying it or specifying a 0 value will display the current date. By default, the gadget has a button to display a calendar in which the user can choose a date (see image below). You can change this by specifying #PB_Date_UpDown in the Flags parameter. This will make the gadget display an up/down button that lets the user change the current selected part of the gadget.

The following commands can be used for this gadget:

- SetGadgetState(): Set the currently displayed date.
- SetGadgetText(): Change the input mask of the gadget.
- SetGadgetAttribute(): Set a minimum/maximum date that the user can choose.
- GetGadgetState(): Get the currently displayed date.
- GetGadgetText(): Get the current displayed date as a string, as it is displayed in the gadget.
- GetGadgetAttribute(): Get the minimum/maximum date for the gadget.

Example:
If OpenWindow(0, 0, 0, 200, 250, #PB_Window_SystemMenu|#PB_Window_Screencentered,"DateGadget()")
If CreateGadgetList(WindowID())
DateGadget(0, 10, 10, 180, 25, "Date: %mm/%dd/%yyyy Time: %hh:%ii")
Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
EndIf

Posted: Mon Oct 11, 2004 4:02 am
by eddy
Date & Calendar

WOW ! That is exactly what i needed to code my todo-list window.

Great job :D

Posted: Mon Oct 11, 2004 5:33 am
by eddy
Listindex() is really different...

Code: Select all

NewList T()

For i=0 To 10
   AddElement(T())
   T()=i
Next 


ForEach T()   
   If ListIndex(T())=4
      DeleteElement(T())
      Debug "T4 deleted"
   Else       
      Debug ListIndex(T())
   EndIf
Next
Result for 3.92b
-----------------
0
1
2
3
T4 deleted
5
6
7
8
9
10

Result for 3.91
-----------------
0
1
2
3
T4 deleted
T4 deleted
T4 deleted
T4 deleted
T4 deleted
T4 deleted
T4 deleted

Posted: Mon Oct 11, 2004 6:32 am
by TheBeck
eddy wrote:Listindex() is really different...
fr34k wrote:- Changed: DeleteElement() now always goes back to the previous element (can be outside the list if
it was the first element), to be fully compatible with ForEach. An optional flag has been added to preserve previous behaviour.
The proper new way I guess would be DeleteElement(T(),#newflag) but I did not see what the new flag is. For now, try this...

Code: Select all

NewList T()

For i=0 To 10
   AddElement(T())
   T()=i
Next 


ForEach T()   
   If ListIndex(T())=4
      DeleteElement(T())
      NextElement(T()) 
      Debug "T4 deleted"
   Else       
      Debug ListIndex(T())
   EndIf
Next

Posted: Mon Oct 11, 2004 9:02 am
by Fred
This is a bug in DeleteElement(), the current index value isn't changed correctly. This is not a normal change, I will fix this tonight. Thank you for the good example :wink:

cross-platform ?

Posted: Mon Oct 11, 2004 7:07 pm
by USCode
:?: Are the new Calendar and Date gadgets cross-platform?

Posted: Mon Oct 11, 2004 9:36 pm
by localmotion34
this is awesome!!

one thing? if ive coded a program where ive used createwindowex_() to make a calendar, how would using the new command interact with the calendar from the API? do i have to go back and change the coge and make it into calendargadget()?

Posted: Mon Oct 11, 2004 10:06 pm
by freak
USCode:
Yes, the gadgets will be available on other platforms as well.

localmotion34:
Generally, there should be no problem with api created controls.

However, there will be a #PB_Event_Gadget event fired when the user
changes you API created Calendar. (because PB can't know the difference)
To prevent any trouble, you should make sure that in the "hMenu" parameter
of CreateWindowEx_() you don't specify a number that is also used for
any other gadget. (That's because this is used to store the gadget number
by PB, so if you have someting like '5' in there, each time your api calendar
is changed, you get a gadget event for gadget 5)

Since that parameter is generally not used for such control (as it only makes
sense if a window has a menu), you probably have a 0 (or #NULL) there.
So just make sure you don't have a gadget with ID 0. If you have all
the gadgets in an Enumeration, you can just do so simply by changing "Enumeration"
to "Enumeration 1"

That should be the only possible conflict though.

Timo

Posted: Tue Oct 12, 2004 6:32 am
by Lebostein

Code: Select all

OpenWindow(0, 0, 0, 400, 300, #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered, "Test")

CreateGadgetList(WindowID())
ImageGadget(0,50,50,100,100,CreateImage(0,100,100))

Repeat
event = WaitWindowEvent()
If event = #WM_LBUTTONDOWN: MessageRequester("Yeah!","Yeah!"): EndIf
Until event = #WM_CLOSE
#WM_LBUTTONDOWN on an image? So far no problem, in the beta 3.92 the event give back nothing. It's a bug?

Posted: Tue Oct 12, 2004 1:24 pm
by Fred
It now returns a gadget event, as other gadgets.

Code: Select all

openWindow(0, 0, 0, 400, 300, #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered, "Test")

CreateGadgetList(WindowID())
ImageGadget(0,50,50,100,100,CreateImage(0,100,100))

Repeat
event = WaitWindowEvent()
If event = #PB_Event_Gadget : MessageRequester("Yeah!","Yeah!"): EndIf
Until event = #PB_Event_CloseWindow
I've fixed the linkedlist library, so feel free to test it and see if all is ok now. The new lib is here: www.purebasic.com/beta/LinkedList

Posted: Tue Oct 12, 2004 3:13 pm
by Psychophanta
Nice!

...but another thing; when excuting code from editor, icon at upper left corner in windows is not got from the compilation-options menu.
In fact, it happens since 3.91.

Please update PBhelp.

Posted: Tue Oct 12, 2004 10:00 pm
by plouf
Nice update :wink:
have plyaingaround here a little bit :)

btw neither CalendarGadget() nor DateGadget() return events here

Posted: Wed Oct 13, 2004 12:11 am
by freak
> btw neither CalendarGadget() nor DateGadget() return events here

8O you are right!

Fred: are you sure you recompiled the Window lib with the latest cvs changes??

Extra flag request

Posted: Wed Oct 13, 2004 12:24 am
by Fangbeast
freak wrote:> DateGadget()
Hello freak, thanks for this new stuff. Could you please add an extra flag to DateGadget() for me? (#DTS_SHOWNONE) which allows me to add a checkbox field into the gadget ot activate/deactivate it by checking/uncheking the field? I desperately need this in my current projects and am hacking my windows in an ugly fashion:):)

These are the constants needed for/used by, that flag.

#DTM_FIRST = $1000
#GDT_NONE = $1
#DTS_SHOWNONE = $2
#DTM_SETSYSTEMTIME = #DTM_FIRST + 2
#DTM_GETSYSTEMTIME = #DTN_FIRST + 1

This is the message used to turn it on/off in code (instead of ticking checkbox)

SendMessage_(gadgethandle,#DTM_SETSYSTEMTIME,#GDT_NONE,0)

..

Posted: Wed Oct 13, 2004 1:41 am
by NoahPhense
Sweet, thanks Fred & Timo..

- np