mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-31 22:04:04 -06:00
rainbow: Gtk backend skinning
git-svn-id: svn://ultimatepp.org/upp/trunk@5681 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b8ac840396
commit
d10461ceab
13 changed files with 76 additions and 70 deletions
|
|
@ -14,7 +14,7 @@ void InitGtkApp(int argc, char **argv, const char **envptr);
|
|||
void GuiMainFn_(); \
|
||||
\
|
||||
int main(int argc, char **argv, const char **envptr) { \
|
||||
UPP::AppInit__(argc, argv, envptr); \
|
||||
UPP::AppInit__(argc, (const char **)argv, envptr); \
|
||||
UPP::InitGtkApp(argc, argv, envptr); \
|
||||
GuiMainFn_(); \
|
||||
UPP::Ctrl::CloseTopCtrls(); \
|
||||
|
|
|
|||
|
|
@ -26,11 +26,18 @@ void InitGtkApp(int argc, char **argv, const char **envptr)
|
|||
{
|
||||
gtk_init(&argc, &argv); // TODO?
|
||||
Ctrl::GlobalBackBuffer();
|
||||
SetStdFont(Arial(12));
|
||||
Ctrl::ReSkin();
|
||||
g_timeout_add(20, (GSourceFunc) Ctrl::TimeHandler, NULL);
|
||||
InstallPanicMessageBox(Ctrl::PanicMsgBox);
|
||||
}
|
||||
|
||||
/*
|
||||
void ChSysInit()
|
||||
{
|
||||
CtrlImg::Reset();
|
||||
CtrlsImg::Reset();
|
||||
ChReset();
|
||||
}
|
||||
*/
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
#ifdef GUI_GTK
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void ChSysInit()
|
||||
{
|
||||
CtrlImg::Reset();
|
||||
CtrlsImg::Reset();
|
||||
ChReset();
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -21,7 +21,7 @@ void GtkGetClipData(GtkClipboard *clipboard, GtkSelectionData *selection_data,
|
|||
ArrayMap<String, ClipData>& target = *(ArrayMap<String, ClipData> *)user_data;
|
||||
LLOG("GtkGetClipData for " << target.GetKey(info));
|
||||
String fmt = target.GetKey(info);
|
||||
Value data = target[info].data;
|
||||
String data = target[info].Render();
|
||||
if(fmt == "text") {
|
||||
String s = data;
|
||||
gtk_selection_data_set_text(selection_data, (const gchar*)~s, s.GetCount());
|
||||
|
|
@ -37,7 +37,7 @@ void GtkGetClipData(GtkClipboard *clipboard, GtkSelectionData *selection_data,
|
|||
}
|
||||
}
|
||||
else {
|
||||
String s = target[info].Render();
|
||||
String s = data;
|
||||
gtk_selection_data_set(selection_data, GAtom(fmt), 8, (const guchar*)~s, s.GetCount());
|
||||
}
|
||||
}
|
||||
|
|
@ -168,6 +168,13 @@ Ctrl::Gclipboard& Ctrl::gclipboard()
|
|||
return c;
|
||||
}
|
||||
|
||||
Ctrl::Gclipboard& Ctrl::gselection()
|
||||
{
|
||||
GuiLock __;
|
||||
static Gclipboard c(GDK_SELECTION_PRIMARY);
|
||||
return c;
|
||||
}
|
||||
|
||||
void AppendClipboard(const char *format, const Value& data, String (*render)(const Value& data))
|
||||
{
|
||||
GuiLock __;
|
||||
|
|
@ -342,7 +349,6 @@ bool IsAvailableFiles(PasteClip& clip)
|
|||
return clip.IsAvailable("files");
|
||||
}
|
||||
|
||||
|
||||
// TODO:
|
||||
Vector<String> GetFiles(PasteClip& clip)
|
||||
{
|
||||
|
|
@ -354,6 +360,17 @@ Vector<String> GetFiles(PasteClip& clip)
|
|||
void PasteClip::GuiPlatformConstruct()
|
||||
{
|
||||
}
|
||||
/*
|
||||
Ptr<Ctrl> Ctrl::sel_ctrl;
|
||||
*/
|
||||
void Ctrl::SetSelectionSource(const char *fmts)
|
||||
{
|
||||
GuiLock __;
|
||||
/* LLOG("SetSelectionSource " << UPP::Name(this) << ": " << fmts);
|
||||
sel_formats = Split(fmts, ';');
|
||||
sel_ctrl = this;
|
||||
XSetSelectionOwner(Xdisplay, XAtom("PRIMARY"), xclipboard().win, CurrentTime);*/
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ void Ctrl::Create(Ctrl *owner, bool popup)
|
|||
gtk_widget_realize(top->window);
|
||||
|
||||
Rect r = GetRect();
|
||||
gtk_window_move(gtk(), rect.left, rect.top);
|
||||
gtk_window_resize(gtk(), rect.GetWidth(), rect.GetHeight());
|
||||
gtk_window_move(gtk(), r.left, r.top);
|
||||
gtk_window_resize(gtk(), r.GetWidth(), r.GetHeight());
|
||||
|
||||
if(owner && owner->top)
|
||||
gtk_window_set_transient_for(gtk(), owner->gtk());
|
||||
|
|
|
|||
|
|
@ -6,10 +6,6 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void ChHostSkin(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Ctrl::GuiPlatformConstruct()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ public:
|
|||
};
|
||||
|
||||
static Gclipboard& gclipboard();
|
||||
static Gclipboard& gselection();
|
||||
|
||||
public:
|
||||
static void EndSession() {}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ int Ctrl::DoDragAndDrop(const char *fmts, const Image& sample, dword actions,
|
|||
return DND_NONE;
|
||||
}
|
||||
|
||||
void Ctrl::SetSelectionSource(const char *fmts) {}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -71,14 +71,6 @@ void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, Color color)
|
|||
cache.Shrink(4 * 1024 * 768, 1000); // Cache must be after Paint because of PaintOnly!
|
||||
}
|
||||
|
||||
void ImageDraw::Init(Size sz)
|
||||
{
|
||||
isz = sz;
|
||||
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, isz.cx, isz.cy);
|
||||
cr = cairo_create(surface);
|
||||
alpha_surface = NULL;
|
||||
}
|
||||
|
||||
Draw& ImageDraw::Alpha()
|
||||
{
|
||||
if(!alpha_surface) {
|
||||
|
|
@ -88,7 +80,7 @@ Draw& ImageDraw::Alpha()
|
|||
return alpha;
|
||||
}
|
||||
|
||||
void ImageDraw::FetchStraight(ImageBuffer& b) const
|
||||
void CairoGet(ImageBuffer& b, Size isz, cairo_surface_t *surface, cairo_surface_t *alpha_surface)
|
||||
{
|
||||
cairo_surface_flush(surface);
|
||||
byte *a = (byte *)cairo_image_surface_get_data(surface);
|
||||
|
|
@ -119,6 +111,11 @@ void ImageDraw::FetchStraight(ImageBuffer& b) const
|
|||
}
|
||||
}
|
||||
|
||||
void ImageDraw::FetchStraight(ImageBuffer& b) const
|
||||
{
|
||||
CairoGet(b, isz, surface, alpha_surface);
|
||||
}
|
||||
|
||||
ImageDraw::operator Image() const
|
||||
{
|
||||
ImageBuffer img(isz);
|
||||
|
|
@ -134,6 +131,15 @@ Image ImageDraw::GetStraight() const
|
|||
return img;
|
||||
}
|
||||
|
||||
void ImageDraw::Init(Size sz)
|
||||
{
|
||||
isz = sz;
|
||||
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, isz.cx, isz.cy);
|
||||
cr = cairo_create(surface);
|
||||
alpha_surface = NULL;
|
||||
del = true;
|
||||
}
|
||||
|
||||
ImageDraw::ImageDraw(Size sz)
|
||||
{
|
||||
Init(sz);
|
||||
|
|
@ -144,13 +150,24 @@ ImageDraw::ImageDraw(int cx, int cy)
|
|||
Init(Size(cx, cy));
|
||||
}
|
||||
|
||||
ImageDraw::ImageDraw(cairo_t *cr_, Size sz)
|
||||
{
|
||||
isz = sz;
|
||||
cr = cr_;
|
||||
surface = cairo_get_target(cr);
|
||||
alpha_surface = NULL;
|
||||
del = false;
|
||||
}
|
||||
|
||||
ImageDraw::~ImageDraw()
|
||||
{
|
||||
cairo_destroy(cr);
|
||||
cairo_surface_destroy(surface);
|
||||
if(alpha_surface) {
|
||||
cairo_destroy(alpha.cr);
|
||||
cairo_surface_destroy(alpha_surface);
|
||||
if(del) {
|
||||
cairo_destroy(cr);
|
||||
cairo_surface_destroy(surface);
|
||||
if(alpha_surface) {
|
||||
cairo_destroy(alpha.cr);
|
||||
cairo_surface_destroy(alpha_surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ struct FontDataSysMaker : LRUCache<FontSysData, Tuple2<Font, int> >::Maker {
|
|||
virtual int Make(FontSysData& object) const { object.Init(font, angle); return 1; }
|
||||
};
|
||||
|
||||
int gtk_antialias = -1;
|
||||
int gtk_hinting = -1;
|
||||
String gtk_hintstyle;
|
||||
String gtk_rgba;
|
||||
|
||||
void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx)
|
||||
{
|
||||
GuiLock __;
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ void Ctrl::Proc()
|
|||
if(GetAlt())
|
||||
kv |= K_ALT;
|
||||
LLOG(GetKeyDesc(kv) << ", pressed: " << pressed << ", count: " << CurrentEvent.count);
|
||||
DispatchKey(!pressed * K_KEYUP + kv, CurrentEvent.count); // TODO: Add compression
|
||||
DispatchKey(!pressed * K_KEYUP + kv, CurrentEvent.count);
|
||||
}
|
||||
break;
|
||||
case EVENT_TEXT: {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#define GUI_GTK
|
||||
|
||||
#define PLATFORM_X11 // To keep legacy code happy
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
|
|
@ -67,6 +69,7 @@ class ImageDraw : public SystemDraw {
|
|||
|
||||
SystemDraw alpha;
|
||||
cairo_surface_t *alpha_surface;
|
||||
bool del;
|
||||
|
||||
void Init(Size sz);
|
||||
void FetchStraight(ImageBuffer& b) const;
|
||||
|
|
@ -81,6 +84,8 @@ public:
|
|||
ImageDraw(Size sz);
|
||||
ImageDraw(int cx, int cy);
|
||||
~ImageDraw();
|
||||
|
||||
ImageDraw(cairo_t *cr, Size sz); // Special variant for chameleon skinning
|
||||
};
|
||||
|
||||
class BackDraw : public SystemDraw {
|
||||
|
|
@ -157,29 +162,6 @@ struct DrawDragRectInfo {
|
|||
|
||||
#define GUIPLATFORM_NOSCROLL
|
||||
|
||||
class PrinterJob {
|
||||
NilDraw nil;
|
||||
Vector<int> pages;
|
||||
|
||||
public:
|
||||
Draw& GetDraw() { return nil; }
|
||||
operator Draw&() { return GetDraw(); }
|
||||
const Vector<int>& GetPages() const { return pages; }
|
||||
int operator[](int i) const { return 0; }
|
||||
int GetPageCount() const { return 0; }
|
||||
|
||||
bool Execute() { return false; }
|
||||
|
||||
PrinterJob& Landscape(bool b = true) { return *this; }
|
||||
PrinterJob& MinMaxPage(int minpage, int maxpage) { return *this; }
|
||||
PrinterJob& PageCount(int n) { return *this; }
|
||||
PrinterJob& CurrentPage(int currentpage) { return *this; }
|
||||
PrinterJob& Name(const char *_name) { return *this; }
|
||||
|
||||
PrinterJob(const char *name = NULL) {}
|
||||
~PrinterJob() {}
|
||||
};
|
||||
|
||||
int rmsecs();
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -19,6 +19,5 @@ file
|
|||
Top.h,
|
||||
Top.cpp,
|
||||
Clip.cpp,
|
||||
DnD.cpp,
|
||||
ChSysInit.cpp;
|
||||
DnD.cpp;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue