mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Developing Tel++
git-svn-id: svn://ultimatepp.org/upp/trunk@6684 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
cdf033a14d
commit
39337c0963
4 changed files with 75 additions and 36 deletions
|
|
@ -36,6 +36,9 @@ private:
|
|||
const byte *pattern, int animation);
|
||||
|
||||
static void DoMouseButton(int event, CParser& p);
|
||||
static void ReadMouseButtons(CParser& p);
|
||||
|
||||
static void Reply();
|
||||
|
||||
friend struct PaintProxy__;
|
||||
friend class TopWindowFrame;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) // LOG(x)
|
||||
#define LLOG(x) // DLOG(x)
|
||||
#define LDUMP(x) // DDUMP(x)
|
||||
#define LTIMING(x)
|
||||
|
||||
|
|
@ -46,7 +46,12 @@ Point GetMousePos() {
|
|||
return MousePos;
|
||||
}
|
||||
|
||||
dword mouseb = 0;
|
||||
bool mouseButtons;
|
||||
|
||||
bool GetMouseLeft() { return mouseButtons & 1; }
|
||||
bool GetMouseRight() { return mouseButtons & 2; }
|
||||
bool GetMouseMiddle() { return mouseButtons & 4; }
|
||||
|
||||
dword modkeys = 0;
|
||||
|
||||
enum KM {
|
||||
|
|
@ -67,9 +72,6 @@ enum KM {
|
|||
KM_ALT = KM_LALT | KM_RALT,
|
||||
};
|
||||
|
||||
bool GetMouseLeft() { return mouseb & (1<<0); }
|
||||
bool GetMouseRight() { return mouseb & (1<<1); }
|
||||
bool GetMouseMiddle() { return mouseb & (1<<2); }
|
||||
bool GetShift() { return modkeys & KM_SHIFT; }
|
||||
bool GetCtrl() { return modkeys & KM_CTRL; }
|
||||
bool GetAlt() { return modkeys & KM_ALT; }
|
||||
|
|
@ -262,6 +264,11 @@ void Ctrl::DoMouseButton(int event, CParser& p)
|
|||
DoMouseFB(decode(button, 0, LEFT, 2, RIGHT, MIDDLE)|event, Point(x, y));
|
||||
}
|
||||
|
||||
void Ctrl::ReadMouseButtons(CParser& p)
|
||||
{
|
||||
mouseButtons = p.ReadInt();
|
||||
}
|
||||
|
||||
bool Ctrl::ProcessEventQueue(const String& event_queue)
|
||||
{
|
||||
StringStream ss(event_queue);
|
||||
|
|
@ -275,14 +282,19 @@ 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);
|
||||
}
|
||||
else
|
||||
if(p.Id("D"))
|
||||
if(p.Id("D")) {
|
||||
ReadMouseButtons(p);
|
||||
DoMouseButton(DOWN, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("U"))
|
||||
if(p.Id("U")) {
|
||||
ReadMouseButtons(p);
|
||||
DoMouseButton(UP, p);
|
||||
}
|
||||
else
|
||||
if(p.Id("K")) {
|
||||
int code = p.ReadInt();
|
||||
|
|
@ -307,23 +319,40 @@ bool Ctrl::ProcessEventQueue(const String& event_queue)
|
|||
return true;
|
||||
}
|
||||
|
||||
HttpHeader http;
|
||||
|
||||
void Ctrl::Reply()
|
||||
{
|
||||
GuiLock __;
|
||||
if(socket.IsOpen()) {
|
||||
TimerProc(GetTickCount());
|
||||
DefferedFocusSync();
|
||||
SyncCaret();
|
||||
SyncTopWindows();
|
||||
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);
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
|
||||
bool Ctrl::IsWaitingEvent()
|
||||
{
|
||||
// LLOG("IsWaitingEvent");
|
||||
if(socket.IsOpen())
|
||||
return true;
|
||||
GuiLock __;
|
||||
Reply();
|
||||
return socket.Timeout(0).Accept(server);
|
||||
}
|
||||
|
||||
bool Ctrl::ProcessEvents(bool *quit)
|
||||
{
|
||||
GuiLock __;
|
||||
LLOG("ProcessEvents");
|
||||
if(!socket.IsOpen()) {
|
||||
if(!IsWaitingEvent())
|
||||
return false;
|
||||
}
|
||||
if(!IsWaitingEvent())
|
||||
return false;
|
||||
|
||||
HttpHeader http;
|
||||
TimeStop tm;
|
||||
LLOG("Trying to read socket");
|
||||
socket.Timeout(20000);
|
||||
|
|
@ -338,29 +367,18 @@ bool Ctrl::ProcessEvents(bool *quit)
|
|||
content.Clear();
|
||||
bool r = ProcessEventQueue(event_queue);
|
||||
_TODO_ // Resolve eventloop exit issue
|
||||
TimerProc(GetTickCount());
|
||||
DefferedFocusSync();
|
||||
SyncCaret();
|
||||
SyncTopWindows();
|
||||
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);
|
||||
|
||||
socket.Close();
|
||||
Reply();
|
||||
return r;
|
||||
}
|
||||
|
||||
void Ctrl::EventLoop(Ctrl *ctrl)
|
||||
{
|
||||
GuiLock __;
|
||||
Reply();
|
||||
ASSERT(IsMainThread());
|
||||
ASSERT(LoopLevel == 0 || ctrl);
|
||||
LoopLevel++;
|
||||
LLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN);
|
||||
DLOG("Entering event loop at level " << LoopLevel << LOG_BEGIN);
|
||||
Ptr<Ctrl> ploop;
|
||||
if(ctrl) {
|
||||
ploop = LoopCtrl;
|
||||
|
|
@ -391,6 +409,7 @@ void Ctrl::EventLoop(Ctrl *ctrl)
|
|||
void Ctrl::GuiSleep(int ms)
|
||||
{
|
||||
GuiLock __;
|
||||
Reply();
|
||||
ASSERT(IsMainThread());
|
||||
// LLOG("GuiSleep");
|
||||
int level = LeaveGuiMutexAll();
|
||||
|
|
|
|||
|
|
@ -110,40 +110,53 @@ window.event_queue = "I\n";
|
|||
|
||||
var canvas = document.getElementById("myCanvas");
|
||||
|
||||
function key_flags(event)
|
||||
{
|
||||
return " " + 1*event.shiftKey + ' ' + 1*event.ctrlKey + ' ' + 1*event.altKey + "\n";
|
||||
}
|
||||
|
||||
function mouse_event(event)
|
||||
{
|
||||
return " " + event.clientX + " " + event.clientY + " " + event.buttons + key_flags(event);
|
||||
}
|
||||
|
||||
canvas.onmousemove = function(event)
|
||||
{
|
||||
event_queue += "M " + event.clientX + " " + event.clientY + "\n";
|
||||
event_queue += "M" + mouse_event(event);
|
||||
Ping();
|
||||
}
|
||||
|
||||
canvas.onmousedown = function(event)
|
||||
{
|
||||
event_queue += "D " + event.button + " " + event.clientX + " " + event.clientY + "\n";
|
||||
event_queue += "D " + event.button + mouse_event(event);
|
||||
Ping();
|
||||
}
|
||||
|
||||
canvas.onmouseup = function(event)
|
||||
{
|
||||
event_queue += "U " + event.button + " " + event.clientX + " " + event.clientY + "\n";
|
||||
event_queue += "U " + event.button + mouse_event(event) + "\n";
|
||||
Ping();
|
||||
}
|
||||
|
||||
document.onkeydown = function(event)
|
||||
{
|
||||
event_queue += "K " + event.keyCode + " " + event.which + "\n";
|
||||
event_queue += "K " + event.keyCode + " " + event.which + key_flags(event);
|
||||
event.preventDefault();
|
||||
Ping();
|
||||
}
|
||||
|
||||
document.onkeypress = function(event)
|
||||
{
|
||||
event_queue += "C " + event.keyCode + " " + event.which + "\n";
|
||||
event_queue += "C " + event.keyCode + " " + event.which + key_flags(event);
|
||||
event.preventDefault();
|
||||
Ping();
|
||||
}
|
||||
|
||||
document.onkeyup = function(event)
|
||||
{
|
||||
event_queue += "k " + event.keyCode + " " + event.which + "\n";
|
||||
event_queue += "k " + event.keyCode + " " + event.which + key_flags(event);
|
||||
event.preventDefault();
|
||||
Ping();
|
||||
}
|
||||
|
||||
function ResizeCanvas()
|
||||
|
|
@ -152,7 +165,7 @@ function ResizeCanvas()
|
|||
canvas.height = window.innerHeight;
|
||||
}
|
||||
|
||||
window.onresize = ResizeCanvas();
|
||||
window.onresize = ResizeCanvas;
|
||||
|
||||
var Processing = false;
|
||||
var timerID;
|
||||
|
|
|
|||
|
|
@ -264,6 +264,10 @@ GUI_APP_MAIN
|
|||
|
||||
SetLanguage(LNG_ENGLISH);
|
||||
SetDefaultCharset(CHARSET_UTF8);
|
||||
|
||||
String xxx;
|
||||
EditText(xxx, "Edit", "Edit");
|
||||
return;
|
||||
|
||||
UWordFs().Type("QTF files", "*.qtf")
|
||||
.AllFilesType()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue