/* Copyright 2010 Aaron J. Radke Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package cc.drx class DrxFrame(val frame:java.awt.Frame) extends AnyVal{ import java.awt.Frame.MAXIMIZED_BOTH private def gc = frame.getGraphicsConfiguration //def setSize(size:Vec):Unit = frame.setSize(size.x.toInt, size.y.toInt) def size = Vec(frame.getSize.width, frame.getSize.height) def size_=(size:Vec) = frame.setSize(size.x.toInt, size.y.toInt) //def setLocation(loc:Vec):Unit = def loc = Vec(frame.getLocation.x, frame.getLocation.y) def loc_=(loc:Vec) = frame.setLocation(loc.x.toInt, loc.y.toInt) /* def isMax:Boolean = { val d = Display.insets(frame) d.size == frame.size && d.loc == frame.loc } */ def maximizeTo(display:Display):Unit = { frame.size_=(display.size) frame.loc = display.loc } def maximize:Unit = maximizeTo(Display.insets(gc)) def fullScreen:Unit = maximizeTo(Display.fullScreen(gc)) def allScreens:Unit = maximizeTo(Display.allScreens) def center(size:Vec):Unit = { val d = Display.insets(gc) frame.size_=(size) frame.loc = d.loc + (d.size - size)/2 } }