Skip to content
Permalink
Browse files

Adding the view to Minibrowser and adding few buttons

  • Loading branch information...
RAJAGOPALAN-GANGADHARAN authored and pulkomandy committed Jun 8, 2019
1 parent 714f104 commit ae1fdf36c991cd0a685524b719c418596bcc5f89
@@ -28,6 +28,7 @@
#include "ArgumentCoders.h"
#include <wtf/CompletionHandler.h>
#include <wtf/StdLibExtras.h>
#include "NotImplemented.h"

namespace IPC {

@@ -122,7 +123,7 @@ void handleMessage(Decoder& decoder, C* object, MF function)

template<typename T, typename C, typename MF>
void handleMessage(Connection& connection, Decoder& decoder, C* object, MF function)
{
{notImplemented();
Optional<typename CodingType<typename T::Arguments>::Type> arguments;
decoder >> arguments;
if (!arguments) {
@@ -43,6 +43,11 @@ namespace WebKit
WebProcessProxy& process)
{
//fprintf(stderr,"called drawing area");
/*BView* temp = fWebView.getView();
temp->LockLooper();
temp->SetFontSize(50.3);
temp->DrawString("Hello",5);
temp->UnlockLooper();*/
return std::make_unique<DrawingAreaProxyCoordinatedGraphics>(*fWebView.page(),process);
}
void PageClientImpl::setViewNeedsDisplay(const WebCore::Region& region)
@@ -316,6 +321,7 @@ namespace WebKit

BView* PageClientImpl::viewWidget()
{
fprintf(stderr,"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n");
return fWebView.getView();
}

@@ -70,3 +70,12 @@ void BWebView::loadHTML()
//WKPageLoadURL(page,uri.get());
WKPageLoadHTMLString(page,str.get(),uri.get());
}

void BWebView::loadURI(const char* uri)
{
auto page = WKViewGetPage( fViewPort.get());
WKRetainPtr<WKURLRef> wuri;
wuri = adoptWK(WKURLCreateWithUTF8CString(uri));
WKPageLoadURL(page,wuri.get());
}

@@ -22,18 +22,23 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "config.h"
#include "WKPage.h"
#include "WKView.h"
#include "WKContext.h"
#include "WKRetainPtr.h"
#include "WKAPICast.h"
#include "WebViewBase.h"

using namespace WebKit;
class BWebView
{
public:
BWebView(BRect,BWindow*);
void initializeOnce();
void loadHTML();
void loadURI(const char*);
BView* getRenderView() { return toImpl(fViewPort.get())->getView(); }
private:
WKRetainPtr<WKViewRef> fViewPort;
WKRetainPtr<WKContextRef> fContext;
@@ -10,26 +10,97 @@

#include "App.h"

#include <interface/StringView.h>
#include <Button.h>
#include <Entry.h>
#include <GridLayoutBuilder.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <SeparatorView.h>
#include <SpaceLayoutItem.h>
#include <StatusBar.h>
#include <StringView.h>
#include <TextControl.h>

enum {
OPEN_LOCATION = 'open',
OPEN_INSPECTOR = 'insp',
SAVE_PAGE = 'save',
GO_BACK = 'goba',
GO_FORWARD = 'gofo',
STOP = 'stop',
GOTO_URL = 'goul',
RELOAD = 'reld',

enum
{
M_BUTTON_GO_URL = 'urlg'
TEXT_SIZE_INCREASE = 'tsin',
TEXT_SIZE_DECREASE = 'tsdc',
TEXT_SIZE_RESET = 'tsrs',
};

App::App(void)
: BApplication("application/x-vnd.lh-MiniBrowser")
{
//initialize counter
fCount = 0;

//create window
frame.Set(100,100,500,400);
myWindow = new BWindow(frame,"MiniBrowser"
, B_TITLED_WINDOW
, B_ASYNCHRONOUS_CONTROLS
| B_QUIT_ON_WINDOW_CLOSE);
myWindow->Show();
//initialize counter
fCount = 0;

//create window
frame.Set(100,100,800,800);
myWindow = new BWindow(frame,"MiniBrowser"
, B_TITLED_WINDOW
, B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS
| B_QUIT_ON_WINDOW_CLOSE);

myWindow->SetLayout(new BGroupLayout(B_HORIZONTAL));


m_menuBar = new BMenuBar("Main menu");
BMenu* menu = new BMenu("Window");
BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
newWindowMessage->AddString("url", "");
BMenuItem* newItem = new BMenuItem("New", newWindowMessage, 'N');
menu->AddItem(newItem);
newItem->SetTarget(be_app);
menu->AddItem(new BMenuItem("Open location", new BMessage(OPEN_LOCATION), 'L'));
menu->AddItem(new BMenuItem("Inspect page", new BMessage(OPEN_INSPECTOR), 'I'));
menu->AddItem(new BMenuItem("Save page", new BMessage(SAVE_PAGE), 'S'));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W', B_SHIFT_KEY));
BMenuItem* quitItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q');
menu->AddItem(quitItem);
quitItem->SetTarget(be_app);
m_menuBar->AddItem(menu);

menu = new BMenu("Text");
menu->AddItem(new BMenuItem("Increase size", new BMessage(TEXT_SIZE_INCREASE), '+'));
menu->AddItem(new BMenuItem("Decrease size", new BMessage(TEXT_SIZE_DECREASE), '-'));
menu->AddItem(new BMenuItem("Reset size", new BMessage(TEXT_SIZE_RESET), '0'));
m_menuBar->AddItem(menu);


m_BackButton = new BButton("Back",new BMessage(GO_BACK));
m_ForwardButton = new BButton("Forward", new BMessage(GO_FORWARD));
m_StopButton = new BButton("Stop", new BMessage(STOP));

m_url = new BTextControl("url", "", "", NULL);

m_goButton = new BButton("", "Go", new BMessage(GOTO_URL));
m_goButton->SetTarget(this);
m_statusText = new BStringView("status", "");
m_statusText->SetAlignment(B_ALIGN_LEFT);
m_statusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
m_statusText->SetExplicitMinSize(BSize(150, 12));

BFont font(be_plain_font);
font.SetSize(ceilf(font.Size() * 0.8));
m_statusText->SetFont(&font, B_FONT_SIZE);

m_loadingProgressBar = new BStatusBar("progress");
m_loadingProgressBar->SetMaxValue(100);
m_loadingProgressBar->Hide();
m_loadingProgressBar->SetBarHeight(12);

}

void App::LocalMessage(BMessage* message)
@@ -91,6 +162,11 @@ App::MessageReceived(BMessage *message)
GlobalMessage(message);
break;

case GOTO_URL:
fprintf(stderr,"Gotoooooooo");
webView->loadURI(m_url->Text());
break;

default:
BApplication::MessageReceived(message);

@@ -99,7 +175,31 @@ App::MessageReceived(BMessage *message)
void App::ReadyToRun()
{
webView = new BWebView(frame,myWindow);
this->testLoader();
const float kInsetSpacing = 5;
const float kElementSpacing = 7;
myWindow->AddChild(BGroupLayoutBuilder(B_VERTICAL)
.Add(m_menuBar)
.Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
.Add(m_BackButton, 0, 0)
.Add(m_ForwardButton, 1, 0)
.Add(m_StopButton, 2, 0)
.Add(m_url, 3, 0)
.Add(m_goButton, 4, 0)
.SetInsets(kInsetSpacing, kInsetSpacing, kInsetSpacing, kInsetSpacing)
)
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
.Add(webView->getRenderView())//this is the view be it mail or anywhere can be added
.Add(BGroupLayoutBuilder(B_HORIZONTAL, kElementSpacing)
.Add(m_statusText)
.Add(m_loadingProgressBar, 0.2)
.AddStrut(12 - kElementSpacing)
.SetInsets(kInsetSpacing, 0, kInsetSpacing, 0)
)
);

m_url->MakeFocus(true);
myWindow->Show();
}
void
App::testLoader()
@@ -15,6 +15,20 @@
#include "WebView.h"
using namespace std;

class BButton;
class BCheckBox;
class BLayoutItem;
class BMenuBar;
class BStatusBar;
class BStringView;
class BTextControl;

enum {
NEW_WINDOW = 'nwnd',
WINDOW_OPENED = 'wndo',
WINDOW_CLOSED = 'wndc',
};

class App : public BApplication
{
public:
@@ -32,6 +46,15 @@ class App : public BApplication
status_t result;
map<string,BLooper*> looperMapping;
map<string,BMessage*> messengerMapping;
//browser widgets
BMenuBar* m_menuBar;
BButton* m_BackButton;
BButton* m_ForwardButton;
BButton* m_StopButton;
BButton* m_goButton;
BTextControl* m_url;
BStringView* m_statusText;
BStatusBar* m_loadingProgressBar;
};

#endif

0 comments on commit ae1fdf3

Please sign in to comment.
You can’t perform that action at this time.