{curl 5.0, 6.0, 7.0 applet}
{curl-file-attributes character-encoding = "shift-jis"}
{applet manifest = "manifest.mcurl"}

{import * from COM.CURL.INPUT-PRINT}
{import * from CURL.LANGUAGE.REFLECTION}

{api-version-switch
 case "6.0" do
    {import * from COM.CURL.GUI.STYLED-CONTROLS}
    {do {set-rendering-mode RenderingMode.high-quality}}
 case "7.0" do
    {install-standard-look-and-feel}
}

{let clr-back:String = "#FAEBD7"}
{let clr-line:String = "#FF4500"}
{let clr-content:String = "white"}

{include "left-frame.scurl"}
{include "left-content.scurl"}
{include "top-frame.scurl"}
{include "right-content.scurl"}
{include "right-frame.scurl"}



{define-class package final InnerFrame {inherits Frame}
  let package dc-key:#OptionKey
  field private fake-dc-option-item:OptionItem
  field private real-dc:#DisplayContext
  field private set?:bool = true

  {constructor package {default ...}
    {construct-super ...}

    {if InnerFrame.dc-key == null then
        set InnerFrame.dc-key =
            {self.name-to-option-key "display-context"}
    }

    set self.fake-dc-option-item =
        {self.new-option-item {non-null InnerFrame.dc-key}, null}
    
  }

  {method protected open {propagate-option-change
                             item:OptionItem,
                             removed?:bool
                         }:void
    {if item.key == InnerFrame.dc-key then
        let display-context:#DisplayContext = item.value asa #DisplayContext
        {if display-context != null then
            set self.real-dc = display-context
            set self.set? = true
         else
            set self.set? = false
        }

        let (new-option-binding-list:OptionItem,
             new-item:OptionItem,
             new?:bool) =
                 {self.fake-dc-option-item.add
                     {non-null InnerFrame.dc-key},
                     self.real-dc
                 }
        set self.fake-dc-option-item = new-item

        {super.propagate-option-change self.fake-dc-option-item, not self.set?}

     else

        {super.propagate-option-change item, removed?}
    }
  }

  {method public open {option-lookup key:#OptionKey, local?:bool}:#OptionItem
    {if not local? and key == InnerFrame.dc-key then
        {if not self.set? then
            {return null}
         else
            {return self.fake-dc-option-item}
        }
    }

    {return {super.option-lookup key asa OptionKey, local?}}
  }
}


{let sheet:AntialiasedFrame = 
    {AntialiasedFrame
    {InnerFrame 
        width = 730px, height = 470px, background = clr-back,
        {HBox 
            valign = "top",
            left-frame, 
            {VBox
                halign = "center",
                top-frame,
                {HBox
                    valign = "top" ,
                    left-content,
                    {Fill width = 4px},
                    right-content,
                    {Fill width = 3px},
                    right-frame,
                    {Fill}
                }
            },
            {Fill}
        }
    }
    }
}
{value sheet}

{value
    let constant cb:CommandButton =
        {CommandButton 
            label = "Print",
            {on Action do
                let pf:#PrintRootFrame
                set pf = {print-graphic sheet}
                {assert pf == null}
            }
        }
    {api-version-switch
     case "6.0" do
        {install-style-sheet-on-Graphic
            cb,
            {manifest-url "file", "DEFAULT-STYLE-SHEET"}
        }
     case "7.0" do
        {install-style-sheet-on-Graphic
            cb,
            {get-default-style-sheet}
        }
    }
    cb
}

