KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > renderer > BrowserFrameUIControl


1 package org.lobobrowser.html.renderer;
2
3 import java.awt.Color JavaDoc;
4 import java.awt.Component JavaDoc;
5 import java.awt.Dimension JavaDoc;
6 import java.awt.Graphics JavaDoc;
7 import org.lobobrowser.html.*;
8 import org.lobobrowser.html.style.HtmlValues;
9 import org.w3c.dom.html2.*;
10
11 class BrowserFrameUIControl implements UIControl {
12     //private final BrowserFrame browserFrame;
13
private final Component JavaDoc component;
14     private final HTMLElement element;
15     
16     public BrowserFrameUIControl(HTMLElement element, BrowserFrame browserFrame) {
17         this.component = browserFrame.getComponent();
18         this.element = element;
19     }
20     
21     public int getVAlign() {
22         return RElement.VALIGN_BASELINE;
23     }
24     
25     public float getAlignmentY() {
26         return 0;
27     }
28
29     public Color JavaDoc getBackgroundColor() {
30         return this.component.getBackground();
31     }
32
33     public Component JavaDoc getComponent() {
34         return this.component;
35     }
36
37     private int availWidth;
38     private int availHeight;
39     
40     public void reset(int availWidth, int availHeight) {
41         this.availWidth = availWidth;
42         this.availHeight = availHeight;
43     }
44     
45     public Dimension JavaDoc getPreferredSize() {
46         int width = HtmlValues.getOldSyntaxPixelSize(element.getAttribute("width"), this.availWidth, 100);
47         int height = HtmlValues.getOldSyntaxPixelSize(element.getAttribute("height"), this.availHeight, 100);
48         return new Dimension JavaDoc(width, height);
49     }
50
51     public void invalidate() {
52         this.component.invalidate();
53     }
54
55     public void paint(Graphics JavaDoc g) {
56         // We actually have to paint it.
57
this.component.paint(g);
58     }
59
60     public boolean paintSelection(Graphics JavaDoc g, boolean inSelection,
61             RenderableSpot startPoint, RenderableSpot endPoint) {
62         // Selection does not cross in here?
63
return false;
64     }
65
66     public void setBounds(int x, int y, int width, int height) {
67         this.component.setBounds(x, y, width, height);
68     }
69
70     public void setRUIControl(RUIControl ruicontrol) {
71         //this.ruiControl = ruicontrol;
72
}
73 }
74
Popular Tags