Branded Dialogs

This library file allows you to easily create branded dialog boxes. The dialogs have a canvas across the top with your logo and a link to your website.

Include this file and call smartDialog() instead of create() when creating your dialog.

Usage:

DB smartDialog([Module m | DB db,] string title [,int options])

You will need to edit the include file to define your logo bitmap file and website URL etc.

Source file:

//<  Smart DXL Dialog Definitions

/*
    S M A R T   D X L   L I M I T E D

    Copyright:          (c) 2008 Smart DXL Limited.

    The information contained in this document is the property
    of Smart DXL Limited. Transmittal, receipt or possession
    of this information does not express licence or imply any
    rights to use sell or manufacture from this information
    and no reproduction of it in whole or part shall be made
    without the written authorisation from an officer of the company.

	Description:

	Provides smartDialog function to create a dialog box with a Smart DXL
	banner across the top.

	Usage:

		DB smartDialog([Module m | DB db,] string title [,int options])

	Change History:

	25-NOV-2008		Tony Goodman	Initial version.

	24-FEB-2011		Tony Goodman	Locate bitmap from addins path.
											Add banner title and website url.
											Use more complex names for global variables.

*/

/***********************************
	Smart DXL logo bitmap file - this is loaded once when first dialog is displayed.
***********************************/
Bitmap smartDxlLogo = null

string SMART_DXL_DB_TITLE      = "Smart DXL"
string SMART_DXL_BANNER_WEBSITE  = "www.smartdxl.com"
string SMART_DXL_BANNER_BITMAP    = "SmartDXL\\bitmaps\\tophat.bmp"

DBE smartDxlBanner = null

bool smartDxlLogoFound = false

string smartDxlBannerText = ""

int   smartDxlLogoWidth   = 0
int   smartDxlLogoHeight  = 0

/***********************************
	getAbsolutePath
***********************************/
string getAbsolutePath(string sFileName)
{
	string sResult  = ""

	string sAddinsPathList      = (getenv "ADDINS") ";"
	string sDoorsAddinsPathList = (getenv "DOORSADDINS") ";"

	if (sAddinsPathList != sDoorsAddinsPathList)
	{
		sAddinsPathList = sDoorsAddinsPathList ";" sAddinsPathList
	}

	Regexp rPath = regexp "([^;]*);(.*)"

	string sLeft    = ""
	string sRight   = ""

	if (rPath sAddinsPathList)
	{
		// test each path in the semicolon separated list
		while (rPath sAddinsPathList)
		{
			  sLeft  = sAddinsPathList[match 1]
			  sRight = sAddinsPathList[match 2]

			  if (fileExists_ (sLeft "\\" sFileName))
			  {
					sResult  = sLeft "\\" sFileName
					break;
			  }
			  else
			  {
					sAddinsPathList = sRight
			  }
		}
	}
	return(sResult)
}

/************************************
  smartDrawLogo
************************************/
void smartDrawLogo(DBE cnvs)
{
	string smartDxlBitmapFile = ""
	Stat   st = null

	if (null smartDxlLogo)
	{
		// bitmap has not been loaded yet, so load it
		smartDxlBitmapFile = getAbsolutePath(SMART_DXL_BANNER_BITMAP)

		// check that the file exists
		st = create(smartDxlBitmapFile)

		if (!null st)
		{
			// file does exist so we can load the bitmap
			delete(st)

			smartDxlLogo = loadBitmap(cnvs, smartDxlBitmapFile, false, smartDxlLogoWidth, smartDxlLogoHeight)
		}
    }

    // draw the bitmap if it was successfully loaded
    if (!null smartDxlLogo)
    {
    	drawBitmap(cnvs, smartDxlLogo, 0, 0)
		smartDxlLogoFound = true
	}
}

/***********************************
	doLogoMouse
***********************************/
void doLogoMouse(DBE cnv, int but, bool ctrl, int x, int y)
{
	if (x > width(cnv) - width(cnv, SMART_DXL_BANNER_WEBSITE) - 5)
	{
		activateURL(SMART_DXL_BANNER_WEBSITE)
	}
}

/***********************************
	doRepaintSmartDxlBanner
***********************************/
void doRepaintSmartDxlBanner(DBE cnv)
{
	int canvasWidth  = width(cnv)
	int titleHeight  = 0
	int y = 0

	realBackground(cnv, realColor_White)

	smartDrawLogo(cnv)

	realColor(cnv, realColor_Black)
	font(cnv, 4, HeadingsFont)

	y = (height(cnv) / 2) + (height(cnv, smartDxlBannerText) / 2) - 3

	draw(cnv, smartDxlLogoWidth + 3, y, smartDxlBannerText)

	realColor(cnv, realColor_Blue)
	font(cnv, 9, HeadingsFont)
	draw(cnv, canvasWidth - width(cnv, SMART_DXL_BANNER_WEBSITE) - 5, y - 1, SMART_DXL_BANNER_WEBSITE)
	line(cnv, canvasWidth - width(cnv, SMART_DXL_BANNER_WEBSITE) - 5, y, canvasWidth - 5, y)
}

/***********************************
	addSmartDxlBanner
***********************************/
void addSmartDxlBanner(DB db)
{
	smartDxlBanner = canvas(db, 0, 32, doRepaintSmartDxlBanner)

	set(smartDxlBanner, doLogoMouse)
}

/***********************************
	showHelp
***********************************/
void showHelp(string helpFile)
{
	system("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" -nohome \"" (getAbsolutePath(helpFile)) "\"")
}

/***********************************
	smartDialog
***********************************/
DB smartDialog(string banner, int options)
{
	DB smartDb = null

	smartDb = create(SMART_DXL_DB_TITLE, options)

	smartDxlBannerText = banner

	addSmartDxlBanner(smartDb)

    return(smartDb)
}

/***********************************
	smartDialog
***********************************/
DB smartDialog(string dbTitle)
{
	return(smartDialog(dbTitle, styleCentered|styleFloating))
}	

/***********************************
	smartDialog
***********************************/
DB smartDialog(Module mParent, string banner, int options)
{
	DB smartDb = null

	smartDb = create(mParent, SMART_DXL_DB_TITLE, options)

	smartDxlBannerText = banner

	addSmartDxlBanner(smartDb)

    return(smartDb)
}

/***********************************
	smartDialog
***********************************/
DB smartDialog(Module mParent, string dbTitle)
{
	return(smartDialog(mParent, dbTitle, styleCentered|styleFloating))
}

/***********************************
	smartDialog
***********************************/
DB smartDialog(DB dbParent, string banner, int options)
{
	DB  smartDb     = null

	smartDb = create(dbParent, SMART_DXL_DB_TITLE, options)

	smartDxlBannerText = banner

	addSmartDxlBanner(smartDb)

    return(smartDb)
}

/***********************************
	smartDialog
***********************************/
DB smartDialog(DB dbParent, string banner)
{
	return(smartDialog(dbParent, banner, styleCentered|styleFloating))
}