mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
RichEdit styling keys
git-svn-id: svn://ultimatepp.org/upp/trunk@449 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ff54a6ae7d
commit
d79766aedc
15 changed files with 190 additions and 71 deletions
|
|
@ -278,6 +278,7 @@ void RichEdit::SetupUnits()
|
|||
{
|
||||
WithUnitLayout<TopWindow> d;
|
||||
CtrlLayoutOKCancel(d, t_("Units"));
|
||||
d.accels <<= THISBACK(StyleKeys);
|
||||
for(int i = 1; i <= 10; i++)
|
||||
d.zoom.Add(10 * i, Format(t_("%d%% of width"), 10 * i));
|
||||
CtrlRetriever r;
|
||||
|
|
@ -452,7 +453,7 @@ void RichEdit::SpellCheck()
|
|||
|
||||
void RichEdit::SerializeSettings(Stream& s)
|
||||
{
|
||||
int version = 2;
|
||||
int version = 3;
|
||||
s / version;
|
||||
s % unit;
|
||||
s % showcodes;
|
||||
|
|
@ -467,6 +468,11 @@ void RichEdit::SerializeSettings(Stream& s)
|
|||
s % findreplace.ignorecase;
|
||||
RefreshBar();
|
||||
imagefs.Serialize(s);
|
||||
if(version >= 3)
|
||||
for(int i = 0; i < 20; i++) {
|
||||
StyleKey& k = stylekey[i];
|
||||
s % k.styleid % k.stylename % k.face % k.height % k.ink % k.paper;
|
||||
}
|
||||
}
|
||||
|
||||
void RichEdit::Reset()
|
||||
|
|
|
|||
|
|
@ -135,6 +135,14 @@ bool RichEdit::Key(dword key, int count)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
if(key >= K_ALT_0 && key <= K_ALT_9) {
|
||||
ApplyStyleKey(key - K_ALT_0);
|
||||
return true;
|
||||
}
|
||||
if(key >= (K_SHIFT|K_ALT_0) && key <= (K_SHIFT|K_ALT_9)) {
|
||||
ApplyStyleKey(key - K_SHIFT|K_ALT_0 + 10);
|
||||
return true;
|
||||
}
|
||||
if(key == K_SHIFT_SPACE)
|
||||
key = ' ';
|
||||
if(key == 9 || key >= 32 && key < 65536) {
|
||||
|
|
|
|||
|
|
@ -332,6 +332,17 @@ private:
|
|||
Array<UndoRec> redo;
|
||||
|
||||
FileSel imagefs;
|
||||
|
||||
struct StyleKey {
|
||||
Uuid styleid;
|
||||
String stylename;
|
||||
String face;
|
||||
int height;
|
||||
Color ink;
|
||||
Color paper;
|
||||
};
|
||||
|
||||
StyleKey stylekey[20];
|
||||
|
||||
Rect GetTextRect() const;
|
||||
Size GetZoomedPage() const;
|
||||
|
|
@ -491,10 +502,15 @@ private:
|
|||
void RefreshDropCaret();
|
||||
|
||||
void InsertImage();
|
||||
|
||||
void StyleKeys();
|
||||
void ApplyStyleKey(int i);
|
||||
|
||||
static bool SpellWord(const wchar *wrd, int len, int lang);
|
||||
static void SpellerAdd(const WString& w, int lang);
|
||||
|
||||
friend class StyleKeysDlg;
|
||||
|
||||
protected:
|
||||
enum {
|
||||
TIMEID_ENDSIZETRACKING = Ctrl::TIMEID_COUNT,
|
||||
|
|
@ -611,6 +627,7 @@ public:
|
|||
void TableTools(Bar& bar);
|
||||
|
||||
void InsertImageTool(Bar& bar);
|
||||
void StyleKeysTool(Bar& bar);
|
||||
|
||||
void DefaultBar(Bar& bar, bool extended = true);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,15 +47,16 @@ LAYOUT(ParaLayout, 488, 352)
|
|||
UNTYPED(n[7], LeftPosZ(408, 54).TopPosZ(320, 19))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(UnitLayout, 244, 144)
|
||||
LAYOUT(UnitLayout, 244, 140)
|
||||
ITEM(LabelBox, dv___0, SetLabel(t_("Units")).LeftPosZ(8, 228).TopPosZ(4, 40))
|
||||
ITEM(Switch, unit, SetLabel(t_("dot\npoint\ninch\nmm\ncm")).LeftPosZ(16, 216).TopPosZ(20, 16))
|
||||
ITEM(Label, dv___2, SetLabel(t_("Reveal codes")).LeftPosZ(12, 76).TopPosZ(55, 13))
|
||||
ITEM(Label, dv___2, SetLabel(t_("Reveal codes")).LeftPosZ(8, 76).TopPosZ(52, 20))
|
||||
ITEM(ColorPusher, showcodes, LeftPosZ(92, 144).TopPosZ(52, 19))
|
||||
ITEM(Label, dv___4, SetLabel(t_("Zoom")).LeftPosZ(12, 76).TopPosZ(80, 19))
|
||||
ITEM(Label, dv___4, SetLabel(t_("Zoom")).LeftPosZ(8, 76).TopPosZ(80, 19))
|
||||
ITEM(DropList, zoom, LeftPosZ(92, 144).TopPosZ(80, 19))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(104, 64).TopPosZ(112, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(172, 64).TopPosZ(112, 24))
|
||||
ITEM(Button, accels, SetLabel(t_("Style keys")).LeftPosZ(8, 76).TopPosZ(108, 24))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(104, 64).TopPosZ(108, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(172, 64).TopPosZ(108, 24))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(SetStyleLayout, 216, 280)
|
||||
|
|
@ -201,3 +202,9 @@ LAYOUT(CellPropertiesLayout, 300, 260)
|
|||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(232, 64).TopPosZ(232, 24))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(StyleKeysLayout, 736, 556)
|
||||
ITEM(ArrayCtrl, list, LeftPosZ(8, 720).TopPosZ(8, 508))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(596, 64).TopPosZ(524, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(664, 64).TopPosZ(524, 24))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ file
|
|||
Find.cpp optimize_speed,
|
||||
Tool.cpp,
|
||||
Clip.cpp,
|
||||
StyleKeys.cpp,
|
||||
RichEdit.t charset "UTF-8",
|
||||
RichEdit.icpp,
|
||||
RichEdit.lay,
|
||||
|
|
|
|||
135
uppsrc/RichEdit/StyleKeys.cpp
Normal file
135
uppsrc/RichEdit/StyleKeys.cpp
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
#include "RichEdit.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
class StyleKeysDlg : public WithStyleKeysLayout<TopWindow> {
|
||||
typedef StyleKeysDlg CLASSNAME;
|
||||
|
||||
Array<DropList> style;
|
||||
Array<DropList> face;
|
||||
Array<DropList> height;
|
||||
Array<ColorPusher> ink;
|
||||
Array<ColorPusher> paper;
|
||||
|
||||
public:
|
||||
void Init(const RichEdit& edit, RichEdit::StyleKey *key);
|
||||
void Retrieve(RichEdit::StyleKey *k);
|
||||
|
||||
StyleKeysDlg();
|
||||
};
|
||||
|
||||
StyleKeysDlg::StyleKeysDlg()
|
||||
{
|
||||
CtrlLayoutOKCancel(*this, "Styling keys");
|
||||
|
||||
list.AddColumn("Key");
|
||||
list.AddColumn("Paragraph style");
|
||||
list.AddColumn("Font");
|
||||
list.AddColumn("Height");
|
||||
list.AddColumn("Ink");
|
||||
list.AddColumn("Paper");
|
||||
list.SetLineCy(EditField::GetStdHeight() + 4);
|
||||
list.NoHorzGrid().EvenRowColor().NoCursor();
|
||||
list.ColumnWidths("117 160 160 75 90 90");
|
||||
}
|
||||
|
||||
void StyleKeysDlg::Init(const RichEdit& edit, RichEdit::StyleKey *key)
|
||||
{
|
||||
const RichText& text = edit.text;
|
||||
for(int i = 0; i < 20; i++) {
|
||||
RichEdit::StyleKey& k = key[i];
|
||||
list.Add((i >= 10 ? "Shift+Alt+" : "Alt+") + AsString(i % 10));
|
||||
|
||||
DropList& st = style.At(i);
|
||||
st.Add(Null);
|
||||
const RichStyles& ts = text.GetStyles();
|
||||
for(int j = 0; j < ts.GetCount(); j++) {
|
||||
st.Add(ts.GetKey(j), ts[j].name);
|
||||
}
|
||||
if(st.FindKey(k.styleid) < 0)
|
||||
st.Add(k.styleid, k.stylename);
|
||||
st <<= k.styleid;
|
||||
list.SetCtrl(i, 1, st, false);
|
||||
|
||||
DropList& fc = face.At(i);
|
||||
fc.Add(Null);
|
||||
for(int j = 0; j < edit.face.GetCount(); j++)
|
||||
fc.Add(Font::GetFaceName(edit.face.GetKey(j)));
|
||||
if(fc.Find(k.face) < 0)
|
||||
fc.Add(k.face);
|
||||
fc <<= k.face;
|
||||
list.SetCtrl(i, 2, fc, false);
|
||||
|
||||
DropList& hg = height.At(i);
|
||||
hg.Add(Null);
|
||||
for(int j = 0; j < edit.height.GetCount(); j++)
|
||||
hg.Add(edit.height.Get(j));
|
||||
if(hg.Find(k.face) < 0)
|
||||
hg.Add(k.face);
|
||||
list.SetCtrl(i, 3, hg, false);
|
||||
|
||||
ColorPusher& n = ink.At(i);
|
||||
n.NullText("");
|
||||
n <<= k.ink;
|
||||
list.SetCtrl(i, 4, n, false);
|
||||
|
||||
ColorPusher& p = paper.At(i);
|
||||
p.NullText("");
|
||||
p <<= k.paper;
|
||||
list.SetCtrl(i, 5, p, false);
|
||||
}
|
||||
}
|
||||
|
||||
void StyleKeysDlg::Retrieve(RichEdit::StyleKey *key)
|
||||
{
|
||||
for(int i = 0; i < 20; i++) {
|
||||
RichEdit::StyleKey& k = key[i];
|
||||
k.styleid = ~style[i];
|
||||
k.stylename = style[i].GetValue();
|
||||
k.face = ~face[i];
|
||||
k.height = ~height[i];
|
||||
k.ink = ~ink[i];
|
||||
k.paper = ~paper[i];
|
||||
}
|
||||
}
|
||||
|
||||
void RichEdit::StyleKeys()
|
||||
{
|
||||
StyleKeysDlg dlg;
|
||||
dlg.Init(*this, stylekey);
|
||||
if(dlg.Run() == IDOK)
|
||||
dlg.Retrieve(stylekey);
|
||||
}
|
||||
|
||||
void RichEdit::ApplyStyleKey(int i)
|
||||
{
|
||||
const StyleKey& k = stylekey[i];
|
||||
if(!IsNull(k.styleid)) {
|
||||
int q = style.FindKey(k.styleid);
|
||||
if(q >= 0) {
|
||||
style.SetIndex(q);
|
||||
Style();
|
||||
}
|
||||
}
|
||||
if(!IsNull(k.face)) {
|
||||
int q = face.FindValue(k.face);
|
||||
if(q >= 0) {
|
||||
face.SetIndex(q);
|
||||
SetFace();
|
||||
}
|
||||
}
|
||||
if(!IsNull(k.height)) {
|
||||
height <<= k.height;
|
||||
SetHeight();
|
||||
}
|
||||
if(!IsNull(k.ink)) {
|
||||
ink <<= k.ink;
|
||||
SetInk();
|
||||
}
|
||||
if(!IsNull(k.paper)) {
|
||||
paper <<= k.paper;
|
||||
SetPaper();
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
@ -413,7 +413,12 @@ void RichEdit::TableTools(Bar& bar)
|
|||
|
||||
void RichEdit::InsertImageTool(Bar& bar)
|
||||
{
|
||||
bar.Add("Insert image from file..", THISBACK(InsertImage));
|
||||
bar.Add(t_("Insert image from file.."), THISBACK(InsertImage));
|
||||
}
|
||||
|
||||
void RichEdit::StyleKeysTool(Bar& bar)
|
||||
{
|
||||
bar.Add(t_("Style keys.."), THISBACK(StyleKeys));
|
||||
}
|
||||
|
||||
void RichEdit::DefaultBar(Bar& bar, bool extended)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _RichEdit_icpp_init_stub
|
||||
#define _RichEdit_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#define BLITZ_INDEX__ F507760F71D06E16B7AC2B30FB35B4251
|
||||
#define BLITZ_INDEX__ F0AD88DAE5AC04DD9AE26D94EEE4D96E1
|
||||
#include "RichEdit.icpp"
|
||||
#undef BLITZ_INDEX__
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
#include "Browser.h"
|
||||
|
||||
class AccelDlg : public WithAccelLayout<TopWindow> {
|
||||
typedef AccelDlg CLASSNAME;
|
||||
|
||||
Array<DropList> style;
|
||||
Array<DropList> font;
|
||||
Array<DropList> height;
|
||||
Array<ColorPusher> ink;
|
||||
Array<ColorPusher> paper;
|
||||
|
||||
public:
|
||||
const RichStyles *textstyles;
|
||||
|
||||
AccelDlg();
|
||||
};
|
||||
|
||||
AccelDlg::AccelDlg()
|
||||
{
|
||||
CtrlLayoutOKCancel(*this, "Styling keys");
|
||||
|
||||
list.AddColumn("Key");
|
||||
list.AddColumn("Paragraph style");
|
||||
list.AddColumn("Font");
|
||||
list.AddColumn("Height");
|
||||
list.AddColumn("Ink");
|
||||
list.AddColumn("Paper");
|
||||
list.SetLineCy(EditField::GetStdHeight() + 2);
|
||||
list.NoGrid().EvenRowColor();
|
||||
|
||||
for(int i = 0; i < 20; i++) {
|
||||
list.Add((i >= 10 ? "Shift+Alt+" : "Alt+") + AsString(i % 10));
|
||||
DropList& st = style.At(i);
|
||||
st.Add(Null, "-");
|
||||
for(int j = 0; j < textstyles->GetCount(); j++)
|
||||
st.Add(textstyles->GetKey(j), (*textstyles)[j].name);
|
||||
list.SetCtrl(i, 1, st);
|
||||
list.SetCtrl(i, 2, font.At(i).Add(Null));
|
||||
list.SetCtrl(i, 3, height.At(i).Add(Null));
|
||||
list.SetCtrl(i, 4, ink.At(i).NullText("<no change>"));
|
||||
list.SetCtrl(i, 5, paper.At(i).NullText("<no change>"));
|
||||
}
|
||||
}
|
||||
|
||||
void TopicEditor::Accels()
|
||||
{
|
||||
AccelDlg dlg;
|
||||
dlg.textstyles = &editor.Get().GetStyles();
|
||||
dlg.Run();
|
||||
}
|
||||
|
|
@ -352,8 +352,6 @@ protected:
|
|||
void InsertItem();
|
||||
|
||||
void FindBrokenRef();
|
||||
|
||||
void Accels();
|
||||
|
||||
public:
|
||||
Callback1<Bar&> WhenTemplatesMenu;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ file
|
|||
Topic.cpp,
|
||||
Template.cpp,
|
||||
Link.cpp,
|
||||
Accels.cpp,
|
||||
TopicWin.cpp,
|
||||
IdeTopic.cpp,
|
||||
TopicI.icpp,
|
||||
|
|
|
|||
|
|
@ -62,10 +62,3 @@ LAYOUT(SaveTemplateLayout, 248, 96)
|
|||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(108, 64).TopPosZ(60, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(176, 64).TopPosZ(60, 24))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(AccelLayout, 736, 556)
|
||||
ITEM(ArrayCtrl, list, LeftPosZ(8, 720).TopPosZ(8, 508))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(596, 64).TopPosZ(524, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(664, 64).TopPosZ(524, 24))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ void TopicEditor::TopicMenu(Bar& bar)
|
|||
"Save as template..", THISBACK(SaveAsTemplate));
|
||||
bar.Add(topic.IsCursor(), "Apply template stylesheet..", THISBACK(ApplyStylesheet));
|
||||
bar.Add("Apply template stylesheet to group..", THISBACK(ApplyStylesheetGroup));
|
||||
bar.Add("Styling keys..", THISBACK(Accels));
|
||||
editor.StyleKeysTool(bar);
|
||||
}
|
||||
|
||||
void TopicEditor::FileBar(Bar& bar)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "ide\Common/init"
|
||||
#include "PdfDraw/init"
|
||||
#include "RichEdit/init"
|
||||
#define BLITZ_INDEX__ FA8D2E284DF16D32149ED216D1C096475
|
||||
#define BLITZ_INDEX__ FBC518112DEEE5BCB5A93FFF277DB6572
|
||||
#include "TopicI.icpp"
|
||||
#undef BLITZ_INDEX__
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
#define IDE_VERSION "808.r135"
|
||||
#define IDE_VERSION "809.r140"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue