.Developing telpp

git-svn-id: svn://ultimatepp.org/upp/trunk@6688 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-12-20 18:31:07 +00:00
parent 1209bc5fd9
commit ce95ca3b1b
5 changed files with 48 additions and 52 deletions

View file

@ -41,6 +41,8 @@ private:
static void MouseEventFB(Ptr<Ctrl> t, int event, Point p, int zdelta);
Vector<Rect> GetPaintRects();
static void DoMouseFB(int event, Point p, int zdelta);
static void DrawLine(const Vector<Rect>& clip, int x, int y, int cx, int cy, bool horz,
const byte *pattern, int animation);
static void DragRectDraw0(const Vector<Rect>& clip, const Rect& rect, int n,
@ -57,7 +59,6 @@ protected:
static int PaintLock;
public:
static void DoMouseFB(int event, Point p, int zdelta = 0);
static bool DoKeyFB(dword key, int cnt);
static void InitFB();

View file

@ -36,7 +36,8 @@ private:
const byte *pattern, int animation);
static void DoMouseButton(int event, CParser& p);
static void ReadMouseButtons(CParser& p);
static void DoMouseFB(int event, Point p, int zdelta, CParser& cp);
static void Reply();
@ -51,7 +52,6 @@ protected:
static int PaintLock;
public:
static void DoMouseFB(int event, Point p, int zdelta = 0);
static bool DoKeyFB(dword key, int cnt);
static void InitTelpp();

View file

@ -133,36 +133,6 @@ Ctrl *Ctrl::FindMouseTopCtrl()
return desktop->IsEnabled() ? desktop : NULL;
}
void Ctrl::DoMouseFB(int event, Point p, int zdelta)
{
MousePos = p;
int a = event & Ctrl::ACTION;
if(a == Ctrl::UP && Ctrl::ignoreclick) {
EndIgnore();
return;
}
else
if(a == Ctrl::DOWN && ignoreclick)
return;
LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
if(captureCtrl)
MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta);
else
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
Ptr<Ctrl> t = topctrl[i];
Rect rr = t->GetRect();
if(rr.Contains(p)) {
MouseEventFB(t, event, p, zdelta);
return;
}
}
Ctrl *desktop = GetDesktop();
if(desktop) {
desktop->DispatchMouse(event, p, zdelta);
desktop->PostInput();
}
}
bool Ctrl::DoKeyFB(dword key, int cnt)
{
DLOG("DoKeyFB " << GetKeyDesc(key) << ", " << cnt);
@ -244,7 +214,7 @@ void Ctrl::PaintCaretCursor(SystemDraw& draw)
}
void Ctrl::DoPaint()
{
{
if(!PaintLock) {
if(invalid && desktop) {
invalid = false;
@ -256,17 +226,43 @@ void Ctrl::DoPaint()
}
}
void Ctrl::DoMouseFB(int event, Point p, int zdelta, CParser& cp)
{
mouseButtons = cp.ReadInt();
MousePos = p;
int a = event & ACTION;
if(a == UP && Ctrl::ignoreclick) {
EndIgnore();
return;
}
else
if(a == DOWN && ignoreclick)
return;
DLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
if(captureCtrl)
MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta);
else
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
Ptr<Ctrl> t = topctrl[i];
Rect rr = t->GetRect();
if(rr.Contains(p)) {
MouseEventFB(t, event, p, zdelta);
return;
}
}
Ctrl *desktop = GetDesktop();
if(desktop) {
desktop->DispatchMouse(event, p, zdelta);
desktop->PostInput();
}
}
void Ctrl::DoMouseButton(int event, CParser& p)
{
int button = p.ReadInt();
int x = p.ReadInt();
int y = p.ReadInt();
DoMouseFB(decode(button, 0, LEFT, 2, RIGHT, MIDDLE)|event, Point(x, y));
}
void Ctrl::ReadMouseButtons(CParser& p)
{
mouseButtons = p.ReadInt();
DoMouseFB(decode(button, 0, LEFT, 2, RIGHT, MIDDLE)|event, Point(x, y), 0, p);
}
bool Ctrl::ProcessEventQueue(const String& event_queue)
@ -282,17 +278,14 @@ bool Ctrl::ProcessEventQueue(const String& event_queue)
if(p.Id("M")) {
int x = p.ReadInt();
int y = p.ReadInt();
ReadMouseButtons(p);
DoMouseFB(MOUSEMOVE, Point(x, y), 0);
DoMouseFB(MOUSEMOVE, Point(x, y), 0, p);
}
else
if(p.Id("D")) {
ReadMouseButtons(p);
DoMouseButton(DOWN, p);
}
else
if(p.Id("U")) {
ReadMouseButtons(p);
DoMouseButton(UP, p);
}
else
@ -332,9 +325,12 @@ void Ctrl::Reply()
SweepMkImageCache();
DoPaint();
if(http.GetURI().GetCount() < 2)
HttpResponse(socket, http.scgi, 200, "OK", "text/html", String(telpp_html, telpp_html_length));
else
HttpResponse(socket, http.scgi, 200, "OK", "text/plain; charset=x-user-defined", content);
HttpResponse(socket, http.scgi, 200, "OK", "text/html", String(telpp_html, telpp_html_length)); // This is weird place, but whatever
else {
String s = GZCompress(content);
HttpResponse(socket, http.scgi, 200, "OK", "text/plain; charset=x-user-defined",
s, "U++ Tel++ server", true);
}
socket.Close();
}
}

View file

@ -112,7 +112,7 @@ var canvas = document.getElementById("myCanvas");
function key_flags(event)
{
return " " + 1*event.shiftKey + ' ' + 1*event.ctrlKey + ' ' + 1*event.altKey + "\n";
return " " + 1*event.shiftKey + 1*event.ctrlKey + 1*event.altKey + "\n";
}
function mouse_event(event)
@ -134,14 +134,14 @@ canvas.onmousedown = function(event)
canvas.onmouseup = function(event)
{
event_queue += "U " + event.button + mouse_event(event) + "\n";
event_queue += "U " + event.button + mouse_event(event);
Ping();
}
document.onkeydown = function(event)
{
event_queue += "K " + event.keyCode + " " + event.which + key_flags(event);
event.preventDefault();
// event.preventDefault();
Ping();
}
@ -152,6 +152,7 @@ document.onkeypress = function(event)
Ping();
}
document.onkeyup = function(event)
{
event_queue += "k " + event.keyCode + " " + event.which + key_flags(event);

View file

@ -4,8 +4,6 @@ uses
Painter,
CtrlLib;
library(POSIX) "SDL2 SDL2main GL";
file
Telpp.h,
Keys.h,