Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Member Functions | Private Attributes
Silverstone.Manticore.Browser.BrowserWindow Class Reference
Inheritance diagram for Silverstone.Manticore.Browser.BrowserWindow:
Inheritance graph
[legend]
Collaboration diagram for Silverstone.Manticore.Browser.BrowserWindow:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 BrowserWindow ()
 BrowserWindow (String aURL)
void LoadURL (String aURL)
void Open ()
void SavePageAs ()
void OnSavePageAsOK (Object sender, CancelEventArgs e)
void Quit ()
void OnProgress (int aProgress, int aProgressMax)
void OnNavigateComplete2 (string aURL)
void OnTitleChange (String aTitle)
void OnStatusTextChange (String aStatusText)
void OnMenuCommand (Object sender, EventArgs e)
 Fired when a |MenuItem| built by the |MenuBuilder| is selected.
void DoCommand (String aCommand)
void DoCommand (String aCommand, Object aData)
bool SupportsCommand (String aCommand)
bool IsCommandEnabled (String aCommand)
void OnClosed (Object sender, EventArgs e)
void OnActivated (Object sender, EventArgs e)

Static Public Member Functions

static BrowserWindow OpenBrowser ()
static BrowserWindow OpenBrowserWithURL (String aURL)

Protected Member Functions

void Init ()
void OnLocationCommit (Object aSender, LocationBarEventArgs aLbea)
void OnLocationModified (Object aSender, LocationBarEventArgs aLbea)

Protected Attributes

bool mShouldLoadHomePage = true
bool mUserTyped = false
bool mUpdatedURLBar = false
String mType = ""

Properties

WebBrowser WebBrowser [get]
String URL [get]
 The currently loaded document's URL.
bool ShouldLoadHomePage [get, set]
Object currentLayoutEngine [get]
String Type [get]

Private Member Functions

void InitializeComponent ()
void LoadStartPage (object sender, EventArgs e)

Private Attributes

MenuBuilder mMenuBuilder
BrowserToolbarBuilder mToolbarBuilder
LocationBar mLocationBar
WebBrowser mWebBrowser
StatusBar mStatusBar
StatusBarPanel mProgressMeter
StatusBarPanel mStatusPanel
String mSessionURL = ""
String mTitle = ""
 Webpage Title.
int previousProgress = 0

Detailed Description

Definition at line 54 of file browserwindow.cs.


Constructor & Destructor Documentation

Definition at line 81 of file browserwindow.cs.

    {
      Init();
    }

Here is the call graph for this function:

Definition at line 86 of file browserwindow.cs.

    {
      mSessionURL = aURL;

      Init();
    }

Here is the call graph for this function:


Member Function Documentation

Implements Silverstone.Manticore.Toolkit.IController.

Definition at line 377 of file browserwindow.cs.

    {
      DoCommand(aCommand, null);
    }

Implements Silverstone.Manticore.Toolkit.IController.

Definition at line 382 of file browserwindow.cs.

    {
      Console.WriteLine(aCommand);
      switch (aCommand) 
      {
        case "file-new-window":
          OpenBrowser();
          break;
        case "file-open":
          Open();
          break;
        case "file-save-as":
          SavePageAs();
          break;
        case "file-save-form":
          TestForm frm = new TestForm();
          frm.Show();
          break;
        case "file-exit":
          Quit();
          break;
        case "view-statusbar":
          if (mStatusBar.Visible)
            mStatusBar.Hide();
          else
            mStatusBar.Show();
          break;
        case "view-go-back":
          mWebBrowser.GoBack();
          break;
        case "view-go-forward":
          mWebBrowser.GoForward();
          break;
        case "view-go-home":
          mWebBrowser.GoHome();
          break;
        case "view-reload":
          mWebBrowser.RefreshPage();
          break;
        case "view-stop":
          mWebBrowser.Stop();
          break;
        case "view-layout-gecko":
          mWebBrowser.SwitchLayoutEngine("gecko");
          break;
        case "view-layout-ie":
          mWebBrowser.SwitchLayoutEngine("trident");
          break;
        case "bookmarks-manage":
          BookmarksWindow bm = new BookmarksWindow();
          bm.Show();
          break;
        case "bookmarks-item":
          String url = ServiceManager.Bookmarks.GetBookmarkAttribute(aData as String, "url");
          LoadURL(url);
          break;
        case "bookmarks-add":
          // XXX need to allow user to customize this. 
          Bookmarks bmks = ServiceManager.Bookmarks;
          String bookmarkID = bmks.CreateBookmark(mTitle, "Bookmarks", -1);
          bmks.SetBookmarkAttribute(bookmarkID, "url", URL);
          break;
        case "bookmarks-file":
          // XXX work on this
          FileBookmark fpWindow = new FileBookmark(URL, mTitle);
          fpWindow.ShowDialog();
          break;
        case "help-about":
          AboutDialog aboutDialog = new AboutDialog(this);
          aboutDialog.ShowDialog();
          break;
        case "tools-options":
          PrefsDialog prefsDialog = new PrefsDialog(this);
          prefsDialog.ShowDialog();
          break;
      }
    }

Here is the call graph for this function:

Reimplemented from Silverstone.Manticore.Toolkit.ManticoreWindow.

Definition at line 93 of file browserwindow.cs.

    {
      mType = "BrowserWindow";

      // Set up UI
      InitializeComponent();

      base.Init();
    }

Definition at line 103 of file browserwindow.cs.

    {
      // XXX read these from a settings file
      this.Width = 640;
      this.Height = 480;
      
      this.Text = "Manticore"; // XXX localize

      mMenuBuilder = new MenuBuilder("browser\\browser-menu.xml", this);
      mMenuBuilder.Build();
      mMenuBuilder.OnCommand += new EventHandler(OnMenuCommand);

      // Show the resize handle
      this.SizeGripStyle = SizeGripStyle.Auto;

      // Set up the Status Bar
      mStatusBar = new StatusBar();
      
      StatusBarPanel docStatePanel = new StatusBarPanel();
      mStatusPanel = new StatusBarPanel();
      mProgressMeter = new StatusBarPanel();
      StatusBarPanel zonePanel = new StatusBarPanel();

      docStatePanel.Text = "X";
      zonePanel.Text = "Internet Region";
      mStatusPanel.Text = "Document Done";
      mStatusPanel.AutoSize = StatusBarPanelAutoSize.Spring;
      

      mStatusBar.Panels.AddRange(new StatusBarPanel[] {docStatePanel, mStatusPanel, mProgressMeter, zonePanel});
      mStatusBar.ShowPanels = true;
      
      this.Controls.Add(mStatusBar);

      mToolbarBuilder = new BrowserToolbarBuilder("browser\\browser-toolbar.xml", this);

      mLocationBar = new LocationBar();
      mLocationBar.Top = mToolbarBuilder.Bounds.Top + mToolbarBuilder.Bounds.Height;
      mLocationBar.Left = 0;
      mLocationBar.Width = ClientRectangle.Width;
      mLocationBar.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
      mLocationBar.LocationBarCommit += new LocationBar.LocationBarEventHandler(OnLocationCommit);
      mLocationBar.LocationBarModified += new LocationBar.LocationBarEventHandler(OnLocationModified);
      this.Controls.Add(mLocationBar);

      mWebBrowser = new WebBrowser(this);
      mWebBrowser.Dock = DockStyle.Bottom;
      mWebBrowser.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
      mWebBrowser.Top = mLocationBar.Top + mLocationBar.Height;
      mWebBrowser.Width = ClientRectangle.Width;
      mWebBrowser.Height = ClientRectangle.Height - mWebBrowser.Top - mStatusBar.Height;
      this.Controls.Add(mWebBrowser);

      // Start Page handler
      this.VisibleChanged += new EventHandler(LoadStartPage);
    }

Here is the call graph for this function:

Implements Silverstone.Manticore.Toolkit.IController.

Definition at line 466 of file browserwindow.cs.

    {
      // XXX implement me
      return true;
    }
void Silverstone.Manticore.Browser.BrowserWindow.LoadStartPage ( object  sender,
EventArgs  e 
) [inline, private]

Definition at line 193 of file browserwindow.cs.

    {
      if (!mShouldLoadHomePage)
        return;

      int startMode = ServiceManager.Preferences.GetIntPref("browser.homepage.mode");
      switch (startMode) {
      case 0:
        // Don't initialize jack.
        break;
      case 1:
        // Load the homepage
        mWebBrowser.GoHome();
        break;
      case 2:
        // Load the session document.
        mWebBrowser.LoadURL(mSessionURL, false);
        break;
      }
    }

Here is the call graph for this function:

Definition at line 173 of file browserwindow.cs.

    {
      mUpdatedURLBar = false;
      mWebBrowser.LoadURL(aURL, false);
    }

Here is the caller graph for this function:

void Silverstone.Manticore.Toolkit.ManticoreWindow.OnActivated ( Object  sender,
EventArgs  e 
) [inline, inherited]

Definition at line 80 of file ManticoreWindow.cs.

    {
      WindowMediator wm = ServiceManager.WindowMediator;
      wm.SetMostRecentWindow(this);
    }

Here is the call graph for this function:

void Silverstone.Manticore.Toolkit.ManticoreWindow.OnClosed ( Object  sender,
EventArgs  e 
) [inline, inherited]

Definition at line 74 of file ManticoreWindow.cs.

    {
      WindowMediator wm = ServiceManager.WindowMediator;
      wm.UnregisterWindow(this);
    }

Here is the call graph for this function:

Definition at line 216 of file browserwindow.cs.

    {
      string url = ServiceManager.Bookmarks.ResolveKeyword(aLbea.Text);
      if (url == "") 
        url = aLbea.Text;

      mUserTyped = false;
      LoadURL(url);
    }

Here is the call graph for this function:

Definition at line 228 of file browserwindow.cs.

    {
      mUserTyped = true;
    }

Fired when a |MenuItem| built by the |MenuBuilder| is selected.

Parameters:
sender
e

Definition at line 368 of file browserwindow.cs.

    {
      ManticoreMenuItem item = sender as ManticoreMenuItem;
      DoCommand(item.Command, item.Data);
    }

Definition at line 343 of file browserwindow.cs.

    {
      if (!mUpdatedURLBar && !mUserTyped) 
      {
        mLocationBar.Text = aURL;
        mUpdatedURLBar = true;
      }
    }
void Silverstone.Manticore.Browser.BrowserWindow.OnProgress ( int  aProgress,
int  aProgressMax 
) [inline]

Definition at line 328 of file browserwindow.cs.

    {
      if (aProgress > 0 && aProgress > previousProgress) {
        int percentage = (int) (aProgress / aProgressMax);
        String text = percentage + "% complete";
        mProgressMeter.Text = text;
      }
      // XXX we really would rather set this in BeforeNavigate2, but we
      //     can't get that event to fire for some reason. 
      if (mUpdatedURLBar) 
        mUpdatedURLBar = false;
    }

Here is the call graph for this function:

void Silverstone.Manticore.Browser.BrowserWindow.OnSavePageAsOK ( Object  sender,
CancelEventArgs  e 
) [inline]

Definition at line 305 of file browserwindow.cs.

    {
      if (e.Cancel != true) 
      {
        SaveFileDialog dlg = sender as SaveFileDialog;
        Console.WriteLine("{0}", dlg.FileName);
      }
    }

Definition at line 358 of file browserwindow.cs.

    {
      mStatusPanel.Text = aStatusText;
    }

Definition at line 352 of file browserwindow.cs.

    {
      mTitle = aTitle;
      this.Text = (aTitle == "about:blank") ? "No page to display" : aTitle;
    }

Definition at line 252 of file browserwindow.cs.

    {
      OpenDialog dlg = new OpenDialog();
      if (dlg.ShowDialog() == DialogResult.OK)
        mWebBrowser.LoadURL(dlg.URL, false);
    }

Definition at line 235 of file browserwindow.cs.

    {
      BrowserWindow window = new BrowserWindow();
      window.Show();
      return window;
    }

Here is the caller graph for this function:

Definition at line 242 of file browserwindow.cs.

    {
      BrowserWindow window = new BrowserWindow(aURL);
      window.Show();
      return window;
    }

Here is the caller graph for this function:

Definition at line 314 of file browserwindow.cs.

    {
      ManticoreApp app = ServiceManager.App;
      app.Quit();
    }

Here is the call graph for this function:

Definition at line 259 of file browserwindow.cs.

    {
      SaveFileDialog dlg = new SaveFileDialog();
      dlg.AddExtension = true;
      dlg.InitialDirectory = FileLocator.GetFolderPath(FileLocator.SpecialFolders.ssfPERSONAL); // XXX persist this. 

      // XXX I want to point out that this is a really lame hack. We need
      //     a URL parser (not a URI parser, a URL parser). 
      string name = mTitle.Replace("\"", "'");
      name = name.Replace("*", " ");
      name = name.Replace(":", " ");
      name = name.Replace("?", " ");
      name = name.Replace("<", "(");
      name = name.Replace(">", ")");
      name = name.Replace("\\", "-");
      name = name.Replace("/", "-");
      name = name.Replace("|", "-");
      dlg.FileName = name;

      dlg.Title = "Save Page As...";
      dlg.ValidateNames = true;
      dlg.OverwritePrompt = true;

      WebRequest req = WebRequest.Create(mWebBrowser.URL);
      WebResponse resp = req.GetResponse();
      string contentType = resp.ContentType;
      switch (contentType) 
      {
        case "text/html":
        case "text/xhtml":
          dlg.Filter = "Web Page, complete (*.htm;*.html)|*.htm*|Web Page, HTML only (*.htm;*.html)|*.htm*|Text only (*.txt)|*.txt";
          dlg.DefaultExt = "html";
          break;
        default:
          string extension = MIMEService.GetExtensionForMIMEType(contentType);
          string description = MIMEService.GetDescriptionForMIMEType(contentType);
          description += " (*" + extension + ")";
          dlg.Filter = description + "|*" + extension + "|All Files (*.*)|*.*";
          dlg.DefaultExt = extension.Substring(1, extension.Length-1);
          break;
      }

      dlg.FileOk += new CancelEventHandler(OnSavePageAsOK);
      dlg.ShowDialog();
    }

Here is the call graph for this function:

Implements Silverstone.Manticore.Toolkit.IController.

Definition at line 460 of file browserwindow.cs.

    {
      // XXX implement me
      return true;
    }

Member Data Documentation

Definition at line 59 of file browserwindow.cs.

Definition at line 56 of file browserwindow.cs.

Definition at line 71 of file browserwindow.cs.

Definition at line 74 of file browserwindow.cs.

Definition at line 179 of file browserwindow.cs.

Definition at line 70 of file browserwindow.cs.

Definition at line 72 of file browserwindow.cs.

Webpage Title.

Definition at line 79 of file browserwindow.cs.

Definition at line 57 of file browserwindow.cs.

Definition at line 52 of file ManticoreWindow.cs.

Definition at line 227 of file browserwindow.cs.

Definition at line 226 of file browserwindow.cs.

Definition at line 61 of file browserwindow.cs.

Definition at line 327 of file browserwindow.cs.


Property Documentation

Definition at line 321 of file browserwindow.cs.

Definition at line 181 of file browserwindow.cs.

Definition at line 55 of file ManticoreWindow.cs.

The currently loaded document's URL.

Definition at line 167 of file browserwindow.cs.

Definition at line 63 of file browserwindow.cs.


The documentation for this class was generated from the following file: