-
Notifications
You must be signed in to change notification settings - Fork 3
/
BPaintDevice.js
executable file
·137 lines (113 loc) · 3.39 KB
/
BPaintDevice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
Copyright (C) 2007 Laszlo Papp (Bonanza Team)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
include('BWindow.js');
include('BDesktop.js');
include('BElement.js');
var MainLabel = 'Desktop';
var Dock = 'Dock';
var BPaintDevice = Base.extend(
{
constructor: function()
{
// It must be singleton, but the language doesn't support it
// I'm thinking of the problem...
BPaintDevice._device= (BPaintDevice._device == undefined) ? this : BPaintDevice._device;
return BPaintDevice._device;
},
setCaption: function( widget, name )
{
if( widget.getParent() != null ) return false;
var win = BWindow.findWindowByWidget(widget);
return win.setCaption(name);
},
caption: function( widget )
{
if( widget.getParent() == null ) return null;
return BWindow.findWindowByWidget(widget).caption(name);
},
setWidth: function(widget, size)
{
widget.getDomElement().setStyle('width', size + 'px');
if( widget.getParent() != null )
{
return size;
}
BWindow.findWindowByWidget(widget).setWidth( size );
},
draw: function( widget )
{
var parent = widget.getParent();
var element;
if( widget instanceof BDock )
{
element = BDesktop.getActiveDesktop().getDockNode();
}
else if( parent == null )
{
var win = new BWindow;
element = win.getDomElement();
BDesktop.getActiveDesktop().getDesktopNode().appendChild( win.getWindowNode() );
win.setChildWidget(widget);
}
else
{
element = parent.getDomElement();
}
element.appendChild( widget.getDomElement() );
},
hide: function( widget )
{
if( widget.getParent() != null )
{
widget.getDomElement().hide();
return true;
}
return BWindow.findWindowByWidget(widget).hide();
},
show: function( widget )
{
if( widget._painted != true )
{
widget.rePaint();
}
if( widget.getParent() != null )
{
widget.getDomElement().show();
return true;
}
if( widget instanceof BDock )
{
widget.getDomElement().show();
return true;
}
return BWindow.findWindowByWidget(widget).show();
},
destroy: function( widget )
{
// Drop Element from the document
}
},
{
_device: undefined,
_window: window,
getDevice: function()
{
if( BPaintDevice._device == undefined )
{
BPaintDevice._device = new BPaintDevice;
}
return BPaintDevice._device;
}
});