SOL9 Sample: DialogView

SOL9 2.0 Samples

1 Screenshot


2 Source code

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



// SOL++2000 sample
// 2000.02.18
// 2012/07/19
// 2012/07/23

#define COMMONCONTROLS_V6

#include <sol\ApplicationView.h>
#include <sol\BorderLayout.h>
#include <sol\ScrolledText.h>
#include <sol\PushButton.h>
#include <sol\DialogView.h>
#include "resource.h"

namespace SOL {

class MessageDialog :public DialogView {
private:
  BorderLayout layout;
  Text         message;
  PushButton   ok;

public:
  MessageDialog(): 
  DialogView() 
  {   
  }

public:
  virtual Boolean create(View* parent, const TCHAR* title, Args& args)
  {
    Boolean rc = DialogView::create(parent, title, args); 
    
    setLayout(&layout);
    Args ar;
    ar.set(XmNstyle, (ulong)ES_MULTILINE);
    message.create(this, _T(""), ar);
    add(&message, BorderLayout::CENTER);

    ar.reset();
    ok.create(this, _T("Popdown"), ar);
    add(&ok, BorderLayout::SOUTH);
                
    resize();
        //<font color="green">Register callback to ok button to pop down this window.</font>
    ok.addCallback(XmNactivateCallback, this, 
      (Callback)&MessageDialog::popdown, NULL);
    return rc;
  }

  void setMessage(const TCHAR* text) 
  {
    message.setText(text);
  }
};

class MainView :public ApplicationView {
private:
  PushButton    popupb;
  MessageDialog  messageDlg;

public:
  //<font color="green"> Constructor</font>
  MainView(Application& applet, const TCHAR* name, Args& args)
        :ApplicationView(applet, name, args) 
  {
    Args ar;
    popupb.create(this, _T("Popup a MessageDialog"), ar);
    add(&popupb);

    ar.reset();
    ar.set(XmNx, 100);
    ar.set(XmNy, 100);
    ar.set(XmNwidth,  300);
    ar.set(XmNheight, 200);
    messageDlg.create(this, _T("MessageDialog"), ar);
    messageDlg.setMessage(_T("Hello.\r\nThis is a DialogView"));

        //<font color="green"> Register popup callback of PopupView class to the popupb.</font>
    popupb.addCallback(XmNactivateCallback, &messageDlg, 
            (Callback)&PopupView::popupAsItIs, NULL);
    
    addCallback(XmNmenuCallback, IDM_EXIT, this, 
        (Callback)&MainView::exit, NULL);
  }
};

}

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(XmNwidth, 300);
    args.set(XmNheight, 200);
    MainView view(applet, name, args);
    view.realize(); 

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

Last modified: 1 Feb 2017

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