1 // Scintilla source code edit control
2 // PlatWX.cxx - implementation of platform facilities on wxWindows
3 // Copyright 1998-1999 by Neil Hodgson <neilh@scintilla.org>
4 // Robin Dunn <robin@aldunn.com>
5 // The License.txt file describes the conditions under which this software may be distributed.
10 #include <wx/encconv.h>
15 #include "wx/stc/stc.h"
23 Point
Point::FromLong(long lpoint
) {
24 return Point(lpoint
& 0xFFFF, lpoint
>> 16);
27 wxRect
wxRectFromPRectangle(PRectangle prc
) {
28 wxRect
rc(prc
.left
, prc
.top
,
29 prc
.right
-prc
.left
, prc
.bottom
-prc
.top
);
33 PRectangle
PRectangleFromwxRect(wxRect rc
) {
34 return PRectangle(rc
.GetLeft(), rc
.GetTop(),
35 rc
.GetRight()+1, rc
.GetBottom()+1);
38 wxColour
wxColourFromCA(const ColourAllocated
& ca
) {
39 ColourDesired
cd(ca
.AsLong());
40 return wxColour(cd
.GetRed(), cd
.GetGreen(), cd
.GetBlue());
43 //----------------------------------------------------------------------
47 allowRealization
= false;
54 void Palette::Release() {
58 // This method either adds a colour to the list of wanted colours (want==true)
59 // or retrieves the allocated colour back to the ColourPair.
60 // This is one method to make it easier to keep the code for wanting and retrieving in sync.
61 void Palette::WantFind(ColourPair
&cp
, bool want
) {
63 for (int i
=0; i
< used
; i
++) {
64 if (entries
[i
].desired
== cp
.desired
)
68 if (used
< numEntries
) {
69 entries
[used
].desired
= cp
.desired
;
70 entries
[used
].allocated
.Set(cp
.desired
.AsLong());
74 for (int i
=0; i
< used
; i
++) {
75 if (entries
[i
].desired
== cp
.desired
) {
76 cp
.allocated
= entries
[i
].allocated
;
80 cp
.allocated
.Set(cp
.desired
.AsLong());
84 void Palette::Allocate(Window
&) {
85 if (allowRealization
) {
90 //----------------------------------------------------------------------
100 void Font::Create(const char *faceName
, int characterSet
, int size
, bool bold
, bool italic
) {
101 wxFontEncoding encoding
;
105 switch (characterSet
) {
107 case wxSTC_CHARSET_ANSI
:
108 case wxSTC_CHARSET_DEFAULT
:
109 encoding
= wxFONTENCODING_DEFAULT
;
112 case wxSTC_CHARSET_BALTIC
:
113 encoding
= wxFONTENCODING_ISO8859_13
;
116 case wxSTC_CHARSET_CHINESEBIG5
:
117 encoding
= wxFONTENCODING_CP950
;
120 case wxSTC_CHARSET_EASTEUROPE
:
121 encoding
= wxFONTENCODING_ISO8859_2
;
124 case wxSTC_CHARSET_GB2312
:
125 encoding
= wxFONTENCODING_CP936
;
128 case wxSTC_CHARSET_GREEK
:
129 encoding
= wxFONTENCODING_ISO8859_7
;
132 case wxSTC_CHARSET_HANGUL
:
133 encoding
= wxFONTENCODING_CP949
;
136 case wxSTC_CHARSET_MAC
:
137 encoding
= wxFONTENCODING_DEFAULT
;
140 case wxSTC_CHARSET_OEM
:
141 encoding
= wxFONTENCODING_DEFAULT
;
144 case wxSTC_CHARSET_RUSSIAN
:
145 encoding
= wxFONTENCODING_KOI8
;
148 case wxSTC_CHARSET_SHIFTJIS
:
149 encoding
= wxFONTENCODING_CP932
;
152 case wxSTC_CHARSET_SYMBOL
:
153 encoding
= wxFONTENCODING_DEFAULT
;
156 case wxSTC_CHARSET_TURKISH
:
157 encoding
= wxFONTENCODING_ISO8859_9
;
160 case wxSTC_CHARSET_JOHAB
:
161 encoding
= wxFONTENCODING_DEFAULT
;
164 case wxSTC_CHARSET_HEBREW
:
165 encoding
= wxFONTENCODING_ISO8859_8
;
168 case wxSTC_CHARSET_ARABIC
:
169 encoding
= wxFONTENCODING_ISO8859_6
;
172 case wxSTC_CHARSET_VIETNAMESE
:
173 encoding
= wxFONTENCODING_DEFAULT
;
176 case wxSTC_CHARSET_THAI
:
177 encoding
= wxFONTENCODING_ISO8859_11
;
181 wxFontEncodingArray ea
= wxEncodingConverter::GetPlatformEquivalents(encoding
);
185 id
= new wxFont(size
,
187 italic
? wxITALIC
: wxNORMAL
,
188 bold
? wxBOLD
: wxNORMAL
,
193 ((wxFont
*)id
)->SetNoAntiAliasing( true ) ;
198 void Font::Release() {
204 //----------------------------------------------------------------------
206 class SurfaceImpl
: public Surface
{
220 void Init(SurfaceID sid
);
221 void InitPixMap(int width
, int height
, Surface
*surface_
);
225 void PenColour(ColourAllocated fore
);
227 int DeviceHeightFont(int points
);
228 void MoveTo(int x_
, int y_
);
229 void LineTo(int x_
, int y_
);
230 void Polygon(Point
*pts
, int npts
, ColourAllocated fore
, ColourAllocated back
);
231 void RectangleDraw(PRectangle rc
, ColourAllocated fore
, ColourAllocated back
);
232 void FillRectangle(PRectangle rc
, ColourAllocated back
);
233 void FillRectangle(PRectangle rc
, Surface
&surfacePattern
);
234 void RoundedRectangle(PRectangle rc
, ColourAllocated fore
, ColourAllocated back
);
235 void Ellipse(PRectangle rc
, ColourAllocated fore
, ColourAllocated back
);
236 void Copy(PRectangle rc
, Point from
, Surface
&surfaceSource
);
238 void DrawTextNoClip(PRectangle rc
, Font
&font_
, int ybase
, const char *s
, int len
, ColourAllocated fore
, ColourAllocated back
);
239 void DrawTextClipped(PRectangle rc
, Font
&font_
, int ybase
, const char *s
, int len
, ColourAllocated fore
, ColourAllocated back
);
240 void MeasureWidths(Font
&font_
, const char *s
, int len
, int *positions
);
241 int WidthText(Font
&font_
, const char *s
, int len
);
242 int WidthChar(Font
&font_
, char ch
);
243 int Ascent(Font
&font_
);
244 int Descent(Font
&font_
);
245 int InternalLeading(Font
&font_
);
246 int ExternalLeading(Font
&font_
);
247 int Height(Font
&font_
);
248 int AverageCharWidth(Font
&font_
);
250 int SetPalette(Palette
*pal
, bool inBackGround
);
251 void SetClip(PRectangle rc
);
252 void FlushCachedState();
254 void SetUnicodeMode(bool unicodeMode_
);
256 void BrushColour(ColourAllocated back
);
257 void SetFont(Font
&font_
);
262 SurfaceImpl::SurfaceImpl() :
263 hdc(0), hdcOwned(0), bitmap(0),
264 x(0), y(0), unicodeMode(0)
267 SurfaceImpl::~SurfaceImpl() {
271 void SurfaceImpl::Release() {
273 ((wxMemoryDC
*)hdc
)->SelectObject(wxNullBitmap
);
285 bool SurfaceImpl::Initialised() {
289 void SurfaceImpl::Init() {
292 hdc
= new wxMemoryDC();
295 // On Mac and GTK the DC is not really valid until it has a bitmap
296 // selected into it. So instead of just creating the DC with no bitmap,
297 // go ahead and give it one.
298 InitPixMap(1,1,NULL
);
302 void SurfaceImpl::Init(SurfaceID hdc_
) {
307 void SurfaceImpl::InitPixMap(int width
, int height
, Surface
*surface_
) {
309 hdc
= new wxMemoryDC();
311 if (width
< 1) width
= 1;
312 if (height
< 1) height
= 1;
313 bitmap
= new wxBitmap(width
, height
);
314 ((wxMemoryDC
*)hdc
)->SelectObject(*bitmap
);
317 void SurfaceImpl::PenColour(ColourAllocated fore
) {
318 hdc
->SetPen(wxPen(wxColourFromCA(fore
), 1, wxSOLID
));
321 void SurfaceImpl::BrushColour(ColourAllocated back
) {
322 hdc
->SetBrush(wxBrush(wxColourFromCA(back
), wxSOLID
));
325 void SurfaceImpl::SetFont(Font
&font_
) {
327 hdc
->SetFont(*((wxFont
*)font_
.GetID()));
331 int SurfaceImpl::LogPixelsY() {
332 return hdc
->GetPPI().y
;
335 int SurfaceImpl::DeviceHeightFont(int points
) {
339 void SurfaceImpl::MoveTo(int x_
, int y_
) {
344 void SurfaceImpl::LineTo(int x_
, int y_
) {
345 hdc
->DrawLine(x
,y
, x_
,y_
);
350 void SurfaceImpl::Polygon(Point
*pts
, int npts
, ColourAllocated fore
, ColourAllocated back
) {
353 hdc
->DrawPolygon(npts
, (wxPoint
*)pts
);
356 void SurfaceImpl::RectangleDraw(PRectangle rc
, ColourAllocated fore
, ColourAllocated back
) {
359 hdc
->DrawRectangle(wxRectFromPRectangle(rc
));
362 void SurfaceImpl::FillRectangle(PRectangle rc
, ColourAllocated back
) {
364 hdc
->SetPen(*wxTRANSPARENT_PEN
);
365 hdc
->DrawRectangle(wxRectFromPRectangle(rc
));
368 void SurfaceImpl::FillRectangle(PRectangle rc
, Surface
&surfacePattern
) {
370 if (((SurfaceImpl
&)surfacePattern
).bitmap
)
371 br
= wxBrush(*((SurfaceImpl
&)surfacePattern
).bitmap
);
372 else // Something is wrong so display in red
373 br
= wxBrush(*wxRED
, wxSOLID
);
374 hdc
->SetPen(*wxTRANSPARENT_PEN
);
376 hdc
->DrawRectangle(wxRectFromPRectangle(rc
));
379 void SurfaceImpl::RoundedRectangle(PRectangle rc
, ColourAllocated fore
, ColourAllocated back
) {
382 hdc
->DrawRoundedRectangle(wxRectFromPRectangle(rc
), 4);
385 void SurfaceImpl::Ellipse(PRectangle rc
, ColourAllocated fore
, ColourAllocated back
) {
388 hdc
->DrawEllipse(wxRectFromPRectangle(rc
));
391 void SurfaceImpl::Copy(PRectangle rc
, Point from
, Surface
&surfaceSource
) {
392 wxRect r
= wxRectFromPRectangle(rc
);
393 hdc
->Blit(r
.x
, r
.y
, r
.width
, r
.height
,
394 ((SurfaceImpl
&)surfaceSource
).hdc
,
395 from
.x
, from
.y
, wxCOPY
);
398 void SurfaceImpl::DrawTextNoClip(PRectangle rc
, Font
&font
, int ybase
,
399 const char *s
, int len
,
400 ColourAllocated fore
, ColourAllocated back
) {
402 hdc
->SetTextForeground(wxColourFromCA(fore
));
403 hdc
->SetTextBackground(wxColourFromCA(back
));
404 FillRectangle(rc
, back
);
406 // ybase is where the baseline should be, but wxWin uses the upper left
407 // corner, so I need to calculate the real position for the text...
408 hdc
->DrawText(stc2wx(s
, len
), rc
.left
, ybase
- font
.ascent
);
411 void SurfaceImpl::DrawTextClipped(PRectangle rc
, Font
&font
, int ybase
,
412 const char *s
, int len
,
413 ColourAllocated fore
, ColourAllocated back
) {
415 hdc
->SetTextForeground(wxColourFromCA(fore
));
416 hdc
->SetTextBackground(wxColourFromCA(back
));
417 FillRectangle(rc
, back
);
418 hdc
->SetClippingRegion(wxRectFromPRectangle(rc
));
420 // see comments above
421 hdc
->DrawText(stc2wx(s
, len
), rc
.left
, ybase
- font
.ascent
);
422 hdc
->DestroyClippingRegion();
425 int SurfaceImpl::WidthText(Font
&font
, const char *s
, int len
) {
430 hdc
->GetTextExtent(stc2wx(s
, len
), &w
, &h
);
435 void SurfaceImpl::MeasureWidths(Font
&font
, const char *s
, int len
, int *positions
) {
436 wxString str
= stc2wx(s
, len
);
439 // Calculate the position of each character based on the widths of
440 // the previous characters
441 int* tpos
= new int[len
];
444 for (i
=0; i
<str
.Length(); i
++) {
446 hdc
->GetTextExtent(str
[i
], &w
, &h
);
448 tpos
[i
] = totalWidth
;
452 // Map the widths for UCS-2 characters back to the UTF-8 input string
456 unsigned char uch
= (unsigned char)s
[i
];
457 positions
[i
++] = tpos
[ui
];
459 if (uch
< (0x80 + 0x40 + 0x20)) {
460 positions
[i
++] = tpos
[ui
];
462 positions
[i
++] = tpos
[ui
];
463 positions
[i
++] = tpos
[ui
];
470 // If not unicode then just use the widths we have
471 memcpy(positions
, tpos
, len
* sizeof(*tpos
));
478 int SurfaceImpl::WidthChar(Font
&font
, char ch
) {
482 char s
[2] = { ch
, 0 };
484 hdc
->GetTextExtent(stc2wx(s
, 1), &w
, &h
);
488 #define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
490 int SurfaceImpl::Ascent(Font
&font
) {
493 hdc
->GetTextExtent(EXTENT_TEST
, &w
, &h
, &d
, &e
);
498 int SurfaceImpl::Descent(Font
&font
) {
501 hdc
->GetTextExtent(EXTENT_TEST
, &w
, &h
, &d
, &e
);
505 int SurfaceImpl::InternalLeading(Font
&font
) {
509 int SurfaceImpl::ExternalLeading(Font
&font
) {
512 hdc
->GetTextExtent(EXTENT_TEST
, &w
, &h
, &d
, &e
);
516 int SurfaceImpl::Height(Font
&font
) {
518 return hdc
->GetCharHeight();
521 int SurfaceImpl::AverageCharWidth(Font
&font
) {
523 return hdc
->GetCharWidth();
526 int SurfaceImpl::SetPalette(Palette
*pal
, bool inBackGround
) {
530 void SurfaceImpl::SetClip(PRectangle rc
) {
531 hdc
->SetClippingRegion(wxRectFromPRectangle(rc
));
534 void SurfaceImpl::FlushCachedState() {
537 void SurfaceImpl::SetUnicodeMode(bool unicodeMode_
) {
538 unicodeMode
=unicodeMode_
;
540 wxASSERT_MSG(unicodeMode
== wxUSE_UNICODE
,
541 wxT("Only unicode may be used when wxUSE_UNICODE is on."));
543 wxASSERT_MSG(unicodeMode
== wxUSE_UNICODE
,
544 wxT("Only non-unicode may be used when wxUSE_UNICODE is off."));
548 Surface
*Surface::Allocate() {
549 return new SurfaceImpl
;
553 //----------------------------------------------------------------------
556 inline wxWindow
* GETWIN(WindowID id
) { return (wxWindow
*)id
; }
561 void Window::Destroy() {
563 GETWIN(id
)->Destroy();
567 bool Window::HasFocus() {
568 return wxWindow::FindFocus() == GETWIN(id
);
571 PRectangle
Window::GetPosition() {
572 wxRect
rc(GETWIN(id
)->GetPosition(), GETWIN(id
)->GetSize());
573 return PRectangleFromwxRect(rc
);
576 void Window::SetPosition(PRectangle rc
) {
577 wxRect r
= wxRectFromPRectangle(rc
);
578 GETWIN(id
)->SetSize(r
);
581 void Window::SetPositionRelative(PRectangle rc
, Window
) {
582 SetPosition(rc
); // ????
585 PRectangle
Window::GetClientPosition() {
586 wxSize sz
= GETWIN(id
)->GetClientSize();
587 return PRectangle(0, 0, sz
.x
, sz
.y
);
590 void Window::Show(bool show
) {
591 GETWIN(id
)->Show(show
);
594 void Window::InvalidateAll() {
595 GETWIN(id
)->Refresh(false);
599 void Window::InvalidateRectangle(PRectangle rc
) {
600 wxRect r
= wxRectFromPRectangle(rc
);
601 GETWIN(id
)->Refresh(false, &r
);
605 void Window::SetFont(Font
&font
) {
606 GETWIN(id
)->SetFont(*((wxFont
*)font
.GetID()));
609 void Window::SetCursor(Cursor curs
) {
614 cursorId
= wxCURSOR_IBEAM
;
617 cursorId
= wxCURSOR_ARROW
;
620 cursorId
= wxCURSOR_ARROW
; // ** no up arrow... wxCURSOR_UPARROW;
623 cursorId
= wxCURSOR_WAIT
;
626 cursorId
= wxCURSOR_SIZEWE
;
629 cursorId
= wxCURSOR_SIZENS
;
631 case cursorReverseArrow
:
632 cursorId
= wxCURSOR_RIGHT_ARROW
;
635 cursorId
= wxCURSOR_ARROW
;
639 wxCursor wc
= wxStockCursor(cursorId
) ;
641 wxCursor wc
= wxCursor(cursorId
) ;
643 GETWIN(id
)->SetCursor(wc
);
647 void Window::SetTitle(const char *s
) {
648 GETWIN(id
)->SetTitle(stc2wx(s
));
652 //----------------------------------------------------------------------
653 // Helper classes for ListBox
656 #if 1 // defined(__WXMAC__)
657 class wxSTCListBoxWin
: public wxListBox
{
659 wxSTCListBoxWin(wxWindow
* parent
, wxWindowID id
)
660 : wxListBox(parent
, id
, wxDefaultPosition
, wxSize(0,0),
661 0, NULL
, wxLB_SINGLE
| wxSIMPLE_BORDER
) {
662 SetCursor(wxCursor(wxCURSOR_ARROW
));
666 void OnFocus(wxFocusEvent
& event
) {
667 GetParent()->SetFocus();
671 wxListBox
* GetLB() { return this; }
674 DECLARE_EVENT_TABLE()
678 BEGIN_EVENT_TABLE(wxSTCListBoxWin
, wxListBox
)
679 EVT_SET_FOCUS(wxSTCListBoxWin::OnFocus
)
687 class wxSTCListBox
: public wxListBox
{
689 wxSTCListBox(wxWindow
* parent
, wxWindowID id
)
690 : wxListBox(parent
, id
, wxDefaultPosition
, wxDefaultSize
,
691 0, NULL
, wxLB_SINGLE
| wxSIMPLE_BORDER
| wxWANTS_CHARS
)
694 void OnKeyDown(wxKeyEvent
& event
) {
695 // Give the key events to the STC. It will then update
696 // the listbox as needed.
697 GetGrandParent()->GetEventHandler()->ProcessEvent(event
);
701 DECLARE_EVENT_TABLE()
704 BEGIN_EVENT_TABLE(wxSTCListBox
, wxListBox
)
705 EVT_KEY_DOWN(wxSTCListBox::OnKeyDown
)
706 EVT_CHAR(wxSTCListBox::OnKeyDown
)
711 #undef wxSTC_USE_POPUP
712 #define wxSTC_USE_POPUP 0 // wxPopupWindow just doesn't work well in this case...
714 // A window to place the listbox upon. If wxPopupWindow is supported then
715 // that will be used so the listbox can extend beyond the client area of the
717 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
718 #include <wx/popupwin.h>
719 #define wxSTCListBoxWinBase wxPopupWindow
720 #define param2 wxBORDER_NONE // popup's 2nd param is flags
722 #define wxSTCListBoxWinBase wxWindow
723 #define param2 -1 // wxWindow's 2nd param is ID
726 class wxSTCListBoxWin
: public wxSTCListBoxWinBase
{
728 wxSTCListBoxWin(wxWindow
* parent
, wxWindowID id
)
729 : wxSTCListBoxWinBase(parent
, param2
) {
730 lb
= new wxSTCListBox(this, id
);
731 lb
->SetCursor(wxCursor(wxCURSOR_ARROW
));
735 void OnSize(wxSizeEvent
& event
) {
736 lb
->SetSize(GetSize());
739 wxListBox
* GetLB() { return lb
; }
741 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
742 virtual void DoSetSize(int x
, int y
,
743 int width
, int height
,
744 int sizeFlags
= wxSIZE_AUTO
) {
746 GetParent()->ClientToScreen(&x
, NULL
);
748 GetParent()->ClientToScreen(NULL
, &y
);
749 wxSTCListBoxWinBase::DoSetSize(x
, y
, width
, height
, sizeFlags
);
755 DECLARE_EVENT_TABLE()
758 BEGIN_EVENT_TABLE(wxSTCListBoxWin
, wxSTCListBoxWinBase
)
759 EVT_SIZE(wxSTCListBoxWin::OnSize
)
763 inline wxListBox
* GETLB(WindowID win
) {
764 return (((wxSTCListBoxWin
*)win
)->GetLB());
767 //----------------------------------------------------------------------
772 ListBox::~ListBox() {
775 void ListBox::Create(Window
&parent
, int ctrlID
) {
776 id
= new wxSTCListBoxWin(GETWIN(parent
.GetID()), ctrlID
);
779 void ListBox::SetVisibleRows(int rows
) {
780 desiredVisibleRows
= rows
;
783 PRectangle
ListBox::GetDesiredRect() {
784 wxSize sz
= GETLB(id
)->GetBestSize();
790 if (sz
.y
> 140) // TODO: Use desiredVisibleRows??
797 void ListBox::SetAverageCharWidth(int width
) {
798 aveCharWidth
= width
;
801 void ListBox::SetFont(Font
&font
) {
802 GETLB(id
)->SetFont(*((wxFont
*)font
.GetID()));
805 void ListBox::Clear() {
809 void ListBox::Append(char *s
) {
810 GETLB(id
)->Append(stc2wx(s
));
813 int ListBox::Length() {
814 return GETLB(id
)->GetCount();
817 void ListBox::Select(int n
) {
823 GETLB(id
)->SetSelection(n
, select
);
829 GETLB(id
)->SetFirstItem(n
);
833 int ListBox::GetSelection() {
834 return GETLB(id
)->GetSelection();
837 int ListBox::Find(const char *prefix
) {
842 void ListBox::GetValue(int n
, char *value
, int len
) {
843 wxString text
= GETLB(id
)->GetString(n
);
844 strncpy(value
, wx2stc(text
), len
);
848 void ListBox::Sort() {
851 //----------------------------------------------------------------------
853 Menu::Menu() : id(0) {
856 void Menu::CreatePopUp() {
861 void Menu::Destroy() {
867 void Menu::Show(Point pt
, Window
&w
) {
868 GETWIN(w
.GetID())->PopupMenu((wxMenu
*)id
, pt
.x
- 4, pt
.y
);
872 //----------------------------------------------------------------------
874 ColourDesired
Platform::Chrome() {
876 c
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
877 return ColourDesired(c
.Red(), c
.Green(), c
.Blue());
880 ColourDesired
Platform::ChromeHighlight() {
882 c
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT
);
883 return ColourDesired(c
.Red(), c
.Green(), c
.Blue());
886 const char *Platform::DefaultFont() {
887 static char buf
[128];
888 strcpy(buf
, wxNORMAL_FONT
->GetFaceName().mbc_str());
892 int Platform::DefaultFontSize() {
896 unsigned int Platform::DoubleClickTime() {
897 return 500; // **** ::GetDoubleClickTime();
900 void Platform::DebugDisplay(const char *s
) {
901 wxLogDebug(stc2wx(s
));
904 bool Platform::IsKeyDown(int key
) {
905 return false; // I don't think we'll need this.
908 long Platform::SendScintilla(WindowID w
,
910 unsigned long wParam
,
913 wxStyledTextCtrl
* stc
= (wxStyledTextCtrl
*)w
;
914 return stc
->SendMsg(msg
, wParam
, lParam
);
917 long Platform::SendScintillaPointer(WindowID w
,
919 unsigned long wParam
,
922 wxStyledTextCtrl
* stc
= (wxStyledTextCtrl
*)w
;
923 return stc
->SendMsg(msg
, wParam
, (long)lParam
);
927 // These are utility functions not really tied to a platform
929 int Platform::Minimum(int a
, int b
) {
936 int Platform::Maximum(int a
, int b
) {
945 void Platform::DebugPrintf(const char *format
, ...) {
949 va_start(pArguments
, format
);
950 vsprintf(buffer
,format
,pArguments
);
952 Platform::DebugDisplay(buffer
);
957 static bool assertionPopUps
= true;
959 bool Platform::ShowAssertionPopUps(bool assertionPopUps_
) {
960 bool ret
= assertionPopUps
;
961 assertionPopUps
= assertionPopUps_
;
965 void Platform::Assert(const char *c
, const char *file
, int line
) {
967 sprintf(buffer
, "Assertion [%s] failed at %s %d", c
, file
, line
);
968 if (assertionPopUps
) {
970 wxMessageBox(stc2wx(buffer
),
971 wxT("Assertion failure"),
973 // if (idButton == IDRETRY) {
975 // } else if (idButton == IDIGNORE) {
981 strcat(buffer
, "\r\n");
982 Platform::DebugDisplay(buffer
);
988 int Platform::Clamp(int val
, int minVal
, int maxVal
) {
997 bool Platform::IsDBCSLeadByte(int codePage
, char ch
) {
1003 //----------------------------------------------------------------------
1005 ElapsedTime::ElapsedTime() {
1009 double ElapsedTime::Duration(bool reset
) {
1010 double result
= wxGetElapsedTime(reset
);
1016 //----------------------------------------------------------------------