コード例 #1
0
ファイル: mouse.c プロジェクト: WhatDream/LCUI
static LCUI_BOOL MouseProc( void )
{
	POINT new_pos;
	LCUI_SystemEvent e;
	static LCUI_Pos old_pos = {0, 0};

	/* 如果是无缝模式则获取系统鼠标游标的坐标 */
	if( LCUIDisplay_GetMode() == LDM_SEAMLESS ) {
		GetCursorPos( &new_pos );
	} else {
		new_pos.x = mouse.x;
		new_pos.y = mouse.y;
	}
	e.type = LCUI_MOUSEMOVE;
	e.type_name = NULL;
	e.data = e.destroy_data = NULL;
	e.rel_x = new_pos.x - old_pos.x;
	e.rel_y = new_pos.y - old_pos.y;
	if( e.rel_x == 0 && e.rel_y == 0 ) {
		return FALSE;
	}
	old_pos.x = new_pos.x;
	old_pos.y = new_pos.y;
	_DEBUG_MSG("x: %d, y: %d, rel_x: %d, rel_y: %d\n", new_pos.x, new_pos.y, e.rel_x, e.rel_y);
	_DEBUG_MSG("post result: %d\n", LCUI_PostEvent( &e ));
	return TRUE;
}
コード例 #2
0
ファイル: graphlayer.c プロジェクト: aem3372/LCUI
LCUI_API int GraphLayer_PrintChildList( LCUI_GraphLayer *glayer )
{
	int i, n;
	LCUI_Queue *child_list;
	LCUI_GraphLayer *child;

	if( glayer == NULL ) {
		return -1;
	}
	child_list = &glayer->child;
	if(child_list == NULL) {
		return -1;
	}
	n = Queue_GetTotal( child_list );
	_DEBUG_MSG("total glayer: %d\n", n);
	for(i=0; i<n; ++i) {
		child = (LCUI_GraphLayer*)Queue_Get( child_list, i );
		if( child == NULL ) {
			continue;
		}
		printf("[%d] glayer: %p, z-index: %d, pos: (%d,%d), size: (%d, %d)\n",
			i, child, child->z_index, child->pos.x, child->pos.y,
			child->graph.w, child->graph.h );
	}
	return 0;
}
コード例 #3
0
void QPadFindReplaceDialog::slotCreate() {
    _DEBUG_MSG("+++");
    ui->setupUi(this);

    connect(ui->ID_TAB, SIGNAL(currentChanged(int)), this , SLOT(slotChangeTab(int)));

    connect(ui->ID_BUTTON_FIND_NEXT_FIND, SIGNAL(clicked()), this, SLOT(slotFindFindNext()));
    connect(ui->ID_BUTTON_COUNT_FIND, SIGNAL(clicked()), this, SLOT(slotFindCount()));
    connect(ui->ID_BUTTON_CLOSE_FIND, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->ID_BUTTON_FA_IN_CUR_FIND, SIGNAL(clicked()), this, SLOT(slotFindFindAllCurrent()));
    connect(ui->ID_BUTTON_FA_IN_ALL_FIND, SIGNAL(clicked()), this, SLOT(slotFindFindAllinOpen()));

    connect(ui->ID_BUTTON_CLOSE_REPLACE, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->ID_BUTTON_FIND_NEXT_REPLACE, SIGNAL(clicked()), this, SLOT(slotReplaceFindNext()));
    connect(ui->ID_BUTTON_REPLACE_REPLACE, SIGNAL(clicked()), this, SLOT(slotReplaceReplace()));
    connect(ui->ID_BUTTON_REPLACE_ALL_REPLACE, SIGNAL(clicked()), this, SLOT(slotReplaceReplaceAll()));
    connect(ui->ID_BUTTON_REPLACE_ALL_IN_ALL_REPLACE, SIGNAL(clicked()), this, SLOT(slotReplaceReplaceAllinAll()));

    connect(ui->ID_BUTTON_CLOSE_FILES, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->ID_BUTTON_BROWSE_FILE, SIGNAL(clicked()), this, SLOT(slotFileBrowse()));
    connect(ui->ID_BUTTON_FIND_ALL_FILES, SIGNAL(clicked()), this, SLOT(slotFileFindAll()));

    connect(ui->ID_BUTTON_CLOSE_MARK, SIGNAL(clicked()), this, SLOT(close()));

    connect(ui->ID_RADIO_ALWAYS, SIGNAL(clicked(bool)), this, SLOT(slotOnAlwaysTransparent(bool)));
    connect(ui->ID_RADIO_ON_LOST_FOCUS, SIGNAL(clicked(bool)), this, SLOT(slotOnFocusTransparent(bool)));
    connect(ui->ID_GROUP_TRANSPARENT, SIGNAL(clicked(bool)), this, SLOT(slotOnClickTransparentGroup(bool)));

    QTimer::singleShot(0, this, SLOT(slotInitTab()));

    setWindowOpacity(1.0);

    m_bIsCreated=true;
    show();
}
コード例 #4
0
void QPadFindReplaceDialog::slotReplaceFindNext() {
    getReplaceTabValue();

    QNewMainWindow *ptrMainWin=qobject_cast<QNewMainWindow*>(parent());
    if (!ptrMainWin) return;
    QPadMdiSubWindow *ptrSubWin=reinterpret_cast<QPadMdiSubWindow*>(ptrMainWin->getMdiActiveWindow());
    if (!ptrSubWin) return;
    QsciScintilla *ptrEdit=reinterpret_cast<QsciScintilla*>(ptrSubWin->widget());
    if (!ptrEdit) return;

    int nLine=-1, nIndex=-1;
    ptrEdit->getCursorPosition(&nLine, &nIndex);
    _DEBUG_MSG("line: %d, index: %d\n", nLine, nIndex);

    if (m_nDirection == QPadFindReplaceDialog::EDIR_UP) {
        int nBLine, nELine, nBIndex, nEIndex;
        ptrEdit->getSelection(&nBLine, &nBIndex, &nELine, &nEIndex);
        nIndex= (nIndex - (nEIndex - nBIndex) < 0 ? 0 : nIndex - (nEIndex - nBIndex));
    }

    bool bResult=ptrEdit->findFirst(ui->ID_COMBO_R_FIND->currentText(), m_nSearchMode == QPadFindReplaceDialog::EMODE_REGEX,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_CASE) == QPadFindReplaceDialog::EFEATURE_CASE,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_WHOLE_WORD) == QPadFindReplaceDialog::EFEATURE_WHOLE_WORD,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_WARP) == QPadFindReplaceDialog::EFEATURE_WARP,
                       m_nDirection == QPadFindReplaceDialog::EDIR_DOWN, nLine, nIndex, true, true);

    if (bResult) {
        ptrEdit->setFocus();
    }
}
コード例 #5
0
static void X11IME_ToText( char ch )
{
	wchar_t text[2];
	text[0] = ch;
	text[1] = '\0';
	_DEBUG_MSG("%S, %d\n", text, ch);
	LCUIIME_Commit( text, 2 );
}
コード例 #6
0
ファイル: timer.c プロジェクト: fshunj/LCUI
/** 打印列表中的定时器信息 */
static void TimerList_Print( LCUI_Queue *timer_list )
{
	int i, total;
	timer_data *timer;

	total = Queue_GetTotal( timer_list );
	_DEBUG_MSG("timer list(%d) start:\n", total);
	for(i=0; i<total; ++i) {
		timer = (timer_data*)Queue_Get( timer_list , i);
		if( !timer ) {
			continue;
		}
		_DEBUG_MSG("[%02d] %d, cur_ms: %dms, total_ms: %dms\n",
			i, timer->id, timer->total_ms - (long int)LCUI_GetTicks(timer->start_time), timer->total_ms );
	}
	_DEBUG_MSG("timer list end\n\n");
}
コード例 #7
0
void QPadFindReplaceDialog::showEvent(QShowEvent *event) {
    _DEBUG_MSG("+++");
    if (!m_bIsCreated) {
        hide();
        return;
    }
    BaseDialog::showEvent(event);
}
コード例 #8
0
ファイル: fontlibrary.c プロジェクト: scrich998/LCUI
/** 载入字体值数据库中 */
LCUI_API int FontLIB_LoadFontFile( const char *filepath )
{
	int id;
#ifdef LCUI_FONT_ENGINE_FREETYPE
	FT_Face face;
	int error_code;
#endif
	if( !filepath ) {
		return -1;
	}
	/* 如果有同一文件路径的字族信息 */
	id = FontLIB_FindInfoByFilePath( filepath );
	if( id >= 0 ) {
		return id;
	}

#ifdef LCUI_FONT_ENGINE_FREETYPE
	error_code = FT_New_Face( fontlib.library, filepath, 0, &face );
	if( error_code != 0 ) {
		_DEBUG_MSG( "%s: open error\n", filepath );
		if ( error_code == FT_Err_Unknown_File_Format ) {
			// ...
		} else {
			// ...
		}
		return -2;
	}
	/* 打印字体信息 */
	printf( "=============== font info ==============\n"
		"family name: %s\n"
		"style name : %s\n"
		"========================================\n" ,
		face->family_name, face->style_name );

	/* 设定为UNICODE,默认的也是 */
	FT_Select_Charmap( face, FT_ENCODING_UNICODE );
	/* 记录字体信息至数据库中 */
	id = FontLIB_AddFontInfo( face->family_name, face->style_name, filepath, face );
#else
	_DEBUG_MSG("warning: not font engine support!");
#endif
	return id;
}
コード例 #9
0
ファイル: helloworld.c プロジェクト: rokite/LCUI
void onTimer( void *arg )
{
	static int mode = LDM_SEAMLESS;
	_DEBUG_MSG("tip\n");
	LCUIDisplay_SetMode( mode );
	if( mode == LDM_SEAMLESS ) {
		mode = LDM_WINDOWED;
	} else {
		mode = LDM_SEAMLESS;
	}
}
コード例 #10
0
static LCUI_BOOL X11IME_ProcessKey( int key, int key_state )
{
	if( key_state != LCUIKEYSTATE_PRESSED ) {
		return FALSE;
	}
	_DEBUG_MSG("key: %d\n", key);
	if( key == LCUIKEY_ENTER || (key >= ' ' && key <= '~') ) {
	    	return TRUE;

	}
	return FALSE;
}
コード例 #11
0
void QPadFindReplaceDialog::findAllinSubWin(QTreeWidgetItem *root, QMdiSubWindow *ptrWin) {
    QPadMdiSubWindow *ptrSubWin=dynamic_cast<QPadMdiSubWindow*>(ptrWin);
    if (!ptrSubWin) return;
    QsciScintilla *ptrEdit=reinterpret_cast<QsciScintilla*>(ptrSubWin->widget());
    if (!ptrEdit) return;

    int nCurPos=ptrEdit->SendScintilla(SCI_GETCURRENTPOS);

    bool bResult=ptrEdit->findFirst(ui->ID_COMBO_FIND->currentText(), m_nSearchMode == QPadFindReplaceDialog::EMODE_REGEX,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_CASE) == QPadFindReplaceDialog::EFEATURE_CASE,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_WHOLE_WORD) == QPadFindReplaceDialog::EFEATURE_WHOLE_WORD,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_WARP) == QPadFindReplaceDialog::EFEATURE_WARP,
                       true, 0, 0, false, false);

    if (!bResult) {
        return;
    }

    int nLine=-1, nIndex=-1;
    ptrEdit->getCursorPosition(&nLine, &nIndex);
    QTreeWidgetItem *ptrRoot=root;
    _DEBUG_MSG("ptrRoot: 0x%x", ptrRoot);
    if (!ptrRoot) return;

    QTreeWidgetItem* pFile=new QTreeWidgetItem(ptrRoot, QStringList(ptrSubWin->m_qstrFileName));
    pFile->setTextColor(0, QColor(0, 150, 0));
    pFile->setBackgroundColor(0, QColor(210, 250, 210));
    ptrRoot->addChild(pFile);

    while (bResult) {
        int nNextLine, nNextIndex;
        ptrEdit->getCursorPosition(&nNextLine, &nNextIndex);

        int nPos=ptrEdit->SendScintilla(SCI_GETCURRENTPOS);

        QTreeWidgetItem *pItem=new QTreeWidgetItem(pFile,
                                   QStringList(QString("Line %1: %2")
                                            .arg(nNextLine)
                                            .arg(ptrEdit->text(nNextLine).replace("\r","").replace("\n", ""))));
        pItem->setData(0, EROLE_SUB_WIN, reinterpret_cast<qlonglong>(ptrSubWin));
        pItem->setData(0, EROLE_FIND_POS, nPos);
        pFile->addChild(pItem);

        bResult=ptrEdit->findNext();
        ptrEdit->getCursorPosition(&nNextLine, &nNextIndex);
        if (nNextLine == nLine && nNextIndex == nIndex)
            break;
    }

    emit sigInsertRootInResultWin(ptrRoot);
    ptrEdit->SendScintilla(SCI_GOTOPOS, nCurPos);
}
コード例 #12
0
ファイル: main.c プロジェクト: yydaor/LCUI
/* 用于退出LCUI,释放LCUI占用的资源 */
LCUI_API void LCUI_Quit( void )
{
	_DEBUG_MSG("start quit\n");
	LCUI_Sys.state = KILLED;	/* 状态标志置为KILLED */
	LCUI_DestroyAllApps();
	LCUI_DestroyMainLoopQueue();

	LCUIModule_Thread_End();
	LCUIModule_IME_End();
	LCUIModule_Event_End();
	LCUIModule_Cursor_End();
	LCUIModule_Widget_End();
	LCUIModule_Font_End();
	LCUIModule_Timer_End();
	LCUIModule_Keyboard_End();
	//LCUIModule_Mouse_End();
	//LCUIModule_TouchScreen_End();
	LCUIModule_Device_End();
	_DEBUG_MSG("end video ....\n");
	LCUIModule_Video_End();
	_DEBUG_MSG("end video .... OK!\n");
}
コード例 #13
0
void QPadFindReplaceDialog::slotFindFindAllCurrent() {
    getFindTabValue();
    QNewMainWindow *ptrMainWin=qobject_cast<QNewMainWindow*>(parent());
    if (!ptrMainWin) return;
    QPadMdiSubWindow *ptrSubWin=reinterpret_cast<QPadMdiSubWindow*>(ptrMainWin->getMdiActiveWindow());
    if (!ptrSubWin) return;

    emit sigOnCreateFindReslutWidget();

    QTreeWidgetItem *ptrRoot=emit sigOnCreateRootItemInResultWin(ui->ID_COMBO_FIND->currentText());
    _DEBUG_MSG("ptrRoot: 0x%x", ptrRoot);

    findAllinSubWin(ptrRoot, ptrSubWin);
}
コード例 #14
0
ファイル: graph_display.c プロジェクト: WhatDream/LCUI
static void OnEvent( LCUI_Surface surface, LCUI_SystemEvent *e )
{
#ifdef LCUI_BUILD_IN_WIN32
	if( display.mode == LDM_SEAMLESS ) {
		return;
	}
	_DEBUG_MSG("surface: %p, event: %d, rel_x: %d, rel_y: %d\n", surface, e->type, e->rel_x, e->rel_y);
	if( e->type == LCUI_MOUSEMOVE ) {
		LCUIMouse_SetPos( e->rel_x, e->rel_y );
		return;
	}
	LCUI_PostEvent( e );
#endif
}
コード例 #15
0
ファイル: mouse.c プロジェクト: WhatDream/LCUI
static void OnMouseButtonEvent( LCUI_SystemEvent *e, void *arg )
{
	if( e->key_code < 1 || e->key_code > 2 ) {
		return;
	}
	_DEBUG_MSG("key_code: %d\n", e->key_code);
	switch( e->type ) {
	case LCUI_MOUSEDOWN:
		mouse.button_state[e->key_code] = LCUIKEYSTATE_PRESSED;
		break;
	case LCUI_MOUSEUP:
		mouse.button_state[e->key_code] = LCUIKEYSTATE_RELEASE;
	default:break;
	}
}
コード例 #16
0
void QPadFindReplaceDialog::slotFindFindAllinOpen() {
    getFindTabValue();
    QNewMainWindow *ptrMainWin=qobject_cast<QNewMainWindow*>(parent());
    if (!ptrMainWin) return;

    QMdiArea *ptrArea=ptrMainWin->getMdiArea();
    if (!ptrArea) return;

    emit sigOnCreateFindReslutWidget();

    QTreeWidgetItem *ptrRoot=emit sigOnCreateRootItemInResultWin(ui->ID_COMBO_FIND->currentText());
    _DEBUG_MSG("ptrRoot: 0x%x", ptrRoot);

    QList<QMdiSubWindow*> subList=ptrArea->subWindowList();
    for (QList<QMdiSubWindow*>::iterator pSubWin=subList.begin(); pSubWin != subList.end(); ++pSubWin) {
        findAllinSubWin(ptrRoot, *pSubWin);
    }

}
コード例 #17
0
ファイル: graph.c プロジェクト: WhatDream/LCUI
int Graph_Create( LCUI_Graph *graph, int w, int h )
{
	size_t size;
	if( w > 10000 || h > 10000 ) {
		_DEBUG_MSG("graph size is too large!");
		abort();
	}
	if( h <= 0 || w <= 0 ) {
		Graph_Free( graph );
		return -1;
	}
	graph->bytes_per_pixel = get_pixel_size( graph->color_type );
	graph->bytes_per_row = graph->bytes_per_pixel * w;
	size = graph->bytes_per_row * h;
	if( Graph_IsValid(graph) ) {
		/* 如果现有图形尺寸大于要创建的图形的尺寸,直接改尺寸即可 */
		if( graph->mem_size >= size ) {
			if( (w != graph->w || h != graph->h)
			 && graph->color_type == COLOR_TYPE_ARGB ) {
				Graph_FillAlpha( graph, 0 );
				Graph_FillColor(graph, RGB(255,255,255));
			}
			graph->w = w;
			graph->h = h;
			return 0;
		}
		Graph_Free( graph );
	}
	graph->mem_size = size;
	graph->bytes = (uchar_t*)malloc( size );
	if( !graph->bytes ) {
		graph->w = 0;
		graph->h = 0;
		return -2;
	}
	/* 默认全透明 */
	if( graph->color_type == COLOR_TYPE_ARGB ) {
		Graph_FillAlpha( graph, 0 );
	}
	graph->w = w;
	graph->h = h;
	return 0;
}
コード例 #18
0
ファイル: graph_display.c プロジェクト: WhatDream/LCUI
/* 设置呈现模式 */
int LCUIDisplay_SetMode( int mode )
{
	int ret;
	_DEBUG_MSG("mode: %d\n", mode);
	LCUIMutex_Lock( &display.mutex );
	switch( mode ) {
	case LDM_WINDOWED:
		ret = LCUIDisplay_Windowed();
		break;
	case LDM_SEAMLESS:
		ret = LCUIDisplay_Seamless();
		break;
	case LDM_FULLSCREEN:
	default:
		ret = LCUIDisplay_FullScreen();
		break;
	}
	LCUIMutex_Unlock( &display.mutex );
	return ret;
}
コード例 #19
0
ファイル: fontlibrary.c プロジェクト: scrich998/LCUI
void FontLIB_Init( void )
{
	if( fontlib.is_inited ) {
		return;
	}
	RBTree_Init( &fontlib.bitmap_cache );
	RBTree_Init( &fontlib.info_cache );
	RBTree_OnDestroy( &fontlib.bitmap_cache, FontLIB_DestroyTreeNode );
	RBTree_SetDataNeedFree( &fontlib.bitmap_cache, TRUE );
	RBTree_SetDataNeedFree( &fontlib.info_cache, TRUE );
#ifdef LCUI_FONT_ENGINE_FREETYPE
	/* 当初始化库时发生了一个错误 */
	if( FT_Init_FreeType(&fontlib.library) ) {
		_DEBUG_MSG("failed to initialize.\n");
		return;
	}
#else
	fontlib.library = NULL;
#endif
	fontlib.is_inited = TRUE;
}
コード例 #20
0
void QPadFindReplaceDialog::slotFindCount() {
    getFindTabValue();
    int nCount=0;

    QNewMainWindow *ptrMainWin=qobject_cast<QNewMainWindow*>(parent());
    if (!ptrMainWin) return;
    QPadMdiSubWindow *ptrSubWin=reinterpret_cast<QPadMdiSubWindow*>(ptrMainWin->getMdiActiveWindow());
    if (!ptrSubWin) return;
    QsciScintilla *ptrEdit=reinterpret_cast<QsciScintilla*>(ptrSubWin->widget());
    if (!ptrEdit) return;

    int nPos=ptrEdit->SendScintilla(SCI_GETCURRENTPOS);

    bool bResult=ptrEdit->findFirst(ui->ID_COMBO_FIND->currentText(), m_nSearchMode == QPadFindReplaceDialog::EMODE_REGEX,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_CASE) == QPadFindReplaceDialog::EFEATURE_CASE,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_WHOLE_WORD) == QPadFindReplaceDialog::EFEATURE_WHOLE_WORD,
                       (m_nSearchFeature & QPadFindReplaceDialog::EFEATURE_WARP) == QPadFindReplaceDialog::EFEATURE_WARP,
                       true, 0, 0, false, false);

    if (!bResult) {
        return;
    }

    int nLine=-1, nIndex=-1;
    ptrEdit->getCursorPosition(&nLine, &nIndex);

    while (bResult) {
        ++nCount;
        bResult=ptrEdit->findNext();
        int nNextLine, nNextIndex;
        ptrEdit->getCursorPosition(&nNextLine, &nNextIndex);
        if (nNextLine == nLine && nNextIndex == nIndex)
            break;
    }

    ptrEdit->SendScintilla(SCI_GOTOPOS, nPos);
    ptrEdit->setFocus();
    _DEBUG_MSG("total count: %d", nCount);
    QMessageBox::information(this, IDS_TITLE_FIND_COUNT, IDS_FIND_COUNT.arg(nCount), QMessageBox::Ok);
}
コード例 #21
0
ファイル: png.c プロジェクト: bitbegin/LCUI
int Graph_GetPNGSize( const char *filepath, int *width, int *height )
{
#ifdef USE_LIBPNG
	int ret;
	png_infop info_ptr;
	png_structp png_ptr;
	char buf[PNG_BYTES_TO_CHECK];
	FILE *fp = fopen( filepath, "rb" );
	if( !fp ) {
		return FILE_ERROR_OPEN_ERROR;
	}
	png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 );
	info_ptr = png_create_info_struct( png_ptr );
	setjmp( png_jmpbuf( png_ptr ) );
	ret = fread( buf, 1, PNG_BYTES_TO_CHECK, fp );
	if( ret < PNG_BYTES_TO_CHECK ) {
		fclose( fp );
		png_destroy_read_struct( &png_ptr, &info_ptr, 0 );
		return FILE_ERROR_UNKNOWN_FORMAT;
	}
	ret = png_sig_cmp( (png_bytep)buf, (png_size_t)0, PNG_BYTES_TO_CHECK );
	if( ret != 0 ) {
		fclose( fp );
		png_destroy_read_struct( &png_ptr, &info_ptr, 0 );
		return FILE_ERROR_UNKNOWN_FORMAT;
	}
	rewind( fp );
	png_init_io( png_ptr, fp );
	png_read_png( png_ptr, info_ptr, PNG_TRANSFORM_EXPAND, 0 );
	*width = png_get_image_width( png_ptr, info_ptr );
	*height = png_get_image_height( png_ptr, info_ptr );
	fclose( fp );
	png_destroy_read_struct( &png_ptr, &info_ptr, 0 );
#else
	_DEBUG_MSG( "warning: not PNG support!" );
#endif
	return ret;
}
コード例 #22
0
static void 
__LCUIThread_PrintInfo( Thread_TreeNode *ttn )
{
	static int level=0;
	int i, n;
	Thread_TreeNode *new_ttn;

	if(ttn == NULL) {
		ttn = &thread_tree;
	}
	_DEBUG_MSG("%*s node: %p, tid: %lu %s\n", level*2, "+", ttn, ttn->tid,
		(ttn == &thread_tree) ? "(root)":"");
	n = Queue_GetTotal( &ttn->child );
	for(i=0; i<n; ++i) {
		new_ttn = Queue_Get( &ttn->child, i );
		if( !new_ttn ) {
			continue;
		}
		++level;
		__LCUIThread_PrintInfo(new_ttn);
		--level;
	}
}
コード例 #23
0
QPadFindReplaceDialog::~QPadFindReplaceDialog()
{
    _DEBUG_MSG("+++");
    _DEL_MEM(ui);
}
コード例 #24
0
void QPadFindReplaceDialog::runFindinFile(QPadFindReplaceDialog *ptrDlg) {
    _DEBUG_MSG("tid: 0x%x", QThread::currentThreadId());
    if (!ptrDlg) return;

}
コード例 #25
0
ファイル: scrollload.c プロジェクト: gitter-badger/LC-Finder
static void OnScroll( LCUI_Widget w, LCUI_WidgetEvent e, void *arg )
{
	_DEBUG_MSG("on scroll\n");
}
コード例 #26
0
ファイル: main.c プロジェクト: WhatDream/LCUI
/** 运行目标主循环 */
int LCUI_MainLoop_Run( LCUI_MainLoop loop )
{
	if( loop->state == STATE_RUNNING ) {
		_DEBUG_MSG("error: main-loop already running.");
		return -1;
	}
	DEBUG_MSG("loop: %p, enter\n", loop);
	loop->state = STATE_RUNNING;
	/* 将主循环记录插入至列表表头 */
	LinkedList_Goto( &MainApp.loop_list, 0 );
	LinkedList_Insert( &MainApp.loop_list, loop );
	MainApp.loop = loop;
	LCUIMutex_Lock( &MainApp.loop_changed );
	/* 广播,让其它线程交出主循环运行权 */
	LCUICond_Broadcast( &MainApp.loop_cond );
	/* 获取运行权 */
	LCUIMutex_Lock( &MainApp.loop_mutex );
	LCUIMutex_Unlock( &MainApp.loop_changed );
	loop->tid = LCUIThread_SelfID();
	while( loop->state != STATE_EXITED ) {
		if( LinkedList_GetTotal(&MainApp.task_list) <= 0 ) {
			DEBUG_MSG("loop: %p, sleeping...\n", loop);
			LCUICond_TimedWait( &MainApp.loop_cond, 1000 );
			DEBUG_MSG("loop: %p, wakeup\n", loop);
			/** 如果当前运行的主循环不是自己 */
			if( MainApp.loop != loop ) {
				loop->state = STATE_PAUSED;
				DEBUG_MSG("loop: %p, release control.\n", loop);
				LCUIMutex_Unlock( &MainApp.loop_mutex );
				/* 等待其它线程获得主循环运行权 */
				LCUIMutex_Lock( &MainApp.loop_changed );
				LCUIMutex_Unlock( &MainApp.loop_changed );
				DEBUG_MSG("loop: %p, waiting...\n", loop);
				/* 等待其它线程释放主循环运行权 */
				LCUIMutex_Lock( &MainApp.loop_mutex );
			}
			continue;
		}
		DEBUG_MSG("loop: %p, run task.\n", loop);
		LCUI_RunTask();
	}
	loop->state = STATE_EXITED;
	LinkedList_Goto( &MainApp.loop_list, 0 );
	LinkedList_Delete( &MainApp.loop_list );
	/* 获取处于列表表头的主循环 */
	loop = (LCUI_MainLoop)LinkedList_Get( &MainApp.loop_list );
	if( loop ) {
		/* 改变当前运行的主循环 */
		MainApp.loop = loop;
		LCUICond_Broadcast( &MainApp.loop_cond );
	}
	/* 释放运行权 */
	LCUIMutex_Unlock( &MainApp.loop_mutex );
	/* 如果列表为空,一般意味着LCUI需要退出了 */
	if( LinkedList_GetTotal( &MainApp.loop_list ) <= 0 ) {
		/** 广播,通知相关线程开始进行清理操作 */
		LCUICond_Broadcast( &MainApp.loop_list_empty );
	}
	DEBUG_MSG("loop: %p, exit\n", loop);
	return 0;
}
コード例 #27
0
ファイル: jpeg.c プロジェクト: add0/LCUI
/* 载入jpeg图片文件 */
LCUI_API int Graph_LoadJPEG( const char *filepath, LCUI_Graph *out )
{
#ifdef USE_LIBJPEG
	FILE *fp;
	uchar_t *bytep;
	int row_stride,jaka;
	int x,y, n, k;
	short int JPsyg;
	
	struct jpeg_decompress_struct cinfo;
	struct my_error_mgr jerr;
	JSAMPARRAY buffer;

	fp = fopen(filepath,"r");
	if(fp == NULL) {
		return FILE_ERROR_OPEN_ERROR;
	}
	
	if( fread( &JPsyg, sizeof(short int), 1, fp ) ) {
		if ( JPsyg != -9985 ) {  /* 如果不是jpg图片 */
			return  FILE_ERROR_UNKNOWN_FORMAT; 
		}
	}
	rewind(fp);
	cinfo.err = jpeg_std_error(&jerr.pub);
	jerr.pub.error_exit = my_error_exit;
	if (setjmp(jerr.setjmp_buffer)) {
		jpeg_destroy_decompress(&cinfo);
		return 2;
	}
	
	jpeg_create_decompress(&cinfo);
	jpeg_stdio_src(&cinfo,fp);
	(void) jpeg_read_header(&cinfo,TRUE);
	(void) jpeg_start_decompress(&cinfo);    
	
	jaka = cinfo.num_components;
	
	//if (jaka==3) printf("color\n"); else printf("grayscale\n");
	out->color_type = COLOR_TYPE_RGB;
	n = Graph_Create(out, cinfo.output_width, cinfo.output_height);
	if( n != 0 ){
		_DEBUG_MSG("error");
		exit(-1);
	}
	
	row_stride = cinfo.output_width * cinfo.output_components;
	buffer = (*cinfo.mem->alloc_sarray)(
			(j_common_ptr) &cinfo,JPOOL_IMAGE,row_stride,1);
	bytep = out->bytes;
	for(y=0; cinfo.output_scanline <cinfo.output_height; ++y) {
		(void) jpeg_read_scanlines(&cinfo, buffer, 1);
		if ( jaka == 3 ) {
			for (x=0;x<out->w;x++) {
				k=x*3;
				*bytep++ = buffer[0][k+2];
				*bytep++ = buffer[0][k+1];
				*bytep++ = buffer[0][k];
			}
		} else {
			for (x=0;x<out->w;x++) {
				*bytep++ = buffer[0][x];
				*bytep++ = buffer[0][x];
				*bytep++ = buffer[0][x];
			}
		} 
	}
	(void) jpeg_finish_decompress(&cinfo);
	jpeg_destroy_decompress(&cinfo);
	fclose(fp);
#else
	printf("warning: not JPEG support!"); 
#endif
	return 0;
}
コード例 #28
0
ファイル: textlayer.c プロジェクト: oyjGit/LCUI
/** 对指定行的文本进行排版 */
static void TextLayer_TextRowTypeset( LCUI_TextLayer* layer, int row )
{
	int col, row_width;
	TextRowData *p_row, *p_next_row;
	TextCharData *p_char;

	p_row = layer->row_list.rowdata[row];
	row_width = 0;
	for( col=0; col<p_row->string_len; ++col ) {
		p_char = p_row->string[col];
		if( !p_char->bitmap ) {
			continue;
		}
		/* 累加行宽度 */
		row_width += p_char->bitmap->advance.x;
		/* 如果是当前行的第一个字符,或者行宽度没有超过宽度限制 */
		if( layer->max_width <= 0 || !layer->is_autowrap_mode 
		 || (layer->is_autowrap_mode && !layer->is_mulitiline_mode)
		 || col < 1 || p_row->max_width <= layer->max_width ) {
			continue;
		}
		TextLayer_BreakTextRow( layer, row, col, EOL_NONE );
		return;
	}
	TextRow_UpdateSize( p_row, layer->text_style.pixel_size );
	/* 如果本行有换行符,或者是最后一行 */
	if( p_row->eol != EOL_NONE || row == layer->row_list.rows-1 ) {
		return;
	}
	
	row_width = p_row->max_width;
	/* 本行的文本宽度未达到限制宽度,需要将下行的文本转移至本行 */
	while( p_row->eol != EOL_NONE ) {
		/* 获取下一行的指针 */
		p_next_row = TextRowList_GetRow( &layer->row_list, row+1 );
		if( !p_next_row ) {
			return;
		}
		for( col=0; col<p_next_row->string_len; ++col ) {
			p_char = p_next_row->string[col];
			/* 忽略无字体位图的文字 */
			if( !p_char->bitmap ) {
				TextRow_Insert( p_row, p_row->string_len, p_char );
				p_next_row->string[col] = NULL;
				continue;
			}
			row_width += p_char->bitmap->advance.x;
			/* 如果没有超过宽度限制 */
			if( !layer->is_autowrap_mode || layer->max_width <= 0
			 || (layer->is_autowrap_mode && !layer->is_mulitiline_mode)
			 || p_row->max_width <= layer->max_width ) {
				TextRow_Insert( p_row, p_row->string_len, p_char );
				p_next_row->string[col] = NULL;
				continue;
			}
			/* 如果插入点在下一行 */
			if( layer->insert_y == row+1 ) {
				/* 如果插入点处于被转移的几个文字中 */
				if( layer->insert_x < col ) {
					layer->insert_y = row;
					layer->insert_x += p_row->string_len;
				} else {
					/* 否则,减去被转移的文字数 */
					layer->insert_x -= col;
				}
			}
			/* 将这一行剩余的文字向前移 */
			TextRow_LeftMove( p_next_row, col );
			TextRow_UpdateSize( p_row, layer->text_style.pixel_size );
			return;
		}
		TextRow_UpdateSize( p_row, layer->text_style.pixel_size );
		TextLayer_InvalidateRowRect( layer, row );
		TextLayer_InvalidateRowRect( layer, row+1 );
		_DEBUG_MSG("remove row %d\n", row+1);
		/* 删除这一行,因为这一行的内容已经转移至当前行 */
		TextRowList_RemoveRow( &layer->row_list, row+1 );
		/* 如果插入点当前行在后面 */
		if( layer->insert_y > row ) {
			--layer->insert_y;
		}
	}
}
コード例 #29
0
ファイル: png.c プロジェクト: bitbegin/LCUI
int Graph_LoadPNG( const char *filepath, LCUI_Graph *graph )
{
#ifdef USE_LIBPNG
	FILE *fp;
	uchar_t *pixel_ptr;
	png_structp png_ptr;
	png_infop info_ptr;
	png_bytep* row_pointers;
	char buf[PNG_BYTES_TO_CHECK];
	int w, h, x, y, ret = 0, temp, color_type;

	fp = fopen( filepath, "rb" );
	if( fp == NULL ) {
		return FILE_ERROR_OPEN_ERROR;
	}

	png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, 0, 0, 0 );
	info_ptr = png_create_info_struct( png_ptr );

	setjmp( png_jmpbuf( png_ptr ) );
	/* 读取PNG_BYTES_TO_CHECK个字节的数据 */
	temp = fread( buf, 1, PNG_BYTES_TO_CHECK, fp );
	/* 若读到的数据并没有PNG_BYTES_TO_CHECK个字节 */
	if( temp < PNG_BYTES_TO_CHECK ) {
		fclose( fp );
		png_destroy_read_struct( &png_ptr, &info_ptr, 0 );
		return FILE_ERROR_UNKNOWN_FORMAT;
	}
	/* 检测数据是否为PNG的签名 */
	temp = png_sig_cmp( (png_bytep)buf, (png_size_t)0, PNG_BYTES_TO_CHECK );
	/* 如果不是PNG的签名,则说明该文件不是PNG文件 */
	if( temp != 0 ) {
		fclose( fp );
		png_destroy_read_struct( &png_ptr, &info_ptr, 0 );
		return FILE_ERROR_UNKNOWN_FORMAT;
	}
	/* 复位文件指针 */
	rewind( fp );
	/* 开始读文件 */
	png_init_io( png_ptr, fp );
	/* 读取PNG图片信息 */
	png_read_png( png_ptr, info_ptr, PNG_TRANSFORM_EXPAND, 0 );
	/* 获取图像的色彩类型 */
	color_type = png_get_color_type( png_ptr, info_ptr );
	/* 获取图像的宽高 */
	w = png_get_image_width( png_ptr, info_ptr );
	h = png_get_image_height( png_ptr, info_ptr );
	/* 获取所有行像素数据,row_pointers里边就是rgba数据 */
	row_pointers = png_get_rows( png_ptr, info_ptr );
	/* 根据不同的色彩类型进行相应处理 */
	switch( color_type ) {
	case PNG_COLOR_TYPE_RGB_ALPHA:
		graph->color_type = COLOR_TYPE_ARGB;
		temp = Graph_Create( graph, w, h );
		if( temp != 0 ) {
			ret = FILE_ERROR_MALLOC_ERROR;
			break;
		}
		pixel_ptr = graph->bytes;
		for( y = 0; y < h; ++y ) {
			/*
			 * Graph的像素数据存储格式是BGRA,而PNG库
			 * 提供像素数据的是RGBA格式的,因此需要调整写入顺序
			 */
			for( x = 0; x < w * 4; x += 4 ) {
				*pixel_ptr++ = row_pointers[y][x + 2];
				*pixel_ptr++ = row_pointers[y][x + 1];
				*pixel_ptr++ = row_pointers[y][x];
				*pixel_ptr++ = row_pointers[y][x + 3];
			}
		}
		break;

	case PNG_COLOR_TYPE_RGB:
		graph->color_type = COLOR_TYPE_RGB;
		temp = Graph_Create( graph, w, h );
		if( temp != 0 ) {
			ret = FILE_ERROR_MALLOC_ERROR;
			break;
		}
		pixel_ptr = graph->bytes;
		for( y = 0; y < h; ++y ) {
			for( x = 0; x < w * 3; x += 3 ) {
				*pixel_ptr++ = row_pointers[y][x + 2];
				*pixel_ptr++ = row_pointers[y][x + 1];
				*pixel_ptr++ = row_pointers[y][x];
			}
		}
		break;
		/* 其它色彩类型的图像就读了 */
	default: ret = FILE_ERROR_UNKNOWN_FORMAT; break;
	}
	fclose( fp );
	png_destroy_read_struct( &png_ptr, &info_ptr, 0 );
#else
	_DEBUG_MSG( "warning: not PNG support!" );
#endif
	return ret;
}
コード例 #30
0
ファイル: png.c プロジェクト: bitbegin/LCUI
int Graph_WritePNG( const char *file_name, const LCUI_Graph *graph )
{
#ifdef USE_LIBPNG
	FILE *fp;
	LCUI_Rect rect;
	png_byte color_type;
	png_structp png_ptr;
	png_infop info_ptr;
	png_bytep *row_pointers;
	int x, y, row_size;

	if( !Graph_IsValid( graph ) ) {
		_DEBUG_MSG( "graph is not valid\n" );
		return -1;
	}
	/* create file */
	fp = fopen( file_name, "wb" );
	if( !fp ) {
		_DEBUG_MSG( "file %s could not be opened for writing\n", file_name );
		return -1;
	}
	/* initialize stuff */
	png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL );
	if( !png_ptr ) {
		fclose( fp );
		_DEBUG_MSG( "png_create_write_struct failed\n" );
		return -1;
	}
	info_ptr = png_create_info_struct( png_ptr );
	if( !info_ptr ) {
		fclose( fp );
		_DEBUG_MSG( "png_create_info_struct failed\n" );
		png_destroy_write_struct( &png_ptr, &info_ptr );
		return -1;
	}
	if( setjmp( png_jmpbuf( png_ptr ) ) ) {
		fclose( fp );
		_DEBUG_MSG( "error during init_io\n" );
		png_destroy_write_struct( &png_ptr, &info_ptr );
		return -1;
	}
	png_init_io( png_ptr, fp );
	if( Graph_HasAlpha( graph ) ) {
		color_type = PNG_COLOR_TYPE_RGB_ALPHA;
	} else {
		color_type = PNG_COLOR_TYPE_RGB;
	}
	/* write header */
	png_set_IHDR( png_ptr, info_ptr, graph->w, graph->h,
		      8, color_type, PNG_INTERLACE_NONE,
		      PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE );

	png_write_info( png_ptr, info_ptr );
	/* write bytes */

	Graph_GetValidRect( graph, &rect );
	graph = Graph_GetQuote( graph );
	if( graph->color_type == COLOR_TYPE_ARGB ) {
		LCUI_ARGB *px_ptr, *px_row_ptr;

		row_size = png_get_rowbytes( png_ptr, info_ptr );
		px_row_ptr = graph->argb + rect.top * graph->width + rect.left;
		row_pointers = (png_bytep*)malloc( rect.height*sizeof( png_bytep ) );
		for( y = 0; y < rect.height; ++y ) {
			row_pointers[y] = png_malloc( png_ptr, row_size );
			px_ptr = px_row_ptr;
			for( x = 0; x < row_size; ++px_ptr ) {
				row_pointers[y][x++] = px_ptr->red;
				row_pointers[y][x++] = px_ptr->green;
				row_pointers[y][x++] = px_ptr->blue;
				row_pointers[y][x++] = px_ptr->alpha;
			}
			px_row_ptr += graph->w;
		}
	} else {
		uchar_t *px_ptr, *px_row_ptr;

		row_size = png_get_rowbytes( png_ptr, info_ptr );
		px_row_ptr = graph->bytes + rect.top * graph->bytes_per_row;
		px_row_ptr += rect.left * graph->bytes_per_pixel;
		row_pointers = (png_bytep*)malloc( rect.height*sizeof( png_bytep ) );
		for( y = 0; y < rect.height; ++y ) {
			row_pointers[y] = (png_bytep)malloc( row_size );
			px_ptr = px_row_ptr;
			for( x = 0; x < row_size; x += 3 ) {
				row_pointers[y][x + 2] = *px_ptr++; // blue
				row_pointers[y][x + 1] = *px_ptr++; // green
				row_pointers[y][x] = *px_ptr++;   // red
			}
			px_row_ptr += graph->bytes_per_row;
		}
	}
	png_write_image( png_ptr, row_pointers );
	/* cleanup heap allocation */
	for( y = 0; y < rect.height; ++y ) {
		free( row_pointers[y] );
	}
	free( row_pointers );
	/* end write */
	png_write_end( png_ptr, NULL );
	png_destroy_write_struct( &png_ptr, &info_ptr );
	fclose( fp );
	return 0;
#else
	printf( "warning: not PNG support!" );
	return 0;
#endif
}