Recent

Author Topic: TDatePicker control  (Read 50837 times)

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
TDatePicker control
« on: January 31, 2010, 09:55:16 pm »
Delphi's VCL has a control TDateTimePicker.
For editing dates LCL has TDateEdit instead. It does not have TDateTimePicker, because it uses native Windows control which does not exist on other platforms.

I prefer VCL's TDateTimePicker, so I created new TDatePicker control.

I tried to create a control which would resemble TDateTimePicker as much as possible. It behaves very much like VCL's control, but derives from TCustomControl and does not use native win control.

I created it on Windows XP with win widget set, but did some test on Ubuntu 9.10 with gtk2 also.

The package DateControls which contains TDatePicker and TDBDatePicker (a data-aware version of the control) can be downloaded here: http://datepicker.000space.com

EDIT: There is now new TZVDateTimePicker control, which completely covers the behavior of TDatePicker. The main advangate is time editing, so you should use it instead. See: http://www.lazarus.freepascal.org/index.php/topic,8754.0.html
« Last Edit: February 27, 2010, 12:32:15 pm by Zoran »

Silvio Clécio

  • Guest
Re: TDatePicker control
« Reply #1 on: January 31, 2010, 10:23:58 pm »
It worked perfectly in Linux (Ubuntu 9.10/GTK2).

Thank you very much!  :D

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: TDatePicker control
« Reply #2 on: January 31, 2010, 10:51:47 pm »
Does not compile under Windows Vista because of these lines:

  Canvas.TextStyle.Layout := tlCenter;
  Canvas.TextStyle.Wordbreak := False;
  Canvas.TextStyle.Opaque := False;

The compiler gives the following error message

C:\Lazarus\components_extra\DateControls\datepicker.pas(1239,19) Error: Argument can't be assigned to

What can I do to correct this error?
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

wOvAN

  • New Member
  • *
  • Posts: 47
    • wxSoft.Ru
Re: TDatePicker control
« Reply #3 on: February 01, 2010, 08:19:07 am »
Confirm assigning Canvas.TextStyle gives an error, I use the latest laz snapshot. fpc 2.4.1

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: TDatePicker control
« Reply #4 on: February 01, 2010, 09:02:04 am »
On Widows XP it works perfectly. It sounds very strange to me that such a problem appears in Vista. I'm at work now and very busy, I'll look into code to try to change that part of code to something else this evening (central european time).

And yes, I use Lazarus 0.9.28.2, fpc 2.2.4 (the current stable version of Lazarus). Could problem be related to some recent changes in Lazarus/FPC, not to OS? I guess, I'll have to install new snapshot this evening.
« Last Edit: February 01, 2010, 09:07:15 am by Zoran »

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: TDatePicker control
« Reply #5 on: February 01, 2010, 09:34:47 am »
I tried to install the component on Windows XP this morning & I got the same error message on the same lines related to

Canvas.TextStyle

I use Lazarus 0.9.29 fpc 2.3.1 of 01/01/2010.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: TDatePicker control
« Reply #6 on: February 01, 2010, 09:46:16 am »
I tried to install the component on Windows XP this morning & I got the same error message on the same lines related to

Canvas.TextStyle

I use Lazarus 0.9.29 fpc 2.3.1 of 01/01/2010.

So, the problem is probably related to some changes in Lazarus or FPC, not OS. I'll install new snapshot and see.

davesimplewear

  • Sr. Member
  • ****
  • Posts: 319
    • Davids Freeware
Re: TDatePicker control
« Reply #7 on: February 01, 2010, 09:59:15 am »
Quote
I tried to install the component on Linux Mint this morning & I got the same error message on the same lines related to

Canvas.TextStyle

Lazarus 0.9.29 FPC 2.5.1 Code Typhon Version
All things considered insanity seems the best option

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: TDatePicker control
« Reply #8 on: February 01, 2010, 10:27:12 am »

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: TDatePicker control
« Reply #9 on: February 01, 2010, 11:11:02 am »
So, the problem is probably related to some changes in Lazarus or FPC

http://wiki.freepascal.org/User_Changes_2.4.0#Treating_direct-mapped_properties_as_regular_fields

Thank you, Theo!

The solution was quite simple, I introduced a variable of TTextStyle type, then all assignments go to it, instead of Canvas.TextStyle. Then changed simple version of TextRect to longer, with TextStyle. That was all. I updated the link, please download it again, it should work now.
« Last Edit: February 01, 2010, 12:55:24 pm by Zoran »

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: TDatePicker control
« Reply #10 on: February 01, 2010, 12:41:24 pm »
I can confirm that it now works. Thanks.
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: TDatePicker control
« Reply #11 on: February 01, 2010, 07:53:22 pm »
@Zoran It would be nice to extend this component to WS part, so why not call it TDateTimePicker, and allow date, time or date & time editing.
For basic functionality it can edit dates only (like you made it - and it doesn't have to be implemented in ws which does not support it), but win32 or qt ws on mac,linux & win have such funcionality and can be fully useable (don't know for carbon or gtk2 but think that there must be such ctrls).

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: TDatePicker control
« Reply #12 on: February 02, 2010, 10:19:20 am »
@Zoran It would be nice to extend this component to WS part, so why not call it TDateTimePicker, and allow date, time or date & time editing.
For basic functionality it can edit dates only (like you made it - and it doesn't have to be implemented in ws which does not support it), but win32 or qt ws on mac,linux & win have such funcionality and can be fully useable (don't know for carbon or gtk2 but think that there must be such ctrls).

Unlike most standard controls (like edit boxes, check boxes or buttons), the native date editing control either does not exist or look and interact with user quite differently on different widget sets. On gtk2, as far as I know, there is no similar control. I don't know anything about other widget sets.

I beleived that many Lazarus users have Delphi background and would like to have the control which looks and feels like VCL's TDateTimePicker, but which would be cross-platform.

Having these things in mind, my intention was therefore to create a Delphi's TDateTimePicker cross-platform clone.
I thought that the best aproach would be to provide a control which would not rely on any native control. I wanted a control which would appear same and interact with a user same on all platforms.

Yes, my control lacks time editing feature. I beleived that the date editing is more needed, so I saw providing this functionality as my first priority. I achieved to have the control act on user interaction same as VCL's control when used for dates, which was my primary aim. The user just cannot input invalid dates.
Furthermore, I extended the functionality to null date value (esspecialy useful when dealing with databases). I think that I acheived the functionality that is most needed. I admit that I would like to see time editing possible.

To summarise -- the purpose of this control is to have one control, totally cross-platform, with same appearance and same functionality on any platform.
So, as the next step I would rather see extending functionality to time editing, but without using native widgets, I don't think that, for this control, going into ws parts would be a good idea.
« Last Edit: February 02, 2010, 10:48:48 am by Zoran »

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: TDatePicker control
« Reply #13 on: February 02, 2010, 04:30:25 pm »
@Zoran, your ctl is very nice and I don't wanna say that something is wrong with it - good start and also I would like to see it in lazarus components ASAP + of course ability to edit time also :)
My idea wasn't to go in the ws direction just because of ws, but because of users which expect same behaviour on OS they use.If you can reach same behaviour as native one than fine :) gtk2 maybe doesn't have such control, but win32, qt (on all supported platforms) and carbon (think so) have such control.

zeljko

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: TDatePicker control
« Reply #14 on: February 02, 2010, 11:19:20 pm »
@Zoran, your ctl is very nice and I don't wanna say that something is wrong with it - good start and also I would like to see it in lazarus components ASAP + of course ability to edit time also :)
My idea wasn't to go in the ws direction just because of ws, but because of users which expect same behaviour on OS they use.If you can reach same behaviour as native one than fine :) gtk2 maybe doesn't have such control, but win32, qt (on all supported platforms) and carbon (think so) have such control.

zeljko

That is exactly how I understood what you meant in the first place. :)

Sorry, I missed to say that I agree with you that extending the control the way you suggested is a nice thing to do, for people who would preffer the control which acts natively on different platforms, it would be nice to provide such behaviour.

I just wanted to point out that same appearance and behavior on different platforms can be prefered and seen as an advantage.

That's what I had in mind when designed this control. I just wanted it to act and appear as much same as Delphi's control as possible on all platforms. I'm still sure that many people want to be able to use old Delphi's control in their programs, and want their application to look as much same as possible when compiled on Linux or Windows.
I would prefer it so.

So... we need two controls. :)
With time editing functionality, of course. ;)
« Last Edit: February 02, 2010, 11:25:06 pm by Zoran »

 

TinyPortal © 2005-2018