Powerbasic Museum 2020-B

IT-Consultant: Patrice Terrier => GDImage => DashBoard => Topic started by: Patrice Terrier on May 22, 2009, 08:55:00 PM

Title: DashBoard (anchor widget)
Post by: Patrice Terrier on May 22, 2009, 08:55:00 PM
This GDImage 5.01 project, shows you how to use the new anchor properties altogether with "widget sprite objects" to mimic the behavior of a standard Windows control.

It works on the same concept that the one being used in the skin engine, and uses the same %ANCHOR constants.


Example:

SUB WidgetNavigation(BYVAL nGDImageCtrl AS LONG, BYVAL nX AS LONG, BYVAL nY AS LONG, BYVAL nAngle AS LONG)
    LOCAL nBitmap, nW, nH AS LONG
    LOCAL nFontSize, nXF, nYF, nWF, nHF AS LONG, sUseFont, sLabel AS STRING

    IF ZD_GetObjectBitmap(%IDS_COMPASSBACK) = 0 THEN
       nBitmap = ZI_CreateBitmapFromFile(SK_FOLDER() + "Navigation.png", nW, nH)
       ZD_DrawBitmapToCtrl(nGDImageCtrl, nX, nY, nBitmap, ZD_ColorARGB(255, 0), %IDS_COMPASSBACK, %ZS_VISIBLE)
       ZD_SetObjectLocked(%IDS_COMPASSBACK, %TRUE)
       ZD_SetObjectFrameCount(%IDS_COMPASSBACK, 2)
       ZD_SetObjectFrameToUse(%IDS_COMPASSBACK, 1, %FALSE)
       '// The static Arrow sprite.
       ZD_CloneObject(%IDS_COMPASSBACK, %IDS_COMPASSARROW, nX, nY)
       ZD_SetObjectLocked(%IDS_COMPASSARROW, %TRUE)
       ZD_SetObjectFrameToUse(%IDS_COMPASSARROW, 2, %FALSE)
       
       nBitmap = ZI_CreateBitmapFromFile(SK_FOLDER() + "CapeKnts.png", nW, 0)
       ZD_DrawBitmapToCtrl(nGDImageCtrl, nX + (nH - nW) / 2, nY - 34, nBitmap, ZD_ColorARGB(255, 0), %IDS_CAPEKNTS, %ZS_VISIBLE)
       ZD_SetObjectLocked(%IDS_CAPEKNTS, %TRUE)
       ZD_SetObjectZorder(%IDS_CAPEKNTS, %ZD_ORDER_BOTTOM) '// Change Z-ORDER

       sLabel = "Navigation"
       sUseFont = "ARIAL BLACK" ' "TREBUCHET MS"
       nFontSize = 17
       ZD_GetTextBound((sLabel), (sUseFont), nFontSize, nWF, nHF, %ZD_TextHorzUp)
       nXF = nX + ((nH - nWF) / 2)
       nYF = nY + nH - 4
       ZD_DrawTextToCtrl(nGDImageCtrl, (sLabel), nXF, nYF, ZD_ARGB(255, 255,255,255), (sUseFont), nFontSize, %IDS_COMPASSLABEL, %ZS_VISIBLE, 0, 0)
       ZD_SetObjectLocked(%IDS_COMPASSLABEL, %TRUE)

       '// Set anchor mode
       ZD_SetObjectAnchorMode(%IDS_COMPASSBACK,  %ANCHOR_CENTER)
       ZD_SetObjectAnchorMode(%IDS_COMPASSARROW, %ANCHOR_CENTER)
       ZD_SetObjectAnchorMode(%IDS_CAPEKNTS,     %ANCHOR_CENTER)
       ZD_SetObjectAnchorMode(%IDS_COMPASSLABEL, %ANCHOR_CENTER)
       
    ELSE
       ZD_SetObjectXY(%IDS_COMPASSBACK, nX, nY, %FALSE)
       ZD_SetObjectXY(%IDS_COMPASSARROW, nX, nY, %FALSE)
    END IF
       
    ZD_SetObjectAngle(%IDS_COMPASSARROW, nAngle, %FALSE)

END SUB


Screen shot:

(http://www.zapsolution.com/pictures/DashBoard5_01.jpg)

...

Title: Custom (hyper-realistic widget control)
Post by: Patrice Terrier on June 13, 2009, 04:17:00 PM
The Custom project, shows you how to create a "hyper-realistic" GDImage widget compass control.

It mixes 2D and 3D altogether, with the hability to change the lens layer on the fly.
All the layers are linked together to work as a single entity, you can see it using the mouse to drag the compass and/or using the keyboard with the direction keys.

The widget itself is composed of 4 layers, including one OpenGL 3D sphere animation.

All the visual parameters can be adjusted using the sliders located on the right panel.

Note: you must have a graphic card that is OpenGL 2.00+ compatible to run this project.

Screen shot:

(http://www.zapsolution.com/pictures/Custom.jpg)

...
Title: Re: DashBoard (anchor widget)
Post by: Patrice Terrier on August 08, 2011, 05:41:51 PM
The first two posts of this thread have been updated, to fix the ZIP file corruption caused by the "Server Collapse".

...