Advancing along here.

This commit is contained in:
Brad Arant 2020-12-09 09:40:32 -08:00
parent 527d2f6f4d
commit 27f0c78b5b
9 changed files with 144 additions and 87 deletions

2
.gitignore vendored
View File

@ -4,4 +4,4 @@ Release
*.o
*.o.d
*.mk
.vscode/**

View File

@ -14,7 +14,7 @@ namespace http {
void onDataReceived(char *data, int len) override {
coreutils::Log(coreutils::LOG_DEBUG_1) << data;
// coreutils::Log(coreutils::LOG_DEBUG_1) << data;
protocol(std::string(data, len));
send();

View File

@ -9,11 +9,13 @@
namespace http {
class HTTPPage : public core::Object {
public:
public:
bool check(std::string request) {
if(request != "") {
if(name.length() > 0) {
if(request.find("?") != -1)
request = request.substr(0, request.find("?"));
if(name.length() > 0) {
if(name == request)
return true;
}
@ -22,14 +24,14 @@ namespace http {
return false;
}
virtual int processCommand(std::string request,
core::TCPSession *session,
HTTPSession *httpSession,
HTTPRequest *httpRequest,
virtual int processCommand(std::string request,
core::TCPSession *session,
HTTPSession *httpSession,
HTTPRequest *httpRequest,
std::stringstream &data) {
return false;
}
};
}

Binary file not shown.

View File

@ -2,6 +2,7 @@
#define ____editview_h__
#include "HTTPPage.h"
#include "File.h"
namespace http {
@ -23,7 +24,11 @@ namespace http {
data << " <canvas id=\"grid\" width=\"600px\" height=\"600px\" style=\"position: absolute; left: 0px; top: 0px; alpha: 0.5; cursor: normal;\"></canvas>" << std::endl;
data << "" << std::endl;
data << "<div id=\"__workspace__\"></div>" << std::endl;
coreutils::File workspace("/home/barant/jetserver/views/testview1.view");
workspace.read();
data << "<div id=\"__workspace__\">";
data << workspace.asString();
data << "</div>" << std::endl;
data << "" << std::endl;
data << " <div id=\"window3\" style=\"position:absolute; top: 235px; left: 610px;" << std::endl;

View File

@ -24,14 +24,14 @@
gridsize.value = gridSize;
drawGrid();
}
function drawGrid() {
var grid = document.getElementById("grid");
var context = grid.getContext("2d");
if(showGrid == true) {
context.clearRect(0,0,grid.width,grid.height);
context.globalAlpha = 0.2;
context.lineWidth = 0.5;
context.lineWidth = 0.5;
for(ix = 0; ix < grid.width; ix += gridSize) {
context.beginPath();
context.moveTo(ix, 0);
@ -40,7 +40,7 @@
context.beginPath();
context.moveTo(0, ix);
context.lineTo(grid.width, ix);
context.stroke();
context.stroke();
}
} else {
context.clearRect(0,0,grid.width,grid.height);
@ -50,11 +50,11 @@
function setDragHint(hint) {
dragHint = hint;
}
function getMouseX(e) {
return e.clientX - mainpage.offsetLeft - parseFloat(mainpage.style.borderWidth);
}
function getMouseY(e) {
return e.clientY - mainpage.offsetTop - parseFloat(mainpage.style.borderWidth);
}
@ -73,7 +73,7 @@
ismousedown = true;
displayParameters();
}
function mouseup() {
ismousedown = false;
dragobject = null;
@ -84,7 +84,7 @@
var mouseX = getMouseX(e);
var mouseY = getMouseY(e);
if(ismousedown) {
if(dragHint == "move") {
if(snapToGrid == false) {
dragobject.style.left = (mouseX - mousedownx) + "px";
@ -97,71 +97,71 @@
dragobject.style.left = "0px";
if((mouseY - mousedowny) < 0)
dragobject.style.top = "0px";
if((mouseX - mousedownx + parseFloat(dragobject.style.width)) > parseFloat(mainpage.style.width))
dragobject.style.left = (mouseX - mousedownx) + "px";
} else if(dragHint == "rightbottomresize") {
if((mouseX - mousedownx + parseFloat(dragobject.style.width)) > parseFloat(mainpage.style.width))
dragobject.style.left = (mouseX - mousedownx) + "px";
} else if(dragHint == "rightbottomresize") {
dragobject.style.width = (mouseX - mouseDownLeft) + "px";
dragobject.style.height = (mouseY - mouseDownTop) + "px";
} else if(dragHint == "rightresize") {
} else if(dragHint == "rightresize") {
if(snapToGrid == false) {
dragobject.style.width = (mouseX - mouseDownLeft) + "px";
dragobject.style.width = (mouseX - mouseDownLeft) + "px";
} else {
dragobject.style.width = (Math.round((mouseX - mouseDownLeft) / gridSize) * gridSize) + "px";
dragobject.style.width = (Math.round((mouseX - mouseDownLeft) / gridSize) * gridSize) + "px";
}
} else if(dragHint == "bottomresize") {
} else if(dragHint == "bottomresize") {
if(snapToGrid == false) {
dragobject.style.height = (mouseY - mouseDownTop) + "px";
} else {
dragobject.style.height = (Math.round((mouseY - mouseDownTop) / gridSize) * gridSize) + "px";
}
} else if(dragHint == "leftresize") {
} else if(dragHint == "leftresize") {
dragobject.style.left = mouseX + "px";
dragobject.style.width = (mouseDownWidth + (mouseDownLeft - mouseX)) + "px";
} else if(dragHint == "topresize") {
} else if(dragHint == "topresize") {
dragobject.style.top = mouseY + "px";
dragobject.style.height = (mouseDownHeight + (mouseDownTop - mouseY)) + "px";
}
data.innerHTML = "<p>" + dragobject.nodeName + "<br>" +
data.innerHTML = "<p>" + dragobject.nodeName + "<br>" +
"Action: " + dragHint + "<br>" +
"MouseLocation: " + mouseX + ":" + mouseY + "<br>" +
"MouseOver Location: " + (mouseX - dragobject.offsetLeft) + ":" + (mouseY - dragobject.offsetTop) + "<br>" +
"Location: " + dragobject.style.left + ":" + dragobject.style.top + "<br>" +
"Size: " + dragobject.style.width + ":" + dragobject.style.height + "<br>" +
"MouseOver Location: " + (mouseX - dragobject.offsetLeft) + ":" + (mouseY - dragobject.offsetTop) + "<br>" +
"Location: " + dragobject.style.left + ":" + dragobject.style.top + "<br>" +
"Size: " + dragobject.style.width + ":" + dragobject.style.height + "<br>" +
"</p>";
} else {
var mouseabove = document.elementFromPoint(mouseX + mainpage.offsetLeft, mouseY + mainpage.offsetTop);
if((mouseabove.id != "mainpage") && (mouseabove.id != "grid")) {
data.innerHTML = "<p>" + mouseabove.nodeName + "<br>" +
data.innerHTML = "<p>" + mouseabove.nodeName + "<br>" +
"Action: " + dragHint + "<br>" +
"MouseLocation: " + mouseX + ":" + mouseY + "<br>" +
"MouseOver Location: " + (mouseX - mouseabove.offsetLeft) + ":" + (mouseY - mouseabove.offsetTop) + "<br>" +
"Location: " + mouseabove.style.left + ":" + mouseabove.style.top + "<br>" +
"Size: " + mouseabove.style.width + ":" + mouseabove.style.height + "<br>" +
"MouseOver Location: " + (mouseX - mouseabove.offsetLeft) + ":" + (mouseY - mouseabove.offsetTop) + "<br>" +
"Location: " + mouseabove.style.left + ":" + mouseabove.style.top + "<br>" +
"Size: " + mouseabove.style.width + ":" + mouseabove.style.height + "<br>" +
"</p>";
if((mouseabove.nodeName == "DIV") ||
(mouseabove.nodeName == "IMG") ||
if((mouseabove.nodeName == "DIV") ||
(mouseabove.nodeName == "IMG") ||
(mouseabove.nodeName == "BUTTON") ||
(mouseabove.nodeName == "INPUT") ||
(mouseabove.nodeName == "SPAN")) {
if((parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) &&
if((parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) &&
(parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) {
mouseabove.style.cursor = "nwse-resize";
dragHint = "rightbottomresize";
} else if((parseFloat(mouseabove.style.left) <= (mouseX - mouseabove.offsetLeft)) &&
dragHint = "rightbottomresize";
} else if((parseFloat(mouseabove.style.left) <= (mouseX - mouseabove.offsetLeft)) &&
((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseY - mouseabove.offsetTop))) {
mouseabove.style.cursor = "nesw-resize";
dragHint = "righttopresize";
} else if(((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) &&
dragHint = "righttopresize";
} else if(((parseFloat(mouseabove.style.borderWidth) + 2) >= (mouseX - mouseabove.offsetLeft)) &&
(parseFloat(mouseabove.style.height) <= (mouseY - mouseabove.offsetTop))) {
mouseabove.style.cursor = "nesw-resize";
dragHint = "leftbottomresize";
dragHint = "leftbottomresize";
} else if(parseFloat(mouseabove.style.width) <= (mouseX - mouseabove.offsetLeft)) {
mouseabove.style.cursor = "ew-resize";
dragHint = "rightresize";
@ -189,12 +189,12 @@
}
displayParameters();
}
function displayParameters() {
itemparameters.innerHTML = "<p>" + selected.nodeName + ": " + selected.id + "<br>" +
"Location: " + selected.style.left + ":" + selected.style.top + "<br>" +
"Size: " + selected.style.width + ":" + selected.style.height + "<br>" +
itemparameters.innerHTML = "<p>" + selected.nodeName + ": " + selected.id + "<br>" +
"Location: " + selected.style.left + ":" + selected.style.top + "<br>" +
"Size: " + selected.style.width + ":" + selected.style.height + "<br>" +
"</p>";
}
@ -209,19 +209,19 @@
</style>
</head>
<body ondragstart="return false;"
ondrop="return false;"
<body ondragstart="return false;"
ondrop="return false;"
onload="init(); return true;">
<div style="position: relative;">
<div id="window1" style="position: absolute; left: 0px; top: 0px; border: 1pt solid black; display: inline-block; padding: 2px; background: #808080; color: #ffffff;">
<span style="font: 20px bebasneue;">View Editor</span>
<div id="mainpage"
style="width: 600px; height: 600px; border: 1px solid black; position: relative; background: #ffffff;"
onmousemove="mousemove(event); return true;"
<div id="mainpage"
style="width: 600px; height: 600px; border: 1px solid black; position: relative; background: #ffffff;"
onmousemove="mousemove(event); return true;"
onmouseup="mouseup(); return true;">
<canvas id="grid" width="600px" height="600px" style="position: absolute; left: 0px; top: 0px; alpha: 0.5; cursor: normal;"></canvas>
@ -229,8 +229,8 @@
<img id="img1" style="position: absolute; user-select: none;" onmousedown="mousedown(this, event); return true;" src="images/barant_web_logo.png" width="336" height="69">
<img id="img2" style="position: absolute; user-select: none;" onmousedown="mousedown(this, event); return true;" src="images/barant_web_logo.png" width="336" height="69">
<button id="button1"
<button id="button1"
style="width: 100px; height: 50px; border: 2px solid green; position: absolute;"
onmousedown="mousedown(this, event); return true;">Press</button>
@ -248,7 +248,7 @@
style="width: 100px; height: 100px; border: 10px solid red; position: absolute; background: #ffff80;"
onmousedown="mousedown(this, event); return true;">
</div>
<span id="text1" onmousedown="mousedown(this, event); return true;"
style="position: absolute; user-select: none; border: 1pt solid black; background: #8080c0;">This is a text label</span>
@ -263,9 +263,9 @@
<span style="font: 20px bebasneue;">OPTIONS</span>
<div style="width: 150px; height: 300px; color: #000000; border: 1px solid black; position: relative; background: #ffffff;"
onmousemove="mousemove(event); return true;"
onmouseup="mouseup(); return true;">
<div style="width: 150px; height: 300px; color: #000000; border: 1px solid black; position: relative; background: #ffffff;"
onmousemove="mousemove(event); return true;"
onmouseup="mouseup(); return true;">
<div id="controls">
<input type="checkbox" name="grid" onchange="showGrid = this.checked; drawGrid(); return true;"><span style="font: 12px bebasneue; margin-bottom: 2px;">Show Grid</span><br>
@ -287,18 +287,18 @@
<span style="font: 20px bebasneue;">Toolbar</span>
<div id="toolbar"
style="width: 80px; height: 200px; border: 1px solid black; position: relative; background: #ffffff;"
onmousemove="mousemove(event); return true;"
<div id="toolbar"
style="width: 80px; height: 200px; border: 1px solid black; position: relative; background: #ffffff;"
onmousemove="mousemove(event); return true;"
onmouseup="mouseup(); return true;">
<button id="button1"
<button id="button1"
style="width: 40px; height: 40px; border: 2px solid green; position: absolute;"
onmousedown="mousedown(this, event); return true;">Press</button>
</div>
</div>
</div>
</div>

View File

@ -7,42 +7,42 @@
namespace http {
class __viewlist : public HTTPPage {
int processCommand(std::string request,
core::TCPSession *session,
HTTPSession *httpSession,
HTTPRequest *httpRequest,
int processCommand(std::string request,
core::TCPSession *session,
HTTPSession *httpSession,
HTTPRequest *httpRequest,
std::stringstream &data) override {
coreutils::Directory directory("/home/bradarant/jetserver/views");
coreutils::Directory directory("../../jetserver/views");
data << "<div>" << std::endl;
data << " <div style=\"background: #484; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
data << " onmousedown=\"getPage('/editview','main');\">" << std::endl;
data << " <span>Create new view</span>" << std::endl;
data << " </div>" << std::endl;
while(!directory.eod()) {
if(directory.get().getName().substr(0, 1) == ".") {
directory.next();
directory.next();
continue;
}
data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
data << " onmousedown=\"getPage('/editview','main');\">" << std::endl;
data << " onmousedown=\"getPage('/editview?view=testview1','main');\">" << std::endl;
data << " <span>" << directory.get().getName() << "</span>" << std::endl;
data << " </div>" << std::endl;
directory.next();
}
data << "</div>" << std::endl;
httpRequest->response.addHeader("Content-Type", "text/html");
httpRequest->response.addHeader("Content-Type", "text/html");
return true;
}
}
};
}

35
_image.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef ____editview_h__
#define ____editview_h__
#include "HTTPPage.h"
#include "File.h"
namespace http {
class _image : public HTTPPage {
bool test(std::string request) {
if(request.substr(0, 6) == "image/") {
return true;
}
return false;
}
int processCommand(std::string request, core::TCPSession *session, HTTPSession *httpSession, HTTPRequest *httpRequest, std::stringstream &data) override {
std::cout << ">>>" << request << std::endl;
coreutils::File workspace("/home/barant/jetserver/images/barant_web_logo.png");
workspace.read();
httpRequest->response.addHeader("Content-Length", workspace.asString().size().toString());
httpRequest->response.addHeader("Content-Type", "image/png");
httpRequest->response.body = workspace.asString();
return 0;
}
};
}
#endif

15
launch.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "C++ Launch (Windows)",
"type": "cppvsdbg",
"request": "launch",
"program": "C:\\app1\\Debug\\app1.exe",
"symbolSearchPath": "C:\\Symbols;C:\\SymbolDir2",
"externalConsole": true,
"logging": {
"moduleLoad": false,
"trace": true
},
"visualizerFile": "${workspaceFolder}/my.natvis",
"showDisplayString": true
}