SOL9 2.0 Class: Button

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * Button.h 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
// 2000.02.18
#pragma once

#include <sol\Primitive.h>

namespace SOL {

class Button :public Primitive {
protected:
//    LRESULT    defaultProc(Event& event);

public:
    Button() :Primitive() { }

public:
    Button(View* parent, HWND hwnd)
        :Primitive(parent, hwnd) { }

public:
    Button(View* parent, const TCHAR* name, Args& args)
    :Primitive(parent, name, 
            args.set(XmNpredefined, True)
                .set(XmNuseDefaultFont, _T("true"))
                .set(XmNclassName, _T("Button")))
    {
        ulong val;
        if (args.get(XmNwidth, &val)  == False ||
            args.get(XmNheight, &val) == False) {
            const TCHAR*   label = name;
            if (args.get(XmNlabelString, &val))
                label = (TCHAR*)val;
            resize(label);
        }
    }

public:
    //<added date="2000.02.13">
    virtual Boolean Button::create(View* parent, const TCHAR* name, Args& args)
    {
        Boolean rc = Primitive::create(parent, name, 
            args.set(XmNpredefined, True)
                .set(XmNuseDefaultFont, _T("true"))
                .set(XmNclassName, _T("Button")));

        ulong val;
        if (args.get(XmNwidth, &val)  == False ||
            args.get(XmNheight, &val) == False) {
            const TCHAR*   label = name;
            if (args.get(XmNlabelString, &val))
                label = (TCHAR*)val;
            resize(label);
        }
        return rc;
    }

//</added>
public:
    long defaultProc(Event& event)
    {
        return discardInput(event);
    }

public:
    void Button::disable()
    {
        if(isEditable()) {
            if(!getNewProc()) 
                replaceWindowProc();
        } else {
               View::disable();
        }
    }

public:
    void Button::enable()
    {
        if(isEditable()) {
            restoreWindowProc();
        } else {
             View::enable();
        }
    }

public:
    Arg* Button::getCallbackTable(int* num)
    {
        static Arg table[] = {
            {XmNactivateCallback,      BN_CLICKED},
         };
        *num = XtNumber(table);
        return table;
    }


    const TCHAR*    defaultCallbackName() { 
        return XmNactivateCallback; 
    }

    
    int        getCheck() {
            return (int)send(BM_GETCHECK, 0, 0L);
    }
    int        getState() {
            return (int)send(BM_GETSTATE, 0, 0L);
    }
    void    setCheck(int check) {
            send(BM_SETCHECK, check, 0L);
    }
    void    setState(int state) {
            send(BM_SETSTATE, state, 0L);
    }
};

}



Last modified: 19 Dec 2009

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