From: <pst...@us...> - 2013-03-18 18:45:05
|
Revision: 970 http://sourceforge.net/p/jazzplusplus/code/970 Author: pstieber Date: 2013-03-18 18:45:02 +0000 (Mon, 18 Mar 2013) Log Message: ----------- Started adding a new control to alter arrays. Added Paths: ----------- trunk/jazz/src/ArrayControl.cpp trunk/jazz/src/ArrayControl.h Added: trunk/jazz/src/ArrayControl.cpp =================================================================== --- trunk/jazz/src/ArrayControl.cpp (rev 0) +++ trunk/jazz/src/ArrayControl.cpp 2013-03-18 18:45:02 UTC (rev 970) @@ -0,0 +1,110 @@ +#include "ArrayControl.h" + +#include "Random.h" + +#include <wx/dcclient.h> + +//***************************************************************************** +// Description: +// This is the array control class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +BEGIN_EVENT_TABLE(JZArrayControl, wxControl) + EVT_SIZE(JZArrayControl::OnSize) + EVT_PAINT(JZArrayControl::OnPaint) +END_EVENT_TABLE() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZArrayControl::JZArrayControl( + wxWindow* pParent, + wxWindowID Id, + const JZRndArray& RandomArray, + const wxPoint& Position, + const wxSize& Size, + long WindowStyle, + const wxValidator& Validator, + const wxString& Name) + : wxControl(), + mpRandomArray(0) +{ + mpRandomArray = new JZRndArray(RandomArray); + + Create( + pParent, + Id, + RandomArray, + Position, + Size, + WindowStyle, + Validator, + Name); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZArrayControl::~JZArrayControl() +{ + delete mpRandomArray; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZArrayControl::Create( + wxWindow* pParent, + wxWindowID Id, + const JZRndArray& RandomArray, + const wxPoint& Position, + const wxSize& Size, + long WindowStyle, + const wxValidator& Validator, + const wxString& Name) +{ + wxControl::Create( + pParent, + Id, + Position, + Size, + WindowStyle | wxNO_BORDER, + Validator, + Name); + + SetInitialSize(Size); + + *mpRandomArray = RandomArray; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZArrayControl::OnSize(wxSizeEvent& SizeEvent) +{ + int Width = SizeEvent.GetSize().GetWidth(); + int Height = SizeEvent.GetSize().GetHeight(); + + SizeEvent.Skip(); + + wxClientDC Dc(this); + + int TextWidth, TextHeight; + Dc.GetTextExtent("123", &TextWidth, &TextHeight); + +#if 0 + if (mStyleBits & ARED_XTICKS) + { + Height -= TextHeight; + } + if (mStyleBits & (ARED_MINMAX | ARED_YTICKS)) + { + x = (int)(TextWidth + TICK_LINE); + Width -= (int)(TextWidth + TICK_LINE); + } + ynul = y + height - Height * (nul - min) / (max - min); +#endif +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZArrayControl::OnPaint(wxPaintEvent& Event) +{ +} Property changes on: trunk/jazz/src/ArrayControl.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/jazz/src/ArrayControl.h =================================================================== --- trunk/jazz/src/ArrayControl.h (rev 0) +++ trunk/jazz/src/ArrayControl.h 2013-03-18 18:45:02 UTC (rev 970) @@ -0,0 +1,46 @@ +#pragma once + +#include <wx/control.h> + +class JZRndArray; + +//***************************************************************************** +//***************************************************************************** +class JZArrayControl : public wxControl +{ + public: + + JZArrayControl( + wxWindow* pParent, + wxWindowID Id, + const JZRndArray& RandomArray, + const wxPoint& Position = wxDefaultPosition, + const wxSize& Size = wxSize(40, 40), + long WindowStyle = wxNO_BORDER, + const wxValidator& Validator = wxDefaultValidator, + const wxString& Name = wxT("arraycontrol")); + + virtual ~JZArrayControl(); + + void Create( + wxWindow* pParent, + wxWindowID Id, + const JZRndArray& RandomArray, + const wxPoint& Position = wxDefaultPosition, + const wxSize& Size = wxSize(40, 40), + long WindowStyle = wxNO_BORDER, + const wxValidator& Validator = wxDefaultValidator, + const wxString& Name = wxT("arraycontrol")); + + private: + + void OnSize(wxSizeEvent& Event); + + void OnPaint(wxPaintEvent& Event); + + private: + + JZRndArray* mpRandomArray; + + DECLARE_EVENT_TABLE() +}; Property changes on: trunk/jazz/src/ArrayControl.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |