Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 15/6/2004 00003 author: Paul D Turner 00004 00005 purpose: Interface to list header segment class. 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUIListHeaderSegment_h_ 00030 #define _CEGUIListHeaderSegment_h_ 00031 00032 #include "../Base.h" 00033 #include "../Window.h" 00034 00035 00036 #if defined(_MSC_VER) 00037 # pragma warning(push) 00038 # pragma warning(disable : 4251) 00039 #endif 00040 00041 00042 // Start of CEGUI namespace section 00043 namespace CEGUI 00044 { 00049 class CEGUIEXPORT ListHeaderSegment : public Window 00050 { 00051 public: 00052 static const String EventNamespace; 00053 static const String WidgetTypeName; 00054 00055 00056 /************************************************************************* 00057 Constants 00058 *************************************************************************/ 00059 // Event names 00064 static const String EventSegmentClicked; 00070 static const String EventSplitterDoubleClicked; 00076 static const String EventSizingSettingChanged; 00082 static const String EventSortDirectionChanged; 00088 static const String EventMovableSettingChanged; 00094 static const String EventSegmentDragStart; 00100 static const String EventSegmentDragStop; 00106 static const String EventSegmentDragPositionChanged; 00112 static const String EventSegmentSized; 00118 static const String EventClickableSettingChanged; 00119 00120 // Defaults 00121 static const float DefaultSizingArea; 00122 static const float SegmentMoveThreshold; 00123 00124 00125 /************************************************************************* 00126 Enumerated types 00127 *************************************************************************/ 00132 enum SortDirection 00133 { 00134 None, 00135 Ascending, 00136 Descending 00137 }; 00138 00139 00140 /************************************************************************* 00141 Accessor Methods 00142 *************************************************************************/ 00150 bool isSizingEnabled(void) const {return d_sizingEnabled;} 00151 00152 00165 SortDirection getSortDirection(void) const {return d_sortDir;} 00166 00167 00175 bool isDragMovingEnabled(void) const {return d_movingEnabled;} 00176 00177 00185 const Vector2f& getDragMoveOffset(void) const {return d_dragPosition;} 00186 00187 00195 bool isClickable(void) const {return d_allowClicks;} 00196 00197 00202 bool isSegmentHovering(void) const {return d_segmentHover;} 00203 00204 00209 bool isSegmentPushed(void) const {return d_segmentPushed;} 00210 00211 00216 bool isSplitterHovering(void) const {return d_splitterHover;} 00217 00218 00223 bool isBeingDragMoved(void) const {return d_dragMoving;} 00224 00225 00230 bool isBeingDragSized(void) const {return d_dragSizing;} 00231 00232 00233 const Image* getSizingCursorImage() const; 00234 const Image* getMovingCursorImage() const; 00235 00236 00237 /************************************************************************* 00238 Manipulator Methods 00239 *************************************************************************/ 00250 void setSizingEnabled(bool setting); 00251 00252 00268 void setSortDirection(SortDirection sort_dir); 00269 00270 00281 void setDragMovingEnabled(bool setting); 00282 00283 00294 void setClickable(bool setting); 00295 00296 00297 void setSizingCursorImage(const Image* image); 00298 void setSizingCursorImage(const String& name); 00299 void setMovingCursorImage(const Image* image); 00300 void setMovingCursorImage(const String& name); 00301 00302 00303 /************************************************************************* 00304 Construction & Destruction 00305 *************************************************************************/ 00310 ListHeaderSegment(const String& type, const String& name); 00311 00312 00317 virtual ~ListHeaderSegment(void); 00318 00319 00320 protected: 00321 /************************************************************************* 00322 Implementation Methods 00323 *************************************************************************/ 00334 void doDragSizing(const Vector2f& local_mouse); 00335 00336 00347 void doDragMoving(const Vector2f& local_mouse); 00348 00349 00354 void initDragMoving(void); 00355 00356 00361 void initSizingHoverState(void); 00362 00363 00368 void initSegmentHoverState(void); 00369 00370 00383 bool isDragMoveThresholdExceeded(const Vector2f& local_mouse); 00384 00385 /************************************************************************* 00386 New Event Handlers 00387 *************************************************************************/ 00392 virtual void onSegmentClicked(WindowEventArgs& e); 00393 00394 00399 virtual void onSplitterDoubleClicked(WindowEventArgs& e); 00400 00401 00406 virtual void onSizingSettingChanged(WindowEventArgs& e); 00407 00408 00413 virtual void onSortDirectionChanged(WindowEventArgs& e); 00414 00415 00420 virtual void onMovableSettingChanged(WindowEventArgs& e); 00421 00422 00427 virtual void onSegmentDragStart(WindowEventArgs& e); 00428 00429 00434 virtual void onSegmentDragStop(WindowEventArgs& e); 00435 00436 00441 virtual void onSegmentDragPositionChanged(WindowEventArgs& e); 00442 00443 00448 virtual void onSegmentSized(WindowEventArgs& e); 00449 00450 00455 virtual void onClickableSettingChanged(WindowEventArgs& e); 00456 00457 00458 /************************************************************************* 00459 Overridden Event Handlers 00460 *************************************************************************/ 00461 virtual void onMouseMove(MouseEventArgs& e); 00462 virtual void onMouseButtonDown(MouseEventArgs& e); 00463 virtual void onMouseButtonUp(MouseEventArgs& e); 00464 virtual void onMouseDoubleClicked(MouseEventArgs& e); 00465 virtual void onMouseLeaves(MouseEventArgs& e); 00466 virtual void onCaptureLost(WindowEventArgs& e); 00467 00468 00469 /************************************************************************* 00470 Implementation Data 00471 *************************************************************************/ 00472 const Image* d_sizingMouseCursor; 00473 const Image* d_movingMouseCursor; 00474 00475 float d_splitterSize; 00476 bool d_splitterHover; 00477 00478 bool d_dragSizing; 00479 Vector2f d_dragPoint; 00480 00481 SortDirection d_sortDir; 00482 00483 bool d_segmentHover; 00484 bool d_segmentPushed; 00485 bool d_sizingEnabled; 00486 bool d_movingEnabled; 00487 bool d_dragMoving; 00488 Vector2f d_dragPosition; 00489 bool d_allowClicks; 00490 00491 private: 00492 /************************************************************************* 00493 Private methods 00494 *************************************************************************/ 00495 void addHeaderSegmentProperties(void); 00496 }; 00497 00498 00499 template<> 00500 class PropertyHelper<ListHeaderSegment::SortDirection> 00501 { 00502 public: 00503 typedef ListHeaderSegment::SortDirection return_type; 00504 typedef return_type safe_method_return_type; 00505 typedef ListHeaderSegment::SortDirection pass_type; 00506 typedef String string_return_type; 00507 00508 static const String& getDataTypeName() 00509 { 00510 static String type("SortDirection"); 00511 00512 return type; 00513 } 00514 00515 static return_type fromString(const String& str) 00516 { 00517 if (str == "Ascending") 00518 { 00519 return ListHeaderSegment::Ascending; 00520 } 00521 else if (str == "Descending") 00522 { 00523 return ListHeaderSegment::Descending; 00524 } 00525 else 00526 { 00527 return ListHeaderSegment::None; 00528 } 00529 } 00530 00531 static string_return_type toString(pass_type val) 00532 { 00533 if (val == ListHeaderSegment::None) 00534 { 00535 return "None"; 00536 } 00537 else if (val == ListHeaderSegment::Ascending) 00538 { 00539 return "Ascending"; 00540 } 00541 else if (val == ListHeaderSegment::Descending) 00542 { 00543 return "Descending"; 00544 } 00545 else 00546 { 00547 assert(false && "Invalid Sort Direction"); 00548 return "Ascending"; 00549 } 00550 } 00551 }; 00552 00553 } // End of CEGUI namespace section 00554 00555 #if defined(_MSC_VER) 00556 # pragma warning(pop) 00557 #endif 00558 00559 #endif // end of guard _CEGUIListHeaderSegment_h_