MiniGUI API Reference (MiniGUI-Threads)  v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Macros | Functions
Mapping Operations

The mapping mode defines the unit of measure used to transform page-space units into device-space units, and also defines the orientation of the device's x and y axes. More...

Macros

#define GetMapMode(hdc)   GetDCAttr (hdc, DC_ATTR_MAP_MODE)
 Retrieve the current mapping mode of a DC. More...
 
#define SetMapMode(hdc, mapmode)   SetDCAttr (hdc, DC_ATTR_MAP_MODE, (DWORD)mapmode)
 Set the mapping mode of a display context. More...
 
#define GetViewportOrg(hdc, pPt)   GetDCLCS(hdc, DC_LCS_VORG, pPt)
 Retrieve the x-coordinates and y-coordinates of the viewport origin for a device context. More...
 
#define GetViewportExt(hdc, pPt)   GetDCLCS(hdc, DC_LCS_VEXT, pPt)
 Retrieve the x-extents and y-extents of the current viewport for a device context. More...
 
#define GetWindowOrg(hdc, pPt)   GetDCLCS(hdc, DC_LCS_WORG, pPt)
 Retrieve the x-coordinates and y-coordinates of the window for a device context. More...
 
#define GetWindowExt(hdc, pPt)   GetDCLCS(hdc, DC_LCS_WEXT, pPt)
 Retrieve the x-extents and y-extents of the current window for a device context. More...
 
#define SetViewportOrg(hdc, pPt)   SetDCLCS(hdc, DC_LCS_VORG, pPt)
 Set the x-coordinates and y-coordinates of the viewport origin for a device context. More...
 
#define SetViewportExt(hdc, pPt)   SetDCLCS(hdc, DC_LCS_VEXT, pPt)
 Set the x-extents and y-extents of the current viewport for a device context. More...
 
#define SetWindowOrg(hdc, pPt)   SetDCLCS(hdc, DC_LCS_WORG, pPt)
 Set the x-coordinates and y-coordinates of the window for a device context. More...
 
#define SetWindowExt(hdc, pPt)   SetDCLCS(hdc, DC_LCS_WEXT, pPt)
 Set the x-extents and y-extents of the current window for a device context. More...
 

Functions

MG_EXPORT void GUIAPI GetDCLCS (HDC hdc, int which, POINT *pt)
 Retrieve mapping parameters of a device context. More...
 
MG_EXPORT void GUIAPI SetDCLCS (HDC hdc, int which, const POINT *pt)
 Set mapping parameters of a device context. More...
 
MG_EXPORT void GUIAPI DPtoLP (HDC hdc, POINT *pPt)
 Converts device coordinates into logical coordinates. More...
 
MG_EXPORT void GUIAPI LPtoDP (HDC hdc, POINT *pPt)
 Converts logical coordinates into device coordinates. More...
 
MG_EXPORT void GUIAPI SPtoLP (HDC hdc, POINT *pPt)
 Converts screen coordinates into logical coordinates. More...
 
MG_EXPORT void GUIAPI LPtoSP (HDC hdc, POINT *pPt)
 Converts logical coordinates into screen coordinates. More...
 

Detailed Description

The mapping mode defines the unit of measure used to transform page-space units into device-space units, and also defines the orientation of the device's x and y axes.

end of draw_adv_2d_fns So far, MiniGUI support only two mapping mode:

 - MM_TEXT\n
   Each logical unit is mapped to on device pixel.
   Positive x is to the right; positive y is down.
 - MM_ANISOTROPIC\n
   Logical units are mapped to arbitrary units with arbitrarily
   scaled axes; Use \a SetWindowExt and \a SetViewportExt functions
   to specify the units, orientation, and scaling required.

The following formula shows the math involved in converting a point from page space to device space:

Dx = ((Lx - WOx) * VEx / WEx) + VOx

The following variables are involved:

 - Dx    x value in device units
 - Lx    x value in logical units (also known as page space units)
 - WO    window x origin
 - VO    viewport x origin
 - WE    window x-extent
 - VE    viewport x-extent

The same equation with y replacing x transforms the y component of a point. The formula first offsets the point from its coordinate origin. This value, no longer biased by the origin, is then scaled into the destination coordinate system by the ratio of the extents. Finally, the scaled value is offset by the destination origin to its final mapping.

Macro Definition Documentation

◆ GetMapMode

#define GetMapMode (   hdc)    GetDCAttr (hdc, DC_ATTR_MAP_MODE)

Retrieve the current mapping mode of a DC.

This function retrieves the current mapping mode of the DC hdc.

So far, MiniGUI support two mapping modes: MM_TEXT and MM_ANISOTROPIC.

Parameters
hdcThe device context.
Returns
The current mapping mode, can be either MM_TEXT or MM_ANISOTROPIC.
See also
SetWindowExt, SetViewportExt, SetMapMode

Definition at line 4471 of file gdi.h.

◆ GetViewportExt

#define GetViewportExt (   hdc,
  pPt 
)    GetDCLCS(hdc, DC_LCS_VEXT, pPt)

Retrieve the x-extents and y-extents of the current viewport for a device context.

This function retrieves the x-extents and y-extens of the current viewport of the specified device context hdc.

Parameters
hdcThe device context.
pPtThe viewport extents will be returned through this buffer.
See also
GetMapMode, SetViewportExt

Definition at line 4577 of file gdi.h.

◆ GetViewportOrg

#define GetViewportOrg (   hdc,
  pPt 
)    GetDCLCS(hdc, DC_LCS_VORG, pPt)

Retrieve the x-coordinates and y-coordinates of the viewport origin for a device context.

This function retrieves the x-coordinates and y-coordinates of the viewport origin of the specified device context hdc.

Parameters
hdcThe device context.
pPtThe viewport origin will be returned through this buffer.
See also
GetMapMode, SetViewportOrg

Definition at line 4562 of file gdi.h.

◆ GetWindowExt

#define GetWindowExt (   hdc,
  pPt 
)    GetDCLCS(hdc, DC_LCS_WEXT, pPt)

Retrieve the x-extents and y-extents of the current window for a device context.

This function retrieves the x-extents and y-extens of the current window of the specified device context hdc.

Parameters
hdcThe device context.
pPtThe window extents will be returned through this buffer.
See also
GetMapMode, SetWindowExt

Definition at line 4607 of file gdi.h.

◆ GetWindowOrg

#define GetWindowOrg (   hdc,
  pPt 
)    GetDCLCS(hdc, DC_LCS_WORG, pPt)

Retrieve the x-coordinates and y-coordinates of the window for a device context.

This function retrieves the x-coordinates and y-coordinates of the window origin of the specified device context hdc.

Parameters
hdcThe device context.
pPtThe window origin will be returned through this buffer.
See also
GetMapMode, SetWindowOrg

Definition at line 4592 of file gdi.h.

◆ SetMapMode

#define SetMapMode (   hdc,
  mapmode 
)    SetDCAttr (hdc, DC_ATTR_MAP_MODE, (DWORD)mapmode)

Set the mapping mode of a display context.

This function sets the mapping mode of the specified display context hdc.

So far, MiniGUI support two mapping modes: MM_TEXT and MM_ANISOTROPIC.

Parameters
hdcThe device context.
mapmodeThe new mapping mode, should be either MM_TEXT or MM_ANISOTROPIC.
Returns
The old mapping mode, either MM_TEXT or MM_ANISOTROPIC.
See also
SetWindowExt, SetViewportExt, SetMapMode

Definition at line 4488 of file gdi.h.

◆ SetViewportExt

#define SetViewportExt (   hdc,
  pPt 
)    SetDCLCS(hdc, DC_LCS_VEXT, pPt)

Set the x-extents and y-extents of the current viewport for a device context.

This function sets the x-extents and y-extens of the current viewport of the specified device context hdc.

Parameters
hdcThe device context.
pPtThe viewport extents will be set.
See also
GetMapMode, GetViewportExt

Definition at line 4637 of file gdi.h.

◆ SetViewportOrg

#define SetViewportOrg (   hdc,
  pPt 
)    SetDCLCS(hdc, DC_LCS_VORG, pPt)

Set the x-coordinates and y-coordinates of the viewport origin for a device context.

This function sets the x-coordinates and y-coordinates of the viewport origin of the specified device context hdc.

Parameters
hdcThe device context.
pPtThe viewport origin will be set.
See also
GetMapMode, GetViewportOrg

Definition at line 4622 of file gdi.h.

◆ SetWindowExt

#define SetWindowExt (   hdc,
  pPt 
)    SetDCLCS(hdc, DC_LCS_WEXT, pPt)

Set the x-extents and y-extents of the current window for a device context.

This function sets the x-extents and y-extens of the current window of the specified device context hdc.

Parameters
hdcThe device context.
pPtThe window extents will be set.
See also
GetMapMode, GetWindowExt

Definition at line 4667 of file gdi.h.

◆ SetWindowOrg

#define SetWindowOrg (   hdc,
  pPt 
)    SetDCLCS(hdc, DC_LCS_WORG, pPt)

Set the x-coordinates and y-coordinates of the window for a device context.

This function sets the x-coordinates and y-coordinates of the window origin of the specified device context hdc.

Parameters
hdcThe device context.
pPtThe window origin will be set.
See also
GetMapMode, GetWindowOrg

Definition at line 4652 of file gdi.h.

Function Documentation

◆ DPtoLP()

void GUIAPI DPtoLP ( HDC  hdc,
POINT pPt 
)

Converts device coordinates into logical coordinates.

This function converts device coordinates into logical coordinates in the device context hdc.

The conversion depends on the mapping mode of the display context, the settings of the origins and extents for the window and viewport. The x-coordinate and y-coordinate contained in struct pPt will be transformed.

Parameters
hdcThe device context.
pPtThe coordinates to be converted, and the transformed coordinates will be contained in this buffer after the function returns.
See also
LPtoDP

◆ GetDCLCS()

void GUIAPI GetDCLCS ( HDC  hdc,
int  which,
POINT pt 
)

Retrieve mapping parameters of a device context.

This function retrieves mapping paramters of the specified device context hdc when the mapping mode is not MM_TEXT.

Parameters
hdcThe device context.
whichWhich parameter you want to retrieve, can be one of the following values:
  • DC_LCS_VORG
    Retrieve the x-coordinates and y-coordinates of the viewport origin.
  • DC_LCS_VEXT
    Retrieve the x-extents and y-extents of the current viewport.
  • DC_LCS_WORG
    Retrieve the x-coordinates and y-coordinates of the window origin.
  • DC_LCS_WEXT
    Retrieve the x-extents and y-extents of the window.
Parameters
ptThe coordinates or extents will be returned through this buffer.
See also
GetMapMode, SetMapMode, SetDCLCS

◆ LPtoDP()

void GUIAPI LPtoDP ( HDC  hdc,
POINT pPt 
)

Converts logical coordinates into device coordinates.

This function converts logical coordinates into device coordinates in the device context hdc.

The conversion depends on the mapping mode of the display context, the settings of the origins and extents for the window and viewport. The x-coordinate and y-coordinate contained in struct pPt will be transformed.

Parameters
hdcThe device context.
pPtThe coordinates to be converted, and the transformed coordinates will be contained in this buffer after the function returns.
See also
DPtoLP

◆ LPtoSP()

void GUIAPI LPtoSP ( HDC  hdc,
POINT pPt 
)

Converts logical coordinates into screen coordinates.

This function converts logical coordinates into screen coordinates in the device context hdc.

The conversion depends on the mapping mode of the display context, the settings of the origins and extents for the window and viewport. The x-coordinate and y-coordinate contained in struct pPt will be transformed.

Parameters
hdcThe device context.
pPtThe coordinates to be converted, and the transformed coordinates will be contained in this buffer after the function returns.
See also
SPtoLP

◆ SetDCLCS()

void GUIAPI SetDCLCS ( HDC  hdc,
int  which,
const POINT pt 
)

Set mapping parameters of a device context.

This function sets mapping paramters of the specified device context hdc when the mapping mode is not MM_TEXT.

Parameters
hdcThe device context.
whichWhich parameter you want to retrieve, can be one of the following values:
  • DC_LCS_VORG
    Set the x-coordinates and y-coordinates of the viewport origin.
  • DC_LCS_VEXT
    Set the x-extents and y-extents of the current viewport.
  • DC_LCS_WORG
    Set the x-coordinates and y-coordinates of the window origin.
  • DC_LCS_WEXT
    Set the x-extents and y-extents of the window.
Parameters
ptThe coordinates or extents will be set.
See also
GetMapMode, SetMapMode, GetDCLCS

◆ SPtoLP()

void GUIAPI SPtoLP ( HDC  hdc,
POINT pPt 
)

Converts screen coordinates into logical coordinates.

This function converts screen coordinates into logical coordinates in the device context hdc.

The conversion depends on the mapping mode of the display context, the settings of the origins and extents for the window and viewport. The x-coordinate and y-coordinate contained in struct pPt will be transformed.

Parameters
hdcThe device context.
pPtThe coordinates to be converted, and the transformed coordinates will be contained in this buffer after the function returns.
See also
LPtoSP