RichEdit: DarkContent, AllowDarkContent

This commit is contained in:
Mirek Fidler 2024-12-26 14:25:32 +01:00
parent 024da56097
commit a3e6c1d919
15 changed files with 91 additions and 917 deletions

View file

@ -258,6 +258,7 @@ UWord::UWord()
static int doc; static int doc;
Title(Format("Document%d", ++doc)); Title(Format("Document%d", ++doc));
Icon(CtrlImg::File()); Icon(CtrlImg::File());
editor.AllowDarkContent();
editor.ClearModify(); editor.ClearModify();
SetBar(); SetBar();
editor.WhenRefreshBar = THISBACK(SetBar); editor.WhenRefreshBar = THISBACK(SetBar);

View file

@ -50,9 +50,17 @@ Color ColorPopUp::hint[18];
ColorPopUp& ColorPopUp::DarkContent(bool b) ColorPopUp& ColorPopUp::DarkContent(bool b)
{ {
dark = b;
wheel.DarkContent(b); wheel.DarkContent(b);
ramp.DarkContent(b); ramp.DarkContent(b);
Refresh();
return *this;
}
ColorPopUp& ColorPopUp::AllowDarkContent(bool b)
{
wheel.AllowDarkContent(b);
ramp.AllowDarkContent(b);
Refresh();
return *this; return *this;
} }
@ -201,6 +209,7 @@ void ColorPopUp::Paint(Draw& w)
} }
int i = 0; int i = 0;
bool dark = IsDarkContent();
for(;;) { for(;;) {
for(int x = 0; x < 18 * DPI(16); x += DPI(16)) { for(int x = 0; x < 18 * DPI(16); x += DPI(16)) {
if(i >= GetColorCount()) { if(i >= GetColorCount()) {

View file

@ -24,7 +24,7 @@ void ColorPusher::Paint(Draw& w)
w.DrawRect(x + cx / 2, y, cx - cx / 2, cy, DarkTheme(c)); w.DrawRect(x + cx / 2, y, cx - cx / 2, cy, DarkTheme(c));
} }
else else
w.DrawRect(x, y, cx, cy, color); w.DrawRect(x, y, cx, cy, colors.IsDarkContent() ? DarkTheme(color) : color);
}; };
if(withtext || withhex) { if(withtext || withhex) {
DrawColor(2, 2, sz.cy - 4, sz.cy - 4); DrawColor(2, 2, sz.cy - 4, sz.cy - 4);
@ -145,7 +145,7 @@ void ColorButton::Paint(Draw& w)
if(IsNull(color)) if(IsNull(color))
w.DrawImage(center.x + push, center.y + push, nullimage); w.DrawImage(center.x + push, center.y + push, nullimage);
else else
w.DrawImage(center.x + push, center.y + push, image, color); w.DrawImage(center.x + push, center.y + push, image, colors.IsDarkContent() ? DarkTheme(color) : color);
w.DrawImage(center.x + push, center.y + push, staticimage); w.DrawImage(center.x + push, center.y + push, staticimage);
} }

View file

@ -65,41 +65,6 @@ LAYOUT(FileSelectorLayout, 652, 488)
ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 68).BottomPosZ(8, 24)) ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 68).BottomPosZ(8, 24))
END_LAYOUT END_LAYOUT
LAYOUT(PaletteLayout, 216, 332)
ITEM(Upp::TabCtrl, palette_tab, HSizePosZ(4, 4).VSizePosZ(4, 82))
ITEM(Upp::Label, dv___1, SetLabel(t_("Color:")).LeftPosZ(4, 36).BottomPosZ(52, 24))
ITEM(Upp::DataPusher, color, HSizePosZ(68, 32).BottomPosZ(54, 22))
ITEM(Upp::Button, set_transparent, RightPosZ(4, 18).BottomPosZ(56, 18))
UNTYPED(fetch_color, RightPosZ(4, 18).BottomPosZ(30, 18))
ITEM(Upp::Label, dv___5, SetLabel(t_("R:")).LeftPosZ(4, 12).BottomPosZ(29, 19))
ITEM(Upp::EditIntSpin, r, LeftPosZ(16, 44).BottomPosZ(29, 19))
ITEM(Upp::Label, dv___7, SetLabel(t_("G:")).LeftPosZ(72, 12).BottomPosZ(29, 19))
ITEM(Upp::EditIntSpin, g, LeftPosZ(84, 44).BottomPosZ(29, 19))
ITEM(Upp::Label, dv___9, SetLabel(t_("B:")).LeftPosZ(136, 12).BottomPosZ(29, 19))
ITEM(Upp::EditIntSpin, b, LeftPosZ(150, 42).BottomPosZ(29, 19))
ITEM(Upp::Label, dv___11, SetLabel(t_("H:")).LeftPosZ(4, 12).BottomPosZ(5, 19))
ITEM(Upp::EditIntSpin, h, LeftPosZ(16, 44).BottomPosZ(5, 19))
ITEM(Upp::Label, dv___13, SetLabel(t_("S:")).LeftPosZ(72, 12).BottomPosZ(5, 19))
ITEM(Upp::EditIntSpin, s, LeftPosZ(84, 44).BottomPosZ(5, 19))
ITEM(Upp::Label, dv___15, SetLabel(t_("V:")).LeftPosZ(136, 12).BottomPosZ(5, 19))
ITEM(Upp::EditIntSpin, v, LeftPosZ(148, 44).BottomPosZ(5, 19))
END_LAYOUT
LAYOUT(PaletteSelectorLayout, 248, 320)
ITEM(Ctrl, palette, HSizePosZ(4, 4).VSizePosZ(4, 32))
ITEM(Upp::Button, ok, SetLabel(t_("OK")).RightPosZ(88, 80).BottomPosZ(4, 22))
ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22))
END_LAYOUT
LAYOUT(PalCtrlSizeLayout, 206, 60)
ITEM(Upp::Label, dv___0, SetLabel(t_("&Rows:")).LeftPosZ(4, 44).TopPosZ(4, 19))
ITEM(Upp::EditIntSpin, rows, LeftPosZ(48, 50).TopPosZ(4, 19))
ITEM(Upp::Label, dv___2, SetLabel(t_("&Columns:")).LeftPosZ(108, 44).TopPosZ(4, 19))
ITEM(Upp::EditIntSpin, columns, LeftPosZ(152, 50).TopPosZ(4, 19))
ITEM(Upp::Button, ok, SetLabel(t_("OK")).RightPosZ(88, 80).BottomPosZ(4, 22))
ITEM(Upp::Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22))
END_LAYOUT
LAYOUT(KeysLayout, 604, 500) LAYOUT(KeysLayout, 604, 500)
ITEM(Upp::ArrayCtrl, group, LeftPosZ(8, 116).TopPosZ(8, 452)) ITEM(Upp::ArrayCtrl, group, LeftPosZ(8, 116).TopPosZ(8, 452))
ITEM(Upp::ArrayCtrl, keys, LeftPosZ(132, 464).TopPosZ(8, 452)) ITEM(Upp::ArrayCtrl, keys, LeftPosZ(132, 464).TopPosZ(8, 452))

View file

@ -1,86 +1,7 @@
#include "CtrlLib.h" #include "CtrlLib.h"
namespace Upp { namespace Upp {
class FetchColorCtrl : public Button
{
public:
FetchColorCtrl();
void SetData(const Value& v);
Value GetData() const;
virtual void LeftDown(Point pt, dword keyflags);
virtual void MouseMove(Point pt, dword keyflags);
virtual bool Key(dword key, int repcnt);
virtual Image CursorImage(Point pt, dword keyflags);
private:
Color user_color;
Color std_color;
};
FetchColorCtrl::FetchColorCtrl()
{
SetImage(CtrlImg::fetch_color());
}
void FetchColorCtrl::SetData(const Value& v)
{
if(IsNull(user_color))
std_color = v;
}
Value FetchColorCtrl::GetData() const
{
return Nvl(user_color, std_color);
}
void FetchColorCtrl::LeftDown(Point pt, dword keyflags)
{
Button::LeftDown(pt, keyflags);
SetCapture();
SetWantFocus();
}
void FetchColorCtrl::MouseMove(Point pt, dword keyflags)
{
if(keyflags & K_MOUSELEFT)
{
if(Rect(GetSize()).Contains(pt))
{
user_color = Null;
Action();
}
else
{
pt += GetScreenView().TopLeft();
user_color = GuiPlatformGetScreenPixel(pt.x, pt.y);
Action();
}
}
Button::MouseMove(pt, keyflags);
}
bool FetchColorCtrl::Key(dword key, int repcnt)
{
if(key == K_ESCAPE && HasCapture())
{
ReleaseCapture();
user_color = Null;
Action();
return true;
}
return Button::Key(key, repcnt);
}
Image FetchColorCtrl::CursorImage(Point pt, dword keyflags)
{
if(keyflags & K_MOUSELEFT)
return CtrlImg::fetch_color_cursor();
return Button::CursorImage(pt, keyflags);
}
const Display& StdColorDisplayNull() const Display& StdColorDisplayNull()
{ {
static ColorDisplayNull display(t_("(no color)")); static ColorDisplayNull display(t_("(no color)"));
@ -467,7 +388,6 @@ enum { PREC = 64 };
Image WheelRampCtrl::PaintRamp(Size size) Image WheelRampCtrl::PaintRamp(Size size)
{ {
DTIMING("Ramp");
ImageDraw iw(size); ImageDraw iw(size);
ImageBuffer ib(PREC, PREC); ImageBuffer ib(PREC, PREC);
for(int y = 0; y < PREC; y++) { for(int y = 0; y < PREC; y++) {
@ -476,7 +396,7 @@ Image WheelRampCtrl::PaintRamp(Size size)
for(int x = 0; x < PREC; x++) { for(int x = 0; x < PREC; x++) {
int s16 = iscale(x, 65535, PREC - 1); int s16 = iscale(x, 65535, PREC - 1);
Color c = HSV16toRGB(h16, s16, v16); Color c = HSV16toRGB(h16, s16, v16);
if(dark) if(IsDarkContent())
c = DarkTheme(c); c = DarkTheme(c);
scan->r = GetRRaw(c); scan->r = GetRRaw(c);
scan->g = GetGRaw(c); scan->g = GetGRaw(c);
@ -492,7 +412,6 @@ Image WheelRampCtrl::PaintRamp(Size size)
Image WheelRampCtrl::PaintWheel(Size size) Image WheelRampCtrl::PaintWheel(Size size)
{ {
DTIMING("Wheel");
ImageBuffer ib(PREC, PREC); ImageBuffer ib(PREC, PREC);
static WheelBuff wb[PREC * PREC]; static WheelBuff wb[PREC * PREC];
ONCELOCK { ONCELOCK {
@ -515,7 +434,7 @@ Image WheelRampCtrl::PaintWheel(Size size)
RGBA *scan = ib[y]; RGBA *scan = ib[y];
for(int x = 0; x < PREC; x++) { for(int x = 0; x < PREC; x++) {
Color c = HSV16toRGB(cwb->arg, cwb->l, v16); Color c = HSV16toRGB(cwb->arg, cwb->l, v16);
if(dark) if(IsDarkContent())
c = DarkTheme(c); c = DarkTheme(c);
*scan++ = c; *scan++ = c;
cwb++; cwb++;
@ -549,7 +468,7 @@ void WheelRampCtrl::PaintColumn(Draw& draw)
int factor = ClientToLevel(i); int factor = ClientToLevel(i);
Color c = ramp ? HSV16toRGB(factor, 65535, 65535) : HSV16toRGB(h16, s16, factor); Color c = ramp ? HSV16toRGB(factor, 65535, 65535) : HSV16toRGB(h16, s16, factor);
// : Color(iscale(nr, factor, 65536), iscale(ng, factor, 65536), iscale(nb, factor, 65536)); // : Color(iscale(nr, factor, 65536), iscale(ng, factor, 65536), iscale(nb, factor, 65536));
draw.DrawRect(column_rect.left, i, size.cx, 1, dark ? DarkThemeCached(c) : c); draw.DrawRect(column_rect.left, i, size.cx, 1, IsDarkContent() ? DarkThemeCached(c) : c);
} }
} }
@ -908,714 +827,4 @@ static void InitColor(Color *out)
out[15] = Color(0x00, 0xFF, 0xFF); out[15] = Color(0x00, 0xFF, 0xFF);
}; };
PalCtrl::Config& PalCtrl::GlobalConfig()
{
static PalCtrl::Config x;
return x;
}
typedef Index<PalCtrl *> PalCtrlIndex;
PalCtrlIndex& PalCtrl::GetActive()
{
static PalCtrlIndex x;
return x;
}
PalCtrl::PalCtrl()
{
color = Null;
color_index = -1;
swap_index = -1;
cellcount = Size(4, 4);
Transparent();
}
PalCtrl::~PalCtrl()
{
GetActive().RemoveKey(this);
}
Vector<Color> PalCtrl::GetPalette()
{
int count = MAXSIZE;
while(count > 0 && IsNull(GlobalConfig().current[count - 1]))
count--;
Vector<Color> out;
out.SetCount(count);
for(int i = 0; i < count; i++)
out[i] = GlobalConfig().current[i];
return out;
}
void PalCtrl::SetPalette(const Vector<Color>& pal)
{
for(int n = min<int>(pal.GetCount(), MAXSIZE), i = 0; i < n; i++)
GlobalConfig().current[i] = pal[i];
PalCtrlIndex& active = GetActive();
for(int c = 0; c < active.GetCount(); c++)
active[c]->Refresh();
}
void PalCtrl::SerializePalette(Stream& stream)
{
int version = StreamHeading(stream, 1, 1, 1, "PalCtrl::Palette");
if(version >= 1)
{
int count = cellcount.cx * cellcount.cy;
stream / count;
for(int i = 0; i < count; i++)
stream % GlobalConfig().current[i];
}
}
INITBLOCK
{
RegisterGlobalConfig("PalCtrl", callback(&PalCtrl::FlushConfig));
}
void PalCtrl::Config::Serialize(Stream& stream)
{
if(stream.IsLoading() && stream.IsEof())
return;
int version = 1;
stream / version;
if(stream.IsError() || version < 1 || version > 1)
{
stream.SetError();
return;
}
int count = __countof(current);
stream / count;
count = min<int>(count, MAXSIZE);
for(int i = 0; i < count; i++)
stream % current[i];
stream % lastsize % lastfile;
}
void PalCtrl::Load()
{
Config& gc = GlobalConfig();
if(!gc.loaded)
{
gc.loaded = true;
InitColor(gc.current);
LoadFromGlobal(gc, "PalCtrl");
cellcount = gc.lastsize;
Layout();
UpdateColorIndex();
}
}
void PalCtrl::SetData(const Value& value)
{
if(Color(value) != color)
{
color = value;
UpdateColorIndex();
UpdateRefresh();
}
}
void PalCtrl::UpdateColorIndex()
{
Config& gc = GlobalConfig();
if(gc.loaded)
color_index =(int)( UPP::Find(gc.current,
gc.current + __countof(gc.current), color, StdEqual<int>()) - gc.current);
}
void PalCtrl::Layout()
{
cell = max((GetSize() - 2 * OGAP - (cellcount + 1) * IGAP) / cellcount, Size(2, 2));
step = cell + IGAP;
offset = (GetSize() - cellcount * step + IGAP) >> 1;
Refresh();
}
void PalCtrl::Paint(Draw& draw)
{
Load();
GetActive().FindAdd(this);
draw.Begin();
Size tcell = GetTextSize("256", StdFont());
bool do_text = (tcell.cx <= cell.cx && tcell.cy <= cell.cy);
for(int i = 0, n = cellcount.cx * cellcount.cy; i < n; i++)
{
Rect rc = IndexToClient(i);
DrawFrame(draw, rc, White, Black);
rc.Deflate(1);
Color c = Nvl(GlobalConfig().current[i], SColorFace);
draw.DrawRect(rc, c);
if(do_text)
{
int brightness = 3 * c.GetR() + 6 * c.GetG() + 1 * c.GetB();
Color ink = (brightness <= 1280 ? White : Black);
draw.DrawText(rc.left + 2, rc.top + 2, IntStr(i + 1), StdFont(), ink);
}
rc.Inflate(1);
draw.ExcludeClip(rc);
}
if(color_index >= 0)
{
Rect selected = IndexToClient(color_index);
selected.Inflate(3);
DrawFatFrame(draw, selected, SColorMark(), 2);
}
draw.End();
}
void PalCtrl::LeftDown(Point pt, dword keyflags)
{
swap_index = ClientToIndex(pt);
if(swap_index < 0)
return;
if(keyflags & K_CTRL)
{
set_index = swap_index;
swap_index = -1;
OnSetColor();
return;
}
color = GlobalConfig().current[swap_index];
color_index = swap_index;
UpdateActionRefresh();
SetCapture();
}
void PalCtrl::LeftUp(Point pt, dword keyflags)
{
ReleaseCapture();
int i = ClientToIndex(pt);
if(i < 0 || swap_index < 0 || i == swap_index)
{
swap_index = -1;
return;
}
Swap(GlobalConfig().current[swap_index], GlobalConfig().current[i]);
color_index = i;
swap_index = -1;
UpdateActionRefresh();
}
Image PalCtrl::CursorImage(Point pt, dword keyflags)
{
if(swap_index >= 0)
return CtrlImg::swap_color_cursor();
return Image::Arrow();
}
void PalCtrl::RightDown(Point pt, dword keyflags)
{
MenuBar bar;
set_index = ClientToIndex(pt);
bar.Add(set_index >= 0 && !IsNull(color), t_("Set color"), THISBACK(OnSetColor))
.Help(t_("Write current color to selected palette slot"));
bar.Add(t_("Default palette"), THISBACK(OnStandard))
.Help(t_("Restore default system palette"));
bar.MenuSeparator();
bar.Add(t_("Save as.."), THISBACK(OnSave))
.Help(t_("Store palette information into a disk file"));
bar.Add(t_("Load"), THISBACK(OnLoad))
.Help(t_("Load previously saved palette"));
bar.MenuSeparator();
bool is_small = (cellcount.cx == 4 && cellcount.cy == 4);
bool is_medium = (cellcount.cx == 8 && cellcount.cy == 8);
bool is_large = (cellcount.cx == 16 && cellcount.cy == 16);
bar.Add(t_("Small"), THISBACK(OnSizeSmall))
.Check(is_small)
.Help(t_("Set up palette size 4 times 4 colors"));
bar.Add(t_("Medium"), THISBACK(OnSizeMedium))
.Check(is_medium)
.Help(t_("Set up palette size 8 times 8 colors"));
bar.Add(t_("Large"), THISBACK(OnSizeLarge))
.Check(is_large)
.Help(t_("Set up palette size 16 times 16 colors (maximum size)"));
bar.Add(t_("Custom..."), THISBACK(OnSizeCustom))
.Check(!is_small && !is_medium && !is_large)
.Help(t_("Select custom palette size"));
bar.Execute();
}
void PalCtrl::OnSetColor()
{
if(set_index >= 0 && set_index < cellcount.cx * cellcount.cy && !IsNull(color))
{
GlobalConfig().current[set_index] = color;
UpdateRefresh();
PalCtrlIndex& active = GetActive();
for(int i = 0; i < active.GetCount(); i++)
{
PalCtrl *pal = active[i];
if(pal->color_index == set_index && pal->color != color)
{
pal->UpdateColorIndex();
pal->Refresh();
}
}
}
}
void PalCtrl::OnStandard()
{
memcpy(GlobalConfig().current, std_palette, min(sizeof(GlobalConfig().current), sizeof(std_palette)));
PalCtrlIndex& active = GetActive();
for(int i = 0; i < active.GetCount(); i++)
{
PalCtrl *pal = active[i];
pal->UpdateColorIndex();
pal->Refresh();
}
}
void PalCtrl::OnSave()
{
recent_file = SelectFileSaveAs("Palette (*.pal)\n*.pal");
if(recent_file.GetCount())
{
StringStream stream;
SerializePalette(stream);
if(!SaveFile(recent_file, stream))
Exclamation(Format(t_("Error writing file [* \1%s\1]."), recent_file));
}
}
void PalCtrl::OnLoad()
{
recent_file = SelectFileOpen("Palette (*.pal)\n*.pal");
if(recent_file.GetCount())
{
FileIn fi(recent_file);
if(!fi.IsOpen())
{
Exclamation(Format(t_("Error opening file [* \1%s\1]."), recent_file));
return;
}
SerializePalette(fi);
fi.Close();
if(fi.IsError())
{
Exclamation(Format(t_("Error reading palette from file [* \1%s\1]."), recent_file));
return;
}
Refresh();
}
}
void PalCtrl::OnSizeSmall()
{
GlobalConfig().lastsize = cellcount = Size(4, 4);
Layout();
}
void PalCtrl::OnSizeMedium()
{
GlobalConfig().lastsize = cellcount = Size(8, 8);
Layout();
}
void PalCtrl::OnSizeLarge()
{
GlobalConfig().lastsize = cellcount = Size(16, 16);
Layout();
}
//RegisterHelpTopicObjectTitle(DlgPalCtrlSize, s_(PalCtrlSizeCustomDlgTitle))
void PalCtrl::OnSizeCustom()
{
WithPalCtrlSizeLayout<TopWindow> dlg;
// CtrlLayoutOKCancel(dlg, DlgPalCtrlSizeHelpTitle());
CtrlLayoutOKCancel(dlg, t_("Palette dimensions"));
dlg.HelpTopic("DlgPalCtrlSize");
dlg.rows <<= cellcount.cy;
dlg.columns <<= cellcount.cx;
dlg.rows.NotNull().MinMax(1, 16);
dlg.columns.NotNull().MinMax(1, 16);
if(dlg.Run() == IDOK)
{
cellcount.cx = ~dlg.columns;
cellcount.cy = ~dlg.rows;
GlobalConfig().lastsize = cellcount;
Layout();
}
}
int PalCtrl::ClientToIndex(Point pt) const
{
Size rel = pt - offset + (IGAP / 2);
Point div = idivfloor(rel, step);
if(div.x < 0 || div.x >= cellcount.cx || div.y < 0 || div.y >= cellcount.cy)
return -1;
return div.x * cellcount.cy + div.y;
}
Rect PalCtrl::IndexToClient(int index) const
{
if(index < 0 || index >= cellcount.cx * cellcount.cy)
return Rect(Null);
return Rect(Size(index / cellcount.cy, index % cellcount.cy) * step + offset, cell);
}
//////////////////////////////////////////////////////////////////////
// ColorSelectorImpl::
class ColorSelectorImpl : public WithPaletteLayout<TopWindow>, public ColorSelector::Impl
{
public:
typedef ColorSelectorImpl CLASSNAME;
ColorSelectorImpl(ColorSelector& parent);
virtual ~ColorSelectorImpl();
void Attach(Ctrl& parent);
virtual void Set(Color color);
virtual Color Get() const;
virtual void NotNull(bool _nn = true);
virtual bool IsNotNull() const;
virtual Vector<Color> GetPalette() const;
virtual void SetPalette(const Vector<Color>& pal);
virtual void SerializeConfig(Stream& stream);
virtual Ctrl& GetCtrl() { return *this; }
public:
FetchColorCtrl fetch_color;
private:
void SetAction(Color color);
void SetRaw();
void UpdateRGB();
void UpdateHSV();
void OnRGB();
void OnHSV();
// void OnColor();
void OnSetTransparent();
void OnWheelCtrl();
void OnRampCtrl();
void OnRGBCtrl();
void OnHSVCtrl();
void OnPalCtrl();
void OnFetchColor();
protected:
// WithPaletteLayout<Ctrl> dialog;
ColorDisplayNull paint_color_display;
private:
ColorSelector& parent;
Color colorval;
WheelRampCtrl wheel;
WheelRampCtrl ramp;
RGBCtrl rgb;
HSVCtrl hsv;
PalCtrl pal;
};
ColorSelectorImpl::ColorSelectorImpl(ColorSelector& parent)
: paint_color_display(t_("(transparent)"))
, parent(parent), wheel(false), ramp(true)
{
Transparent();
CtrlLayout(*this);
parent << SizePos();
// dialog.palette_tab.Background(SLtGray);
palette_tab.Add(pal.HSizePos(4, 4).VSizePos(4, 4), t_("Palette"));
pal <<= THISBACK(OnPalCtrl);
palette_tab.Add(wheel.HSizePos(4, 4).VSizePos(4, 4), t_("Wheel"));
wheel <<= THISBACK(OnWheelCtrl);
palette_tab.Add(ramp.HSizePos(4, 4).VSizePos(4, 4), t_("Hue"));
ramp <<= THISBACK(OnRampCtrl);
palette_tab.Add(rgb.HSizePos(4, 4).VSizePos(4, 4), t_("RGB"));
rgb <<= THISBACK(OnRGBCtrl);
palette_tab.Add(hsv.HSizePos(4, 4).VSizePos(4, 4), t_("HSV"));
hsv <<= THISBACK(OnHSVCtrl);
color.SetFrame(InsetFrame());
color.SetDisplay(paint_color_display);
color.NoWantFocus();
color.SetReadOnly();
// dialog.color.WhenAction = THISBACK(OnColor);
fetch_color <<= THISBACK(OnFetchColor);
set_transparent <<= THISBACK(OnSetTransparent);
set_transparent.SetImage(CtrlImg::set_transparent());
EditIntSpin *spins[6] =
{
&r, &g, &b,
&h, &s, &v,
};
int i;
for(i = 0; i < __countof(spins); i++)
{
spins[i] -> MinMax(0, 255);
spins[i]->WhenAction = (i < 3 ? THISBACK(OnRGB) : THISBACK(OnHSV));
}
Set(Black);
}
ColorSelectorImpl::~ColorSelectorImpl()
{
}
void ColorSelectorImpl::SerializeConfig(Stream& stream)
{
int version = 2;
stream / version;
if(version < 2)
stream % palette_tab;
else {
int t = palette_tab.Get();
stream / t;
palette_tab.Set(t);
}
Color c = colorval;
stream % c;
if(stream.IsLoading())
Set(c);
PalCtrl::SerializeConfig(stream);
}
void ColorSelectorImpl::NotNull(bool _nn)
{
set_transparent.Enable(!_nn);
}
bool ColorSelectorImpl::IsNotNull() const
{
return !set_transparent.IsEnabled();
}
Vector<Color> ColorSelectorImpl::GetPalette() const
{
return pal.GetPalette();
}
void ColorSelectorImpl::SetPalette(const Vector<Color>& p)
{
pal.SetPalette(p);
}
void ColorSelectorImpl::SetRaw()
{
wheel <<= ramp <<= rgb <<= hsv <<= pal <<= colorval;
parent.WhenSetColor();
}
void ColorSelectorImpl::SetAction(Color color)
{
Set(color);
parent.Action();
}
Color ColorSelectorImpl::Get() const
{
return colorval;
}
void ColorSelectorImpl::Set(Color c)
{
colorval = c;
color <<= c;
fetch_color <<= c;
UpdateRGB();
UpdateHSV();
wheel <<= ramp <<= rgb <<= hsv <<= pal <<= c;
parent.Update();
parent.WhenSetColor();
}
void ColorSelectorImpl::UpdateRGB()
{
Color c = Nvl(colorval, Black);
r <<= c.GetR();
g <<= c.GetG();
b <<= c.GetB();
}
void ColorSelectorImpl::UpdateHSV()
{
Color c = Nvl(colorval, Black);
double vh, vs, vv;
RGBtoHSV(c.GetR() / 255.0, c.GetG() / 255.0, c.GetB() / 255.0, vh, vs, vv);
h <<= fround(vh * 255);
s <<= fround(vs * 255);
v <<= fround(vv * 255);
}
void ColorSelectorImpl::OnRGB()
{
int vr = Nvl((int)~r, 0), vg = Nvl((int)~g, 0), vb = Nvl((int)~b, 0);
colorval = Color(vr, vg, vb);
color <<= colorval;
UpdateHSV();
SetRaw();
}
void ColorSelectorImpl::OnHSV()
{
int vh = Nvl((int)~h, 0), vs = Nvl((int)~s, 0), vv = Nvl((int)~v, 0);
double r, g, b;
HSVtoRGB(vh / 255.0, vs / 255.0, vv / 255.0, r, g, b);
colorval = Color(fround(255 * r), fround(255 * g), fround(255 * b));
color <<= colorval;
UpdateRGB();
SetRaw();
}
/*
void ColorSelectorImpl::OnColor()
{
SetColor(~dialog.color);
}
*/
void ColorSelectorImpl::OnSetTransparent()
{
SetAction(Null);
}
void ColorSelectorImpl::OnWheelCtrl()
{
SetAction(~wheel);
}
void ColorSelectorImpl::OnRampCtrl()
{
SetAction(~ramp);
}
void ColorSelectorImpl::OnRGBCtrl()
{
SetAction(~rgb);
}
void ColorSelectorImpl::OnHSVCtrl()
{
SetAction(~hsv);
h <<= hsv.GetHValue();
s <<= hsv.GetSValue();
v <<= hsv.GetVValue();
}
void ColorSelectorImpl::OnPalCtrl()
{
SetAction(~pal);
}
void ColorSelectorImpl::OnFetchColor()
{
SetAction(~fetch_color);
}
//////////////////////////////////////////////////////////////////////
// ColorSelector::
ColorSelector::ColorSelector(bool not_null)
{
Transparent();
impl = new ColorSelectorImpl(*this);
impl->NotNull(not_null);
}
class DlgSelectColor : public WithPaletteSelectorLayout<TopWindow>
{
public:
typedef DlgSelectColor CLASSNAME;
DlgSelectColor();
virtual void Serialize(Stream& stream);
Color Run(Color init_color, bool not_null, const char *title, bool *ok);
private:
ColorSelector selector;
};
Color RunDlgSelectColor(Color init_color, bool not_null, const char *title, bool *ok)
{ return DlgSelectColor().Run(init_color, not_null, title, ok); }
//RegisterHelpTopicObjectTitle(DlgSelectColor, s_(DlgColorDefaultTitle));
DlgSelectColor::DlgSelectColor()
{
palette.Transparent().NoWantFocus() << selector.SizePos();
// CtrlLayoutOKCancel(*this, DlgSelectColorHelpTitle());
CtrlLayoutOKCancel(*this, t_("Select color"));
//RegisterHelpTopicObjectTitle(DlgSelectColor, );
HelpTopic("DlgSelectColor");
Sizeable().MaximizeBox();
}
INITBLOCK
{
RegisterGlobalConfig("DlgSelectColor");
}
void DlgSelectColor::Serialize(Stream& stream)
{
if(stream.IsLoading() && stream.IsEof())
return;
int version = 1;
stream / version;
if(stream.IsError() || version < 1 || version > 1) {
stream.SetError();
return;
}
SerializePlacement(stream);
}
Color DlgSelectColor::Run(Color init_color, bool not_null, const char *title, bool *ok)
{
if(title)
Title(title);
selector.NotNull(not_null).Set(init_color);
LoadFromGlobal(*this, "DlgSelectColor");
bool is_ok = (TopWindow::Run() == IDOK);
StoreToGlobal(*this, "DlgSelectColor");
if(ok)
*ok = is_ok;
return is_ok ? selector.Get() : init_color;
}
ColorCtrl::ColorCtrl(bool not_null)
: DataPusher(NoConvert(), StdColorDisplayNull())
{
SetFrame(EditFieldFrame());
AddFrame(empty);
empty.SetImage(CtrlImg::cross());
empty <<= THISBACK(OnClear);
NotNull(not_null);
}
ColorCtrl::~ColorCtrl() {}
void ColorCtrl::DoAction()
{
bool ok;
Color new_color = RunDlgSelectColor(GetConvert().Format(GetData()), IsNotNull(), 0, &ok);
if(ok)
SetDataAction(GetConvert().Scan(new_color));
}
} }

View file

@ -19,7 +19,9 @@ public:
Event<> WhenLeftDouble; Event<> WhenLeftDouble;
void DarkContent(bool b = true) { dark = b; } WheelRampCtrl& DarkContent(bool b = true) { dark_content = b; return *this; }
WheelRampCtrl& AllowDarkContent(bool b = true) { allow_dark_content = b; return *this; }
bool IsDarkContent() const { return dark_content || allow_dark_content && IsDarkTheme(); }
private: private:
void SetColor(Color color, bool set_norm, bool set_hsv); void SetColor(Color color, bool set_norm, bool set_hsv);
@ -33,7 +35,8 @@ private:
private: private:
bool ramp; bool ramp;
bool dark = false; bool dark_content = false;
bool allow_dark_content = false;
Color color; Color color;
Color normalized_color; Color normalized_color;
int h16, s16, v16; int h16, s16, v16;
@ -63,74 +66,6 @@ struct ColorRampCtrl : public WheelRampCtrl {
ColorRampCtrl() : WheelRampCtrl(true) {} ColorRampCtrl() : WheelRampCtrl(true) {}
}; };
class ColorSelector : public Ctrl
{
public:
ColorSelector(bool not_null = true);
ColorSelector& NotNull(bool nn = true) { impl->NotNull(nn); return *this; }
ColorSelector& NoNotNull() { return NotNull(false); }
bool IsNotNull() const { return impl->IsNotNull(); }
Color Get() const { return impl->Get(); }
void Set(Color c) { impl->Set(c); }
Vector<Color> GetPalette() const { return impl->GetPalette(); }
void SetPalette(const Vector<Color>& palette) { impl->SetPalette(palette); }
void SerializeConfig(Stream& stream) { impl->SerializeConfig(stream); }
virtual void SetData(const Value& color) { Set(color); }
virtual Value GetData() const { return Get(); }
Ctrl& GetImplCtrl() { return impl->GetCtrl(); }
public:
Event<> WhenSetColor;
public:
class Impl
{
public:
virtual ~Impl() {}
virtual void Set(Color c) = 0;
virtual Color Get() const = 0;
virtual void NotNull(bool nn) = 0;
virtual bool IsNotNull() const = 0;
virtual Vector<Color> GetPalette() const = 0;
virtual void SetPalette(const Vector<Color>& pal) = 0;
virtual void SerializeConfig(Stream& stream) = 0;
virtual Ctrl& GetCtrl() = 0;
protected:
Impl() {}
};
protected:
One<Impl> impl;
};
class ColorCtrl : public DataPusher
{
public:
typedef ColorCtrl CLASSNAME;
ColorCtrl(bool not_null = true);
virtual ~ColorCtrl();
ColorCtrl& NotNull(bool _nn = true) { empty.Show(!_nn); return *this; }
ColorCtrl& NoNotNull() { return NotNull(false); }
bool IsNotNull() const { return !empty.IsVisible(); }
protected:
virtual void DoAction();
void OnClear() { SetDataAction(Null); }
protected:
FrameRight<Button> empty;
};
Color RunDlgSelectColor(Color init_color = Black, bool not_null = true, const char *title = 0, bool *ok = 0);
const Display& StdColorDisplayNull(); const Display& StdColorDisplayNull();
class ColorPopUp : public Ctrl { class ColorPopUp : public Ctrl {
@ -173,7 +108,6 @@ private:
bool hints; bool hints;
bool open; bool open;
bool withvoid; bool withvoid;
bool dark;
String nulltext; String nulltext;
String voidtext; String voidtext;
Color color; Color color;
@ -206,6 +140,8 @@ public:
ColorPopUp& NoRampWheel(bool b = true) { norampwheel = b; return *this; } ColorPopUp& NoRampWheel(bool b = true) { norampwheel = b; return *this; }
ColorPopUp& Hints(bool b = true) { hints = b; return *this; } ColorPopUp& Hints(bool b = true) { hints = b; return *this; }
ColorPopUp& DarkContent(bool b = true); ColorPopUp& DarkContent(bool b = true);
ColorPopUp& AllowDarkContent(bool b = true);
bool IsDarkContent() const { return wheel.IsDarkContent(); }
ColorPopUp(); ColorPopUp();
virtual ~ColorPopUp(); virtual ~ColorPopUp();
@ -249,7 +185,8 @@ public:
ColorPusher& Track(bool b = true) { track = b; return *this; } ColorPusher& Track(bool b = true) { track = b; return *this; }
ColorPusher& NoTrack() { return Track(false); } ColorPusher& NoTrack() { return Track(false); }
ColorPusher& NoRampWheel(bool b = true) { colors.NoRampWheel(b); return *this; } ColorPusher& NoRampWheel(bool b = true) { colors.NoRampWheel(b); return *this; }
ColorPusher& DarkContent(bool b = true) { colors.DarkContent(b); return *this; } ColorPusher& DarkContent(bool b = true) { colors.DarkContent(b); Refresh(); return *this; }
ColorPusher& AllowDarkContent(bool b = true) { colors.AllowDarkContent(b); Refresh(); return *this; }
ColorPusher(); ColorPusher();
virtual ~ColorPusher(); virtual ~ColorPusher();

View file

@ -102,8 +102,9 @@ void RichEdit::Paint(Draw& w)
p_size = sz; p_size = sz;
Rect tr = GetTextRect(); Rect tr = GetTextRect();
Zoom zoom = GetZoom(); Zoom zoom = GetZoom();
w.DrawRect(sz, White); w.DrawRect(sz, IsDarkContent() ? SColorPaper() : White());
PageY py = text.GetHeight(pagesz); PageY py = text.GetHeight(pagesz);
Color showcodesa = IsDarkContent() ? DarkTheme(showcodes) : showcodes;
{ {
EditPageDraw pw(w); EditPageDraw pw(w);
pw.x = tr.left; pw.x = tr.left;
@ -126,9 +127,10 @@ void RichEdit::Paint(Draw& w)
pi.bottom = GetPageY(sb + sz.cy); pi.bottom = GetPageY(sb + sz.cy);
pi.usecache = true; pi.usecache = true;
pi.sizetracking = sizetracking; pi.sizetracking = sizetracking;
pi.showcodes = showcodes; pi.showcodes = showcodesa;
pi.showlabels = !IsNull(showcodes) && viewborder >= 16; pi.showlabels = !IsNull(showcodes) && viewborder >= 16;
pi.hyperlink = LtBlue; // because we have white paper even in dark mode pi.hyperlink = IsDarkContent() ? DarkTheme(LtBlue()) : LtBlue(); // because we have white paper even in dark mode
pi.darktheme = IsDarkContent();
if(spellcheck) if(spellcheck)
pi.spellingchecker = SpellParagraph; pi.spellingchecker = SpellParagraph;
@ -144,7 +146,7 @@ void RichEdit::Paint(Draw& w)
} }
text.Paint(pw, pagesz, pi); text.Paint(pw, pagesz, pi);
} }
w.DrawRect(tr.left, GetPosY(py) - sb, 20, 3, showcodes); w.DrawRect(tr.left, GetPosY(py) - sb, 20, 3, showcodesa);
if(objectpos >= 0) { if(objectpos >= 0) {
Rect r = objectrect; Rect r = objectrect;
r.Offset(tr.left, -sb); r.Offset(tr.left, -sb);
@ -336,6 +338,12 @@ void RichEdit::SetupRuler()
zoom, q.grid, q.numbers, q.numbermul, q.marks); zoom, q.grid, q.numbers, q.numbermul, q.marks);
} }
void RichEdit::SetupDark(ColorPusher& c) const
{
c.AllowDarkContent(allow_dark_content);
c.DarkContent(dark_content);
}
void RichEdit::SetupUnits() void RichEdit::SetupUnits()
{ {
WithUnitLayout<TopWindow> d; WithUnitLayout<TopWindow> d;
@ -344,6 +352,7 @@ void RichEdit::SetupUnits()
for(int i = 1; i <= 10; i++) for(int i = 1; i <= 10; i++)
d.zoom.Add(10 * i, Format(t_("%d%% of width"), 10 * i)); d.zoom.Add(10 * i, Format(t_("%d%% of width"), 10 * i));
CtrlRetriever r; CtrlRetriever r;
SetupDark(d.showcodes);
r(d.unit, unit)(d.showcodes, showcodes)(d.zoom, zoom); r(d.unit, unit)(d.showcodes, showcodes)(d.zoom, zoom);
if(d.Execute() == IDOK) { if(d.Execute() == IDOK) {
r.Retrieve(); r.Retrieve();
@ -824,4 +833,25 @@ RichEditWithToolBar::RichEditWithToolBar()
extended = true; extended = true;
} }
bool RichEdit::IsDarkContent() const
{
return dark_content || allow_dark_content && IsDarkTheme();
}
RichEdit& RichEdit::DarkContent(bool b)
{
dark_content = b;
Refresh();
DoRefreshBar();
return *this;
}
RichEdit& RichEdit::AllowDarkContent(bool b)
{
allow_dark_content = b;
Refresh();
DoRefreshBar();
return *this;
}
} }

View file

@ -293,7 +293,7 @@ struct RulerStyleDisplay : Display {
} }
}; };
ParaFormatting::ParaFormatting() ParaFormatting::ParaFormatting(const RichEdit& e)
{ {
CtrlLayout(*this); CtrlLayout(*this);
tabtype.Add(ALIGN_LEFT, t_("Left")); tabtype.Add(ALIGN_LEFT, t_("Left"));
@ -349,6 +349,8 @@ ParaFormatting::ParaFormatting()
rulerstyle.Add(RichPara::RULER_SOLID); rulerstyle.Add(RichPara::RULER_SOLID);
rulerstyle.Add(RichPara::RULER_DOT); rulerstyle.Add(RichPara::RULER_DOT);
rulerstyle.Add(RichPara::RULER_DASH); rulerstyle.Add(RichPara::RULER_DASH);
e.SetupDark(rulerink);
} }
void StyleManager::EnterStyle() void StyleManager::EnterStyle()
@ -533,7 +535,8 @@ void StyleManager::Setup(const Vector<int>& faces, int aunit)
face.Add(faces[i]); face.Add(faces[i]);
} }
StyleManager::StyleManager() StyleManager::StyleManager(const RichEdit& e)
: para(e)
{ {
CtrlLayoutOKCancel(*this, t_("Styles")); CtrlLayoutOKCancel(*this, t_("Styles"));
list.NoHeader().NoGrid(); list.NoHeader().NoGrid();
@ -544,6 +547,8 @@ StyleManager::StyleManager()
list.WhenBar = THISBACK(Menu); list.WhenBar = THISBACK(Menu);
list.WhenAcceptEdit = THISBACK(ReloadNextStyles); list.WhenAcceptEdit = THISBACK(ReloadNextStyles);
ink.NotNull(); ink.NotNull();
e.SetupDark(ink);
e.SetupDark(paper);
face <<= height <<= italic <<= bold <<= underline <<= strikeout <<= THISBACK(SetupFont); face <<= height <<= italic <<= bold <<= underline <<= strikeout <<= THISBACK(SetupFont);
Vector<int> ffs; Vector<int> ffs;
Vector<int> ff; Vector<int> ff;

View file

@ -5,7 +5,9 @@ namespace Upp {
struct ParaFormatDlg : public WithParaFormatLayout<TopWindow> { struct ParaFormatDlg : public WithParaFormatLayout<TopWindow> {
ParaFormatting para; ParaFormatting para;
ParaFormatDlg() { ParaFormatDlg(const RichEdit& e)
: para(e)
{
CtrlLayoutOKCancel(*this, t_("Paragraph format")); CtrlLayoutOKCancel(*this, t_("Paragraph format"));
ActiveFocus(para.before); ActiveFocus(para.before);
} }
@ -13,7 +15,7 @@ struct ParaFormatDlg : public WithParaFormatLayout<TopWindow> {
void RichEdit::ParaFormat() void RichEdit::ParaFormat()
{ {
ParaFormatDlg d; ParaFormatDlg d(*this);
d.para.Set(unit, formatinfo, !IsSelection() && cursorp.level == 0); d.para.Set(unit, formatinfo, !IsSelection() && cursorp.level == 0);
if(d.Execute() != IDOK || !d.para.IsChanged()) if(d.Execute() != IDOK || !d.para.IsChanged())
return; return;
@ -110,7 +112,7 @@ void RichEdit::SetStyle()
void RichEdit::Styles() void RichEdit::Styles()
{ {
NextUndo(); NextUndo();
StyleManager s; StyleManager s(*this);
s.Setup(ffs, unit); s.Setup(ffs, unit);
s.Set(text, formatinfo.styleid); s.Set(text, formatinfo.styleid);
if(s.Execute() != IDOK || !s.IsChanged()) if(s.Execute() != IDOK || !s.IsChanged())

View file

@ -128,6 +128,8 @@ struct FontHeight : public WithDropChoice<EditDouble> {
bool EditRichHeaderFooter(String& header_qtf, String& footer_qtf); bool EditRichHeaderFooter(String& header_qtf, String& footer_qtf);
class RichEdit;
class ParaFormatting : public WithParaLayout<StaticRect> { class ParaFormatting : public WithParaLayout<StaticRect> {
public: public:
DropList n[8]; DropList n[8];
@ -159,7 +161,7 @@ public:
void NewHdrFtr(); void NewHdrFtr();
void SyncHdrFtr(); void SyncHdrFtr();
ParaFormatting(); ParaFormatting(const RichEdit& e);
}; };
class StyleManager : public WithStylesLayout<TopWindow> { class StyleManager : public WithStylesLayout<TopWindow> {
@ -197,7 +199,7 @@ public:
void Setup(const Vector<int>& faces, int aunit = UNIT_DOT); void Setup(const Vector<int>& faces, int aunit = UNIT_DOT);
StyleManager(); StyleManager(const RichEdit& e);
}; };
void SetupFaceList(DropList& face); void SetupFaceList(DropList& face);
@ -308,6 +310,8 @@ private:
bool ignore_physical_size; bool ignore_physical_size;
bool pixel_mode = false; bool pixel_mode = false;
bool dark_content = false;
bool allow_dark_content = false;
static int fh[]; static int fh[];
@ -809,6 +813,8 @@ public:
void ApplyStylesheet(const RichText& r); void ApplyStylesheet(const RichText& r);
void SetPage(const Size& sz) { pagesz = sz; Finish(); } void SetPage(const Size& sz) { pagesz = sz; Finish(); }
Size GetPage() { return pagesz; } Size GetPage() { return pagesz; }
bool IsDarkContent() const;
void SetupDark(ColorPusher& c) const;
RichEdit& NoRuler() { RemoveFrame(ruler); return *this; } RichEdit& NoRuler() { RemoveFrame(ruler); return *this; }
RichEdit& SingleLine(bool b = true) { singleline = b; return *this; } RichEdit& SingleLine(bool b = true) { singleline = b; return *this; }
@ -830,6 +836,8 @@ public:
RichEdit& SetPaintInfo(const PaintInfo& pi) { paint_info = pi; return *this; } RichEdit& SetPaintInfo(const PaintInfo& pi) { paint_info = pi; return *this; }
RichEdit& IgnorePhysicalObjectSize(bool b = true){ ignore_physical_size = b; return *this; } RichEdit& IgnorePhysicalObjectSize(bool b = true){ ignore_physical_size = b; return *this; }
RichEdit& PixelMode(); RichEdit& PixelMode();
RichEdit& DarkContent(bool b = true);
RichEdit& AllowDarkContent(bool b = true);
struct UndoInfo { struct UndoInfo {
int undoserial; int undoserial;

View file

@ -133,6 +133,8 @@ void RichEdit::TableProps()
if(IsSelection() || cursorp.table == 0) if(IsSelection() || cursorp.table == 0)
return; return;
RichEditTableProperties dlg; RichEditTableProperties dlg;
SetupDark(dlg.framecolor);
SetupDark(dlg.gridcolor);
dlg.Breaker(dlg.destroy, IDNO); dlg.Breaker(dlg.destroy, IDNO);
RichTable::Format fmt = text.GetTableFormat(cursorp.table); RichTable::Format fmt = text.GetTableFormat(cursorp.table);
String ratios; String ratios;
@ -337,6 +339,8 @@ void RichEdit::CellProperties()
return; return;
WithCellPropertiesLayout<TopWindow> dlg; WithCellPropertiesLayout<TopWindow> dlg;
CtrlLayoutOKCancel(dlg, t_("Cell properties")); CtrlLayoutOKCancel(dlg, t_("Cell properties"));
SetupDark(dlg.color);
SetupDark(dlg.border);
int tab; int tab;
Rect a; Rect a;
if(tablesel) { if(tablesel) {

View file

@ -115,11 +115,13 @@ void RichEdit::FontTools(Bar& bar)
void RichEdit::InkTool(Bar& bar) void RichEdit::InkTool(Bar& bar)
{ {
ink.DarkContent(IsDarkContent());
bar.Add(!IsReadOnly(), ink); bar.Add(!IsReadOnly(), ink);
} }
void RichEdit::PaperTool(Bar& bar) void RichEdit::PaperTool(Bar& bar)
{ {
paper.DarkContent(IsDarkContent());
bar.Add(!IsReadOnly(), paper); bar.Add(!IsReadOnly(), paper);
} }

View file

@ -35,6 +35,7 @@ TopicEditor::TopicEditor()
topics_search.SetFilter(CharFilterToUpper); topics_search.SetFilter(CharFilterToUpper);
editor.SetPage(TopicPage()); editor.SetPage(TopicPage());
editor.AllowDarkContent();
editor.WhenRefreshBar = THISBACK(SetBar); editor.WhenRefreshBar = THISBACK(SetBar);
editor.WhenHyperlink = THISBACK(Hyperlink); editor.WhenHyperlink = THISBACK(Hyperlink);

View file

@ -310,6 +310,7 @@ QtfDlgEditor::QtfDlgEditor()
SetRect(0, 0, r.GetWidth() - 100, r.GetHeight() - 100); SetRect(0, 0, r.GetWidth() - 100, r.GetHeight() - 100);
SetMinSize(Size(min(640, r.GetWidth() - 100), min(480, r.GetHeight() - 100))); SetMinSize(Size(min(640, r.GetWidth() - 100), min(480, r.GetHeight() - 100)));
Title("Editor"); Title("Editor");
editor.AllowDarkContent();
} }
void QTFEdit(String& text) void QTFEdit(String& text)

View file

@ -81,7 +81,7 @@ struct IdeQtfDes : IdeDesigner, RichEditWithToolBar {
typedef IdeQtfDes CLASSNAME; typedef IdeQtfDes CLASSNAME;
IdeQtfDes() { Extended(); } IdeQtfDes() { Extended(); AllowDarkContent(); }
}; };
INITIALIZE(Qtf) INITIALIZE(Qtf)