I wrote this because I was fed up with using dbPrint which is what I consider to be a poorly designed command.
The main thing that irritated me when using dbPrint was having to constantly convert data to meet dbPrint's needs because it only took a small number of data types. MikePrint more or less ends this problem.
MikePrint's key features are:
-Create text area objects who's properties can be individually changed e.g. font, text style, text color, text background color, text size etc.
-Wrap text on a per word basis or a per letter basis.
-Easily print most data types without manually converting between one an other. The system used is similar to that of “iostream.h”'s cout.
Below is an example application that uses MikePrint. There are 3 text area's (top left, top right and bottom) all with different text and properties.
Screenshot:
Code:
#include "DarkGDK.h"
#include "MikePrint.h"
void DarkGDK()
{
// Setup some text areas
// Create them
MikePrint mpTopLeftBox;
MikePrint mpTopRightBox;
MikePrint mpBottomBox;
// Set their dimensions
// Top left box fills the top left of the window
// Top right box fills the top right of the window
// Bottom box fills the bottom half of the window
mpTopLeftBox.SetAnchor(0,0);
mpTopLeftBox.SetMax(dbScreenWidth()/2);
mpTopRightBox.SetAnchor(dbScreenWidth()/2,0);
mpTopRightBox.SetMax(dbScreenWidth());
mpBottomBox.SetAnchor(0,dbScreenHeight()/2);
mpBottomBox.SetMax(dbScreenWidth());
// Set wrapping mode
// Top left box and bottom box wrap on a letter basis
// Top right box wraps on a word basis
mpTopLeftBox.SetWrap(WW_LETTER);
mpTopRightBox.SetWrap(WW_WORD);
mpBottomBox.SetWrap(WW_LETTER);
// Show red cursor on top left box
// Default is off so other boxes will not show cursor
mpTopLeftBox.SetCursorVisible(true);
mpTopLeftBox.SetCursorColor(dbRGB(255,0,0));
// Set text color for boxes
// Top left box text is coloured green
// Top right box text is coloured blue
// Bottom box text is coloured red
mpTopLeftBox.SetTextColor(dbRGB(0,255,0));
mpTopRightBox.SetTextColor(dbRGB(0,0,255));
mpBottomBox.SetTextColor(dbRGB(255,0,0));
// Set text opaque and background colour
// Top left box text background is blue
// By default other boxes' text have no background, they are transparent
mpTopLeftBox.SetTextOpaque(true);
mpTopLeftBox.SetTextBackgroundColor(dbRGB(0,0,255));
// Set text styles
// Top left box text is bold
// Top right box text is italic
// Bottom box is by default normal
mpTopLeftBox.SetTextStyle(S_BOLD);
mpTopRightBox.SetTextStyle(S_ITALIC);
// Set text font
// Top left box text is 'Comic Sans MS'
// Top right box text is 'Arial Black'
// Bottom box text is 'Times New Roman'
mpTopLeftBox.SetTextFont("Comic Sans MS");
mpTopRightBox.SetTextFont("Arial Black");
mpBottomBox.SetTextFont("Times New Roman");
// Set text size
// Top left box text is size 30
// Top right box text is size 18
// Bottom box text is size 32
mpTopLeftBox.SetTextSize(30);
mpTopRightBox.SetTextSize(18);
mpBottomBox.SetTextSize(32);
// Write text in boxes
// Top left box text
mpTopLeftBox << "Hello, my name is professor plum and I'm wrapping by letters. My text size is "<<mpTopLeftBox.GetTextSize()<<". My font is "<<mpTopLeftBox.GetTextFont();
mpTopLeftBox << ". By the way, those red lines are my cursor which is quite beautiful although really they are just useful for debugging";
// Top right box text
mpTopRightBox << "Look at me i'm wrapping by words so that when a word is too big for a line, it goes onto another line! Rather magical..nnn";
mpTopRightBox << "Hey, I made some new lines :). ";
DWORD dOldTextColour = mpTopRightBox.GetTextColor();
mpTopRightBox.SetTextColor(dbRGB(200,200,200));
mpTopRightBox << "Woah! I feel a bit pale!! ";
mpTopRightBox.SetTextColor(dOldTextColour);
mpTopRightBox << "Phew, I feel better now..";
// Bottom box text
mpBottomBox << "Would you like to see an integer? Yes.. you would: "<<5<<". Wow that was fun! Just to let you know, i'm wrapping by letters.";
mpBottomBox.SetCursorVisible(true);
mpBottomBox << " HERE'S MY CURSOR!";
mpBottomBox.SetCursorVisible(false);
mpBottomBox << " *woosh* and now its gone again (thank goodness for that).";
// Wait for a key to be pressed before exiting
dbWaitKey();
return;
}
MikePrint files and documentation are attached to this post in a zip file, click download to get them. The documentation explains how to get going with MikePrint.
Let me know what you think of this and if there are any problems with it