SOL9 Sample: GradientLabelGadget

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * GradientLabelGadget.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
// 2008/07/01

#include <sol\ApplicationView.h>
#include <sol\GradientLabelGadget.h>
#include "resource.h"

namespace SOL {

class AppView :public ApplicationView {
private:
  GradientLabelGadget redLabel;
  GradientLabelGadget greenLabel;
  GradientLabelGadget blueLabel;
  GradientLabelGadget multiLines;

public:
  /**
   *
   */
  AppView(Application& applet, const TCHAR* label, Args& args)
  :ApplicationView(applet, label, args)
  {
    Args args1;
    Args args2;
    Args args3; 
    Args args4;

    redLabel.create(this, _T("Red label gadget."), 
      args1.set(XmNwidth, 100)  
           .set(XmNheight, 30) 
         .set(XmNtextAlignment, DT_CENTER|DT_VCENTER|DT_SINGLELINE)
           .set(XmNgradientBaseColor, 
        GradientLabelGadget::GRADIENT_BASECOLOR_RED));

    greenLabel.create(this, _T("This is a green label gadget."), 
      args2.set(XmNgradientBaseColor, 
        GradientLabelGadget::GRADIENT_BASECOLOR_GREEN));

    blueLabel.create(this, _T("This is a blue label gadget."), 
      args3.set(XmNwidth, 400)
      .set(XmNgradientBaseColor, 
        GradientLabelGadget::GRADIENT_BASECOLOR_BLUE));

    blueLabel.setHighLightTextColor();

    multiLines.create(this, _T("This is a red label gadget with multilines.\r\nYou can see a new line."),
      args4.set(XmNwidth, 500)
           .set(XmNgradientBaseColor, 
        GradientLabelGadget::GRADIENT_BASECOLOR_RED));
  
    multiLines.setMargin(10);

    addEventHandler(WM_PAINT, this, 
      (Handler)&AppView::paint, NULL);
    addCallback(XmNmenuCallback, IDM_EXIT, this,
      (Callback)&AppView::exit, NULL);
  }

private:
  long paint(Event& event)
  {
    PaintDC pdc(this);

    redLabel.draw(&pdc, 4, 4);

    greenLabel.draw(&pdc, 4, 4+50);

    blueLabel.draw(&pdc, 4, 4+50*2);

    multiLines.draw(&pdc, 4, 4+50*3);

    return 0L;
  }
};

}

// SOL9 Application main
void  Main(int argc, TCHAR** argv)
{
  ModuleFileName module(argv[0]);
  const TCHAR* name = module.getFileName();
  try {
    Application applet(name, argc, argv);

    Args args;
    args.set(XmNclassStyle, 0);
    AppView appview(applet, name, args);
    appview.realize();
    applet.run();

  } catch (Exception& ex) {
    caught(ex);
  } catch (...) {
    caught(UnknownException());
  }
}

Last modified: 1 Feb 2017

Copyright (c) 2017 Antillia.com ALL RIGHTS RESERVED.