//======================================================================= // Author: Jamie Cansdale // Email: jamie@obsolete.com // Date: 19/03/97 // Comments: // // Is is important that you initialize StretchyLayout *after* you've // sized and added your components. This allows it to work with the // Visual Cafe compiler. It doesn't matter if Visual Cafe sets // the Layout to null before StretchyLayout has been initialized. // // StretchyLayout should be set with the following command... // // setLayout(new StretchyLayout(this)); // // If you're using it with a Visual Cafe 'null' layout, this line should // be after {{INIT_CONTROLS ... }} in your classes initializor. // // Feel free to mail me with comments or suggstions... // //======================================================================= // Update: Kent L. Smotherman // Email: kents@tconl.com // Date: September 30, 1997 // Comments: // // Fixed StretchyComponent to handle insets properly. //======================================================================= // Update: Kent L. Smotherman // Email: kents@tconl.com // Date: Octoboer 8, 1997 // Comments: // // Updated StretchyComponent to provide automatic font scaling. // Updated StretchyLayout with API to query the current X/Y scaling // relative to the initial design sizes. //======================================================================= import java.awt.*; import java.util.*; //================================================================= public class StretchyLayout implements LayoutManager { //The scales represent the scale percentage*10 to avoid using float //but retain .1% accuracy int scaleX=1000, scaleY=1000; Rectangle oldBounds; public int getScaleX() { return scaleX; } public int getScaleY() { return scaleY; } //----------------------------------------------------------------- public StretchyLayout(Container cont) { Component[] components = cont.getComponents(); oldBounds = cont.getBounds(); for(int count=0;count= 5) fontsize++; hash = f.getName()+fontsize+f.getStyle(); if (!fonts.containsKey(hash)) { f = new Font(f.getName(),f.getStyle(),fontsize); fonts.put(hash,f); } else f = (Font)fonts.get(hash); thisComp.setFont(f); } //----------------------------------------------------------------- } //=================================================================