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

  1. /*  Project partsasm
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    partsasm.apx Application
  6.     ファイル:        dslider.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TDSliderInput (TDialog) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include <owl\slider.h>
  19. #include <owl\static.h>
  20. #include "dslider.h"
  21. #include "syscolor.h"
  22.  
  23. #include "log.h"
  24.  
  25. const int scaling = 10;
  26.  
  27. class TNSlider: public THSlider {
  28. public:
  29.     TNSlider(TWindow*        parent,
  30.              int             id,
  31.              int X, int Y, int W, int H,
  32.              TResId          thumbResId = IDB_HSLIDERTHUMB,
  33.              TModule*        module = 0) :
  34.         THSlider(parent, id, X, Y, W, H, thumbResId, module) {}
  35.  
  36.  
  37.     virtual int PointToPos(TPoint& point) {
  38.       return ((int)((long)point.x*Range))/((int)(Attr.W-ThumbRect.Width())) + (int)Min;
  39.     }
  40. };
  41.  
  42.  
  43. //
  44. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  45. // 応答テーブルを作成する
  46. //
  47. DEFINE_RESPONSE_TABLE1(TDSliderInput, TDialog)
  48. //{{TDSliderInputRSP_TBL_BEGIN}}
  49.     EV_CHILD_NOTIFY_ALL_CODES(IDC_SLIDER, EvSlider),
  50. //{{TDSliderInputRSP_TBL_END}}
  51. END_RESPONSE_TABLE;
  52.  
  53.  
  54. //{{TDSliderInput Implementation}}
  55.  
  56.  
  57. TDSliderInput::TDSliderInput (TWindow* parent, char *t, char *m, char **gname, int &pos, TResId resId, TModule* module):
  58.     TDialog(parent, resId, module)
  59. {
  60.     // INSERT>> コンストラクタ用のコードはここに
  61.  
  62. //    SetBkgndColor(TColor::LtGray);
  63.  
  64.     text = new TStatic(this, ID_PROMPT);
  65.     value = new TStatic(this, IDC_SLIDERVALUE, 8);
  66.     slider = new TNSlider(this, IDC_SLIDER, 45, 45, 296, 27);
  67. //    slider->SetBkgndColor(TColor::LtGray);
  68.     position = &pos;
  69.     title = t;
  70.     mess = m;
  71.     gridname = gname;
  72. }
  73.  
  74.  
  75. TDSliderInput::~TDSliderInput ()
  76. {
  77.     Destroy();
  78.  
  79.     // INSERT>> デストラクタ用のコードはここに
  80.  
  81. }
  82.  
  83.  
  84. void TDSliderInput::SetupWindow ()
  85. {
  86.     TDialog::SetupWindow();
  87.  
  88.     // INSERT>> 追加のコードはここに
  89.  
  90.     slider->SetBkgndColor(TColor::LtGray);
  91.     
  92.     slider->PageMagnitude = scaling;
  93.     slider->LineMagnitude = scaling;
  94.  
  95.     for (int i = 0; gridname[i] != NULL; ++i) {
  96.         if (gridname[i] == '\0') {
  97.             break;
  98.         }
  99.     }
  100.     slider->SetRange(0, (i-1) * scaling);
  101.     if (*position < 0) *position = 0;
  102.     if (*position > i-1) *position = i-1;
  103.     slider->SetPosition((*position) * scaling);
  104.     slider->SetRuler(scaling, TRUE);
  105. //    slider->SetPosition((*position) * scaling);
  106.     slider->MoveWindow(value->Attr.X + value->Attr.W, value->Attr.Y,
  107.                         TWindow::Attr.W - value->Attr.X*2 - value->Attr.W, value->Attr.H);
  108.     slider->SetPosition(0);
  109.     slider->SetPosition((*position) * scaling);
  110.     text->SetText(mess);
  111.     value->SetText(gridname[*position]);
  112.     SetCaption(title);
  113. }
  114.  
  115. void TDSliderInput::EvSlider(UINT /*code*/)
  116. {
  117.     if (*position != slider->GetPosition()) {
  118.         *position = slider->GetPosition()/ scaling;
  119.         value->SetText(gridname[*position]);
  120.     }
  121.  
  122. }
  123.  
  124.  
  125.