/[pcsx2_0.9.7]/trunk/common/include/Utilities/wxGuiTools.h
ViewVC logotype

Contents of /trunk/common/include/Utilities/wxGuiTools.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years ago) by william
File MIME type: text/plain
File size: 23395 byte(s)
re-commit (had local access denied errors when committing)
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #pragma once
17
18 // ----------------------------------------------------------------------------
19 // wxGuiTools.h
20 //
21 // This file is meant to contain utility classes for users of the wxWidgets library.
22 // All classes in this file are dependent on wxBase and wxCore libraries! Meaning
23 // you will have to use wxCore header files and link against wxCore (GUI) to build
24 // them. For tools which require only wxBase, see wxBaseTools.h
25 // ----------------------------------------------------------------------------
26
27
28 #if wxUSE_GUI
29
30 #include "Dependencies.h"
31 #include "ScopedPtr.h"
32 #include <stack>
33
34 #include <wx/wx.h>
35
36 class pxStaticText;
37 class pxStaticHeading;
38 class pxCheckBox;
39 class wxSpinCtrl;
40
41 namespace pxSizerFlags
42 {
43 static const int StdPadding = 4;
44
45 extern wxSizerFlags StdSpace();
46 extern wxSizerFlags StdCenter();
47 extern wxSizerFlags StdExpand();
48 extern wxSizerFlags TopLevelBox();
49 extern wxSizerFlags SubGroup();
50 extern wxSizerFlags StdButton();
51 extern wxSizerFlags Checkbox();
52 };
53
54 #define wxSF wxSizerFlags()
55
56 // --------------------------------------------------------------------------------------
57 // pxAlignment / pxStretchType
58 // --------------------------------------------------------------------------------------
59 // These are full blown class types instead of enumerations because wxSizerFlags has an
60 // implicit conversion from integer (silly design flaw creating more work for me!)
61 //
62 struct pxAlignmentType
63 {
64 enum
65 {
66 Centre,
67 Center = Centre,
68 Middle,
69 Left,
70 Right,
71 Top,
72 Bottom
73 };
74
75 int intval;
76
77 wxSizerFlags Apply( wxSizerFlags flags=wxSizerFlags() ) const;
78
79 wxSizerFlags operator& ( const wxSizerFlags& _flgs ) const
80 {
81 return Apply( _flgs );
82 }
83
84 wxSizerFlags Expand() const
85 {
86 return Apply().Expand();
87 }
88
89 wxSizerFlags Border( int dir, int padding ) const
90 {
91 return Apply().Border( dir, padding );
92 }
93
94 wxSizerFlags Proportion( int prop ) const
95 {
96 return Apply().Proportion( intval );
97 }
98
99 operator wxSizerFlags() const
100 {
101 return Apply();
102 }
103 };
104
105 struct pxStretchType
106 {
107 enum
108 {
109 Shrink,
110 Expand,
111 Shaped,
112 ReserveHidden,
113 FixedMinimum
114 };
115
116 int intval;
117
118 wxSizerFlags Apply( wxSizerFlags flags=wxSizerFlags() ) const;
119
120 wxSizerFlags operator& ( const wxSizerFlags& _flgs ) const
121 {
122 return Apply( _flgs );
123 }
124
125 wxSizerFlags Border( int dir, int padding ) const
126 {
127 return Apply().Border( dir, padding );
128 }
129
130 wxSizerFlags Proportion( int prop ) const
131 {
132 return Apply().Proportion( intval );
133 }
134
135 operator wxSizerFlags() const
136 {
137 return Apply();
138 }
139 };
140
141 static __fi wxSizerFlags pxProportion( int prop )
142 {
143 return wxSizerFlags( prop );
144 }
145
146 static __fi wxSizerFlags pxBorder( int dir=wxALL, int pad=pxSizerFlags::StdPadding )
147 {
148 return wxSizerFlags().Border( dir, pad );
149 }
150
151 class pxStretchSpacer
152 {
153 public:
154 int proportion;
155
156 pxStretchSpacer( int prop=0 )
157 {
158 proportion = prop;
159 }
160 };
161
162 extern const pxAlignmentType
163 pxCentre, // Horizontal centered alignment
164 pxCenter,
165 pxMiddle, // vertical centered alignment
166
167 pxAlignLeft,
168 pxAlignRight,
169 pxAlignTop,
170 pxAlignBottom;
171
172 extern const pxStretchType
173 pxShrink,
174 pxExpand,
175 pxShaped,
176 pxReserveHidden,
177 pxFixedMinimum;
178
179 // --------------------------------------------------------------------------------------
180 // pxWindowAndFlags
181 // --------------------------------------------------------------------------------------
182 // This struct is a go-between for combining windows and sizer flags in "neat" fashion.
183 // To create the struct, use the | operator, like so:
184 //
185 // myPanel | wxSizerFlags().Expand()
186 //
187 // Implementation Note: This struct is a template as it allows us to use a special
188 // version of the += operator that retains the type information of the window, in case
189 // the window implements its own += overloads (one example is pxStaticText). Without the
190 // template, the type of the window would only be known as "wxWindow" when it's added to the
191 // sizer, and would thus fail to invoke the correct operator overload.
192 //
193 template< typename WinType >
194 struct pxWindowAndFlags
195 {
196 WinType* window;
197 wxSizerFlags flags;
198 };
199
200
201 extern wxSizerFlags operator& ( const wxSizerFlags& _flgs, const wxSizerFlags& _flgs2 );
202
203 template< typename WinType >
204 pxWindowAndFlags<WinType> operator | ( WinType* _win, const wxSizerFlags& _flgs )
205 {
206 pxWindowAndFlags<WinType> result = { _win, _flgs };
207 return result;
208 }
209
210 template< typename WinType >
211 pxWindowAndFlags<WinType> operator | ( WinType& _win, const wxSizerFlags& _flgs )
212 {
213 pxWindowAndFlags<WinType> result = { &_win, _flgs };
214 return result;
215 }
216
217 // --------------------------------------------------------------------------------------
218 // wxSizer Operator += .. a wxSizer.Add() Substitute
219 // --------------------------------------------------------------------------------------
220 // This set of operators is the *recommended* method for adding windows to sizers, not just
221 // because it's a lot prettier but also because it allows controls like pxStaticText to over-
222 // ride default sizerflags behavior.
223 //
224 // += operator works on either sizers, wxDialogs or wxPanels. In the latter case, the window
225 // is added to the dialog/panel's toplevel sizer (wxPanel.GetSizer() is used). If the panel
226 // has no sizer set via SetSizer(), an assertion is generated.
227 //
228
229 extern void operator+=( wxSizer& target, wxWindow* src );
230 extern void operator+=( wxSizer& target, wxSizer* src );
231 extern void operator+=( wxSizer& target, wxWindow& src );
232 extern void operator+=( wxSizer& target, wxSizer& src );
233
234 extern void operator+=( wxSizer* target, wxWindow& src );
235 extern void operator+=( wxSizer* target, wxSizer& src );
236
237 extern void operator+=( wxSizer& target, int spacer );
238 extern void operator+=( wxWindow& target, int spacer );
239 extern void operator+=( wxSizer& target, const pxStretchSpacer& spacer );
240 extern void operator+=( wxWindow& target, const pxStretchSpacer& spacer );
241
242 // ----------------------------------------------------------------------------
243 // Important: This template is needed in order to retain window type information and
244 // invoke the proper overloaded version of += (which is used by pxStaticText and other
245 // classes to perform special actions when added to sizers).
246 template< typename WinType >
247 void operator+=( wxWindow& target, WinType* src )
248 {
249 if( !pxAssert( target.GetSizer() != NULL ) ) return;
250 *target.GetSizer() += src;
251 }
252
253 template< typename WinType >
254 void operator+=( wxWindow& target, WinType& src )
255 {
256 if( !pxAssert( target.GetSizer() != NULL ) ) return;
257 *target.GetSizer() += src;
258 }
259
260 template< typename WinType >
261 void operator+=( wxWindow& target, const pxWindowAndFlags<WinType>& src )
262 {
263 if( !pxAssert( target.GetSizer() != NULL ) ) return;
264 *target.GetSizer() += src;
265 }
266
267 template< typename WinType >
268 void operator+=( wxSizer& target, const pxWindowAndFlags<WinType>& src )
269 {
270 target.Add( src.window, src.flags );
271 }
272
273 // ----------------------------------------------------------------------------
274 // Pointer Versions! (note that C++ requires one of the two operator params be a
275 // "poper" object type (non-pointer), so that's why some of these are missing.
276
277 template< typename WinType >
278 void operator+=( wxWindow* target, WinType& src )
279 {
280 if( !pxAssert( target != NULL ) ) return;
281 if( !pxAssert( target->GetSizer() != NULL ) ) return;
282 *target->GetSizer() += src;
283 }
284
285 template< typename WinType >
286 void operator+=( wxWindow* target, const pxWindowAndFlags<WinType>& src )
287 {
288 if( !pxAssert( target != NULL ) ) return;
289 if( !pxAssert( target->GetSizer() != NULL ) ) return;
290 *target->GetSizer() += src;
291 }
292
293 template< typename WinType >
294 void operator+=( wxSizer* target, const pxWindowAndFlags<WinType>& src )
295 {
296 if( !pxAssert( target != NULL ) ) return;
297 target->Add( src.window, src.flags );
298 }
299
300
301 BEGIN_DECLARE_EVENT_TYPES()
302 // Added to the event queue by pxDialogWithHelpers
303 DECLARE_EVENT_TYPE( pxEvt_OnDialogCreated, -1 )
304 END_DECLARE_EVENT_TYPES()
305
306
307 // --------------------------------------------------------------------------------------
308 // pxDialogCreationFlags
309 // --------------------------------------------------------------------------------------
310 class pxDialogCreationFlags
311 {
312 public:
313 wxSize MinimumSize;
314 wxOrientation BoxSizerOrient;
315
316 bool isResizable;
317 bool hasContextHelp;
318 bool hasCaption;
319 bool hasMinimizeBox;
320 bool hasMaximizeBox;
321 bool hasSystemMenu;
322 bool hasCloseBox;
323
324 public:
325 virtual ~pxDialogCreationFlags() throw() {}
326
327 pxDialogCreationFlags()
328 {
329 MinimumSize = wxDefaultSize;
330 BoxSizerOrient = wxVERTICAL;
331 isResizable = false;
332 hasContextHelp = false;
333
334 hasCloseBox = true;
335 hasSystemMenu = true;
336 hasMinimizeBox = false;
337 hasMaximizeBox = false;
338 hasCaption = true;
339 }
340
341 pxDialogCreationFlags& SetSizerOrient( wxOrientation orient )
342 {
343 BoxSizerOrient = orient;
344 return *this;
345 }
346
347 pxDialogCreationFlags& SetResize( bool enable=true )
348 {
349 isResizable = enable;
350 return *this;
351 }
352
353 pxDialogCreationFlags& SetMinimize( bool enable=true )
354 {
355 hasMinimizeBox = enable;
356 return *this;
357 }
358
359 pxDialogCreationFlags& SetMaximize( bool enable=true )
360 {
361 hasMaximizeBox = enable;
362 return *this;
363 }
364
365 // NOTE: Enabling system menu on dialogs usually doesn't work, and might cause
366 // other unwanted behavior, such as a missing close button.
367 pxDialogCreationFlags& SetSystemMenu( bool enable=true )
368 {
369 hasSystemMenu = enable;
370 return *this;
371 }
372
373 pxDialogCreationFlags& SetCaption( bool enable=true )
374 {
375 hasCaption = enable;
376 return *this;
377 }
378
379 pxDialogCreationFlags& SetCloseBox( bool enable=true )
380 {
381 hasCloseBox = enable;
382 return *this;
383 }
384
385 pxDialogCreationFlags SetContextHelp( bool enabled=true )
386 {
387 hasContextHelp = enabled;
388 return *this;
389 }
390
391 pxDialogCreationFlags& SetMinWidth( int width )
392 {
393 if( width > MinimumSize.x ) MinimumSize.SetWidth( width );
394 return *this;
395 }
396
397 pxDialogCreationFlags& SetMinHeight( int height )
398 {
399 if( height > MinimumSize.y ) MinimumSize.SetHeight( height );
400 return *this;
401 }
402
403 pxDialogCreationFlags& SetMinSize( const wxSize& size )
404 {
405 return SetMinWidth(size.x).SetMinHeight(size.y);
406 }
407
408
409 pxDialogCreationFlags Horizontal() const
410 {
411 return pxDialogCreationFlags(*this).SetSizerOrient( wxHORIZONTAL );
412 }
413
414 pxDialogCreationFlags Vertical() const
415 {
416 return pxDialogCreationFlags(*this).SetSizerOrient( wxVERTICAL );
417 }
418
419 pxDialogCreationFlags NoSizer() const
420 {
421 return pxDialogCreationFlags(*this).SetSizerOrient( (wxOrientation)0 );
422 }
423
424 pxDialogCreationFlags Resize( bool enable=true ) const
425 {
426 return pxDialogCreationFlags(*this).SetResize( enable );
427 }
428
429 pxDialogCreationFlags Minimize( bool enable=true ) const
430 {
431 return pxDialogCreationFlags(*this).SetMinimize( enable );
432 }
433
434 pxDialogCreationFlags Maximize( bool enable=true ) const
435 {
436 return pxDialogCreationFlags(*this).SetMaximize( enable );
437 }
438
439 // NOTE: Enabling system menu on dialogs usually doesn't work, and might cause
440 // other unwanted behavior, such as a missing close button.
441 pxDialogCreationFlags SystemMenu( bool enable=true ) const
442 {
443 return pxDialogCreationFlags(*this).SetSystemMenu( false );
444 }
445
446 pxDialogCreationFlags Caption( bool enable=true ) const
447 {
448 return pxDialogCreationFlags(*this).SetCaption( enable );
449 }
450
451 pxDialogCreationFlags CloseBox( bool enable=true ) const
452 {
453 return pxDialogCreationFlags(*this).SetCloseBox( enable );
454 }
455
456 pxDialogCreationFlags NoResize() const
457 {
458 return pxDialogCreationFlags(*this).SetResize( false );
459 }
460
461 pxDialogCreationFlags NoMinimize() const
462 {
463 return pxDialogCreationFlags(*this).SetMinimize( false );
464 }
465
466 pxDialogCreationFlags NoMaximize() const
467 {
468 return pxDialogCreationFlags(*this).SetMaximize( false );
469 }
470
471 pxDialogCreationFlags NoSystemMenu() const
472 {
473 return pxDialogCreationFlags(*this).SetSystemMenu( false );
474 }
475
476 pxDialogCreationFlags NoCaption() const
477 {
478 return pxDialogCreationFlags(*this).SetCaption( false );
479 }
480
481 pxDialogCreationFlags NoCloseBox() const
482 {
483 return pxDialogCreationFlags(*this).SetCloseBox( false );
484 }
485
486 pxDialogCreationFlags MinWidth( int width ) const
487 {
488 return pxDialogCreationFlags(*this).SetMinWidth( width );
489 }
490
491 pxDialogCreationFlags MinHeight( int height ) const
492 {
493 return pxDialogCreationFlags(*this).SetMinHeight( height );
494 }
495
496 pxDialogCreationFlags MinSize( const wxSize& size ) const
497 {
498 return pxDialogCreationFlags(*this).SetMinSize( size );
499 }
500
501 pxDialogCreationFlags MinSize( int width, int height ) const
502 {
503 return pxDialogCreationFlags(*this).SetMinWidth( width ).SetMinHeight( height );
504 }
505
506 int GetWxWindowFlags() const
507 {
508 int retval = 0;
509 if( isResizable ) retval |= wxRESIZE_BORDER;
510 if( hasCaption ) retval |= wxCAPTION;
511 if( hasMaximizeBox ) retval |= wxMAXIMIZE_BOX;
512 if( hasMinimizeBox ) retval |= wxMINIMIZE_BOX;
513 if( hasSystemMenu ) retval |= wxSYSTEM_MENU;
514 if( hasCloseBox ) retval |= wxCLOSE_BOX;
515
516 return retval;
517 }
518 };
519
520 // --------------------------------------------------------------------------------------
521 // wxDialogWithHelpers
522 // --------------------------------------------------------------------------------------
523 class wxDialogWithHelpers : public wxDialog
524 {
525 typedef wxDialog _parent;
526 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDialogWithHelpers)
527
528 protected:
529 bool m_hasContextHelp;
530 wxBoxSizer* m_extraButtonSizer;
531 wxRect m_CreatedRect;
532
533 public:
534 wxDialogWithHelpers();
535 wxDialogWithHelpers(wxWindow* parent, const wxString& title, const pxDialogCreationFlags& cflags = pxDialogCreationFlags() );
536 virtual ~wxDialogWithHelpers() throw();
537
538 void Init( const pxDialogCreationFlags& cflags );
539 void AddOkCancel( wxSizer& sizer, bool hasApply=false );
540 void AddOkCancel( wxSizer* sizer=NULL, bool hasApply=false );
541
542 virtual void SmartCenterFit();
543 virtual int ShowModal();
544 virtual bool Show( bool show=true );
545 virtual bool Destroy();
546
547 // Must return the same thing as GetNameStatic; a name ideal for use in uniquely
548 // identifying dialogs. (this version is the 'instance' version, which is called
549 // by BaseConfigurationDialog to assign the wxWidgets dialog name, and for saving
550 // screenshots to disk)
551 virtual wxString GetDialogName() const;
552
553 virtual wxStaticText& Label( const wxString& label );
554 virtual pxStaticText& Text( const wxString& label );
555 virtual pxStaticText& Heading( const wxString& label );
556
557 wxDialogWithHelpers& SetMinWidth( int newWidth );
558 wxDialogWithHelpers& SetMinHeight( int newHeight );
559
560 int GetCharHeight() const;
561
562 protected:
563 void OnDialogCreated( wxCommandEvent& evt );
564 void OnOkCancel(wxCommandEvent& evt);
565 void OnCloseWindow(wxCloseEvent& event);
566
567 bool ShouldPreventAppExit() const { return false; }
568
569 void DoAutoCenter();
570 };
571
572 // --------------------------------------------------------------------------------------
573 // wxPanelWithHelpers
574 // --------------------------------------------------------------------------------------
575 // Overview of Helpers provided by this class:
576 // * Simpler constructors that have wxID, position, and size parameters removed (We never
577 // use them in pcsx2)
578 //
579 // * Automatic 'primary box sizer' creation, assigned via SetSizer() -- use GetSizer()
580 // to retrieve it, or use the "*this += window;" syntax to add windows directly to it.
581 //
582 // * Built-in support for StaticBoxes (aka groupboxes). Create one at construction with
583 // a wxString label, or add one "after the fact" using AddFrame.
584 //
585 // * Propagates IdealWidth settings from parenting wxPanelWithHelpers classes, and auto-
586 // matically adjusts the width based on the sizer type (groupsizers get truncated to
587 // account for borders).
588 //
589 class wxPanelWithHelpers : public wxPanel
590 {
591 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPanelWithHelpers)
592
593 public:
594 wxPanelWithHelpers( wxWindow* parent, wxOrientation orient, const wxString& staticBoxLabel );
595 wxPanelWithHelpers( wxWindow* parent, wxOrientation orient );
596 wxPanelWithHelpers( wxWindow* parent, const wxPoint& pos, const wxSize& size=wxDefaultSize );
597 explicit wxPanelWithHelpers( wxWindow* parent=NULL );
598
599 wxPanelWithHelpers* AddFrame( const wxString& label, wxOrientation orient=wxVERTICAL );
600
601 wxStaticText& Label( const wxString& label );
602 pxStaticText& Text( const wxString& label );
603 pxStaticText& Heading( const wxString& label );
604
605 virtual wxPanelWithHelpers& SetMinWidth( int newWidth );
606
607 protected:
608 void Init();
609 };
610
611
612 // --------------------------------------------------------------------------------------
613 // pxTextWrapperBase
614 // --------------------------------------------------------------------------------------
615 // this class is used to wrap the text on word boundary: wrapping is done by calling
616 // OnStartLine() and OnOutputLine() functions. This class by itself can be used as a
617 // line counting tool, but produces no formatted text output.
618 //
619 // [class "borrowed" from wxWidgets private code, made public, and renamed to avoid possible
620 // conflicts with future editions of wxWidgets which might make it public. Why this isn't
621 // publicly available already in wxBase I'll never know-- air]
622 //
623 class pxTextWrapperBase
624 {
625 protected:
626 bool m_eol;
627 int m_linecount;
628 wxString m_indent;
629
630 public:
631 virtual ~pxTextWrapperBase() throw() { }
632
633 pxTextWrapperBase( const wxString& indent=wxEmptyString )
634 : m_indent( indent )
635 {
636 m_eol = false;
637 m_linecount = 0;
638 }
639
640 // win is used for getting the font, text is the text to wrap, width is the
641 // max line width or -1 to disable wrapping
642 pxTextWrapperBase& Wrap( const wxWindow& win, const wxString& text, int widthMax );
643
644 int GetLineCount() const
645 {
646 return m_linecount;
647 }
648
649 protected:
650 // line may be empty
651 virtual void OnOutputLine(const wxString& line) { }
652
653 // called at the start of every new line (except the very first one)
654 virtual void OnNewLine() { }
655
656 void DoOutputLine(const wxString& line);
657 bool IsStartOfNewLine();
658 };
659
660 // --------------------------------------------------------------------------------------
661 // pxTextWrapper
662 // --------------------------------------------------------------------------------------
663 // This class extends pxTextWrapperBase and adds the ability to retrieve the formatted
664 // result of word wrapping.
665 //
666 class pxTextWrapper : public pxTextWrapperBase
667 {
668 typedef pxTextWrapperBase _parent;
669
670 protected:
671 wxString m_text;
672
673 public:
674 pxTextWrapper( const wxString& wrapPrefix=wxEmptyString )
675 : pxTextWrapperBase( wrapPrefix )
676 { }
677
678 virtual ~pxTextWrapper() throw() { }
679
680 const wxString& GetResult() const
681 {
682 return m_text;
683 }
684
685 pxTextWrapper& Wrap( const wxWindow& win, const wxString& text, int widthMax );
686 pxTextWrapper& Wrap( const wxWindow* win, const wxString& text, int widthMax );
687
688 protected:
689 void OnOutputLine(const wxString& line);
690 void OnNewLine();
691 };
692
693 // --------------------------------------------------------------------------------------
694 // pxWindowTextWriter
695 // --------------------------------------------------------------------------------------
696 class pxWindowTextWriter
697 {
698 protected:
699 wxDC& m_dc;
700
701 wxAlignment m_align;
702 wxPoint m_curpos;
703 int m_leading;
704
705 virtual void _DoWriteLn( const wxChar* msg );
706 void _DoWrite( const wxChar* msg );
707
708 public:
709 pxWindowTextWriter( wxDC& dc );
710 virtual ~pxWindowTextWriter() throw() { }
711
712 virtual void OnFontChanged();
713
714 pxWindowTextWriter& WriteLn();
715 pxWindowTextWriter& FormatLn( const wxChar* fmt, ... );
716 pxWindowTextWriter& WriteLn( const wxChar* fmt );
717 pxWindowTextWriter& SetFont( const wxFont& font );
718 pxWindowTextWriter& Align( const wxAlignment& align );
719
720 pxWindowTextWriter& SetLeading( int lead )
721 {
722 m_leading = lead;
723 return *this;
724 }
725
726 pxWindowTextWriter& SetWeight( int weight );
727 pxWindowTextWriter& SetStyle( int style );
728 pxWindowTextWriter& Normal();
729
730 pxWindowTextWriter& Bold()
731 {
732 return SetWeight(wxBOLD);
733 }
734
735 pxWindowTextWriter& Italic()
736 {
737 return SetStyle(wxITALIC);
738 }
739
740 pxWindowTextWriter& SetPos( const wxPoint& pos );
741 pxWindowTextWriter& MovePos( const wxSize& delta );
742
743 pxWindowTextWriter& SetPos( int xpos, int ypos )
744 {
745 return SetPos( wxPoint(xpos,ypos) );
746 }
747
748 pxWindowTextWriter& MovePos( int xdelta, int ydelta )
749 {
750 return MovePos( wxSize(xdelta, ydelta) );
751 }
752
753 pxWindowTextWriter& SetY( int ypos );
754 pxWindowTextWriter& MoveY( int ydelta );
755 };
756
757 // --------------------------------------------------------------------------------------
758 // MoreStockCursors
759 // --------------------------------------------------------------------------------------
760 // Because (inexplicably) the ArrowWait cursor isn't in wxWidgets stock list.
761 //
762 class MoreStockCursors
763 {
764 protected:
765 ScopedPtr<wxCursor> m_arrowWait;
766
767 public:
768 MoreStockCursors() { }
769 virtual ~MoreStockCursors() throw() { }
770 const wxCursor& GetArrowWait();
771 };
772
773 enum BusyCursorType
774 {
775 Cursor_NotBusy,
776 Cursor_KindaBusy,
777 Cursor_ReallyBusy,
778 };
779
780 extern MoreStockCursors StockCursors;
781
782 // --------------------------------------------------------------------------------------
783 // ScopedBusyCursor
784 // --------------------------------------------------------------------------------------
785 // ... because wxWidgets wxBusyCursor doesn't really do proper nesting (doesn't let me
786 // override a partially-busy cursor with a really busy one)
787
788 class ScopedBusyCursor
789 {
790 protected:
791 static std::stack<BusyCursorType> m_cursorStack;
792 static BusyCursorType m_defBusyType;
793
794 public:
795 ScopedBusyCursor( BusyCursorType busytype );
796 virtual ~ScopedBusyCursor() throw();
797
798 static void SetDefault( BusyCursorType busytype );
799 static void SetManualBusyCursor( BusyCursorType busytype );
800 };
801
802 // --------------------------------------------------------------------------------------
803 // pxFitToDigits
804 // --------------------------------------------------------------------------------------
805 // Fits a given text or spinner control to the number of digits requested, since by default
806 // they're usually way over-sized.
807
808 extern void pxFitToDigits( wxWindow* win, int digits );
809 extern void pxFitToDigits( wxSpinCtrl* win, int digits );
810 extern wxTextCtrl* CreateNumericalTextCtrl( wxWindow* parent, int digits, long flags = wxTE_RIGHT );
811
812
813 //////////////////////////////////////////////////////////////////////////////////////////////
814
815 extern bool pxDialogExists( const wxString& name );
816 extern bool pxIsValidWindowPosition( const wxWindow& window, const wxPoint& windowPos );
817 extern wxRect wxGetDisplayArea();
818 extern wxString pxGetAppName();
819
820 extern int pxGetCharHeight( const wxWindow* wind, int rows=1 );
821 extern int pxGetCharHeight( const wxWindow& wind, int rows=1 );
822
823 extern wxString pxFormatToolTipText( wxWindow* wind, const wxString& src );
824 extern void pxSetToolTip( wxWindow* wind, const wxString& src );
825 extern void pxSetToolTip( wxWindow& wind, const wxString& src );
826 extern wxFont pxGetFixedFont( int ptsize=8, int weight=wxNORMAL );
827
828 extern pxDialogCreationFlags pxDialogFlags();
829
830 #endif

  ViewVC Help
Powered by ViewVC 1.1.22