2012-02-09 2 views
0

나는 운영 체제에 따라 특정 윈도우 스킨을 가지고 있습니다.윈도우 스킨 OS에 따라

내 피부 아래를 참조하십시오.

<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:fb="http://ns.adobe.com/flashbuilder/2009" 
     xmlns:Layout="skin.Layout.*" 
     alpha.disabledGroup="0.5" 
     creationComplete="sparkskin1_creationCompleteHandler(event)"> 

<fx:Metadata> 
    [HostComponent("fr.inter.ui.windowSkin.wCustomWindow")] 
</fx:Metadata> 


<fx:Script> 
    <![CDATA[ 
     import mx.events.FlexEvent; 
     protected function btResize_mouseDownHandler(event:MouseEvent):void 
     { 
      btResize.addEventListener(MouseEvent.MOUSE_UP, btResize_mouseUpHandler); 
      stage.nativeWindow.startResize(); 
     } 

     protected function btResize_mouseOutHandler(event:MouseEvent):void 
     { 
      btResize.removeEventListener(MouseEvent.MOUSE_OUT, btResize_mouseOutHandler);    
     } 


     protected function btResize_mouseUpHandler(event:MouseEvent):void 
     { 
      btResize.removeEventListener(MouseEvent.MOUSE_UP, btResize_mouseUpHandler); 



     } 

     protected function sparkskin1_creationCompleteHandler(event:FlexEvent):void 
     { 

      if (NativeApplication.supportsDockIcon) 
      { 
       this.currentState = "supportsDockIcon";//mac 
      } 
      else 
      { 
       this.currentState = "supportsSystemTray"; 
      } 
     } 


    ]]> 
</fx:Script> 


<s:states> 
    <s:State name="disabledAndInactive" stateGroups="disabledGroup, inactiveGroup" /> 
    <s:State name="maximizedGroup"/> 
    <s:State name="normal" /> 
    <s:State name="disabled" stateGroups="disabledGroup" /> 
    <s:State name="normalAndInactive" stateGroups="inactiveGroup" /> 
    <s:State name="supportsDockIcon" /> 
    <s:State name="supportsSystemTray"/> 
</s:states> 

<s:Rect id="backgroundRect" 
     left="0" 
     right="0" 
     top="0" 
     bottom="0" 
     alpha="0" 
     > 
    <s:fill> 
     <s:SolidColor alpha="0"/> 
    </s:fill> 
</s:Rect> 

<s:Group bottom="0" left="0" right="0" 
     top="0" 
     > 
    <!--Fond de la fenetre--> 
    <s:Rect bottom="0" left="0" right="0" 
      top="0" 
      radiusX="8" radiusY="8" > 
     <s:fill> 
      <s:SolidColor color="#656565" alpha=".7" /> 
     </s:fill> 
     <s:stroke> 
      <s:SolidColorStroke color="#666666" /> 
     </s:stroke> 
    </s:Rect> 

    <s:Group height="38" id="moveArea" 
      left="0" right="0" > 

     <!--Barre bleu avec filet--> 
     <s:Rect height="25" left="10" right="10" top="10"> 
      <s:fill> 
       <s:SolidColor color="#055a90" /> 
      </s:fill> 
      <s:stroke> 
       <s:SolidColorStroke color="#666666" /> 
      </s:stroke> 
     </s:Rect> 


     <s:BitmapImage id="icon" 
         left.supportsSystemTray="5" right.supportsDockIcon="5" 
         verticalCenter="0" /> 

     <s:Label id="titleDisplay" 
       styleName="swindowTitle" 
       left.supportsSystemTray="60" left.supportsDockIcon="{this.width/2}" 
       top="18" verticalAlign="middle" horizontalCenter="0" 
       /> 

     <!--Zone de bouton--> 

     <s:HGroup right.supportsSystemTray="12" left.supportsDockIcon="12" verticalCenter="0"> 

      <s:Button id="btMinimize" buttonMode="true" 
         skinClass.supportsSystemTray="skin.components.MinimizeButtonSkin" 
         skinClass.supportsDockIcon="skin.components.MinimizeButtonSkinM" 
         verticalCenter="0"/> 

      <s:Button id="btMaximize" buttonMode="true" 
         skinClass.supportsSystemTray="skin.components.MaximizeButtonSkin" 
         skinClass.supportsDockIcon="skin.components.MaximizeButtonSkinM" 
         verticalCenter="0"/> 

      <s:Button id="closeButton" buttonMode="true" 
         skinClass.supportsSystemTray="skin.components.CloseButtonSkin" 
         skinClass.supportsDockIcon="skin.components.CloseButtonSkinM" 
         verticalCenter="0"/> 

     </s:HGroup> 

    </s:Group> 

    <!--Fond de la zone principale--> 

    <s:Rect id="background" left="10" top="35" right="10" bottom="10"> 
     <s:fill> 
      <s:LinearGradient rotation="-90"> 
       <s:GradientEntry color="#edf0f7"/> 
       <s:GradientEntry color="#fcfbfb" /> 
      </s:LinearGradient> 
     </s:fill> 
     <s:stroke> 
      <s:SolidColorStroke color="#666666" /> 
     </s:stroke> 
    </s:Rect> 

    <!--Zone dans laquelle les elements vont se positionner--> 


    <s:Group id="contentGroup" left="15" right="15" top="43" bottom="15" minWidth="0" 
      minHeight="0" width="100%" height="100%"> 

    </s:Group> 



</s:Group> 
<s:Button height="15" id="btResize" width="15" 
      bottom="0" right="0" 
      skinClass="spark.skins.spark.windowChrome.GripperSkin" 
      mouseDown="btResize_mouseDownHandler(event)" 
      buttonMode="true"/> 

창이 뜨면 버튼이 잘 나타납니다. 하지만 창이 비활성화되고 활성화 된 후에는 MacOs 및 Windows 버튼이 나타납니다.

어떻게 해결해야할지 모르겠다면 도와 주시겠습니까?

감사

답변

0

당신은 그 피부의 currentState 직접 피부 내에서 hostComponent 수행해야하기 때문에 치료를 설정 안하고 있습니다. 창을 비활성화하고 다시 활성화하면 hostComponent는 스킨 상태를 원래 상태 (예 : normal) 중 하나로 다시 설정하므로 두 개의 사용자 정의 상태가 무시됩니다.

특정 조건에 따라 스킨의 상태를 설정하려면 hostComponent의 getCurrentSkinState() 메서드를 재정의해야합니다. 그러나이 특별한 경우에 나는 그것이 너무 복잡 할 것이기 때문에 이것이 올바른 접근이라고 생각하지 않는다.

여기에서 가장 쉬운 해결책은 스킨의 updateDisplayList() 메서드를 재정 의하여 요소를 배치하는 것입니다. 이것은 스킨의 모든 요소를 ​​올바르게 표시하는 방법입니다.

<fx:Script> 
    <![CDATA[ 
     override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { 
      super.updateDisplayList(unscaledWidth, unscaledHeight); 

      if (NativeApplication.supportsDockIcon) { 
       titleDisplay.left = width/2; 
       //position other elements for mac 
      } 
      else { 
       titleDisplay.left = 60; 
       //position other elements for win 
      } 
     } 
    ]]> 
</fx:Script> 

또 다른 - 어쩌면 더 나은 - 방법은 두 개의 분리 된 피부의 (Mac 용 하나, Windows 용 하나)를 생성하여 윈도우에 올바른 스킨을 적용하는 것입니다. 이것은 우리에게 능력을 검사하는 if/else의 연속성을 제거 할 것입니다.

관련 문제