mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
.gtk BE
git-svn-id: svn://ultimatepp.org/upp/trunk@5665 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
635bd726e5
commit
b4e3a438d7
4 changed files with 47 additions and 30 deletions
|
|
@ -4,7 +4,8 @@
|
|||
static gboolean GtkProc(GtkWidget *widget, GdkEvent *event, gpointer user_data);
|
||||
static void IMCommit(GtkIMContext *context, gchar *str, gpointer user_data);
|
||||
|
||||
|
||||
bool DispatchMouseIn(int act, int zd);
|
||||
void GtkMouseEvent(int action, int act, Point p, int zd);
|
||||
void GtkMouseEvent(int action, GdkEvent *event);
|
||||
void GtkKeyEvent(GdkEventKey *key, bool pressed);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,39 +38,44 @@ bool GetMouseRight() { syncMousePos(); return sModmask & GDK_BUTTON3_MASK; }
|
|||
bool GetMouseMiddle() { syncMousePos(); return sModmask & GDK_BUTTON2_MASK; }
|
||||
Point GetMousePos() { syncMousePos(); return sMousepos; }
|
||||
|
||||
bool Ctrl::DispatchMouseIn(int act, int zd)
|
||||
{
|
||||
Point p = GetMousePos();
|
||||
Rect r = GetScreenRect();
|
||||
if(r.Contains(p)) {
|
||||
p -= r.TopLeft();
|
||||
DispatchMouse(act, p, zd);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Ctrl::GtkMouseEvent(int action, int act, Point p, int zd)
|
||||
{
|
||||
DDUMP(zd);
|
||||
if(grabpopup && activePopup.GetCount()) {
|
||||
for(int i = activePopup.GetCount() - 1; i >= 0; i--)
|
||||
if(activePopup[i]->DispatchMouseIn(act, zd))
|
||||
return;
|
||||
Ptr<TopWindow> w = activePopup[0]->GetTopWindow();
|
||||
if(action == DOWN) { // Deactivate active popup(s) if clicked outside of active popups
|
||||
IgnoreMouseUp();
|
||||
activePopup.Top()->GetTopWindow()->ActivateWnd();
|
||||
}
|
||||
else
|
||||
w->DispatchMouseIn(act, zd);
|
||||
return;
|
||||
}
|
||||
DispatchMouse(act, p, zd);
|
||||
}
|
||||
|
||||
void Ctrl::GtkMouseEvent(int action, GdkEvent *event)
|
||||
{
|
||||
GdkEventButton *e = (GdkEventButton *)event;
|
||||
int act = action;
|
||||
if(action != MOUSEMOVE)
|
||||
act |= e->button == 2 ? MIDDLE : e->button == 3 ? RIGHT : LEFT;
|
||||
if(grabpopup && activePopup.GetCount()) {
|
||||
Point p = GetMousePos();
|
||||
for(int i = activePopup.GetCount() - 1; i >= 0; i--) {
|
||||
Ctrl *w = activePopup[i];
|
||||
Rect r = w->GetScreenRect();
|
||||
if(r.Contains(p)) {
|
||||
p -= r.TopLeft();
|
||||
w->DispatchMouse(act, p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(action == DOWN) { // Deactivate active popup(s) if clicked outside of active popups
|
||||
IgnoreMouseUp();
|
||||
Ptr<TopWindow> w = activePopup.Top()->GetTopWindow();
|
||||
if(w)
|
||||
w->ActivateWnd();
|
||||
if(w) {
|
||||
Rect r = w->GetScreenRect();
|
||||
if(r.Contains(p)) {
|
||||
p -= r.TopLeft();
|
||||
w->DispatchMouse(MOUSEMOVE, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
DispatchMouse(act, Point((int)e->x, (int)e->y));
|
||||
GtkMouseEvent(action, act, Point((int)e->x, (int)e->y), 0);
|
||||
}
|
||||
|
||||
#ifdef LOG_EVENTS
|
||||
|
|
@ -166,7 +171,6 @@ bool Ctrl::Proc(GdkEvent *event)
|
|||
GdkEventExpose *e = (GdkEventExpose *)event;
|
||||
SystemDraw w(gdk_cairo_create(gdk()));
|
||||
painting = true;
|
||||
DDUMP(RectC(e->area.x, e->area.y, e->area.width, e->area.height));
|
||||
UpdateArea(w, RectC(e->area.x, e->area.y, e->area.width, e->area.height));
|
||||
cairo_destroy(w);
|
||||
if(top->dr)
|
||||
|
|
@ -193,6 +197,12 @@ bool Ctrl::Proc(GdkEvent *event)
|
|||
else
|
||||
GtkMouseEvent(UP, event);
|
||||
break;
|
||||
case GDK_SCROLL: {
|
||||
GdkEventScroll *e = (GdkEventScroll *)event;
|
||||
GtkMouseEvent(MOUSEWHEEL, MOUSEWHEEL, Point((int)e->x, (int)e->y),
|
||||
findarg(e->direction, GDK_SCROLL_UP, GDK_SCROLL_LEFT) < 0 ? -120 : 120);
|
||||
break;
|
||||
}
|
||||
case GDK_KEY_PRESS:
|
||||
pressed = true;
|
||||
key = (GdkEventKey *)event;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
ImageGdk gdk_icon;
|
||||
bool topmost;
|
||||
|
||||
enum { FULLSCREEN = 99 };
|
||||
|
||||
void CenterRect(Ctrl *owner);
|
||||
void SetMode(int mode);
|
||||
void SyncTopMost();
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ struct MyApp4 : TopWindow {
|
|||
void MainMenu(Bar& bar)
|
||||
{
|
||||
bar.Add("Menu", THISBACK(Menu));
|
||||
bar.Add("Menu", THISBACK(Menu));
|
||||
}
|
||||
|
||||
void SetMenu()
|
||||
|
|
@ -302,7 +303,10 @@ struct MyApp4 : TopWindow {
|
|||
MyApp4() {
|
||||
ToolWindow();
|
||||
Title("Complex Rainbow test");
|
||||
edit.SetQTF("[A9 [/ Hello] [_ World]!");
|
||||
String qtf;
|
||||
for(int i = 0; i < 100; i++)
|
||||
qtf << "[A9 [/ Hello] [_ World]!]";
|
||||
edit.SetQTF(qtf);
|
||||
Sizeable().Zoomable();
|
||||
Add(edit.SizePos());
|
||||
AddFrame(menu);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue