Home » U++ Library support » CalendarCtrl » Little improvement of Caledar & DropDate controls
Re: Little improvement of Caledar & DropDate controls [message #40539 is a reply to message #40109] |
Sun, 11 August 2013 03:21   |
 |
bushman
Messages: 134 Registered: February 2009
|
Experienced Member |
|
|
Actually, after peering further into your code, I observed a few aspects I'd like to submit to your review, for I guess they might be relevant to other Upp users too:
1. Class member , defined in DateTimeCtrl.h around line #170 gets initialized in DateTimeCtrl.cpp like curdate = Format("%s %d", MonthName(view.month - 1), view.year); , around line #462, but is never used; I just commented both lines out and it didn't make any difference whatsoever. So what role does this member play?
2. When assingning the following style to Calendar Calendar::Style& st = cal.StyleDefault().Write();
st.font = Arial(8);
st.bgmain = Color(33, 33, 33);
st.bgselect = Color(190, 150, 80);
st.bgtoday = Color(66, 66, 66);
st.fgmain = Color(198, 198, 198);
st.dayname = Color(190, 150, 80);
st.fgselect = Color(198, 198, 198);
st.selectday = Color(198, 198, 198);
st.selecttoday = Color(190, 150, 80);
st.today = Color(198, 198, 198);
st.curdate = Color(198, 198, 198);
st.cursorday = Color(255, 255, 192);
st.fgtoday = Color(198, 198, 198);
st.week = Color(127, 127, 127);
st.header = Color(255, 127, 0);
cal.SetStyle(Calendar::StyleDefault());
cal.OneButton();
, that's the graphic result I got:
(they say an image is worth a thousand words)
Please, observe that the year + month header is not initialized centered between the left and right buttons when using a smaller font size (Arial(8 )). I assume Calendar does not initialize its FlatSpin members with the assigned calendar font promptly right after the call to SetStyle, so I propose this modification Calendar& Calendar::SetStyle(const Style& s)
{
style = &s;
nbg = Colorize(CtrlImg::Bg(), s.header, 150);
spin_month.SetFont(s.font); // inserted line
spin_year.SetFont(s.font); // inserted line
spin_all.SetFont(s.font); // inserted line
UpdateFields(); // inserted line
Refresh();
return *this;
}
, which corrects all misalignments, with or without SwapMonthYear(), OneButton() or the combination of both.
3. Yet insisting on my last posting before this one, the week days and weekend day numbers would be hardly visible without the following modifications, which then again I'd like to submit to your appreciation:
// Add new member Color weekend to Calendar Style definition:
class Calendar : public PopUpCtrl
{
public:
struct Style : ChStyle<Style> {
Color header;
Color bgmain;
Color bgtoday;
Color bgselect;
Color fgmain;
Color fgtoday;
Color fgselect;
Color outofmonth;
Color curdate;
Color today;
Color selecttoday;
Color cursorday;
Color selectday;
Color line;
Color dayname;
Color week;
Color weekend; // <== Inserted line
Font font;
Image spinleftimg;
Image spinrightimg;
bool spinhighlight;
};
...
, together with
...
if(m == view.month)
{
Day(j, i) = d;
fg = st.fgmain; // fg = Black; // <== Modified line
if(j == 6)
{
fg = st.weekend; // fg = Red; // <== Modified line
}
...
, in Calendars Paint function, fixes this issue.
Sorry for the very long post.
Thank you.
-
Attachment: Calendar.png
(Size: 5.06KB, Downloaded 975 times)
[Updated on: Sun, 11 August 2013 03:38] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Jul 18 03:15:30 CEST 2025
Total time taken to generate the page: 0.03970 seconds
|