2000-09-04 03:38:07 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 2000 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-09-11 04:57:35 +04:00
|
|
|
* Ben Goodger <ben@netscape.com> (Original Author)
|
2000-09-04 03:38:07 +04:00
|
|
|
*/
|
|
|
|
|
2000-09-04 01:38:08 +04:00
|
|
|
const kMenuHeight = 130;
|
2000-10-22 14:15:11 +04:00
|
|
|
const kPaletteWidth = 130;
|
2000-09-04 01:38:08 +04:00
|
|
|
const kPropertiesWidth = 170;
|
2000-09-11 04:57:35 +04:00
|
|
|
const kProjectWidth = 170;
|
2000-09-04 01:38:08 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
var vxShell =
|
2000-09-04 01:38:08 +04:00
|
|
|
{
|
2000-09-11 04:57:35 +04:00
|
|
|
mFocusObserver: null,
|
|
|
|
mFocusedWindow: null,
|
2000-10-23 14:58:39 +04:00
|
|
|
mTxnSvc: null,
|
2000-09-11 04:57:35 +04:00
|
|
|
|
|
|
|
startup: function ()
|
|
|
|
{
|
|
|
|
_dd("vx_Startup");
|
|
|
|
|
|
|
|
// Shell Startup
|
|
|
|
// This requires several steps. Probably more, in time.
|
2000-09-05 05:58:17 +04:00
|
|
|
|
2000-10-22 14:15:11 +04:00
|
|
|
// append the controller
|
|
|
|
var mainWindow = document.getElementById("vixenMain");
|
|
|
|
mainWindow.controllers.insertControllerAt(0, CentralController);
|
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
// position and initialise the application window
|
|
|
|
vxShell.initAppWindow();
|
|
|
|
|
|
|
|
// load the property inspector
|
|
|
|
// loadPropertyInspector();
|
|
|
|
|
|
|
|
// load document inspector window
|
|
|
|
// loadDocumentInspector();
|
2000-09-05 05:58:17 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
// load the palette
|
|
|
|
vxShell.loadPalette();
|
|
|
|
|
2000-10-21 07:09:18 +04:00
|
|
|
// load the history window
|
2000-10-22 14:15:11 +04:00
|
|
|
vxShell.loadHistory();
|
2000-10-21 07:09:18 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
// load a blank form (until projects come online)
|
2000-10-22 14:15:11 +04:00
|
|
|
vxShell.focusedWindow = vxShell.loadFormDesigner(null);
|
2000-09-05 05:58:17 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
// initialise the document focus observer
|
2000-09-14 03:57:52 +04:00
|
|
|
const kObserverServiceCONTRACTID = "@mozilla.org/observer-service;1";
|
2000-09-11 04:57:35 +04:00
|
|
|
const kObserverServiceIID = "nsIObserverService";
|
2000-10-22 14:15:11 +04:00
|
|
|
vxShell.observerService = nsJSComponentManager.getService(kObserverServiceCONTRACTID, kObserverServiceIID);
|
2000-09-11 04:57:35 +04:00
|
|
|
|
|
|
|
},
|
2000-09-04 01:38:08 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
shutdown: function ()
|
|
|
|
{
|
|
|
|
_dd("vx_Shutdown");
|
|
|
|
},
|
2000-09-04 01:38:08 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
initAppWindow: function ()
|
|
|
|
{
|
|
|
|
// size the window
|
|
|
|
moveTo(0,0);
|
|
|
|
outerWidth = screen.availWidth;
|
|
|
|
outerHeight = kMenuHeight;
|
|
|
|
},
|
2000-09-04 01:38:08 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
loadPalette: function ()
|
2000-09-04 01:38:08 +04:00
|
|
|
{
|
2000-09-11 04:57:35 +04:00
|
|
|
// open the palette window
|
|
|
|
const features = "resizable=no,dependent,chrome,dialog=yes";
|
|
|
|
var hPalette = openDialog("chrome://vixen/content/palette/vxPalette.xul", "", features);
|
2000-09-04 01:38:08 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
// size the palette window
|
|
|
|
hPalette.moveTo(0, kMenuHeight + 5);
|
2000-10-22 14:15:11 +04:00
|
|
|
hPalette.outerWidth = kPaletteWidth;
|
2000-10-21 07:09:18 +04:00
|
|
|
hPalette.outerHeight = screen.availHeight - kMenuHeight - 60;
|
|
|
|
},
|
|
|
|
|
|
|
|
loadHistory: function ()
|
|
|
|
{
|
|
|
|
// open the history window
|
2000-10-23 14:58:39 +04:00
|
|
|
const features = "resizable=yes,dependent,chrome,dialog=yes";
|
2000-10-21 07:09:18 +04:00
|
|
|
var hHistory = openDialog("chrome://vixen/content/history/history.xul", "", features);
|
|
|
|
|
|
|
|
// size the history window
|
|
|
|
hHistory.moveTo(screen.availWidth - kPropertiesWidth - 10, kMenuHeight + 5);
|
|
|
|
hHistory.outerWidth = kPropertiesWidth;
|
|
|
|
hHistory.outerHeight = screen.availHeight - kMenuHeight - 60;
|
2000-09-04 01:38:08 +04:00
|
|
|
},
|
|
|
|
|
2000-10-22 14:15:11 +04:00
|
|
|
newDocument: function ()
|
|
|
|
{
|
|
|
|
// need to ask for document type in dialog
|
|
|
|
this.loadFormDesigner(null);
|
|
|
|
},
|
|
|
|
|
|
|
|
loadFormDesigner: function (aURL)
|
2000-09-04 01:38:08 +04:00
|
|
|
{
|
2000-10-22 14:15:11 +04:00
|
|
|
_ddf("vx_LoadDocument", aURL);
|
2000-09-11 04:57:35 +04:00
|
|
|
// open a blank form designer window
|
|
|
|
const features = "resizable=yes,dependent,chrome,dialog=yes";
|
|
|
|
var params = {
|
|
|
|
documentURL: aURL
|
|
|
|
};
|
2000-10-22 14:15:11 +04:00
|
|
|
|
|
|
|
var rv = vxUtils.positionDocumentWindow("vixen:formdesigner");
|
2000-09-11 04:57:35 +04:00
|
|
|
var hVFD = window.openDialog("chrome://vixen/content/vfd/vfd.xul", "", features, params);
|
2000-10-22 14:15:11 +04:00
|
|
|
hVFD.moveTo(rv.x, rv.y);
|
|
|
|
hVFD.outerWidth = screen.availWidth - kPropertiesWidth - kPaletteWidth - 20;
|
|
|
|
hVFD.outerHeight = screen.availHeight - kMenuHeight - 40;
|
2000-09-11 04:57:35 +04:00
|
|
|
return hVFD;
|
2000-09-04 01:38:08 +04:00
|
|
|
},
|
|
|
|
|
2000-10-22 14:15:11 +04:00
|
|
|
loadFormDesignerWithUI: function ()
|
2000-09-04 01:38:08 +04:00
|
|
|
{
|
2000-09-11 04:57:35 +04:00
|
|
|
const kFilePickerIID = "nsIFilePicker";
|
2000-09-14 03:57:52 +04:00
|
|
|
const kFilePickerCONTRACTID = "@mozilla.org/filepicker;1";
|
|
|
|
var filePicker = nsJSComponentManager.createInstance(kFilePickerCONTRACTID, kFilePickerIID);
|
2000-09-11 04:57:35 +04:00
|
|
|
if (filePicker) {
|
|
|
|
const FP = Components.interfaces.nsIFilePicker;
|
|
|
|
filePicker.init(window, "Open", FP.modeOpen);
|
|
|
|
// XUL VFDs
|
|
|
|
filePicker.appendFilter("XUL Files", "*.xul");
|
|
|
|
// XXX-TODO: add filters for other types, e.g. string tables
|
2000-09-04 01:38:08 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
var filePicked = filePicker.show();
|
|
|
|
if (filePicked == FP.returnOK && filePicker.file) {
|
|
|
|
var file = filePicker.file.QueryInterface(Components.interfaces.nsILocalFile);
|
2000-10-22 14:15:11 +04:00
|
|
|
return this.loadFormDesigner(file.path);
|
2000-09-11 04:57:35 +04:00
|
|
|
}
|
2000-09-04 01:38:08 +04:00
|
|
|
}
|
2000-09-11 04:57:35 +04:00
|
|
|
return null;
|
2000-09-04 01:38:08 +04:00
|
|
|
},
|
2000-09-20 12:25:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit menu functions
|
|
|
|
*/
|
|
|
|
undo: function ()
|
|
|
|
{
|
|
|
|
this.mFocusedWindow.vxVFD.mTxMgrShell.undoTransaction();
|
|
|
|
},
|
|
|
|
|
|
|
|
redo: function ()
|
|
|
|
{
|
|
|
|
this.mFocusedWindow.vxVFD.mTxMgrShell.redoTransaction();
|
|
|
|
},
|
2000-10-22 14:15:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save VFD
|
|
|
|
*/
|
|
|
|
saveDocument: function ()
|
|
|
|
{
|
|
|
|
var vixenShell = Components.classes["@mozilla.org/vixen/shell;1"].createInstance();
|
|
|
|
if (vixenShell) {
|
|
|
|
vixenShell = vixenShell.QueryInterface(Components.interfaces.nsIVixenShell);
|
|
|
|
var focusedVFDDocument = this.mFocusedWindow.vxVFD.getContent(true).document;
|
|
|
|
var documentAsString = vixenShell.encodeDocumentToString(focusedVFDDocument);
|
|
|
|
_ddf("document as string", documentAsString);
|
|
|
|
}
|
|
|
|
},
|
2000-10-19 15:25:53 +04:00
|
|
|
|
2000-09-11 04:57:35 +04:00
|
|
|
appAbout: function ()
|
2000-09-04 01:38:08 +04:00
|
|
|
{
|
2000-09-11 04:57:35 +04:00
|
|
|
// XXX TEMP
|
|
|
|
alert("ViXEn - The Visual XUL Environment.\nhttp://www.mozilla.org/projects/vixen/");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2000-10-19 15:25:53 +04:00
|
|
|
function XXX_dumpDOM()
|
|
|
|
{
|
|
|
|
var focusedWindow = vxShell.mFocusedWindow;
|
|
|
|
var insertionPoint = focusedWindow.vxVFD.getInsertionPoint();
|
|
|
|
dumpDOM(insertionPoint.parent);
|
|
|
|
}
|