SOL9 2.0 Sample: IconHolder

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * IconHolder.cpp 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
// 2000.02.18


#include <sol\ApplicationView.h>
#include <sol\Icon.h>
#include <sol\PaintDC.h>

namespace SOL {

class IconHolder :public ApplicationView {
private:
    int      num;
    Icon**    icons;
/*
    long      paint(Event& event);
  public:
    IconHolder(Application& applet, const TCHAR* name, Args& args);
    ~IconHolder();
};
*/

public:
    IconHolder(Application& applet, const TCHAR* name, Args& args)
    :ApplicationView(applet, name, 
        args.set(XmNstyle, (ulong)WS_VSCROLL|WS_HSCROLL))
    {
        num   = 5;
        icons = new Icon*[num];
        int x = 20;
        int y = 20;
        int n = 0;

        icons[n] = new Icon(_T("Application"), LoadIcon(NULL,IDI_APPLICATION));
        icons[n++] -> move(x, y); x += 100;

        icons[n] = new Icon(_T("Asterisk"),    LoadIcon(NULL,IDI_ASTERISK));
        icons[n++] -> move(x, y); x += 100;

        icons[n] = new Icon(_T("Exclamation"), LoadIcon(NULL,IDI_EXCLAMATION));
        icons[n++] -> move(x, y); x += 100;

        icons[n] = new Icon(_T("Hand"), LoadIcon(NULL,IDI_HAND));
        icons[n++] -> move(x, y); x += 100;

        icons[n] = new Icon(_T("Question"),    LoadIcon(NULL,IDI_QUESTION));
        icons[n++] -> move(x, y); 

        addEventHandler(WM_PAINT, this,
            (Handler)&IconHolder::paint, NULL);
    }

public:
    ~IconHolder()
    {
        for(int i = 0; i<num; i++)
            delete icons[i];
    }

private:
    long paint(Event& event)
    {
        PaintDC pdc(this);
        int x     = getScrollPos(SB_HORZ);
        int y     = getScrollPos(SB_VERT);
        for(int i = 0; i<num; i++) {
            icons[i]->draw(pdc.get(), -x, -y);
        }
        return NULL;
    }
};

}


//

void    Main(int argc, TCHAR** argv)
{
    const String  appClass= "IconHolder";
    try {
        Application applet(appClass, argc, argv);

        Args args;
        args.set(XmNhorizScrollMaximum, 200);
        args.set(XmNvertScrollMaximum,   30);
        args.set(XmNclassStyle, 0);

        IconHolder iconHolder(applet, appClass, args);
        iconHolder.realize();

        applet.run();
    } catch (...) {

    }
}


Last modified: 11 Nov 2009

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