home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / PASM.LZH / DSELCOL.CPP < prev    next >
C/C++ Source or Header  |  1996-07-03  |  4KB  |  171 lines

  1. /*  Project partsasm
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    partsasm.apx Application
  6.     ファイル:        dselcol.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TDSelColor (TDialog) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include "dselcol.h"
  19. #include "owl\radiobut.h"
  20. #include "owl\edit.h"
  21.  
  22.  
  23. //
  24. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  25. // 応答テーブルを作成する
  26. //
  27. DEFINE_RESPONSE_TABLE1(TDSelColor, TDialog)
  28. //{{TDSelColorRSP_TBL_BEGIN}}
  29.     EV_BN_CLICKED(IDOK, CmOK),
  30.     EV_WM_PAINT,
  31.     EV_WM_LBUTTONDOWN,
  32. //{{TDSelColorRSP_TBL_END}}
  33. END_RESPONSE_TABLE;
  34.  
  35.  
  36. //{{TDSelColor Implementation}}
  37.  
  38.  
  39. TDSelColor::TDSelColor (TWindow* parent, int icolor, int ilight, int iwidth, int iheight):
  40.     TDialog(parent, IDD_COLOR, 0)
  41. {
  42.     // INSERT>> コンストラクタ用のコードはここに
  43.  
  44.     editwidth  = new TEdit(this, IDC_REND_WIDTH);
  45.     editheight = new TEdit(this, IDC_REND_HEIGHT);
  46.  
  47.     selcolor = icolor;
  48.     sellight = ilight;
  49.     selwidth = iwidth;
  50.     selheight = iheight;
  51.     int i;
  52.     for (i = 0; i < SELCOL_COLORS; ++i) {
  53.         button[i] = new TRadioButton(this, IDC_COLOR_WH + i);
  54.     }
  55.     for (i = 0; i < SELCOL_LIGHTS; ++i) {
  56.         lbutton[i] = new TRadioButton(this, IDC_LIGHT_LEFT + i);
  57.     }
  58. }
  59.  
  60.  
  61. TDSelColor::~TDSelColor ()
  62. {
  63.     Destroy();
  64.  
  65.     // INSERT>> デストラクタ用のコードはここに
  66.  
  67. }
  68.  
  69.  
  70. void TDSelColor::SetupWindow ()
  71. {
  72.     TDialog::SetupWindow();
  73.  
  74.     // INSERT>> 追加のコードはここに
  75.  
  76.     if (0 <= selcolor && selcolor < SELCOL_COLORS) {
  77.         button[selcolor]->Check();
  78.     }
  79.     if (0 <= sellight && sellight < SELCOL_LIGHTS) {
  80.         lbutton[sellight]->Check();
  81.     }
  82.     char mes[32];
  83.     wsprintf(mes, "%d", selwidth);
  84.     editwidth->SetText(mes);
  85.     wsprintf(mes, "%d", selheight);
  86.     editheight->SetText(mes);
  87. }
  88.  
  89.  
  90. void TDSelColor::CmOK ()
  91. {
  92.     // INSERT>> 追加コードはここに
  93.     int i;
  94.     for (i = 0; i < SELCOL_COLORS; ++i) {
  95.         if (button[i]->GetCheck() == BF_CHECKED) {
  96.             selcolor = i;
  97.         }
  98.     }
  99.     for (i = 0; i < SELCOL_LIGHTS; ++i) {
  100.         if (lbutton[i]->GetCheck() == BF_CHECKED) {
  101.             sellight = i;
  102.         }
  103.     }
  104.     int n;
  105.     char mes[32];
  106.     editwidth->GetText(mes, 32);
  107.     n = atoi(mes);
  108.     if (0 < n && n <= 2048) selwidth = n;
  109.  
  110.     editheight->GetText(mes, 32);
  111.     n = atoi(mes);
  112.     if (0 < n && n <= 2048) selheight = n;
  113.  
  114.     CloseWindow(IDOK);
  115. }
  116.  
  117. void TDSelColor::EvPaint ()
  118. {
  119.     TDialog::EvPaint();
  120.  
  121.     // INSERT>> 追加コードはここに
  122.  
  123.     // INSERT>> 追加のコードはここに
  124.     static TColor col[SELCOL_COLORS] = {
  125.                         TColor::White,
  126.                         TColor::LtBlue,
  127.                         TColor::LtRed,
  128.                         TColor::LtGreen,
  129.                         TColor::LtMagenta};
  130.     TClientDC dc(*this);
  131.  
  132.     int y1, y2;
  133.     y1 = button[0]->Attr.Y - 12;
  134.     y2 = y1+12;
  135.  
  136.     for (int i = 0; i < SELCOL_COLORS; ++i) {
  137.         dc.SelectObject(TBrush(col[i]));
  138.         dc.Rectangle(button[i]->Attr.X, y1,
  139.                     button[i]->Attr.X + button[i]->Attr.W,y2);
  140.     }
  141.  
  142. }
  143.  
  144.  
  145.  
  146. void TDSelColor::EvLButtonDown (UINT modKeys, TPoint& point)
  147. {
  148.     TDialog::EvLButtonDown(modKeys, point);
  149.  
  150.     // INSERT>> 追加コードはここに
  151.  
  152.     int y1, y2;
  153.     y1 = button[0]->Attr.Y - 12;
  154.     y2 = y1+12;
  155.  
  156.     for (int i = 0; i < SELCOL_COLORS; ++i) {
  157.         if (point.x >= button[i]->Attr.X
  158.          && point.x <= button[i]->Attr.X + button[i]->Attr.W
  159.          && point.y >= y1 && point.y <= y2) {
  160.             for (int j = 0; j < SELCOL_COLORS; ++j) {
  161.                 if (i == j) {
  162.                     button[j]->SetCheck(BF_CHECKED);
  163.                 } else {
  164.                     button[j]->SetCheck(BF_UNCHECKED);
  165.                 }
  166.             }
  167.          }
  168.     }
  169. }
  170.  
  171.