Flex DateChooser - font difference for days of the week / weekends

I would like to see different colors in my DateChooser / CalendarLayout for weekdays and weekends. I would also like to achieve this using a custom name-style (for example: "weekColor" and "weekendColor".

Any idea how this can be achieved?

Cheers, Rick

+3
source share
2 answers

It took me a couple of days, but I found it. So, for future reference: here is my solution:

I expanded DateChooser and added an override to the updateDisplayList (w: Number, h: Number) function (the SMTWTFS day names were set in this function).

updateDisplayList mx_internal:: dateGrid.dayBlockArrays [column] [row], CalendarLayout. / SMTWTFS. dayNumbers. , , , . :

override protected function updateDisplayList(w:Number, h:Number):void
    {
        super.updateDisplayList(w, h);



        // Now the dayBlocksArray has been filled. The Array looks as follows 
        // dayBlocksArray["rows"]["columns] .... therefor [i][0 (zero)] will always get the dayNames (SMTWTFS)
        // Compare the dayNames with the set this.dayNames (which always start with sunday) and find the weekend days
        var colIndex:uint = 0;
        var rowIndex:uint = 1; // The first row (SMTWTFS) is handled seperately
        var currentColumn:Array;
        var dayName:UITextField;
        var backgroundColor:uint = this.getStyle("dayNamesBackgroundColor");
        var isWeekendCol:Boolean = false;
        var currentTextFormat:TextFormat;

        // When the style is not found the default of white will be used.
        if (!backgroundColor)
        {
            backgroundColor = 0xFFFFFF;
        }

        for (colIndex; colIndex < 7; colIndex++)
        {
            // First determine if the first item in this row (SMTWTFS) is a week/weekend day
            currentColumn = mx_internal::dateGrid.dayBlocksArray[colIndex];
            dayName = currentColumn[0];

            // Determine if this is a weekend row
            // The dayNames array is fixed in the order of index 0 = sunday and index 6 = saturday. 
            // Therefor check of the text value of the current dayName is equal to either of 
            // those two. If it is we are dealing with a weekend column
            isWeekendCol = dayName.text == this.dayNames[0] || dayName.text == this.dayNames[6];

            if (isWeekendCol)
            {
                // Set the color
                currentTextFormat = dayName.getTextFormat();
                currentTextFormat.color = getStyle("weekendHeaderColor");
                dayName.setTextFormat(currentTextFormat);

                // Set the background color
                dayName.background = true;
                dayName.backgroundColor = backgroundColor;
            }
            else
            {
                currentTextFormat = dayName.getTextFormat();
                currentTextFormat.color = getStyle("weekHeaderColor");
                dayName.setTextFormat(currentTextFormat);

                // Set the background color
                dayName.background = true;
                dayName.backgroundColor = backgroundColor;
            }

            // Reset the rowIndex
            rowIndex = 1;

            // Now go through all the other rows of this column
            for (rowIndex; rowIndex < currentColumn.length; rowIndex++)
            {
                dayName = currentColumn[rowIndex];

                if (isWeekendCol)
                {
                    dayName.setColor(getStyle("weekendColor"));
                }
                else
                {
                    dayName.setColor(getStyle("weekColor"));
                }
            }
        } 
}

CSS :

DateChooser {

cornerRadius: 0;  headerColors: #FFFFFF, #FFFFFF;  todayColor: # 00448c;   : ;  dropShadowEnabled: false;  fontFamily: myGeorgia;  dayNamesBackgroundColor: #ECECEC;  weekHeaderColor: # 444444;  weekendHeaderColor: #DDDDDD;  weekColor: # 00317F;  weekendColor: #DDDDDD;  headerStyleName: "dateChooserHeaderStyle";
 comboBoxStyleName: "comboBoxStyleName"; }

"dayNamesBackgroundColor" ( , SMTWTFS) "weekendHeaderColor", "weekHeaderColor", "weekColor", "weekendColor"

, /, SMTWTFS ,

, . , :)

+3

- . , CalendarLayout, . DateChooser, CalendarLayout.

; , , ; .

+2

All Articles