[email protected] schrieb:
> On 05/04/11 18:08, Zoltán Lengyel wrote:
>
> I'd post an example, but can't find it - someone may have something
> lying around?
Yes, but it's a little oversized, not all english and there are some
linux parts missing (returning zero). But it takes account of multi
screens and prevents caption from vanishing (so the window cannot be
moved any more). I think, it points to the right direction...
//-----------------------------------------------------------------------------
#include <FL/Fl.H>
#include <FL/x.H>
#include <FL/Fl_Window.H>
#ifdef WIN32
#include <windows.h>
#else
#include <X11/Xlib.h>
#endif
//-----------------------------------------------------------------------------
int Caption_Height()
{ // Bildschirmgröße in y-Richtung
#ifdef WIN32
return GetSystemMetrics(SM_CYCAPTION);
#else
return 0;
#endif
}
//-----------------------------------------------------------------------------
int x_Border()
{ // Bildschirmgröße in y-Richtung
#ifdef WIN32
return GetSystemMetrics(SM_CXBORDER);
#else
return 0;
#endif
}
//-----------------------------------------------------------------------------
int y_Border()
{ // Bildschirmgröße in y-Richtung
#ifdef WIN32
return GetSystemMetrics(SM_CYBORDER);
#else
return 0;
#endif
}
//----------------------------------------------------------------------------
int Screen_Index(int px, int py)
{ // Liefert den Screen von Screen 0 bis Screen n zur gegebenen Position
// oder -1, wenn Koordinate nicht sichtbar
if (Fl::screen_count() > 1)
{ // Mehrere Desks aktiv, aufaddieren
for (int i= 0; i< Fl::screen_count(); ++i)
{
int x, y, w, h;
Fl::screen_xywh(x, y, w, h, i);
if ((px >= x && px < x+w) && (py >= y && py < py +w))
return i;
}
return -1; // Koordinate nicht sichtbar
}
else
{
if ((px >= 0 && px < Fl::w()) && (py >= 0 && py < Fl::h()))
return 0;
else return -1;
}
}
//----------------------------------------------------------------------------
void Screen_Multi(int Index, int& sx, int& sy, int& sw, int& sh)
{ // Liefert Koordinaten des Desktops von Index
if (Fl::screen_count() > 1) Fl::screen_xywh(sx, sy, sw, sh, Index);
// Tatsächlich mehrere Desks aktiv
else
{
#ifdef WIN32
sx= 0;
sy= 0;
sw= GetSystemMetrics(SM_CXSCREEN);
sh= GetSystemMetrics(SM_CYSCREEN);
#endif
}
}
//-----------------------------------------------------------------------------
int Size_Screen_X()
{ // Bildschirmgröße in x-Richtung
#ifdef WIN32
return GetSystemMetrics(SM_CXSCREEN);
#else
return XDisplayWidth(fl_display, 0);
#endif
}
//-----------------------------------------------------------------------------
int Size_Screen_Y()
{ // Bildschirmgröße in y-Richtung
#ifdef WIN32
return GetSystemMetrics(SM_CYSCREEN);
#else
return XDisplayHeight(fl_display, 0);
#endif
}
//-----------------------------------------------------------------------------
bool m_Fullscreen= false; // Member
void Fl_Dialog_Window::Vollbild(bool An)
{
int sx= 0, sy= 0, sw, sh;
int i= Screen_Index(m_x, m_y);
if (i) Screen_Multi(i, sx, sy, sw, sh);
else // if (i == Desktop Null)
{
sw= Size_Screen_X();
sh= Size_Screen_Y();
}
if (An)
{ // Vollbild-Modus einschalten
m_Fullscreen= true;
resize(sx, sy, sw, sh);
}
else
{ // Fullscreen-Modus beenden
m_Fullscreen= false;
if (m_y== 0)
{ // Titelleiste einblenden, wenn nicht sichtbar
int bx= x_Border();
int by= y_Border();
if (m_w > Fl::w() - 2* bx) m_w= Fl::w() - 2 *bx;
if (m_h > Fl::h() - 2* by) m_h= Fl::h() - 2 *by;
int ch= Caption_Height() + by;
m_y+= ch;
if (m_x < bx) m_x= bx;
m_h-= ch + by;
}
resize(m_x, m_y, m_w, m_h);
}
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk