本文整理汇总了C++中wxCHECK_MSG函数的典型用法代码示例。如果您正苦于以下问题:C++ wxCHECK_MSG函数的具体用法?C++ wxCHECK_MSG怎么用?C++ wxCHECK_MSG使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxCHECK_MSG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxCHECK_MSG
bool wxWrapperInputStream::IsSeekable() const
{
wxCHECK_MSG(m_parent_i_stream, false, "Stream not valid");
return m_parent_i_stream->IsSeekable();
}
示例2: GetLastAccess
wxFileOffset wxStreamBuffer::Seek(wxFileOffset pos, wxSeekMode mode)
{
wxFileOffset ret_off, diff;
wxFileOffset last_access = GetLastAccess();
if ( !m_flushable )
{
switch (mode)
{
case wxFromStart:
diff = pos;
break;
case wxFromCurrent:
diff = pos + GetIntPosition();
break;
case wxFromEnd:
diff = pos + last_access;
break;
default:
wxFAIL_MSG( wxT("invalid seek mode") );
return wxInvalidOffset;
}
if (diff < 0 || diff > last_access)
return wxInvalidOffset;
size_t int_diff = wx_truncate_cast(size_t, diff);
wxCHECK_MSG( (wxFileOffset)int_diff == diff, wxInvalidOffset, wxT("huge file not supported") );
SetIntPosition(int_diff);
return diff;
}
switch ( mode )
{
case wxFromStart:
// We'll try to compute an internal position later ...
ret_off = m_stream->OnSysSeek(pos, wxFromStart);
ResetBuffer();
return ret_off;
case wxFromCurrent:
diff = pos + GetIntPosition();
if ( (diff > last_access) || (diff < 0) )
{
// We must take into account the fact that we have read
// something previously.
ret_off = m_stream->OnSysSeek(diff-last_access, wxFromCurrent);
ResetBuffer();
return ret_off;
}
else
{
size_t int_diff = wx_truncate_cast(size_t, diff);
wxCHECK_MSG( (wxFileOffset)int_diff == diff, wxInvalidOffset, wxT("huge file not supported") );
SetIntPosition(int_diff);
return diff;
}
case wxFromEnd:
// Hard to compute: always seek to the requested position.
ret_off = m_stream->OnSysSeek(pos, wxFromEnd);
ResetBuffer();
return ret_off;
}
return wxInvalidOffset;
}
示例3: wxCHECK_MSG
bool wxTreeListCtrl::IsSelected(wxTreeListItem item) const
{
wxCHECK_MSG( m_view, false, "Must create first" );
return m_view->IsSelected(m_model->ToNonRootDVI(item));
}
示例4: GetDataBrowserTableViewColumnProperty
int wxListBox::DoListHitTest(const wxPoint& inpoint) const
{
OSStatus err;
// There are few reasons why this is complicated:
// 1) There is no native HitTest function for Mac
// 2) GetDataBrowserItemPartBounds only works on visible items
// 3) We can't do it through GetDataBrowserTableView[Item]RowHeight
// because what it returns is basically inaccurate in the context
// of the coordinates we want here, but we use this as a guess
// for where the first visible item lies
wxPoint point = inpoint;
// get column property ID (req. for call to itempartbounds)
DataBrowserTableViewColumnID colId = 0;
err = GetDataBrowserTableViewColumnProperty(m_peer->GetControlRef(), 0, &colId);
wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewColumnProperty"));
// OK, first we need to find the first visible item we have -
// this will be the "low" for our binary search. There is no real
// easy way around this, as we will need to do a SLOW linear search
// until we find a visible item, but we can do a cheap calculation
// via the row height to speed things up a bit
UInt32 scrollx, scrolly;
err = GetDataBrowserScrollPosition(m_peer->GetControlRef(), &scrollx, &scrolly);
wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserScrollPosition"));
UInt16 height;
err = GetDataBrowserTableViewRowHeight(m_peer->GetControlRef(), &height);
wxCHECK_MSG(err == noErr, wxNOT_FOUND, wxT("Unexpected error from GetDataBrowserTableViewRowHeight"));
// these indices are 0-based, as usual, so we need to add 1 to them when
// passing them to data browser functions which use 1-based indices
int low = scrolly / height,
high = GetCount() - 1;
// search for the first visible item (note that the scroll guess above
// is the low bounds of where the item might lie so we only use that as a
// starting point - we should reach it within 1 or 2 iterations of the loop)
while ( low <= high )
{
Rect bounds;
err = GetDataBrowserItemPartBounds(
m_peer->GetControlRef(), low + 1, colId,
kDataBrowserPropertyEnclosingPart,
&bounds); // note +1 to translate to Mac ID
if ( err == noErr )
break;
// errDataBrowserItemNotFound is expected as it simply means that the
// item is not currently visible -- but other errors are not
wxCHECK_MSG( err == errDataBrowserItemNotFound, wxNOT_FOUND,
wxT("Unexpected error from GetDataBrowserItemPartBounds") );
low++;
}
// NOW do a binary search for where the item lies, searching low again if
// we hit an item that isn't visible
while ( low <= high )
{
int mid = (low + high) / 2;
Rect bounds;
err = GetDataBrowserItemPartBounds(
m_peer->GetControlRef(), mid + 1, colId,
kDataBrowserPropertyEnclosingPart,
&bounds); //note +1 to trans to mac id
wxCHECK_MSG( err == noErr || err == errDataBrowserItemNotFound,
wxNOT_FOUND,
wxT("Unexpected error from GetDataBrowserItemPartBounds") );
if ( err == errDataBrowserItemNotFound )
{
// item not visible, attempt to find a visible one
// search lower
high = mid - 1;
}
else // visible item, do actual hitttest
{
// if point is within the bounds, return this item (since we assume
// all x coords of items are equal we only test the x coord in
// equality)
if ((point.x >= bounds.left && point.x <= bounds.right) &&
(point.y >= bounds.top && point.y <= bounds.bottom) )
{
// found!
return mid;
}
if ( point.y < bounds.top )
// index(bounds) greater then key(point)
high = mid - 1;
else
// index(bounds) less then key(point)
low = mid + 1;
}
}
//.........这里部分代码省略.........
示例5: target_drag_drop
static gboolean target_drag_drop( GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time,
wxDropTarget *drop_target )
{
/* Owen Taylor: "if the drop is not in a drop zone,
return FALSE, otherwise, if you aren't accepting
the drop, call gtk_drag_finish() with success == FALSE
otherwise call gtk_drag_data_get()" */
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->GTKSetDragContext( context );
// Does the source actually accept the data type?
if (drop_target->GTKGetMatchingPair() == (GdkAtom) 0)
{
// cancel the whole thing
gtk_drag_finish( context,
FALSE, // no success
FALSE, // don't delete data on dropping side
time );
drop_target->GTKSetDragContext( NULL );
drop_target->m_firstMotion = true;
return FALSE;
}
/* inform the wxDropTarget about the current drag widget.
this is only valid for the duration of this call */
drop_target->GTKSetDragWidget( widget );
/* inform the wxDropTarget about the current drag time.
this is only valid for the duration of this call */
drop_target->GTKSetDragTime( time );
/* reset the block here as someone might very well
show a dialog as a reaction to a drop and this
wouldn't work without events */
g_blockEventsOnDrag = false;
bool ret = drop_target->OnDrop( x, y );
if (!ret)
{
wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned FALSE") );
/* cancel the whole thing */
gtk_drag_finish( context,
FALSE, /* no success */
FALSE, /* don't delete data on dropping side */
time );
}
else
{
wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned true") );
GdkAtom format = drop_target->GTKGetMatchingPair();
// this does happen somehow, see bug 555111
wxCHECK_MSG( format, FALSE, wxT("no matching GdkAtom for format?") );
/* this should trigger an "drag_data_received" event */
gtk_drag_get_data( widget,
context,
format,
time );
}
/* after this, invalidate the drop_target's GdkDragContext */
drop_target->GTKSetDragContext( NULL );
/* after this, invalidate the drop_target's drag widget */
drop_target->GTKSetDragWidget( NULL );
/* this has to be done because GDK has no "drag_enter" event */
drop_target->m_firstMotion = true;
return ret;
}
示例6: wxCHECK_MSG
unsigned char wxColour::Blue() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid colour") );
return wxByte(M_COLDATA->m_blue >> SHIFT);
}
示例7: wxCHECK_MSG
bool wxCheckListBox::IsChecked(unsigned int uiIndex) const
{
wxCHECK_MSG( IsValid(uiIndex), false, wxT("bad wxCheckListBox index") );
return GetItem(uiIndex)->IsChecked();
}
示例8: defined
//.........这里部分代码省略.........
if(parser.Found(wxT("b"), &newBaseDir)) {
#if defined(__WXMSW__)
homeDir = newBaseDir;
#else
wxLogDebug("Ignoring the Windows-only --basedir option as not running Windows");
#endif
}
// Set the log file verbosity. NB Doing this earlier seems to break wxGTK debug output when debugging CodeLite
// itself :/
FileLogger::OpenLog("codelite.log", clConfig::Get().Read(kConfigLogVerbosity, FileLogger::Error));
CL_DEBUG(wxT("Starting codelite..."));
// Copy gdb pretty printers from the installation folder to a writeable location
// this is needed because python complies the files and in most cases the user
// running codelite has no write permissions to /usr/share/codelite/...
DoCopyGdbPrinters();
// Since GCC 4.8.2 gcc has a default colored output
// which breaks codelite output parsing
// to disable this, we need to set GCC_COLORS to an empty
// string.
// https://sourceforge.net/p/codelite/bugs/946/
// http://gcc.gnu.org/onlinedocs/gcc/Language-Independent-Options.html
::wxSetEnv("GCC_COLORS", "");
#if defined(__WXGTK__)
if(homeDir.IsEmpty()) {
homeDir = clStandardPaths::Get()
.GetUserDataDir(); // By default, ~/Library/Application Support/codelite or ~/.codelite
if(!wxFileName::Exists(homeDir)) {
wxLogNull noLog;
wxFileName::Mkdir(homeDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
wxCHECK_MSG(wxFileName::DirExists(homeDir), false, "Failed to create the requested data dir");
}
// Create the directory structure
wxLogNull noLog;
wxMkdir(homeDir);
wxMkdir(homeDir + wxT("/lexers/"));
wxMkdir(homeDir + wxT("/rc/"));
wxMkdir(homeDir + wxT("/images/"));
wxMkdir(homeDir + wxT("/templates/"));
wxMkdir(homeDir + wxT("/config/"));
wxMkdir(homeDir + wxT("/tabgroups/"));
// copy the settings from the global location if needed
wxString installPath(INSTALL_DIR, wxConvUTF8);
if(!CopySettings(homeDir, installPath)) return false;
ManagerST::Get()->SetInstallDir(installPath);
} else {
wxFileName fn(homeDir);
fn.MakeAbsolute();
ManagerST::Get()->SetInstallDir(fn.GetFullPath());
}
#elif defined(__WXMAC__)
homeDir = clStandardPaths::Get().GetUserDataDir();
if(!wxFileName::Exists(homeDir)) {
wxLogNull noLog;
wxFileName::Mkdir(homeDir, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
wxCHECK_MSG(wxFileName::DirExists(homeDir), false, "Failed to create the requested data dir");
}
{
示例9: wxCHECK_MSG
wxDragResult wxDropSource::DoDragDrop(int flags)
{
wxCHECK_MSG( m_data && m_data->GetFormatCount(), wxDragNone,
wxT("Drop source: no data") );
// still in drag
if (g_blockEventsOnDrag)
return wxDragNone;
// don't start dragging if no button is down
if (g_lastButtonNumber == 0)
return wxDragNone;
// we can only start a drag after a mouse event
if (g_lastMouseEvent == NULL)
return wxDragNone;
GTKConnectDragSignals();
wxON_BLOCK_EXIT_OBJ0(*this, wxDropSource::GTKDisconnectDragSignals);
m_waiting = true;
GtkTargetList *target_list = gtk_target_list_new( NULL, 0 );
wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
m_data->GetAllFormats( array );
size_t count = m_data->GetFormatCount();
for (size_t i = 0; i < count; i++)
{
GdkAtom atom = array[i];
wxLogTrace(TRACE_DND, wxT("Drop source: Supported atom %s"),
gdk_atom_name( atom ));
gtk_target_list_add( target_list, atom, 0, 0 );
}
delete[] array;
int allowed_actions = GDK_ACTION_COPY;
if ( flags & wxDrag_AllowMove )
allowed_actions |= GDK_ACTION_MOVE;
// VZ: as we already use g_blockEventsOnDrag it shouldn't be that bad
// to use a global to pass the flags to the drop target but I'd
// surely prefer a better way to do it
gs_flagsForDrag = flags;
m_retValue = wxDragCancel;
GdkDragContext *context = gtk_drag_begin( m_widget,
target_list,
(GdkDragAction)allowed_actions,
g_lastButtonNumber, // number of mouse button which started drag
(GdkEvent*) g_lastMouseEvent );
if ( !context )
{
// this can happen e.g. if gdk_pointer_grab() failed
return wxDragError;
}
m_dragContext = context;
PrepareIcon( allowed_actions, context );
while (m_waiting)
gtk_main_iteration();
g_signal_handlers_disconnect_by_func (m_iconWindow,
(gpointer) gtk_dnd_window_configure_callback, this);
return m_retValue;
}
示例10: wxCHECK_MSG
wxRibbonButtonBarButtonBase *wxRibbonButtonBar::GetItem(size_t n) const
{
wxCHECK_MSG(n < m_buttons.GetCount(), NULL, "wxRibbonButtonBar item's index is out of bound");
return m_buttons.Item(n);
}
示例11: wxCHECK_MSG
int wxEventLoopManual::Run()
{
// event loops are not recursive, you need to create another loop!
wxCHECK_MSG( !IsRunning(), -1, wxT("can't reenter a message loop") );
// ProcessIdle() and ProcessEvents() below may throw so the code here should
// be exception-safe, hence we must use local objects for all actions we
// should undo
wxEventLoopActivator activate(this);
// we must ensure that OnExit() is called even if an exception is thrown
// from inside ProcessEvents() but we must call it from Exit() in normal
// situations because it is supposed to be called synchronously,
// wxModalEventLoop depends on this (so we can't just use ON_BLOCK_EXIT or
// something similar here)
#if wxUSE_EXCEPTIONS
for ( ;; )
{
try
{
#endif // wxUSE_EXCEPTIONS
// this is the event loop itself
for ( ;; )
{
// give them the possibility to do whatever they want
OnNextIteration();
// generate and process idle events for as long as we don't
// have anything else to do
while ( !Pending() && ProcessIdle() )
;
// if the "should exit" flag is set, the loop should terminate
// but not before processing any remaining messages so while
// Pending() returns true, do process them
if ( m_shouldExit )
{
while ( Pending() )
ProcessEvents();
break;
}
// a message came or no more idle processing to do, dispatch
// all the pending events and call Dispatch() to wait for the
// next message
if ( !ProcessEvents() )
{
// we got WM_QUIT
break;
}
}
#if wxUSE_EXCEPTIONS
// exit the outer loop as well
break;
}
catch ( ... )
{
try
{
if ( !wxTheApp || !wxTheApp->OnExceptionInMainLoop() )
{
OnExit();
break;
}
//else: continue running the event loop
}
catch ( ... )
{
// OnException() throwed, possibly rethrowing the same
// exception again: very good, but we still need OnExit() to
// be called
OnExit();
throw;
}
}
}
#endif // wxUSE_EXCEPTIONS
return m_exitcode;
}
示例12: wxCHECK_MSG
wxWindow* wxWindow::CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd)
{
wxCHECK_MSG( parent, NULL, _T("must have valid parent for a control") );
wxString str(wxGetWindowClass(hWnd));
str.UpperCase();
long id = wxGetWindowId(hWnd);
long style = GetWindowLong((HWND) hWnd, GWL_STYLE);
wxWindow* win = NULL;
if (str == wxT("BUTTON"))
{
int style1 = (style & 0xFF);
#if wxUSE_CHECKBOX
if ((style1 == BS_3STATE) || (style1 == BS_AUTO3STATE) || (style1 == BS_AUTOCHECKBOX) ||
(style1 == BS_CHECKBOX))
{
win = new wxCheckBox;
}
else
#endif
#if wxUSE_RADIOBTN
if ((style1 == BS_AUTORADIOBUTTON) || (style1 == BS_RADIOBUTTON))
{
win = new wxRadioButton;
}
else
#endif
#if wxUSE_BMPBUTTON
#if defined(__WIN32__) && defined(BS_BITMAP)
if (style & BS_BITMAP)
{
// TODO: how to find the bitmap?
win = new wxBitmapButton;
wxLogError(wxT("Have not yet implemented bitmap button as BS_BITMAP button."));
}
else
#endif
if (style1 == BS_OWNERDRAW)
{
// TODO: how to find the bitmap?
// TODO: can't distinguish between bitmap button and bitmap static.
// Change implementation of wxStaticBitmap to SS_BITMAP.
// PROBLEM: this assumes that we're using resource-based bitmaps.
// So maybe need 2 implementations of bitmap buttons/static controls,
// with a switch in the drawing code. Call default proc if BS_BITMAP.
win = new wxBitmapButton;
}
else
#endif
#if wxUSE_BUTTON
if ((style1 == BS_PUSHBUTTON) || (style1 == BS_DEFPUSHBUTTON))
{
win = new wxButton;
}
else
#endif
#if wxUSE_STATBOX
if (style1 == BS_GROUPBOX)
{
win = new wxStaticBox;
}
else
#endif
{
wxLogError(wxT("Don't know what kind of button this is: id = %ld"),
id);
}
}
#if wxUSE_COMBOBOX
else if (str == wxT("COMBOBOX"))
{
win = new wxComboBox;
}
#endif
#if wxUSE_TEXTCTRL
// TODO: Problem if the user creates a multiline - but not rich text - text control,
// since wxWin assumes RichEdit control for this. Should have m_isRichText in
// wxTextCtrl. Also, convert as much of the window style as is necessary
// for correct functioning.
// Could have wxWindow::AdoptAttributesFromHWND(WXHWND)
// to be overridden by each control class.
else if (str == wxT("EDIT"))
{
win = new wxTextCtrl;
}
#endif
#if wxUSE_LISTBOX
else if (str == wxT("LISTBOX"))
{
win = new wxListBox;
}
#endif
#if wxUSE_SCROLLBAR
else if (str == wxT("SCROLLBAR"))
{
win = new wxScrollBar;
}
//.........这里部分代码省略.........
示例13: wxASSERT_MSG
size_t wxStreamBuffer::Write(const void *buffer, size_t size)
{
wxASSERT_MSG( buffer, wxT("Warning: Null pointer is about to be send") );
if (m_stream)
{
// lasterror is reset before all new IO calls
m_stream->Reset();
}
size_t ret;
if ( !HasBuffer() && m_fixed )
{
wxOutputStream *outStream = GetOutputStream();
wxCHECK_MSG( outStream, 0, wxT("should have a stream in wxStreamBuffer") );
// no buffer, just forward the call to the stream
ret = outStream->OnSysWrite(buffer, size);
}
else // we [may] have a buffer, use it
{
size_t orig_size = size;
while ( size > 0 )
{
size_t left = GetBytesLeft();
// if the buffer is too large to fit in the stream buffer, split
// it in smaller parts
//
// NB: If stream buffer isn't fixed (as for wxMemoryOutputStream),
// we always go to the second case.
//
// FIXME: fine, but if it fails we should (re)try writing it by
// chunks as this will (hopefully) always work (VZ)
if ( size > left && m_fixed )
{
PutToBuffer(buffer, left);
size -= left;
buffer = (char *)buffer + left;
if ( !FlushBuffer() )
{
SetError(wxSTREAM_WRITE_ERROR);
break;
}
m_buffer_pos = m_buffer_start;
}
else // we can do it in one gulp
{
PutToBuffer(buffer, size);
size = 0;
}
}
ret = orig_size - size;
}
if (m_stream)
{
// i am not entirely sure what we do this for
m_stream->m_lastcount = ret;
}
return ret;
}
示例14: wxSetFocusToChild
bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
{
wxCHECK_MSG( win, false, _T("wxSetFocusToChild(): invalid window") );
wxCHECK_MSG( childLastFocused, false,
_T("wxSetFocusToChild(): NULL child poonter") );
if ( *childLastFocused )
{
// It might happen that the window got reparented
if ( (*childLastFocused)->GetParent() == win )
{
wxLogTrace(TRACE_FOCUS,
_T("SetFocusToChild() => last child (0x%p)."),
(*childLastFocused)->GetHandle());
// not SetFocusFromKbd(): we're restoring focus back to the old
// window and not setting it as the result of a kbd action
(*childLastFocused)->SetFocus();
return true;
}
else
{
// it doesn't count as such any more
*childLastFocused = (wxWindow *)NULL;
}
}
// set the focus to the first child who wants it
wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst();
while ( node )
{
wxWindow *child = node->GetData();
node = node->GetNext();
#ifdef __WXMAC__
if ( child->GetParent()->MacIsWindowScrollbar( child ) )
continue;
#endif
if ( child->AcceptsFocusFromKeyboard() && !child->IsTopLevel() )
{
#ifdef __WXMSW__
// If a radiobutton is the first focusable child, search for the
// selected radiobutton in the same group
wxRadioButton* btn = wxDynamicCast(child, wxRadioButton);
if (btn)
{
wxRadioButton* selected = wxGetSelectedButtonInGroup(btn);
if (selected)
child = selected;
}
#endif
wxLogTrace(TRACE_FOCUS,
_T("SetFocusToChild() => first child (0x%p)."),
child->GetHandle());
*childLastFocused = child;
child->SetFocusFromKbd();
return true;
}
}
return false;
}
示例15: wxCHECK_MSG
wxString wxFont::GetFaceName() const
{
wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") );
//knorr?? face??
// return fnt->Face();
}