SOL9 Sample: PopupView

SOL9 2.0 Samples

1 Screenshot


2 Source code

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



// SOL++2000 sample
// 2000.02.18

#define COMMONCONTROLS_V6

#include <sol\ApplicationView.h>
#include <sol\BorderLayout.h>
#include <sol\PushButton.h>
#include <sol\PopupView.h>
#include <sol\Static.h>
#include "resource.h"

namespace SOL {

class PopupMessage :public PopupView {
private:
  Static    message;
  PushButton  ok;
  BorderLayout layout;
  
public:
  PopupMessage(): PopupView() { }


public:
  virtual Boolean create(View* parent, const TCHAR* title, Args& args)
  {
    Boolean rc = PopupView::create(parent, title, args);
    setLayout(&layout);
    Args ar;
    message.create(this, NULL, ar);
    add(message, BorderLayout::CENTER);
    
    ar.reset();
    ok.create(this, _T("Popdown"), ar);
    add(ok, BorderLayout::SOUTH);
    // Call resize method to layout imediately.
    resize();    

    //<font color="green"> Register callback to ok button to pop down this window.</font>
    ok.addCallback(XmNactivateCallback, this,
          (Callback)&PopupMessage::popdown, NULL);
    return rc;
  }

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

// 
class MainView :public ApplicationView {
private:
  PushButton     popupb;
    PopupMessage  message;

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

    ar.reset();
    ar.set(XmNwidth,  300);
    ar.set(XmNheight, 100);
    ar.set(XmNstyle, (ulong)WS_THICKFRAME|WS_MINIMIZEBOX|WS_SYSMENU);

    message.create(this, _T("PopupMessage"), ar);
    message.setMessage(_T("This is a PopupView"));

    addCallback(XmNmenuCallback, IDM_EXIT, this,
      (Callback)&MainView::exit, NULL);

    //<font color="green"> Register popup callback of PopupMessage class to the popupb.</font>
    popupb.addCallback(XmNactivateCallback, &message, 
      (Callback)&PopupView::popup, 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.