wxRectTracker
|
00001 /* **************************************************************************** 00002 * RectTrackerRatio.h * 00003 * * 00004 * (c) 2004-2012 - Rémi Peyronnet <remi+rphoto@via.ecp.fr> * 00005 * * 00006 * RectTracker was originally designed for RPhoto, but can be used separately * 00007 * It is a control similar to the CRectTracker of MS MFC. * 00008 * * 00009 * Licence : wxWindows (based on L-GPL) * 00010 * * 00011 * ************************************************************************** */ 00012 00013 00014 #ifndef __RECTTRACKERRATIO_H__ 00015 #define __RECTTRACKERRATIO_H__ 00016 00017 #include "RectTracker.h" 00018 00019 /** Tracker with Ratio constraint. 00020 * 00021 * This class adds a width/height constraint in the tracker. The user can only 00022 * drag a tracker which respect this constraint. It uses basically : 00023 * - ratio : the selected ratio (0 if none) 00024 * - orientation : the desired orientation (0 : automatic, -1 : portrait, 1 : landscape) 00025 * - fixed size : to set a constant size which cannot be resized 00026 * - 4 guides line with a given radio (ex : 0 = none; 0.5 = middle ; 0.66 = third) 00027 * 00028 */ 00029 class wxRectTrackerRatio : public wxRectTracker 00030 { 00031 DECLARE_CLASS(wxRectTrackerRatio) 00032 public: 00033 wxRectTrackerRatio(wxWindow* parent, wxFrame * frame = NULL); 00034 virtual ~wxRectTrackerRatio(); 00035 00036 public: 00037 // Manipulation function 00038 double GetRatio() { return ratio; }; 00039 double GetGuideRatio() { return guideRatio; }; 00040 int GetOrientation() { return orientation; }; 00041 int GetFixedWidth() { return fixedWidth; } 00042 int GetFixedHeight() { return fixedHeight; } 00043 void SetRatio(double ratio); 00044 void SetGuideRatio(double ratio); 00045 void SetOrientation(int orientation); 00046 void SetFixedSize(int width, int height); 00047 00048 protected: 00049 // Behaviour Functions 00050 long CalcRectDist(wxRect r1, wxRect r2); 00051 wxRect CalcRectNearer(wxRect rr, wxRect r1, wxRect r2); 00052 virtual void AdjustTrackerRect(wxRect & curRect, int handler); 00053 void AdjustTrackerRectRatio(wxRect & curRect, int handler, bool expand); 00054 void AdjustTrackerRectFixed(wxRect & curRect, int handler); 00055 // Helper Functions 00056 virtual void DrawRect(wxDC & dc, int x, int y, int w, int h); 00057 virtual void DrawTracker(wxDC & dc, int x, int y, int w, int h); 00058 00059 protected: 00060 /// The tracker should keep this ratio (0 : don't use) 00061 double ratio; 00062 /// Ratio of the 4 guide lines (ex : 0 = none; 0.5 = middle ; 0.66 = third) 00063 double guideRatio; 00064 /// Fixed width 00065 int fixedWidth; 00066 /// Fixed height 00067 int fixedHeight; 00068 /// Orientation : 0 : automatic, -1 : portrait, 1 : landscape 00069 int orientation; 00070 }; 00071 00072 #endif // __RECTTRACKERRATIO_H__