Revision 8959 trunk/libraries/libCorePlugin/src/com/iver/core/mdiManager/NewSkin.java

View differences:

NewSkin.java
41 41
package com.iver.core.mdiManager;
42 42

  
43 43
import java.awt.BorderLayout;
44
import java.awt.Color;
44 45
import java.awt.Component;
45 46
import java.awt.Container;
46 47
import java.awt.Cursor;
47 48
import java.awt.Dimension;
49
import java.awt.Graphics;
50
import java.awt.Image;
48 51
import java.awt.KeyEventDispatcher;
49 52
import java.awt.Point;
50 53
import java.awt.event.ActionEvent;
......
90 93
	private static final int DefaultYMargin = 20; // Added for the method 'centreJInternalFrame'
91 94
	private static final int MinimumXMargin = 130; // Added for the method 'centreJInternalFrame'
92 95
	private static final int MinimumYMargin = 60; // Added for the method 'centreJInternalFrame'
93
	
94
	
96

  
97

  
95 98
    /**
96 99
     * Variable privada <code>desktopManager</code> para usarlo cuando sale
97 100
     * una ventana que no queremos que nos restaure las que tenemos maximizadas.
......
103 106
    private static Logger logger = Logger.getLogger(NewSkin.class.getName());
104 107

  
105 108
    /** Panel de la MDIFrame */
106
    private JDesktopPane panel = new JDesktopPane();
109
    private MyDesktopPane panel = new MyDesktopPane();
107 110

  
108 111
    /** MDIFrame */
109 112
    private MDIFrame mainFrame;
......
113 116
    private DialogStackSupport dss;
114 117

  
115 118
    /**
116
     * Associates JInternalFrames with the IWindow they contain 
119
     * Associates JInternalFrames with the IWindow they contain
117 120
     */
118 121
    private FrameWindowSupport fws;
119 122

  
......
124 127
    private SingletonWindowSupport sws;
125 128

  
126 129
    private Cursor lastCursor = null;
130
	private Image image;
127 131

  
128 132
    /**
129 133
     * @see com.iver.andami.ui.mdiManager.MDIManager#init(com.iver.andami.ui.mdiFrame.MDIFrame)
......
240 244
            return p;
241 245
        }
242 246
    }
243
    
247

  
244 248
    /**
245 249
     * Similar method as 'addView' but in this case centres the new JInternalFrame of the View in the contentPane of the MainFrame
246
     * 
250
     *
247 251
     * @see com.iver.core.mdiManager.NewSkin#addWindow(com.iver.andami.ui.mdiManager.IWindow)
248
     * 
252
     *
249 253
     * @author Pablo Piqueras Bartolom?
250 254
     */
251 255
	public IWindow addCentredWindow(IWindow p) throws SingletonDialogAlreadyShownException {
......
270 274
                    .getWindowInfo(sv))) {
271 275
                singletonPreviouslyAdded = true;
272 276
            }
273
        }        
274
      
277
        }
278

  
275 279
        if (singletonPreviouslyAdded) {
276 280
            // Si la vista no est? actualmente abierta
277 281
            if (!sws.contains((SingletonWindow) p)) {
......
298 302
                return fws.getWindow((JInternalFrame) frame);
299 303
            }
300 304
        } else {
301
        	centreJInternalFrame(fws.getJInternalFrame(p)); // Centre this JInternalFrame 
305
        	centreJInternalFrame(fws.getJInternalFrame(p)); // Centre this JInternalFrame
302 306
            if (vi.isModal()) {
303 307
                addJDialog(p);
304 308
            } else {
......
307 311
                    public void actionPerformed(ActionEvent e) {
308 312
                        IWindow w = wis.getWindowById(Integer.parseInt(e
309 313
                                .getActionCommand()));
310
                        JInternalFrame f = fws.getJInternalFrame(w);                        
314
                        JInternalFrame f = fws.getJInternalFrame(w);
311 315
                        activateJInternalFrame(f);
312 316
                    }
313 317
                });
......
317 321
            return p;
318 322
        }
319 323
	}
320
	
324

  
321 325
	/**
322 326
	 * Centres the JInternalFrame in the center of the contentPane of the MainFrame
323 327
	 * If it can't be showed completely the JInternalFrame, tries that the top-left corner of the JInternalFrame would be showed
324
	 * 
328
	 *
325 329
	 * @author Pablo Piqueras Bartolom?
326
	 * 
330
	 *
327 331
	 * @param jInternalFrame A reference to the frame to centring
328 332
	 */
329 333
	private static synchronized void centreJInternalFrame(JInternalFrame jInternalFrame) {
330
		
334

  
331 335
		// The top-left square of frame reference
332 336
		Point newReferencePoint = new Point();
333
		
337

  
334 338
		// A reference to the panel where the JInternalFrame will be displayed
335 339
		Container contentPane = ((JFrame)PluginServices.getMainFrame()).getContentPane();
336
		
340

  
337 341
		// Get the NewStatusBar component
338 342
		NewStatusBar newStatusBar = ((NewStatusBar)contentPane.getComponent(1));
339 343
		JDesktopPane jDesktopPane = ((JDesktopPane)contentPane.getComponent(2));
340
		
344

  
341 345
		int visibleWidth = contentPane.getWidth() - contentPane.getX(); // The last substraction is for if there is any menu,... at left
342 346
		int visibleHeight = contentPane.getHeight() - newStatusBar.getHeight() - contentPane.getY() - Math.abs(jDesktopPane.getY() - contentPane.getY()); // The last substraction is for if there is any menu,... at top
343 347
		int freeWidth = visibleWidth - jInternalFrame.getWidth();
......
353 357
		}
354 358
		else
355 359
			newReferencePoint.x = freeWidth / 2;
356
			
360

  
357 361
		if (freeHeight < 0)
358 362
		{
359 363
			if (visibleHeight > MinimumYMargin)
......
367 371
		// Set the new location for this JInternalFrame
368 372
		jInternalFrame.setLocation(newReferencePoint);
369 373
	}
370
	
371
	
374

  
375

  
372 376
    /**
373 377
     * DOCUMENT ME!
374 378
     *
......
747 751
            wss.setActive(panel);
748 752

  
749 753
            JInternalFrame frame = fws.getJInternalFrame(panel);
750
            
754

  
751 755
            if (wi.isMaximizable()){
752 756
            	frame.setMaximizable(true);
753 757
            }
......
756 760
                    frame.setMaximum(false);
757 761
                } catch (PropertyVetoException e1) {
758 762
                }
759
            }            
763
            }
760 764
            mainFrame.enableControls();
761 765
            if (wi.getSelectedTool() != null)
762 766
                mainFrame.setSelectedTool(wi.getSelectedTool());
......
893 897
        }
894 898
        return (IWindow[]) windows.toArray(new IWindow[0]);
895 899
    }
896
    
900
     
897 901
    /**
898 902
     * @see com.iver.andami.ui.mdiManager.MDIManager#getOrderedWindows()
899 903
     */
......
923 927

  
924 928
        return (IWindow[]) winList.toArray(new IWindow[0]);
925 929
    }
926

  
927 930
    public void setMaximum(IWindow v, boolean bMaximum) throws PropertyVetoException
928 931
    {
929 932
        JInternalFrame f = fws.getJInternalFrame(v);
......
970 973
		activateJInternalFrame(f);
971 974
   }
972 975

  
976
	public void setBackgroundImage(Image image) {
977
		this.image=image;
978

  
979
	}
980
	  class MyDesktopPane extends JDesktopPane
981
	    {
982
	      public MyDesktopPane(){
983
	    	  //this.setBackground(new Color(0,0,0,200));
984
	      }
985
	      public void paintComponent(Graphics g){
986
	        super.paintComponent(g);
987
	        int w=(int)(getWidth()/1.5);
988
	        int h=(int)(getHeight()/1.5);
989
	        if(image != null) g.drawImage(image, w/4,h/4,w,h,this);
990
	      }
991
	    }
973 992
}

Also available in: Unified diff