//------------------------------------------------------------------------------
// serialize
//------------------------------------------------------------------------------
std::ostream& Database::serialize(std::ostream& sout, const int i, const bool slotsOnly) const
{
    int j = 0;
    if ( !slotsOnly ) {
        sout << "( " << getFactoryName() << std::endl;
        j = 4;
    }

    if (strlen(getPathname()) > 0) {
        indent(sout,i+j);
        sout << "pathname: \"";
        sout << getPathname();
        sout << "\"" << std::endl;
    }

    if (strlen(getFilename()) > 0) {
        indent(sout,i+j);
        sout << "filename: \"";
        sout << getFilename();
        sout << "\"" << std::endl;
    }

    if ( !slotsOnly ) {
        indent(sout,i);
        sout << ")" << std::endl;
    }

    return sout;
}
BOOL LLButton::handleMouseDown(S32 x, S32 y, MASK mask)
{
	if (!childrenHandleMouseDown(x, y, mask))
	{
		// Route future Mouse messages here preemptively.  (Release on mouse up.)
		gFocusMgr.setMouseCapture( this );

		if (hasTabStop() && !getIsChrome())
		{
			setFocus(TRUE);
		}

		/*
		 * ATTENTION! This call fires another mouse down callback.
		 * If you wish to remove this call emit that signal directly
		 * by calling LLUICtrl::mMouseDownSignal(x, y, mask);
		 */
		LLUICtrl::handleMouseDown(x, y, mask);

		LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname());

		if(mMouseDownSignal) (*mMouseDownSignal)(this, LLSD());

		mMouseDownTimer.start();
		mMouseDownFrame = (S32) LLFrameTimer::getFrameCount();
		mMouseHeldDownCount = 0;

		
		if (getSoundFlags() & MOUSE_DOWN)
		{
			make_ui_sound("UISndClick");
		}
	}
	return TRUE;
}
//------------------------------------------------------------------------------
// Load a DTED cell into memory
//------------------------------------------------------------------------------
bool DtedFile::loadData()
{
    // Compute the filename (why can't we be given just one filename string!??)
    std::string temp_filename;
    const char* p = getPathname();
    if (p != nullptr)
    {
        temp_filename += p;
        temp_filename += '/';
    }
    p = getFilename();
    if (p != nullptr)
        temp_filename += p;

    // Open the terrain file.
    const char* filename = temp_filename.c_str();

    std::ifstream in;
    in.open(filename, std::ios::binary);
    if ( in.fail() )
    {
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "DtedFile::loadData() ERROR, could not open file: " << filename << std::endl;
        }
        return false;
    }

    // Read cell parameters from the DTED headers
    if (! readDtedHeaders(in))
    {
        clearData();
        in.close();
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "DtedFile::loadData() ERROR reading DTED headers in file: " << filename << std::endl;
        }
        return false;
    }

    // Read elevation data from the DTED file
    if (! readDtedData(in))
    {
        clearData();
        in.close();
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "DtedFile::loadData() ERROR reading data from file: " << filename << std::endl;
        }
        return false;
    }

    // Close the file
    in.close();
    return true;
}
BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask)
{
	// We only handle the click if the click both started and ended within us
	if( hasMouseCapture() )
	{
		// Always release the mouse
		gFocusMgr.setMouseCapture( NULL );

		/*
		 * ATTENTION! This call fires another mouse up callback.
		 * If you wish to remove this call emit that signal directly
		 * by calling LLUICtrl::mMouseUpSignal(x, y, mask);
		 */
		LLUICtrl::handleMouseUp(x, y, mask);
		LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); 

		// Regardless of where mouseup occurs, handle callback
		if(mMouseUpSignal) (*mMouseUpSignal)(this, LLSD());

		resetMouseDownTimer();

		// DO THIS AT THE VERY END to allow the button to be destroyed as a result of being clicked.
		// If mouseup in the widget, it's been clicked
		if (pointInView(x, y))
		{
			if (getSoundFlags() & MOUSE_UP)
			{
				make_ui_sound("UISndClickRelease");
			}

			if (mIsToggle)
			{
				toggleState();
			}

			LLUICtrl::onCommit();
		}
	}
	else
	{
		childrenHandleMouseUp(x, y, mask);
	}

	return TRUE;
}
long ProjectBrowser::onDoubleClick(FXObject* sender, FXSelector sel, void* ptr)
{
	FXTRACE((1, "FileBrowser::onDoubleClick()\n"));
	if (ptr)
	{
		FXTreeItem* item = (FXTreeItem*)ptr;
		if (!projectTree->isItemLeaf(item))
		{
	    	if(projectTree->isItemExpanded(item))
	    	{
				projectTree->collapseTree(item, TRUE);
			}
			else
			{
				projectTree->expandTree(item, TRUE);
			}
		}
		else// if (projectTree->isItemLeaf(item))
		{
			mainWin->getEditor()->openFile(getPathname(item));
		}
	}
	return 1;
}