CTGRWindowPlacementDlg::WPDImpl::CreateParts()ではパーツを作って配置していきます。これは力業です。この部分はGUI開発環境で要所要所のパーツを含む画面を作ってひな形となるソースを書き出させて、規則的に生成出来る部分はエディタでコピーしながら作ってしまった方が簡単です。
トップレベルウィンドウの作成はこんな↓感じでやっています。
void CTGRWindowPlacementDlg::WPDImpl::CreateParts()
{
WPDImplMain = new WSCmainWindow(al::gui::GetAppMainWindow(),"WPDImplMain");
WPDImplMain->initialize();
WPDImplMain->setPropertyV(WSNname,"WPDImplMain");
WPDImplMain->setPropertyV(WSNtitleString,"お手軽ウィンドウ配置ダイアログ");
// WPDImplMain->setPropertyV(WSNx,(short)100);
// WPDImplMain->setPropertyV(WSNy,(short)100);
WPDImplMain->setPropertyV(WSNwidth,(unsigned short)410);
WPDImplMain->setPropertyV(WSNheight,(unsigned short)480);
WPDImplMain->setPropertyV(WSNbackColor,"#c0c0ff");
WPDImplMain->setPropertyV(WSNtopShadowColor,"#ffffff");
WPDImplMain->setPropertyV(WSNbottomShadowColor,"#8080c0");
WPDImplMain->setPropertyV(WSNtitleBar,(char)3);
WPDImplMain->setPropertyV(WSNshadowType,(char)4);
WPDImplMain->setPropertyV(WSNvis,(WSCbool)0);
WPDImplMain->setPropertyV(WSNexit,(WSCbool)0);
.....
new の行の al::gui::GetAppMainWindow() の呼び出しはアプリケーションのメインウィンドウを取得するための関数です。
タンゴレンではトップレベルウィンドウの表示位置は別に管理しているので、WSNxとWSNyプロパティはセットしないようにしています。
WPDImplMain->setPropertyV(WSNtitleBar,(char)3);での (char)3 のように記号定数を使うべきと思われる場所に直接値が書かれているところはGUI開発環境がそのように出力しています。わざわざ直す必要は感じないのでそのまま使っていますが、設定を変更することになったらきっと記号定数で書くでしょう。
続けて、「メインウィンドウサイズ」の枠線を表示させるためのWSCtformを、さっきのダイアログを親として生成し、座標値などを設定していきます。
WPDtfor_main_window_size = new WSCtform(WPDImplMain,"WPDtfor_main_window_size");
WPDtfor_main_window_size->initialize();
WPDtfor_main_window_size->setPropertyV(WSNtitleString,"メインウィンドウサイズ");
WPDtfor_main_window_size->setPropertyV(WSNname,"WPDtfor_main_window_size");
WPDtfor_main_window_size->setPropertyV(WSNx,(short)0);
WPDtfor_main_window_size->setPropertyV(WSNy,(short)10);
WPDtfor_main_window_size->setPropertyV(WSNwidth,(unsigned short)400);
WPDtfor_main_window_size->setPropertyV(WSNheight,(unsigned short)90);
WPDtfor_main_window_size->setPropertyV(WSNbackColor,"#c0c0ff");
WPDtfor_main_window_size->setPropertyV(WSNtopShadowColor,"#ffffff");
WPDtfor_main_window_size->setPropertyV(WSNbottomShadowColor,"#8080c0");
WPDtfor_main_window_size->setPropertyV(WSNvis,(WSCbool)1);
配置されるパーツ類のWSNx/WSNyはきっちり設定します。
座標はもちろん親ウィンドウ内の相対座標です。
更に、「幅:」見出しのWSCvlabelをフォームの上に載せ … 、
WPDvlab_mw_w = new WSCvlabel(WPDtfor_main_window_size,"WPDvlab_mw_w");
WPDvlab_mw_w->initialize();
WPDvlab_mw_w->setPropertyV(WSNshadowType,(char)-1);
WPDvlab_mw_w->setPropertyV(WSNlabelString,"幅:");
WPDvlab_mw_w->setPropertyV(WSNalignmentH,(unsigned char)1);
WPDvlab_mw_w->setPropertyV(WSNname,"WPDvlab_mw_w");
WPDvlab_mw_w->setPropertyV(WSNvis,(WSCbool)1);
WPDvlab_mw_w->setPropertyV(WSNx,(short)10);
WPDvlab_mw_w->setPropertyV(WSNy,(short)20);
WPDvlab_mw_w->setPropertyV(WSNwidth,(unsigned short)60);
選択用のラジオボタンを配置していきます。ここでは“○広い”の設定だけ示しておきます。
WPDvrad_mw_w_w = new WSCvradio(WPDtfor_main_window_size,"WPDvrad_mw_w_w");
WPDvrad_mw_w_w->initialize();
WPDvrad_mw_w_w->setPropertyV(WSNunique,(WSCbool)1);
WPDvrad_mw_w_w->setPropertyV(WSNgroup,"WPDvrad_mw_w");
WPDvrad_mw_w_w->setPropertyV(WSNselectReset,(WSCbool)1);
WPDvrad_mw_w_w->setPropertyV(WSNbackColor,"#c0c0ff");
WPDvrad_mw_w_w->setPropertyV(WSNtopShadowColor,"#ffffff");
WPDvrad_mw_w_w->setPropertyV(WSNbottomShadowColor,"#8080c0");
WPDvrad_mw_w_w->setPropertyV(WSNlabelString,"広い");
WPDvrad_mw_w_w->setPropertyV(WSNname,"WPDvrad_mw_w_w");
WPDvrad_mw_w_w->setPropertyV(WSNvis,(WSCbool)1);
WPDvrad_mw_w_w->setPropertyV(WSNx,(short)75);
WPDvrad_mw_w_w->setPropertyV(WSNy,(short)20);
WPDvrad_mw_w_w->setPropertyV(WSNwidth,(unsigned short)60);
ラジオボタンの設定で大事なのは、グループ化されるボタンにはWSNgroupプロパティで同じ文字列(グループ名)を与えておくことと、WSNuniqプロパティをTrue(つまり(WSCbool)1)にしておくこと。まあ、当たり前ですが。
最下段の四角く配置されたラジオボタンにはテキストがありませんが、単にWSNlabelStringプロパティをセットしていないだけで、特に変わったことをしている訳ではありません。WSNwidthが24というのはボタンが綺麗に並ぶように、見た目で適当に決めた値です。
あと、CTGRWindowPlacementDlg::WPDImpl::SetupVectorsは、配列形式で処理出来るようにするために各パーツへのポインタをvector変数にpush_back()しています。これも力業ですが、こういう風にしておくと、一部の処理は楽になります。
(続く)