ubit
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
ubit::UDisp Class Referenceabstract

Display Context. More...

#include <udisp.hpp>

Classes

struct  LastResize
 

Public Member Functions

bool isOpened () const
 returns true if the Display was sucessufully opened.
 
int getID () const
 returns the ID of this Display. More...
 
const UConfgetConf () const
 returns the configuration of this Display.
 
int getBpp () const
 returns the number of bit per pixel of this UDisp. More...
 
const UStrgetDisplayName () const
 returns the name of the UDisp's X11 server (when X11 is used).
 
int getScreenWidth () const
 returns the width of the UDisp's screen.
 
int getScreenHeight () const
 returns the height of the UDisp's screen.
 
void setPixelPerInch (double pixel_per_inch)
 changes the pixel density (number of pixels per inch).
 
void setPixelPerMM (double pixel_per_mm)
 changes the pixel density (number of pixels per mm).
 
virtual void add (UWin &)
 add a window (UFrame, UDialog, etc) to this display. More...
 
void add (UWin *)
 see add(UWin&).
 
virtual void remove (UWin &, bool auto_delete)
 remove a window from this display. More...
 
void remove (UWin *, bool auto_delete)
 see remove(UWin&, bool auto_delete).
 
virtual void setPointerPos (const UPoint &screen_pos)=0
 move the pointer to this position on the screen.
 
virtual UPoint getPointerPos () const =0
 returns the position of the pointer on the screen.
 
virtual int getPointerState () const =0
 returns the state of the modifier keys and pointer buttons.
 
virtual bool grabPointer (const UCursor *=null)=0
 starts a physical grab of the native pointer. More...
 
virtual void ungrabPointer ()=0
 ends a physical grab of the native pointer. More...
 
virtual bool pickWindow (int &x_in_win, int &y_in_win, UHardwinImpl *window, UCursor *cursor=null, UCall *callback=null)=0
 grabs the pointer and lets the user pick a window interactively with the mouse. More...
 
UEventFlowgetChannelFlow (int channel) const
 returns the Event Flow for this channel on this display (null if not found). More...
 
UEventFlowobtainChannelFlow (int channel)
 gets or creates the Event Flow that corresponds to this channel on this display. More...
 
USelectiongetChannelSelection (int channel)
 returns the text selection of a given event flow on this display. More...
 
const UStrgetCopyBuffer () const
 returns the copy buffer.
 
UStrgetPasteTarget (int &pos) const
 [impl] returns the string (and the pos in this string) where the paste will take place.
 
void clearPasteTarget ()
 [impl] clears the paste target.
 
virtual void copySelection (UMouseEvent &, USelection &)
 [impl] copies the content of the selection in the copy buffer and tells the X server we own the X selection. More...
 
virtual void pasteSelection (UMouseEvent &, UStr *paste_str, int paste_pos)
 [impl] pastes the X selection into this UStr at this pos. More...
 
URenderContextgetDefaultContext ()
 
void makeDefaultContextCurrentIfNeeded ()
 
void addHardwin (UWin *)
 
void removeHardwin (UWin *)
 
virtual unsigned long createColorPixel (const URgba &)=0
 
virtual UHardwinImplcreateWinImpl (UWin *)=0
 
virtual UCursorImpl * createCursorImpl (int curtype)=0
 
virtual void deleteCursorImpl (UCursorImpl *)=0
 
virtual UHardFontgetFont (const UFontDesc *)
 returns (possibily creating) the requested font (see NOTES). More...
 
virtual UHardFontrealizeFont (const UFont &)
 
virtual UHardFontrealizeFont (const UFontDesc &)
 
virtual void realizeFontFamily (const UFontFamily &)
 
unsigned long getBlackPixel () const
 
unsigned long getWhitePixel () const
 
unsigned long getRedMask () const
 
unsigned long getGreenMask () const
 
unsigned long getBlueMask () const
 
int getRedShift () const
 
int getGreenShift () const
 
int getBlueShift () const
 
int getRedBits () const
 
int getGreenBits () const
 
int getBlueBits () const
 
UEventFlowobtainFlow (unsigned int ev_state, int channel)
 returns the corresponding Event Flow (creates it if does not already exist).
 
virtual void onPaint (UView *winview, float x, float y, float w, float h)
 
virtual void onResize (UView *winview, const UDimension &size)
 
void onResizeCB (UView *winview)
 
virtual bool setSelectionOwner (UMouseEvent &)
 [X11 only] tells the X-server the appli owns the X selection.
 
virtual void pasteSelectionRequest (UMouseEvent &)
 [X11 only] asks the X selection. More...
 
virtual void copySelectionCB (void *system_event)
 [X11 only] copie reellement la selection (ou plus exactement envoie son contenu a l'appli qui la demande). More...
 
virtual void pasteSelectionCB (void *system_event)
 [X11 only] recupere effectivement le contenu de la X selection. More...
 

Static Public Member Functions

static UDispcreate (const UStr &display_name)
 creates and opens a new Display. More...
 
static void countBits (unsigned long mask, int &bits, int &shift)
 

Protected Types

typedef std::list< UHardwinImpl * > HardwinList
 

Protected Member Functions

 UDisp (const UStr &display_name)
 
virtual void startAppli ()=0
 
virtual void quitAppli ()=0
 
virtual void startLoop (bool main_loop)=0
 
virtual void quitLoop (bool main_loop)=0
 

Protected Attributes

int id
 
UConfconf
 
UStr display_name
 
int bpp
 
int depth_size
 
int stencil_size
 
int screen_width
 
int screen_height
 
int screen_width_mm
 
int screen_height_mm
 
bool is_opened
 
URenderContextdefault_context
 
const UGlcontext * current_glcontext
 
std::vector< UHardFont ** > font_map
 
unsigned long app_motion_time
 
unsigned long nat_motion_time
 
unsigned long black_pixel
 
unsigned long white_pixel
 
unsigned long red_mask
 
unsigned long green_mask
 
unsigned long blue_mask
 
int red_shift
 
int green_shift
 
int blue_shift
 
int red_bits
 
int green_bits
 
int blue_bits
 
double IN_TO_PX
 
double CM_TO_PX
 
double MM_TO_PX
 
double PT_TO_PX
 
double PC_TO_PX
 
HardwinList hardwin_list
 
UStr copy_buffer
 
uptr< UStrpaste_str
 
int paste_pos
 
UElem winlist
 
struct ubit::UDisp::LastResize last_resize
 

Friends

class UAppli
 
class UAppliImpl
 
class UWin
 
class UHardwinImpl
 
class UView
 
class UGraph
 
class UEvent
 
class UFontFamily
 
class UFontMetrics
 
class UGlcontext
 
class UGlcanvas
 
class ULength
 
class UFont
 

Detailed Description

Display Context.

A UAppli can open windows on several displays, which can be on remote machines when X11 is used as a windowing systems. A UDisp contains the data related to a given display (or to a specific screen of a given display when screens are logically separated, ie. when a window cannot move freely from one screen to another one).

UWin objects (and UFrame, UDialog, UMenu subclasses) can be attached to a specific UDisp by using UDisp::add(). Widgets that are contained in several UWin objects ("contained" meaning they are a child of them) are AUTOMATICCALY REPLICATED and synchronized on all these windows.

UAppli derives from UDisp. The UAppli object (which must be unique) represents the default display.

Member Function Documentation

§ add()

virtual void ubit::UDisp::add ( UWin )
virtual

add a window (UFrame, UDialog, etc) to this display.

Note that windows are initially hidden, their show() method must be called to make them visible. Moreover, as show() calculates the window size, it should called after adding the window children (see also: UWin::adjustSize()).

See also
: UAppli::add() and classes UWin, UFrame, UDialog, UMenu.

§ copySelection()

void UDisp::copySelection ( UMouseEvent e,
USelection textsel 
)
virtual

[impl] copies the content of the selection in the copy buffer and tells the X server we own the X selection.

note: there is 1 selection per UEventFlow but only 1 copy_buffer per UDisp

§ copySelectionCB()

virtual void ubit::UDisp::copySelectionCB ( void *  system_event)
inlinevirtual

[X11 only] copie reellement la selection (ou plus exactement envoie son contenu a l'appli qui la demande).

l'event doit etre un XSelectionRequestEvent

§ create()

NAMESPACE_UBIT UDisp * UDisp::create ( const UStr display_name)
static

creates and opens a new Display.

'display_name' is the name of the X Window server, it must be specified as follows:

  • hostname:screen_no or just:
  • hostname (screen 0 is taken in this case)

NOTES:

  • the UAppli is the default UDisp, its ID number is 0.
  • the default BPP (number of bits per pixel) is 24, this can be changed globally for the whole application in UConf or for a given display by calling UDisp(UConf&)

§ getBpp()

int ubit::UDisp::getBpp ( ) const
inline

returns the number of bit per pixel of this UDisp.

when X11 is used, this bpp may differ from the default BPP of the X11 display.

§ getChannelFlow()

UEventFlow * UDisp::getChannelFlow ( int  channel) const

returns the Event Flow for this channel on this display (null if not found).

0 is the channel of the native Event Flow on this display. Don't confuse channels with event flow IDs: channels depend on displays, while IDs are unique for the whole UAppli. For instance, if an appli is displayed on 2 displays, it will have (at least) 2 event flows, 1 on disp1 and 1 on disp2. The channel of both event flow will be 0, but their IDs will differ.

See also
: UAppli class and UAppli::getFlow()

§ getChannelSelection()

USelection * UDisp::getChannelSelection ( int  channel)

returns the text selection of a given event flow on this display.

See also
getDispFlow() for details.

§ getFont()

UHardFont * UDisp::getFont ( const UFontDesc f)
virtual

returns (possibily creating) the requested font (see NOTES).

IMPORTANT NOTES:

  • 1. fonts depends on the default Graphics Context (
    See also
    getDefaultGC()). Hence, when OpenGL is used, fonts can only be drawn by using this GC or by a GC that shares the displaylists with this GC (
    UGraph::createGC)
  • 2. this function may change the current GC: the default GC will then become the current GC (by calling getDefaultGC()->makeCurrent()). Programs that use multiple GC may need to change the current GC after calling getFont().

§ getID()

int ubit::UDisp::getID ( ) const
inline

returns the ID of this Display.

the ID of the default Display is 0 (the default Display is the UAppli).

§ grabPointer()

virtual bool ubit::UDisp::grabPointer ( const UCursor = null)
pure virtual

starts a physical grab of the native pointer.

the UCursor arg is the cursor that is shown during the grab. A default value (such as UCursor::crosshair) is used if this argument is null. returns true if the pointer could be grabbed. BEWARE that grabPointer() may lock the X server!

See also
ungrabPointer().

§ obtainChannelFlow()

UEventFlow * UDisp::obtainChannelFlow ( int  channel)

gets or creates the Event Flow that corresponds to this channel on this display.

calls getDispFlow() then creates a new flow if getDispFlow() returns null.

See also
getDispFlow() for details.

§ pasteSelection()

void UDisp::pasteSelection ( UMouseEvent e,
UStr paste_str,
int  paste_pos 
)
virtual

[impl] pastes the X selection into this UStr at this pos.

ATTENTION: c'est lie a chaque disp et c'est ASYNCHRONE: le paste n'est pas fait immediatement mais par appel ulterieur d'un callback

§ pasteSelectionCB()

virtual void ubit::UDisp::pasteSelectionCB ( void *  system_event)
inlinevirtual

[X11 only] recupere effectivement le contenu de la X selection.

l'appel de cette fct est provoque par pasteSelectionRequest() the XEvent must be a XSelectionEvent event.

§ pasteSelectionRequest()

virtual void ubit::UDisp::pasteSelectionRequest ( UMouseEvent )
inlinevirtual

[X11 only] asks the X selection.

cette fct ne recupere PAS tout de suite le contenu de la selection mais entrainera un appel ulterieur de pasteSelectionCallback(). the UEvent must be a button event.

§ pickWindow()

virtual bool ubit::UDisp::pickWindow ( int &  x_in_win,
int &  y_in_win,
UHardwinImpl window,
UCursor cursor = null,
UCall callback = null 
)
pure virtual

grabs the pointer and lets the user pick a window interactively with the mouse.

(note: this function only works when X11 is used).

  • returns false if no window was picked
  • 'x_in_win' and 'y_in_win' are the position of the pointer in the window
  • 'window' must be previously created by createWinImpl(null). Its content is set so that it points to teh picked window
  • 'cursor' specifies the cursor that is shown during the grab operation (UCursor::crosshair is used is this arg. is null)
  • if 'callback' is not null, it is fired when the mouse is pressed, moved, released during the grab operation. 'callback' is a callback object created by one of the ucall<> templates (
    See also
    UCall).

§ remove()

virtual void ubit::UDisp::remove ( UWin ,
bool  auto_delete 
)
virtual

remove a window from this display.

for explanations on 'auto_delete' see: UElem::remove()

§ ungrabPointer()

virtual void ubit::UDisp::ungrabPointer ( )
pure virtual

ends a physical grab of the native pointer.

See also
grabPointer() for details.

The documentation for this class was generated from the following files: