/*
* Form.h
* Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2009/09/29
// Windows WC_DIALOG class wrapper class.
//
// This class can be used to give a simple user interface to support a keyboard navigation.
// For example, you can paste a instance of this class in the client area of SOL Application Window.
#pragma once
#include <sol\Composite.h>
namespace SOL {
class Form :public Composite {
private:
long defaultProc(Event& event)
{
return FALSE;
}
public:
long close(Event& event)
{
return 0L;
}
private:
//2009/09/25
// WM_COMMAND message handler.
long Form::command(Event& event)
{
//<added date="2009/09/25">
WORD menuId = (WORD)event.getMenuId();
//For the case of menu item selection for a menuBar or contextMenu
if(event.isMenuSelected() == TRUE ||
event.fromAccelerator() == TRUE) {
// menu or accelarator has been selected.
callCallback(XmNmenuCallback, (Key)menuId,
NULL,event);
return 0L;
}
//</added>
//From the case of command message from a child control.
WORD controlId = event.getControlId();
HWND child = event.getChild();
if(controlId > 0) {
HWND item = getItem(controlId);
if(::IsWindow(item))
child = item;
}
//Find and call a callback fuction for this command message
View* view = (View*)Application::lookup(child);
const TCHAR* name = XmNactivateCallback;
if(view) {
name = view->getCallbackName(event);
}
callCallback(name, (Key)child, NULL, event);
return 0L;
}
private:
// Dialog Procedure
static BOOL FAR PASCAL procedure(HWND hwnd,
UINT message, WPARAM wParam, LPARAM lParam)
{
Event event(message, wParam, lParam);
View* view = Application::lookup(hwnd);
if(view == NULL) {
return FALSE;
}
return (BOOL) view -> dispatch(event);
}
public:
Form(): Composite() { }
public:
// WS_EX_CONTROLPARENT enables a keyboard interface
Form(View* parent, const TCHAR* name, Args& args)
:Composite(parent, name,
args.set(XmNstyle, (ulong)WS_CHILD)
.set(XmNexStyle, (ulong)(WS_EX_TRANSPARENT|WS_EX_CONTROLPARENT))
.set(XmNpredefined, TRUE)
.set(XmNclassName, (ulong)WC_DIALOG))
{
addEventHandler(WM_CLOSE, this,
(Handler)&Form::close, NULL);
setWindowLong(DWL_DLGPROC, (LPARAM)Form::procedure);
setValues(args);
}
public:
~Form()
{
}
public:
virtual Boolean create(View* parent, const TCHAR* name, Args& args)
{
Boolean rc = Composite::create(parent, name,
args.set(XmNstyle, (ulong)WS_CHILD)
.set(XmNexStyle, (ulong)(WS_EX_TRANSPARENT|WS_EX_CONTROLPARENT))
.set(XmNpredefined, TRUE)
.set(XmNclassName, (ulong)WC_DIALOG));
addEventHandler(WM_CLOSE, this,
(Handler)&Form::close, NULL);
setWindowLong(DWL_DLGPROC, (LPARAM)Form::procedure);
setValues(args);
return rc;
}
};
}
|