mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
reference: WebWord (Turtle)
git-svn-id: svn://ultimatepp.org/upp/trunk@6856 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2884b6e087
commit
43045b03f8
7 changed files with 218 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
description "Using StatusBar to provide informations at the bottom of the window";
|
||||
description "Using StatusBar to provide informations at the bottom of the window\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
|
|
|||
4
reference/StatusBar/init
Normal file
4
reference/StatusBar/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _StatusBar_icpp_init_stub
|
||||
#define _StatusBar_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#endif
|
||||
93
reference/WebWord/WebWord.cpp
Normal file
93
reference/WebWord/WebWord.cpp
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
#include "WebWord.h"
|
||||
|
||||
String FormatSize(int64 n)
|
||||
{
|
||||
if(n < 10000)
|
||||
return Format("%d B", n);
|
||||
else
|
||||
if(n < 10000 * 1024)
|
||||
return Format("%d.%d KB", n >> 10, (n & 1023) / 103);
|
||||
else
|
||||
if(n < I64(10000000) * 1024)
|
||||
return Format("%d.%d MB", n >> 20, (n & 1023) / 103);
|
||||
else
|
||||
return Format("%d.%d GB", n >> 30, (n & 1023) / 103);
|
||||
}
|
||||
|
||||
|
||||
void WebWord::ShowInfo()
|
||||
{
|
||||
String s;
|
||||
s << "Mem " << MemoryUsedKb() << " KB";
|
||||
#ifdef PLATFORM_TURTLE
|
||||
int secs = GetSysTime() - Ctrl::stat_started;
|
||||
Time tm = Time(1, 1, 1, 0, 0, 0) + secs;
|
||||
s << ", uptime " << Format("%d:%0d:%02d:%02d", tm - Date(1, 1, 1), tm.hour, tm.minute, tm.second);
|
||||
s << ", data sent " << FormatSize(Ctrl::stat_data_send);
|
||||
if(secs)
|
||||
s << ", average bandwidth " << FormatSize(Ctrl::stat_data_send / secs) << "/s";
|
||||
s << ", actual bandwidth " << FormatSize(Ctrl::stat_data_send - sent_prev);
|
||||
s << ", putimage " << Ctrl::stat_putimage;
|
||||
s << ", putrect " << Ctrl::stat_putrect;
|
||||
s << ", setimage " << Ctrl::stat_setimage << " len " << FormatSize(Ctrl::stat_setimage_len);
|
||||
s << ", roundtrip " << Ctrl::stat_roundtrip_ms << " ms";
|
||||
s << ", client " << Ctrl::stat_client_ms << " ms";
|
||||
#ifdef PLATFORM_POSIX
|
||||
s << ", cpu time " << int((double) clock() / CLOCKS_PER_SEC * 1000) << " ms";
|
||||
#endif
|
||||
sent_prev = Ctrl::stat_data_send;
|
||||
statusbar.Set(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
WebWord::WebWord()
|
||||
{
|
||||
AddFrame(statusbar);
|
||||
Add(editor.SizePos());
|
||||
Sizeable().Zoomable();
|
||||
// FrameLess();
|
||||
Maximize();
|
||||
Title("WebWord");
|
||||
Icon(CtrlImg::File());
|
||||
editor.ClearModify();
|
||||
ActiveFocus(editor);
|
||||
SetTimeCallback(-1000, THISBACK(ShowInfo));
|
||||
}
|
||||
|
||||
void Main()
|
||||
{
|
||||
WebWord w;
|
||||
w.Run();
|
||||
}
|
||||
|
||||
#ifdef flagTURTLE
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
MemoryLimitKb(100000000); // Perhaps a good idea to set a limit to prevent DDoS
|
||||
Ctrl::connection_limit = 50; // Maximum number of concurrent users (preventing DDoS)
|
||||
|
||||
#ifdef _DEBUG
|
||||
Ctrl::debugmode = true; // Only single session in debug (no forking)
|
||||
#endif
|
||||
|
||||
// Ctrl::WhenDisconnect = callback(FinishApp); // Use this to gracefully exit (save data?)
|
||||
|
||||
#ifndef _DEBUG
|
||||
Ctrl::host = "eventcraft.eu";
|
||||
#endif
|
||||
|
||||
if(Ctrl::StartSession()) {
|
||||
Main();
|
||||
Ctrl::EndSession();
|
||||
}
|
||||
|
||||
LOG("Session Finished");
|
||||
}
|
||||
#else
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
Main();
|
||||
}
|
||||
#endif
|
||||
22
reference/WebWord/WebWord.h
Normal file
22
reference/WebWord/WebWord.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef _WebWord_WebWord_h_
|
||||
#define _WebWord_WebWord_h_
|
||||
|
||||
#include <RichEdit/RichEdit.h>
|
||||
#include <PdfDraw/PdfDraw.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct WebWord : public TopWindow {
|
||||
public:
|
||||
RichEditWithToolBar editor;
|
||||
StatusBar statusbar;
|
||||
|
||||
void ShowInfo();
|
||||
|
||||
public:
|
||||
typedef WebWord CLASSNAME;
|
||||
|
||||
WebWord();
|
||||
};
|
||||
|
||||
#endif
|
||||
18
reference/WebWord/WebWord.upp
Normal file
18
reference/WebWord/WebWord.upp
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
description "Package demonstrating TURTLE (thin JavaScript client to U++ based GUI server application)\377";
|
||||
|
||||
uses
|
||||
Core,
|
||||
RichEdit,
|
||||
PdfDraw,
|
||||
Turtle;
|
||||
|
||||
uses(TURTLE) plugin/DroidFonts;
|
||||
|
||||
file
|
||||
WebWord.h,
|
||||
WebWord.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "TURTLE",
|
||||
"" = "GUI";
|
||||
|
||||
8
reference/WebWord/init
Normal file
8
reference/WebWord/init
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _WebWord_icpp_init_stub
|
||||
#define _WebWord_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#include "RichEdit/init"
|
||||
#include "PdfDraw/init"
|
||||
#include "Turtle/init"
|
||||
#include "plugin/DroidFonts/init"
|
||||
#endif
|
||||
72
reference/WebWord/test.qtf
Normal file
72
reference/WebWord/test.qtf
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue