public static void MBSetText(GuiMLTextCtrl text, GuiWindowCtrl frame, string msg) { // Get the extent of the text box. Point2I ext = text.getExtent(); // Set the text in the center of the text box. text.setText("<just:center>" + msg); // Force the textbox to resize itself vertically. text.forceReflow(); // Grab the new extent of the text box. Point2I newExtent = text.getExtent(); // Get the vertical change in extent. int deltaY = newExtent.y - ext.y; // Resize the window housing the text box. Point2I windowPos = frame.getPosition(); Point2I windowExt = frame.getExtent(); frame.resize(windowPos.x, (windowPos.y - (deltaY / 2)), windowExt.x, (windowExt.y + deltaY)); frame.canMove = false; frame.resizeWidth = false; frame.resizeHeight = false; frame.canMinimize = false; frame.canMaximize = false; //TODO //omni.Util._sfxPlayOnce("messageBoxBeep"); }
public static void MBOKCancelDetailsToggleInfoFrame() { GuiScrollCtrl MBOKCancelDetailsScroll = "MBOKCancelDetailsScroll"; if (!MBOKCancelDetailsScroll.isVisible()) { MBOKCancelDetailsScroll.setVisible(true); GuiMLTextCtrl MBOKCancelDetailsText = "MBOKCancelDetailsText"; Point2I textExtent = MBOKCancelDetailsText.getExtent(); int textExtentY = textExtent.y; Point2I textPos = MBOKCancelDetailsText.getPosition(); int textPosY = textPos.y; int verticalStretch = textExtentY; if (verticalStretch > 260 || verticalStretch < 0) { verticalStretch = 260; } Point2I extent = new Point2I(((GuiWindowCtrl)"MBOKCancelDetailsFrame")["defaultExtent"]); int height = extent.y; int posY = textPosY + textExtentY + 10; int posX = MBOKCancelDetailsScroll.getPosition().x; MBOKCancelDetailsScroll.setPosition(posX, posY); MBOKCancelDetailsScroll.setExtent(new Point2F(MBOKCancelDetailsScroll.extent.x, verticalStretch)); ((GuiWindowCtrl)"MBOKCancelDetailsFrame").setExtent(new Point2F(300, (height + verticalStretch + 10))); } else { Point2I extent = new Point2I(((GuiWindowCtrl)"MBOKCancelDetailsFrame")["defaultExtent"]); int width = extent.x; int height = extent.y; ((GuiWindowCtrl)"MBOKCancelDetailsFrame").setExtent(new Point2F(width, height)); MBOKCancelDetailsScroll.setVisible(false); } }