Mailinglist Archive: libyui-devel (8 mails)

< Previous Next >
Re: [libyui-devel] YDateField and YTimeField issues
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Il 17/02/2014 22:31, Angelo Naselli ha scritto:
Hi I understand that they are "optional", but i think they are
important.

So to summarize i found: 1) ncurses does not implement them at all
:(
Added both, the behaviour is the same as YGTimeField and YGDateField,
non check on value insertion atm

Pull requested.

2) gtk YTimeField does not manage seconds
Fixed.
Added to the current pull request

3) gtk YTimeField allows 99:99 (and sets value accordingly) 4) gtk
YDateField allows 9999-99-99 (and sets value accordingly)
Untouched

5) QT YDateField does not send any events on date change 6) QT
YTimeField does not send any events on time change
I'm currently start working on these 2

Attached a c++ example to test.

Regards,
Angelo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlMFEJIACgkQqEs9DA4DquDH6gCeIemC4QNdq2A1LJjXrj4SSUU7
lCEAoJXM5HqXnxDPbaaHMS3ua8Rc9wBA
=0n1S
-----END PGP SIGNATURE-----
/*
Copyright (c) 2014 Angelo Naselli <anaselli@xxxxxxxx>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


// YDateField and YTimeField libyui example.
//
// Compile with:
//
// g++ -I/usr/include/yui -lyui DateTime.cc -o DateTime

#include <yui/YUI.h>
#include <yui/YApplication.h>
#include <yui/YWidgetFactory.h>
#include <yui/YOptionalWidgetFactory.h>
#include <yui/YDialog.h>
#include <yui/YLayoutBox.h>
#include <yui/YEvent.h>
#include <yui/YPushButton.h>
#include <yui/YDateField.h>
#include <yui/YTimeField.h>
#include <time.h>

int main( int argc, char **argv )
{

YDialog * dialog = YUI::widgetFactory()->createPopupDialog();
YLayoutBox * vbox = YUI::widgetFactory()->createVBox( dialog );
YUI::widgetFactory()->createLabel ( vbox, "Date and time" );
YOptionalWidgetFactory * pOpt = YUI::optionalWidgetFactory();
YDateField *pDate = NULL;
time_t rawtime;
struct tm * timeinfo;
char buffer [20];

if (pOpt->hasDateField()) {
pDate = pOpt->createDateField(vbox, "DateField");
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer, 20, "%F", timeinfo);
pDate->setValue(buffer);
}
YTimeField *pTime = NULL;
if (pOpt->hasTimeField()) {
pTime = pOpt->createTimeField(vbox, "TimeField");
strftime (buffer, 20, "%H:%M:%S", timeinfo);
pTime->setValue(buffer);
}
YPushButton* quitButton = YUI::widgetFactory()->createPushButton( vbox,
"&Quit" );

while (1)
{
YEvent* pEvent = dialog->waitForEvent(1000);

if (pEvent->eventType() == YEvent::CancelEvent) {
break;
}
else if (pEvent->eventType() == YEvent::TimeoutEvent) {
if (pOpt->hasTimeField()) {
std::string val = pTime->value();
strptime(val.c_str(), "%H:%M:%S", timeinfo);
rawtime = mktime(timeinfo) +1;
timeinfo = localtime (&rawtime);
strftime (buffer, 20, "%H:%M:%S", timeinfo);
pTime->setValue(buffer);
}
}
else if ( pEvent->widget() == quitButton )
break;
}

dialog->destroy();
}
< Previous Next >
References