/*
 * Copyright(c) 1999 Andrew Lister
 *                        All rights reserved
 * Permission to use, copy, modify and distribute this material for
 * any purpose and without fee is hereby granted, provided that the
 * above copyright notice and this permission notice appear in all
 * copies, and that the name of Bellcore not be used in advertising
 * or publicity pertaining to this material without the specific,
 * prior written permission of an authorized representative of
 * Bellcore.
 *
 * BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
 * PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
 * FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE
 * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
 * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
 * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
 * ING TO THE SOFTWARE.
 *
 * $Id: multibyte.c,v 1.1 1999/08/04 21:24:17 danny Exp $
 */

#include <Xbae/Matrix.h>
#include <locale.h>

void
labelCB( mw, cd, cb )
Widget mw;
XtPointer cd;
XtPointer cb;
{
    XbaeMatrixLabelActivateCallbackStruct *cbs =
	( XbaeMatrixLabelActivateCallbackStruct * )cb;

    if( cbs->row_label )
	if( XbaeMatrixIsRowSelected( mw, cbs->row ) )
	    XbaeMatrixDeselectRow( mw, cbs->row );
	else
	    XbaeMatrixSelectRow( mw, cbs->row );
    else
	if( XbaeMatrixIsColumnSelected( mw, cbs->column ) )
	    XbaeMatrixDeselectColumn( mw, cbs->column );
	else
	    XbaeMatrixSelectColumn( mw, cbs->column );
}

/*
 * Simple example of loaded Matrix
 */


String text[] =
{
    "一部のダム端末では、前処理フラグを参照によ り",
    "生成される縦方向の動作を処理できません。このような端末で出力",
    "エラーを防ぐには、 e フラグを指定するときに t も同時に指定し",
    "て、暗黙的にを呼び出してください。ただしこの回避処置",
    "をとると、スーパースクリプト (上付き文字) とサブスクリプト (",
    "下付き文字) の出力が、たとえ端末がその出力機能を持っていても",
    "不可能になってしまうという欠点があります。端末がの出",
    "力 により正常に動作しなくなってしまったら、を使っ",
};


int
main(argc, argv)
int argc;
char *argv[];
{
    Widget toplevel, mw;
    XtAppContext app;

#ifdef USE_EDITRES
    extern void _XEditResCheckMessages();
#endif

    setlocale(LC_ALL, "");
    toplevel = XtVaAppInitialize(&app, "Multibyte",
				 NULL, 0,
				 &argc, argv,
				 NULL,
				 NULL);
#ifdef USE_EDITRES
    XtAddEventHandler( toplevel, (EventMask)0, True,
                       _XEditResCheckMessages, NULL);
#endif

    mw = XtVaCreateManagedWidget("mw",
				 xbaeMatrixWidgetClass, toplevel,
				 XmNrows, sizeof(text)/sizeof(text[0]),
				 XmNcolumns, 1,
				 NULL);

    XtAddCallback( mw, XmNlabelActivateCallback, ( XtCallbackProc )labelCB,
		   NULL );
    
    XtRealizeWidget(toplevel);

    XtAppMainLoop(app);
    
    /*NOTREACHED*/
    return 0;
}

