2011-05-05 1 views
3

평일과 주말 동안 내 DateChooser/CalendarLayout에서 다른 색상을보고 싶습니다. 나는이 (예를 들어 사용자 정의는, styleName을 사용하여 달성하기 위해 싶습니다.? "weekColor"와 "weekendColor"Flex DateChooser - 주/주말의 글꼴 색상의 차이

어떤 생각을이 달성 할 수있는 방법을

응원, 릭

답변

2

내가 뭔가를했다 접근 방식은 CalendarLayout 클래스를 확장하여 해당 스타일을 수락하고 해당 날짜에 스타일을 수정 한 다음 DateChooser를 확장하여 동일한 스타일을 적용하고 새 CalendarLayout 클래스에 전달합니다.

It 's 지루한, 당신은 가장 가능성이 개인 변수로 실행됩니다 내가 말하다. 그러나 그것은 가능합니다.

+0

어쨌든 지루하다. 어도비가 CalendarLayout을 만지는 것을 원하지 않는 것처럼 보인다. 거의 모든 것이 그 클래스에서 사적이다. 적어도 나는 바른 길에 있다는 것을 듣게되어 기쁩니다. –

3

며칠이 걸렸지 만 발견했습니다. 그래서 나중에 참조 할 수 있습니다 : 여기 내 해결책은 다음과 같습니다.

이 함수에서는 updateDisplayList (w : Number, h : Number) 함수에 대해 DateChooser를 확장하고 재정의를 추가했습니다 (이 함수에서는 SMTWTFS 요일 이름이 설정되었습니다).

updateDisplayList에서 CalendarLayout에 대한 모든 값을 포함하는 mx_internal :: dateGrid.dayBlockArrays [column] [row]를 가져올 수 있습니다. 해당 배열/배열에서 각 열의 첫 번째 행은 SMTWTFS 일 중 하나입니다. 다른 행은 dayNumber입니다. 일단 내가 알게되면 주말의 날을 결정하고 이에 따라 색상을 조정해야합니다. 나는 아래 표와 같이

DateChooser { 

CornerRadius를 : CSS 파일에서

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")); 
       } 
      } 
     } 
} 

나는 다음과 같은 스타일 추가 0; headerColors : #FFFFFF, #FFFFFF; todayColor : # 00448c; border-style : none; dropShadowEnabled : false; fontFamily : myGeorgia; dayNamesBackgroundColor : #ECECEC; weekHeaderColor : # 444444; weekendHeaderColor : #DDDDDD; weekColor : # 00317F; weekendColor : #DDDDDD; headerStyleName : "dateChooserHeaderStyle";
comboBoxStyleName : "comboBoxStyleName"; 여기 }

가장 흥미로운 스타일은 사용자 정의 스타일합니다 (SMTWTFS 세트에 배경 색상을 제공하는 데 사용됩니다) "dayNamesBackgroundColor"및 사용자 정의 스타일 "weekendHeaderColor", "weekHeaderColor", "weekColor", "weekendColor 있습니다 "

은 내가 SMTWTFS 설정이 미래에 다른 사람을 도움이 될 것 일 수

희망과 다른 색상을 얻을 수있는 곳 주/주말 색상의 차이에 대한 모든 권한을 얻을 수 위의 방법에서 이러한 색상을 읽어 . 나에게 많은 시간을 할애 해 주었다.