Differenze tra le versioni di "Ottenere informazioni relative allo schermo mediante le funzioni del API di CBX"
Da Gambas-it.org - Wikipedia.
(Creata pagina con 'Il protocollo '''XCB''' (''X C-language Binding'') è stato realizzato con lo scopo di sostituire ''Xlib'' presentando rispetto a quest'ultimo ad esempio dimensioni ridotte, u...') |
|||
Riga 63: | Riga 63: | ||
With screen | With screen | ||
Print "Dimensioni dello schermo:\n" | Print "Dimensioni dello schermo:\n" | ||
− | Print "Larghezza in pixel: " | + | Print "Larghezza in pixel: "; .width_in_pixels |
− | Print "Altezza in pixel: " | + | Print "Altezza in pixel: "; .height_in_pixels |
− | Print "Larghezza in millimetri: "; | + | Print "Larghezza in millimetri: "; .width_in_millimeters |
− | Print "Altezza in millimetri: " | + | Print "Altezza in millimetri: "; .height_in_millimeters |
− | Print "Mappa dei colori predefinita: "; | + | Print "Mappa dei colori predefinita: "; .default_colormap |
End With | End With | ||
Versione delle 17:18, 3 feb 2017
Il protocollo XCB (X C-language Binding) è stato realizzato con lo scopo di sostituire Xlib presentando rispetto a quest'ultimo ad esempio dimensioni ridotte, un accesso diretto al protocollo, migliorando il threading e la estensibilità.
E' possibile mediante alcune risorse del API di CBX ottenere informazioni generali relative allo schermo in uso.
Per poter fruire delle risorse di XCB in Gambas, bisognerà utilizzare la libreria attualmente alla versione: "libxcb.so.1.1.0"
Mostriamo un semplice esempio:
Public Struct xcb_screen_t root As Integer default_colormap As Integer white_pixel As Integer black_pixel As Integer current_input_masks As Integer width_in_pixels As Short height_in_pixels As Short width_in_millimeters As Short height_in_millimeters As Short min_installed_maps As Short max_installed_maps As Short root_visual As Integer backing_stores As Byte save_unders As Byte root_depth As Byte allowed_depths_len As Byte End Struct Library "libxcb:1.1.0" ' xcb_connection_t * xcb_connect (const char *display, int *screen) ' Connects to the X server specified by display. Private Extern xcb_connect(display As String, screenPo As Pointer) As Pointer ' const xcb_setup_t * xcb_get_setup (xcb_connection_t *c) ' Accessor for the data returned by the server when the xcb_connection_t was initialized. Private Extern xcb_get_setup(c As Pointer) As Pointer ' xcb_screen_iterator_t xcb_setup_roots_iterator (const xcb_setup_t *R) ' Get the next element of the iterator. Private Extern xcb_setup_roots_iterator(R As Pointer) As Pointer ' void xcb_disconnect (xcb_connection *c) ' Closes the file descriptor and frees all memory associated with the connection. Private Extern xcb_disconnect(c As Pointer) Public Sub Main() Dim disp, xcb_setup As Pointer Dim screen As New Xcb_screen_t ' Apre una connessione con il server X: disp = xcb_connect(Null, 0) ' Ottiene il primo schermo: xcb_setup = xcb_get_setup(disp) screen = xcb_setup_roots_iterator(xcb_setup) ' Mostra in console alcune informazioni sullo schermo utilizzato: With screen Print "Dimensioni dello schermo:\n" Print "Larghezza in pixel: "; .width_in_pixels Print "Altezza in pixel: "; .height_in_pixels Print "Larghezza in millimetri: "; .width_in_millimeters Print "Altezza in millimetri: "; .height_in_millimeters Print "Mappa dei colori predefinita: "; .default_colormap End With ' Va in chiusura: xcb_disconnect(disp) End