mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Adding uppdev....
git-svn-id: svn://ultimatepp.org/upp/trunk@328 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
0fab880126
commit
351994a6cc
2823 changed files with 619073 additions and 0 deletions
9
uppdev/DashEdit/DashEdit.upp
Normal file
9
uppdev/DashEdit/DashEdit.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
CtrlLib,
|
||||
RichEdit;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
82
uppdev/DashEdit/main.cpp
Normal file
82
uppdev/DashEdit/main.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
#include <RichEdit/RichEdit.h>
|
||||
|
||||
struct DashEdit : public RichEdit {
|
||||
virtual void SetData(const Value& data);
|
||||
virtual Value GetData() const;
|
||||
|
||||
Button dash;
|
||||
|
||||
void Dash();
|
||||
|
||||
typedef DashEdit CLASSNAME;
|
||||
|
||||
DashEdit();
|
||||
};
|
||||
|
||||
void DashEdit::Dash()
|
||||
{
|
||||
RichTxt::FormatInfo f = GetFormatInfo();
|
||||
f.charvalid = RichText::DASHED;
|
||||
f.dashed = !f.dashed;
|
||||
ApplyFormatInfo(f);
|
||||
}
|
||||
|
||||
DashEdit::DashEdit()
|
||||
{
|
||||
dash <<= THISBACK(Dash);
|
||||
NoRuler();
|
||||
}
|
||||
|
||||
void DashEdit::SetData(const Value& data)
|
||||
{
|
||||
RichText text;
|
||||
String d = data;
|
||||
RichPara para;
|
||||
RichPara::Format f;
|
||||
for(const char *s = d; *s; s++)
|
||||
if(*s == '\n') {
|
||||
text.Cat(para);
|
||||
para.part.Clear();
|
||||
}
|
||||
else
|
||||
if(*s == '~')
|
||||
f.dashed = !f.dashed;
|
||||
else
|
||||
if((byte)*s >= ' ')
|
||||
para.Cat(String(*s, 1).ToWString(), f);
|
||||
text.Cat(para);
|
||||
Pick(text);
|
||||
}
|
||||
|
||||
Value DashEdit::GetData() const
|
||||
{
|
||||
const RichText& txt = Get();
|
||||
String r;
|
||||
for(int i = 0; i < txt.GetPartCount(); i++) {
|
||||
if(i)
|
||||
r << "\r\n";
|
||||
if(txt.IsPara(i)) {
|
||||
RichPara p = txt.Get(i);
|
||||
for(int j = 0; j < p.GetCount(); j++)
|
||||
if(p.part[j].format.dashed) {
|
||||
r << '~';
|
||||
r << p.part[j].text;
|
||||
r << '~';
|
||||
}
|
||||
else
|
||||
r << p.part[j].text;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
TopWindow win;
|
||||
DashEdit edit;
|
||||
win.Add(edit.SizePos());
|
||||
edit.Add(edit.dash.RightPos(0, 20).BottomPos(0, 20));
|
||||
edit <<= "This is just a ~test~\nof ~dashing\nelements";
|
||||
win.Run();
|
||||
DUMP(edit.GetData());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue