René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Right aligned text [Ming wrapper example]

This example right aligns text.
This flash movie was created with the following program.
RightAlignedText.cpp
#include "SWFMovie.h"

int main() {
  Movie movie   ("RightAlignedText.swf", 200, 200);
  Font     verdana ("Verdana.fdb");

  int font_size=24;

  float y=font_size;
  float Hello_width=verdana.Width("Hello"           , font_size);
  float this_width =verdana.Width("this text"       , font_size);
  float right_width=verdana.Width("is right aligned", font_size);

  Text  Hello   (verdana, font_size, 195-Hello_width, y, "Hello", 255, 0, 0);

  y+=verdana.LineHeight(font_size);
  Text  this_txt(verdana, font_size, 195-this_width , y, "this text"       , 255, 0, 0);   

  y+=verdana.LineHeight(font_size);
  Text  right_al(verdana, font_size, 195-right_width, y, "is right aligned", 255, 0, 0);   

  movie.Add(Hello   );
  movie.Add(this_txt);
  movie.Add(right_al);

  movie.BackgroundColor(0x7f, 0x7f, 0x7f);

  return 0;
}
This is one of a series of examples that demonstrates the C++ ming wrapper classes. Other examples can be found here.