Created
January 24, 2013 17:03
-
-
Save ecere/4625149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "HTMLView" | |
class AddressBar : Window | |
{ | |
background = activeBorder; | |
EditBox address | |
{ | |
this, text = "Address", anchor = Anchor { left = 60, right = 60, top = 0, bottom = 0 }, hotKey = altA; | |
bool NotifyKeyDown(EditBox editBox, Key key, unichar ch) | |
{ | |
if((SmartKey)key == enter) | |
((Explorer)parent).htmlView.Open(editBox.contents, null); | |
return true; | |
} | |
}; | |
Label { this, anchor = Anchor { left = 5 }, labeledWindow = address }; | |
Button button | |
{ | |
this, bevelOver = true, inactive = true, text = "Go!", anchor = Anchor { top = 0, right = 0, bottom = 0 }, size = Size { 60 }, hotKey = altG; | |
bool NotifyClicked(Button button, int x, int y, Modifiers mods) | |
{ | |
((Explorer)parent).htmlView.Open(address.contents, null); | |
return true; | |
} | |
}; | |
} | |
class Explorer : Window | |
{ | |
tabCycle = true; | |
background = activeBorder; | |
hasMenuBar = true; | |
hasStatusBar = true; | |
borderStyle = sizable; | |
hasClose = true; | |
hasMaximize = true; | |
hasMinimize = true; | |
text = "ECERE Web Browser"; | |
size = Size { 800, 600 }; | |
state = maximized; | |
AddressBar addressBar { this, borderStyle = bevel, anchor = Anchor { top = 0, left = 0, right = 0 }, size.h = 26, hotKey = altA }; | |
HTMLView htmlView { this, borderStyle = deep, hasVertScroll = true, hasHorzScroll = true, anchor = Anchor { left = 0, right = 0, top = 26, bottom = 0 }, NotifyPageOpened = PageOpened }; | |
// File Menu | |
menu = Menu {}; | |
Menu fileMenu { menu, "File", f }; | |
MenuItem openItem { fileMenu, "Open...\tCtrl+O", o, ctrlO }; | |
MenuItem closeItem { fileMenu, "Close\tCtrl-F4", c, NotifySelect = MenuFileClose }; | |
MenuDivider { fileMenu }; | |
MenuItem saveAsItem { fileMenu, "Save As...", NotifySelect = MenuFileSaveAs }; | |
MenuDivider { fileMenu }; | |
MenuItem exitItem { fileMenu, "Exit\tAlt+F4", x, NotifySelect = MenuFileExit }; | |
bool PageOpened() | |
{ | |
char caption[MAX_LOCATION]; | |
strcpy(caption, "ECERE Web Browser - "); | |
strcat(caption, htmlView.fileName); | |
text = caption; | |
addressBar.address.Clear(); | |
addressBar.address.PutS(htmlView.fileName); | |
return true; | |
} | |
bool OnCreate() | |
{ | |
//htmlView.Open("http://www.ecere.com/default.htm", NULL); | |
//htmlView.location = "http://www.ecere.com/default.htm"); | |
#ifndef ECERE_MODULE | |
if(app.argc > 1) | |
htmlView.location = app.argv[1]; | |
else | |
#endif | |
//htmlView.location = "localhost:8080"; | |
htmlView.location = "google.com"; | |
//htmlView.location = "www.ecere.com"; | |
return true; | |
} | |
} | |
#ifndef ECERE_MODULE | |
class BrowserApp : GuiApplication | |
{ | |
// driver = "OpenGL"; | |
Explorer explorerWindow {}; | |
bool Init() | |
{ | |
app = this; | |
return true; | |
} | |
} | |
BrowserApp app; | |
#else | |
extern GuiApplication app; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment