~cdparra/gelee/trunk

« back to all changes in this revision

Viewing changes to webui/lime/draw2d/Dialog.js

  • Committer: parra
  • Date: 2010-03-15 15:56:56 UTC
  • Revision ID: svn-v4:ac5bba68-f036-4e09-846e-8f32731cc928:trunk/gelee:1448
merged gelee at svn

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This notice must be untouched at all times.
 
2
 
 
3
Open-jACOB Draw2D
 
4
The latest version is available at
 
5
http://www.openjacob.org
 
6
 
 
7
Copyright (c) 2006 Andreas Herz. All rights reserved.
 
8
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )
 
9
 
 
10
LICENSE: LGPL
 
11
 
 
12
This library is free software; you can redistribute it and/or
 
13
modify it under the terms of the GNU Lesser General Public
 
14
License (LGPL) as published by the Free Software Foundation; either
 
15
version 2.1 of the License, or (at your option) any later version.
 
16
 
 
17
This library is distributed in the hope that it will be useful,
 
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
20
Lesser General Public License for more details.
 
21
 
 
22
You should have received a copy of the GNU Lesser General Public
 
23
License along with this library; if not, write to the Free Software
 
24
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,
 
25
or see http://www.gnu.org/copyleft/lesser.html
 
26
*/
 
27
 
 
28
/**
 
29
 * 
 
30
 * @version 0.9.14
 
31
 * @author Andreas Herz
 
32
 * @param {String} title The title of the window.
 
33
 * @constructor
 
34
 */
 
35
draw2d.Dialog=function( /*:String*/ title)
 
36
{
 
37
  /** @private **/
 
38
  this.buttonbar = null;
 
39
  if(title)
 
40
    draw2d.Window.call(this,title);
 
41
  else
 
42
    draw2d.Window.call(this,"Dialog");
 
43
  this.setDimension(400,300);
 
44
}
 
45
 
 
46
draw2d.Dialog.prototype = new draw2d.Window;
 
47
/** @private **/
 
48
draw2d.Dialog.prototype.type="Dialog";
 
49
 
 
50
/**
 
51
 * @private
 
52
 **/
 
53
draw2d.Dialog.prototype.createHTMLElement=function()
 
54
{
 
55
  var item = draw2d.Window.prototype.createHTMLElement.call(this);
 
56
 
 
57
  var oThis = this;
 
58
 
 
59
  this.buttonbar = document.createElement("div");
 
60
  this.buttonbar.style.position="absolute";
 
61
  this.buttonbar.style.left   = "0px";
 
62
  this.buttonbar.style.bottom = "0px";
 
63
  this.buttonbar.style.width  = this.getWidth()+"px";
 
64
  this.buttonbar.style.height = "30px";
 
65
  this.buttonbar.style.margin = "0px";
 
66
  this.buttonbar.style.padding= "0px";
 
67
  this.buttonbar.style.font="normal 10px verdana";
 
68
  this.buttonbar.style.backgroundColor="#c0c0c0";
 
69
  this.buttonbar.style.borderBottom="2px solid gray";
 
70
  this.buttonbar.style.whiteSpace="nowrap";
 
71
  this.buttonbar.style.textAlign="center";
 
72
 
 
73
  this.okbutton = document.createElement("button");
 
74
  this.okbutton.style.border="1px solid gray";
 
75
  this.okbutton.style.font="normal 10px verdana";
 
76
  this.okbutton.style.width="80px";
 
77
  this.okbutton.style.margin="5px";
 
78
  this.okbutton.innerHTML = "Ok";
 
79
  this.okbutton.onclick=function(){oThis.onOk();};
 
80
  this.buttonbar.appendChild(this.okbutton);
 
81
 
 
82
  this.cancelbutton = document.createElement("button");
 
83
  this.cancelbutton.innerHTML = "Cancel";
 
84
  this.cancelbutton.style.font="normal 10px verdana";
 
85
  this.cancelbutton.style.border="1px solid gray";
 
86
  this.cancelbutton.style.width="80px";
 
87
  this.cancelbutton.style.margin="5px";
 
88
  this.cancelbutton.onclick=function(){oThis.onCancel();};
 
89
  this.buttonbar.appendChild(this.cancelbutton);
 
90
 
 
91
  item.appendChild(this.buttonbar);
 
92
 
 
93
  return item;
 
94
}
 
95
 
 
96
/**
 
97
 * This method will be called if the user pressed the OK button in buttonbar of the dialog.<br>
 
98
 * Subclasses can override this method to implement there own stuff.<br><br>
 
99
 * Don't forget to call the super method after you have done your stuff with
 
100
 * <code>Dialog.prototype.onOk.call(this);</code>
 
101
 **/
 
102
draw2d.Dialog.prototype.onOk=function()
 
103
{
 
104
  this.workflow.removeFigure(this);
 
105
}
 
106
 
 
107
/**
 
108
 * This method will be called if the user pressed the CANCEL button in buttonbar of the dialog.<br>
 
109
 * Subclasses can override this method to implement there own stuff.<br><br>
 
110
 * Don't forget to call the super method after you have done your stuff with
 
111
 * <code>Dialog.prototype.onCancel.call(this);</code>
 
112
 **/
 
113
draw2d.Dialog.prototype.onCancel=function()
 
114
{
 
115
  this.workflow.removeFigure(this);
 
116
}
 
117
 
 
118
/**
 
119
 * Set the new dimension of the dialog.
 
120
 * @param {int} w new width of the window. 
 
121
 * @param {int} h new height of the window. 
 
122
 **/
 
123
draw2d.Dialog.prototype.setDimension=function(/*:int*/ w, /*:int*/ h)
 
124
{
 
125
  draw2d.Window.prototype.setDimension.call(this,w,h);
 
126
  if(this.buttonbar!=null)
 
127
  {
 
128
    this.buttonbar.style.width=this.getWidth()+"px";
 
129
  }
 
130
}
 
131
 
 
132
/**
 
133
 * @param {draw2d.Workflow} workflow The new workflow of the object. 
 
134
 * @private
 
135
 **/
 
136
draw2d.Dialog.prototype.setWorkflow= function(/*:draw2d.Workflow*/ workflow)
 
137
{
 
138
  draw2d.Window.prototype.setWorkflow.call(this, workflow);
 
139
  this.setFocus();
 
140
}
 
141
 
 
142
/**
 
143
 * The framework call this method after dialog creation. You can
 
144
 * set the focus to your HTML input element or something else.
 
145
 * It is always recommeded to call the super method if a sub class override this
 
146
 * method. <br>
 
147
 * Call: <code>draw2d.Dialog.prototype.setFocus.call(this);</code>
 
148
 **/
 
149
draw2d.Dialog.prototype.setFocus=function()
 
150
{
 
151
}
 
152
 
 
153
/**
 
154
 * Framework callback if an object has beend deleted, move, added or something else.
 
155
 * Sub classes can override this method to implement there own stuff. e.g. update some
 
156
 * UI elements in relation to the document dirty state.
 
157
 **/
 
158
draw2d.Dialog.prototype.onSetDocumentDirty=function()
 
159
{
 
160
}
 
 
b'\\ No newline at end of file'