/[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 62 - (show annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 11 months ago) by william
File MIME type: text/plain
File size: 23343 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
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 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDialogWithHelpers)
526
527 protected:
528 bool m_hasContextHelp;
529 wxBoxSizer* m_extraButtonSizer;
530 wxRect m_CreatedRect;
531
532 public:
533 wxDialogWithHelpers();
534 wxDialogWithHelpers(wxWindow* parent, const wxString& title, const pxDialogCreationFlags& cflags = pxDialogCreationFlags() );
535 virtual ~wxDialogWithHelpers() throw();
536
537 void Init( const pxDialogCreationFlags& cflags );
538 void AddOkCancel( wxSizer& sizer, bool hasApply=false );
539 void AddOkCancel( wxSizer* sizer=NULL, bool hasApply=false );
540
541 virtual void SmartCenterFit();
542 virtual int ShowModal();
543 virtual bool Show( bool show=true );
544
545 // Must return the same thing as GetNameStatic; a name ideal for use in uniquely
546 // identifying dialogs. (this version is the 'instance' version, which is called
547 // by BaseConfigurationDialog to assign the wxWidgets dialog name, and for saving
548 // screenshots to disk)
549 virtual wxString GetDialogName() const;
550
551 virtual wxStaticText& Label( const wxString& label );
552 virtual pxStaticText& Text( const wxString& label );
553 virtual pxStaticText& Heading( const wxString& label );
554
555 wxDialogWithHelpers& SetMinWidth( int newWidth );
556 wxDialogWithHelpers& SetMinHeight( int newHeight );
557
558 int GetCharHeight() const;
559
560 protected:
561 void OnDialogCreated( wxCommandEvent& evt );
562 void OnOkCancel(wxCommandEvent& evt);
563 void OnCloseWindow(wxCloseEvent& event);
564
565 bool ShouldPreventAppExit() const { return false; }
566
567 void DoAutoCenter();
568 };
569
570 // --------------------------------------------------------------------------------------
571 // wxPanelWithHelpers
572 // --------------------------------------------------------------------------------------
573 // Overview of Helpers provided by this class:
574 // * Simpler constructors that have wxID, position, and size parameters removed (We never
575 // use them in pcsx2)
576 //
577 // * Automatic 'primary box sizer' creation, assigned via SetSizer() -- use GetSizer()
578 // to retrieve it, or use the "*this += window;" syntax to add windows directly to it.
579 //
580 // * Built-in support for StaticBoxes (aka groupboxes). Create one at construction with
581 // a wxString label, or add one "after the fact" using AddFrame.
582 //
583 // * Propagates IdealWidth settings from parenting wxPanelWithHelpers classes, and auto-
584 // matically adjusts the width based on the sizer type (groupsizers get truncated to
585 // account for borders).
586 //
587 class wxPanelWithHelpers : public wxPanel
588 {
589 DECLARE_DYNAMIC_CLASS_NO_COPY(wxPanelWithHelpers)
590
591 public:
592 wxPanelWithHelpers( wxWindow* parent, wxOrientation orient, const wxString& staticBoxLabel );
593 wxPanelWithHelpers( wxWindow* parent, wxOrientation orient );
594 wxPanelWithHelpers( wxWindow* parent, const wxPoint& pos, const wxSize& size=wxDefaultSize );
595 explicit wxPanelWithHelpers( wxWindow* parent=NULL );
596
597 wxPanelWithHelpers* AddFrame( const wxString& label, wxOrientation orient=wxVERTICAL );
598
599 wxStaticText& Label( const wxString& label );
600 pxStaticText& Text( const wxString& label );
601 pxStaticText& Heading( const wxString& label );
602
603 virtual wxPanelWithHelpers& SetMinWidth( int newWidth );
604
605 protected:
606 void Init();
607 };
608
609
610 // --------------------------------------------------------------------------------------
611 // pxTextWrapperBase
612 // --------------------------------------------------------------------------------------
613 // this class is used to wrap the text on word boundary: wrapping is done by calling
614 // OnStartLine() and OnOutputLine() functions. This class by itself can be used as a
615 // line counting tool, but produces no formatted text output.
616 //
617 // [class "borrowed" from wxWidgets private code, made public, and renamed to avoid possible
618 // conflicts with future editions of wxWidgets which might make it public. Why this isn't
619 // publicly available already in wxBase I'll never know-- air]
620 //
621 class pxTextWrapperBase
622 {
623 protected:
624 bool m_eol;
625 int m_linecount;
626 wxString m_indent;
627
628 public:
629 virtual ~pxTextWrapperBase() throw() { }
630
631 pxTextWrapperBase( const wxString& indent=wxEmptyString )
632 : m_indent( indent )
633 {
634 m_eol = false;
635 m_linecount = 0;
636 }
637
638 // win is used for getting the font, text is the text to wrap, width is the
639 // max line width or -1 to disable wrapping
640 pxTextWrapperBase& Wrap( const wxWindow& win, const wxString& text, int widthMax );
641
642 int GetLineCount() const
643 {
644 return m_linecount;
645 }
646
647 protected:
648 // line may be empty
649 virtual void OnOutputLine(const wxString& line) { }
650
651 // called at the start of every new line (except the very first one)
652 virtual void OnNewLine() { }
653
654 void DoOutputLine(const wxString& line);
655 bool IsStartOfNewLine();
656 };
657
658 // --------------------------------------------------------------------------------------
659 // pxTextWrapper
660 // --------------------------------------------------------------------------------------
661 // This class extends pxTextWrapperBase and adds the ability to retrieve the formatted
662 // result of word wrapping.
663 //
664 class pxTextWrapper : public pxTextWrapperBase
665 {
666 typedef pxTextWrapperBase _parent;
667
668 protected:
669 wxString m_text;
670
671 public:
672 pxTextWrapper( const wxString& wrapPrefix=wxEmptyString )
673 : pxTextWrapperBase( wrapPrefix )
674 { }
675
676 virtual ~pxTextWrapper() throw() { }
677
678 const wxString& GetResult() const
679 {
680 return m_text;
681 }
682
683 pxTextWrapper& Wrap( const wxWindow& win, const wxString& text, int widthMax );
684 pxTextWrapper& Wrap( const wxWindow* win, const wxString& text, int widthMax );
685
686 protected:
687 void OnOutputLine(const wxString& line);
688 void OnNewLine();
689 };
690
691 // --------------------------------------------------------------------------------------
692 // pxWindowTextWriter
693 // --------------------------------------------------------------------------------------
694 class pxWindowTextWriter
695 {
696 protected:
697 wxDC& m_dc;
698
699 wxAlignment m_align;
700 wxPoint m_curpos;
701 int m_leading;
702
703 virtual void _DoWriteLn( const wxChar* msg );
704 void _DoWrite( const wxChar* msg );
705
706 public:
707 pxWindowTextWriter( wxDC& dc );
708 virtual ~pxWindowTextWriter() throw() { }
709
710 virtual void OnFontChanged();
711
712 pxWindowTextWriter& WriteLn();
713 pxWindowTextWriter& FormatLn( const wxChar* fmt, ... );
714 pxWindowTextWriter& WriteLn( const wxChar* fmt );
715 pxWindowTextWriter& SetFont( const wxFont& font );
716 pxWindowTextWriter& Align( const wxAlignment& align );
717
718 pxWindowTextWriter& SetLeading( int lead )
719 {
720 m_leading = lead;
721 return *this;
722 }
723
724 pxWindowTextWriter& SetWeight( int weight );
725 pxWindowTextWriter& SetStyle( int style );
726 pxWindowTextWriter& Normal();
727
728 pxWindowTextWriter& Bold()
729 {
730 return SetWeight(wxBOLD);
731 }
732
733 pxWindowTextWriter& Italic()
734 {
735 return SetStyle(wxITALIC);
736 }
737
738 pxWindowTextWriter& SetPos( const wxPoint& pos );
739 pxWindowTextWriter& MovePos( const wxSize& delta );
740
741 pxWindowTextWriter& SetPos( int xpos, int ypos )
742 {
743 return SetPos( wxPoint(xpos,ypos) );
744 }
745
746 pxWindowTextWriter& MovePos( int xdelta, int ydelta )
747 {
748 return MovePos( wxSize(xdelta, ydelta) );
749 }
750
751 pxWindowTextWriter& SetY( int ypos );
752 pxWindowTextWriter& MoveY( int ydelta );
753 };
754
755 // --------------------------------------------------------------------------------------
756 // MoreStockCursors
757 // --------------------------------------------------------------------------------------
758 // Because (inexplicably) the ArrowWait cursor isn't in wxWidgets stock list.
759 //
760 class MoreStockCursors
761 {
762 protected:
763 ScopedPtr<wxCursor> m_arrowWait;
764
765 public:
766 MoreStockCursors() { }
767 virtual ~MoreStockCursors() throw() { }
768 const wxCursor& GetArrowWait();
769 };
770
771 enum BusyCursorType
772 {
773 Cursor_NotBusy,
774 Cursor_KindaBusy,
775 Cursor_ReallyBusy,
776 };
777
778 extern MoreStockCursors StockCursors;
779
780 // --------------------------------------------------------------------------------------
781 // ScopedBusyCursor
782 // --------------------------------------------------------------------------------------
783 // ... because wxWidgets wxBusyCursor doesn't really do proper nesting (doesn't let me
784 // override a partially-busy cursor with a really busy one)
785
786 class ScopedBusyCursor
787 {
788 protected:
789 static std::stack<BusyCursorType> m_cursorStack;
790 static BusyCursorType m_defBusyType;
791
792 public:
793 ScopedBusyCursor( BusyCursorType busytype );
794 virtual ~ScopedBusyCursor() throw();
795
796 static void SetDefault( BusyCursorType busytype );
797 static void SetManualBusyCursor( BusyCursorType busytype );
798 };
799
800 // --------------------------------------------------------------------------------------
801 // pxFitToDigits
802 // --------------------------------------------------------------------------------------
803 // Fits a given text or spinner control to the number of digits requested, since by default
804 // they're usually way over-sized.
805
806 extern void pxFitToDigits( wxWindow* win, int digits );
807 extern void pxFitToDigits( wxSpinCtrl* win, int digits );
808 extern wxTextCtrl* CreateNumericalTextCtrl( wxWindow* parent, int digits, long flags = wxTE_RIGHT );
809
810
811 //////////////////////////////////////////////////////////////////////////////////////////////
812
813 extern bool pxDialogExists( const wxString& name );
814 extern bool pxIsValidWindowPosition( const wxWindow& window, const wxPoint& windowPos );
815 extern wxRect wxGetDisplayArea();
816 extern wxString pxGetAppName();
817
818 extern int pxGetCharHeight( const wxWindow* wind, int rows=1 );
819 extern int pxGetCharHeight( const wxWindow& wind, int rows=1 );
820
821 extern wxString pxFormatToolTipText( wxWindow* wind, const wxString& src );
822 extern void pxSetToolTip( wxWindow* wind, const wxString& src );
823 extern void pxSetToolTip( wxWindow& wind, const wxString& src );
824 extern wxFont pxGetFixedFont( int ptsize=8, int weight=wxNORMAL );
825
826 extern pxDialogCreationFlags pxDialogFlags();
827
828 #endif

  ViewVC Help
Powered by ViewVC 1.1.22