Esempio n. 1
0
////////////////////
// Adjusts the size of the column header according to the current style
void CListviewColumn::ReadjustSize()
{
	CColumnStyle *style = getCurrentStyle();
	cParent->setColumnHeight(MAX(cParent->getColumnHeight(), GetTextHeight(getCurrentStyle()->cFont, sText) + style->cBorder.getTopW() +
		style->cBorder.getBottomW()));
	cParent->ReadjustScrollbar();
}
Esempio n. 2
0
////////////////////////
// Draw the column header
void CListviewColumn::Draw(SDL_Surface *bmpDest, int x, int y, int w, int h)
{
	CColumnStyle *style = getCurrentStyle();

	// Background
	style->cBackground.Draw(bmpDest, x, y, w, h);

	// Text
	SDL_Rect r = {x + style->cBorder.getLeftW(), y + style->cBorder.getTopW(),
		w - ((style->bmpSortArrow.get().get() && iSortDirection != sort_None) ? style->bmpSortArrow->w : 0) - 
		style->cBorder.getLeftW() - style->cBorder.getRightW(), 
		h -	style->cBorder.getTopW() - style->cBorder.getBottomW()};

	style->cText.tFontRect = &r;
	DrawGameText(bmpDest, sText, style->cFont, style->cText);

	// Sort arrow
	SDL_Rect r1(MakeRect(x + w - 3 - style->bmpSortArrow->w, y, w, h));
	SDL_Rect r2(MakeRect(0, 0, style->bmpSortArrow->w, style->bmpSortArrow->h));
	if (style->bmpSortArrow.get().get() && iSortDirection != sort_None)
		DrawImageAdv(bmpDest, style->bmpSortArrow.get(), r1, r2);

	// Border
	style->cBorder.Draw(bmpDest, x, y, w, h);
}
void AP_Win32Dialog_Styles::runModal(XAP_Frame * pFrame)
{
	UT_return_if_fail (pFrame);
//
// Get View and Document pointers. Place them in member variables
//
	setFrame(pFrame);

	setView((FV_View *) pFrame->getCurrentView());
	UT_return_if_fail (getView());

	setDoc(getView()->getLayout()->getDocument());
	UT_return_if_fail (getDoc());


	// raise the dialog
	_win32Dialog.runModal(pFrame, AP_DIALOG_ID_STYLES, AP_RID_DIALOG_STYLES_TOP, this);
	
	
	if (m_answer == AP_Dialog_Styles::a_OK)
	{
		const char* szStyle = getCurrentStyle();
		if (szStyle)
		{
			getDoc()->updateDocForStyleChange(szStyle, true);
			getView()->getCurrentBlock()->setNeedsRedraw();
			getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT);
		}
	}

}
Esempio n. 4
0
/////////////////////
// Draw the widget subitem
void CWidgetSubitem::Draw(SDL_Surface *bmpDest, const SDL_Rect &r)
{
	CItemStyle *style = getCurrentStyle();

	// Background
	if (bUseCustomStyle)
		style->cBackground.Draw(bmpDest, r.x, r.y, r.w, r.h);
	
	// Widget
	if (cWidget)  {
		ScopedSurfaceClip(bmpDest, r);

		// Draw according to the valign
		switch (iVAlign)  {
			case algTop:
				cWidget->Draw(bmpDest, r.x + style->cBorder.getLeftW(), r.y + style->cBorder.getTopW());
			break;

			case algMiddle:
				cWidget->Draw(bmpDest, r.x + style->cBorder.getLeftW(), r.y + style->cBorder.getTopW() + (r.h - cWidget->getHeight())/2);
			break;

			case algBottom:
				cWidget->Draw(bmpDest, r.x + style->cBorder.getLeftW(), r.y + r.h - cWidget->getHeight() - style->cBorder.getBottomW());
			break;
		}
	}

	// Border
	if (bUseCustomStyle)
		style->cBorder.Draw(bmpDest, r.x, r.y, r.w, r.h);
}
Esempio n. 5
0
////////////////////
// Draw the item
void CListviewItem::Draw(SDL_Surface *bmpDest, const SDL_Rect &r)
{
	// Save the clipping rect
	ScopedSurfaceClip clip(bmpDest, r);

	CItemStyle *style = getCurrentStyle();

	// Background
	style->cBackground.Draw(bmpDest, r.x, r.y, r.w, r.h);

	// Draw the subitems
	std::list<CListviewSubitem *>::iterator subit = tSubitems.begin();
	std::vector<CListviewColumn *>::const_iterator colit = cParent->getColumns().begin();
	int cur_x = r.x + style->cBorder.getLeftW();

	for ( ; subit != tSubitems.end() && colit != cParent->getColumns().end(); colit++, subit++)  {
		(*subit)->Draw(bmpDest, MakeRect(cur_x, r.y + style->cBorder.getTopW(), (*colit)->getWidth(), 
				r.h - style->cBorder.getTopW() - style->cBorder.getBottomW()));

		cur_x += (*colit)->getWidth();
	}

	// If no subitems, draw the text
	if (tSubitems.size() == 0)  {
		DrawItemText(bmpDest, r);
	}

	// Border
	style->cBorder.Draw(bmpDest, r.x, r.y, r.w, r.h);
}
Esempio n. 6
0
/////////////////////
// Get the width
int CWidgetSubitem::getWidth()
{
	CItemStyle *style = getCurrentStyle();
	if (cWidget)
		return cWidget->getWidth() + style->cBorder.getLeftW() + style->cBorder.getRightW();
	else
		return 0;
}
Esempio n. 7
0
////////////////////
// Get the height
int CWidgetSubitem::getHeight()
{
	CItemStyle *style = getCurrentStyle();
	if (cWidget)
		return cWidget->getHeight() + style->cBorder.getTopW() + style->cBorder.getBottomW();
	else
		return 0;
}
Esempio n. 8
0
bool ofxWidget::cursorIn(TUIO::TuioCursor & tuioCursor){
	ofRectangle area = getActiveArea(getCurrentStyle());
	bool cursorIn= tuioCursor.getX()>= area.x &&
	tuioCursor.getX() <= area.x + area.width &&
	tuioCursor.getY() >= area.y &&
	tuioCursor.getY() <= area.y + area.height ;

	ofLog(OF_LOG_VERBOSE,"cursorIn: %i",cursorIn?1:0);
	return (cursorIn);
}
void AP_UnixDialog_Styles::event_Apply(void)
{
	// TODO save out state of radio items
	m_answer = AP_Dialog_Styles::a_OK;
	const gchar * szStyle = getCurrentStyle();
	if(szStyle && *szStyle)
	{
		getView()->setStyle(szStyle);
	}
}
Esempio n. 10
0
bool ofxWidget::mouseIn(){
	ofRectangle area = getActiveArea(getCurrentStyle());
	bool mouseIn= mouse.x >= area.x &&
	mouse.x <= area.x + area.width &&
	mouse.y >= area.y &&
	mouse.y <= area.y + area.height ;

	//ofLog(OF_LOG_VERBOSE,(title + " mousein: %i").c_str(),mouseIn?1:0);
	return (mouseIn);
}
Esempio n. 11
0
/////////////////
// Draw the text subitem
void CTextSubitem::Draw(SDL_Surface *bmpDest, const SDL_Rect &r)
{
	CItemStyle *style = getCurrentStyle();

	// Background
	if (bUseCustomStyle)
		style->cBackground.Draw(bmpDest, r.x, r.y, r.w, r.h);
	
	// Image
	DrawItemText(bmpDest, r);

	// Border
	if (bUseCustomStyle)
		style->cBorder.Draw(bmpDest, r.x, r.y, r.w, r.h);
}
Esempio n. 12
0
///////////////////
// Get the widget rectangle
SDL_Rect CWidgetSubitem::getWidgetRect(int item_h)
{
	CItemStyle *style = getCurrentStyle();
	SDL_Rect r = {style->cBorder.getLeftW(), 0, cWidget->getWidth(), cWidget->getHeight()};
	switch (iVAlign)  {
	case algTop:
		r.y = style->cBorder.getTopW();
		break;
	case algMiddle:
		r.y = style->cBorder.getTopW() + (item_h - cWidget->getHeight())/2;
		break;
	case algBottom:
		r.y = item_h - cWidget->getHeight() - style->cBorder.getBottomW();
		break;
	}

	return r;
}
Esempio n. 13
0
/////////////////////
// Get the column width automatically
int CListviewColumn::getAutoWidth()
{
	if (!cParent)
		return 0;

	CColumnStyle *style = getCurrentStyle();

	// Preferred width of the column
	int preferred_w = GetTextWidth(style->cFont, sText) + 20; // 20 - spacing

	// Width of all columns in the listview
	int all_column_w = 0;
	for (std::vector<CListviewColumn *>::iterator it = cParent->getColumns().begin();
		it != cParent->getColumns().end(); it++)  {
			all_column_w += (*it)->getWidth();
	}

	// Available width for the columns
	int avail_width = cParent->getWidth() - cParent->cBorder.getLeftW() - cParent->cBorder.getRightW();


	// Check if there's some space left
	if (all_column_w < avail_width)  {
		if (preferred_w <= avail_width - all_column_w)
			return preferred_w;
		else
			return avail_width - all_column_w;
	} else {
		// Just resize one of the last columns to make space
		int retval = MIN_COL_WIDTH;
		std::vector<CListviewColumn *>::reverse_iterator i = cParent->getColumns().rbegin();
		while (i != cParent->getColumns().rend())
			if ((*i)->getWidth() > MIN_COL_WIDTH)  {
				int new_w = MAX((*i)->getWidth() / 2, MIN_COL_WIDTH);
				retval = (*i)->getWidth() - new_w;
				(*i)->setWidth(new_w);
				break;
			}

		return retval;
	}
}
void TextInputWidget::drawAt( Drawer & drawer, MenuWidget * parent, int x, int y, Align align )
{
	if ( !show )
	{
		return;
	}

	if ( active && !SDL_IsTextInputActive() )
	{
		SDL_StartTextInput();
	}

	// Choose correct style
	Style * currentStyle = getCurrentStyle();

	if ( this->textCache == nullptr )
	{
		this->prepare( drawer, *currentStyle );
		lastStyle = style;
	}
	else
	{
		if ( currentStyle != lastStyle || textChanged )
		{
			prepare( drawer, *currentStyle );
			lastStyle = currentStyle;
		}
	}

	// draw
	if ( currentStyle == nullptr )
	{
		SDL_Point alignedPos = this->getAlignedPos( x, y, align );
		lastPos = alignedPos;
		this->textCache->drawAt( alignedPos );
	}
	else
	{
		SDL_Point alignedPos = this->getAlignedPos( x, y, align );
		SDL_Rect size = { alignedPos.x, alignedPos.y, this->getWidth(), this->getHeight() };
		lastPos = alignedPos;

		drawer.setClipRect( size );

		// draw background
		currentStyle->drawBackground( drawer, size );

		// draw text
		DirSize padding = style->getPadding();
		SDL_Point innerPos = { alignedPos.x + padding.left, alignedPos.y + padding.top };
		int innerWidth = style->getWidth() - padding.left - padding.right;
		drawer.setClipRect( { innerPos.x, innerPos.y, innerWidth, style->getHeight() } );
		innerPos.y += ( style->getHeight() - padding.top - padding.bottom - textCache->getHeight() ) / 2;

		int width = drawer.getTextSize( this->text.substr( 0, this->cursorPosition ),
										style->getFontSize(), style->getFontStyle() ).w + 1;

		int offset = 0;

		if ( width > innerWidth )
		{
			offset = width - innerWidth;
		}

		if ( text != "" )
			this->textCache->drawAt( innerPos.x - offset, innerPos.y );

		if ( active )
		{
			drawer.setDrawingColor( style->getFontColor() );
			drawer.drawLine( { width + innerPos.x - offset - 1, innerPos.y - 2 },
			{ width + innerPos.x - offset - 1, innerPos.y + textCache->getHeight() + 2 } );
		}

		drawer.setClipRect( size );

		// draw border
		SDL_Rect border = size;

		drawer.setDrawingColor( currentStyle->getBorderColor() );
		for ( int i = 0; i < currentStyle->getBorderThickness(); i++ )
		{
			drawer.drawRect( border );
			border.x++;
			border.y++;
			border.w -= 2;
			border.h -= 2;
		}

		drawer.cancelClipRect();
	}
}
Esempio n. 15
0
ofPoint ofxWidget::getRelativePosition(float x, float y){
	return ofPoint((x-getActiveArea(getCurrentStyle()).x)/getActiveArea(getCurrentStyle()).width
						,(y-getActiveArea(getCurrentStyle()).y)/getActiveArea(getCurrentStyle()).height);
}
Esempio n. 16
0
void ofxWidget::draw(ofEventArgs & args){
	//ofLog(OF_VERBOSE, "style for state: " + getCurrentStyle().styleState);
	ofPushStyle();
		render(getCurrentStyle());
	ofPopStyle();
}
BOOL AP_Win32Dialog_Styles::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
	WORD wNotifyCode = HIWORD(wParam);
	WORD wId = LOWORD(wParam);
	HWND hWndCtrl = (HWND)lParam;

	switch (wId)
	{
	case AP_RID_DIALOG_STYLES_TOP_BUTTON_APPLY:
		{
			const gchar * szStyle = getCurrentStyle();
			if(szStyle && *szStyle)
			{
				getView()->setStyle(szStyle);
			}		
		}
		m_answer = a_OK;
		return 1;

	case AP_RID_DIALOG_STYLES_TOP_BUTTON_CLOSE:
	case IDCANCEL:
		m_answer = a_CANCEL;
		EndDialog(hWnd,0);
		return 1;

	case IDOK:
		{	
     		const XAP_StringSet * pSS = m_pApp->getStringSet ();
			WCHAR stylename[MAX_EBX_LENGTH+1];
			// Verfiy a name value for the style
			// TODO - Verify unique name value
			GetDlgItemTextW(hWnd,AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME,stylename,MAX_EBX_LENGTH);
			/*_win32DialogNewModify.getControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_EBX_NAME,
                                                  m_newStyleName,
	                                              MAX_EBX_LENGTH );*/
			UT_UTF8String str;
			str.appendUCS2((const UT_UCS2Char*)stylename,0);
			strcpy(m_newStyleName,str.utf8_str());

			if( !m_newStyleName || !strlen(m_newStyleName) )
			{
			    getFrame()->showMessageBox( pSS->getValue (AP_STRING_ID_DLG_Styles_ErrBlankName),
											XAP_Dialog_MessageBox::b_O,
											XAP_Dialog_MessageBox::a_OK);

			    return 1;
    		}

			//strcpy (m_newStyleName, (AP_Win32App::s_fromWinLocaleToUTF8(m_newStyleName)).utf8_str());

		}
		m_answer = a_OK;
		EndDialog(hWnd,0);
		return 1;


	case AP_RID_DIALOG_STYLES_TOP_COMBO_LIST:
		if( wNotifyCode == CBN_SELCHANGE )
		{
			switch(_win32Dialog.getComboSelectedIndex(AP_RID_DIALOG_STYLES_TOP_COMBO_LIST))
			{
			case 0:
				m_whichType = USED_STYLES;
				break;
				
			case 1:
				m_whichType = ALL_STYLES;
				break;
				
			case 2:
				m_whichType = USER_STYLES;
				break;
			}

			_populateWindowData();
		}
		return 1;

	case AP_RID_DIALOG_STYLES_TOP_LIST_STYLES:
		if (wNotifyCode == LBN_SELCHANGE)
		{
			
			UT_uint32	nData = -1;
			const char* name;
			const PD_Style * pcStyle = NULL;
			
			int row = _win32Dialog.getListSelectedIndex(AP_RID_DIALOG_STYLES_TOP_LIST_STYLES);					
			
			nData = _win32Dialog.getListDataItem( AP_RID_DIALOG_STYLES_TOP_LIST_STYLES, row);
			
			if (row!=LB_ERR)
			{
				getDoc()->enumStyles(nData, &name, &pcStyle);				
				m_selectedStyle = name; 
				
				m_nSelectedStyleIdx = nData;
							
				// refresh the previews
				_populatePreviews(false);	
			}
			
			break;			
		}
		return 1;

	case AP_RID_DIALOG_STYLES_TOP_BUTTON_DELETE:
		{
			if( m_selectedStyle != "" )
			{
				if ( !getDoc()->removeStyle(m_selectedStyle.c_str()) ) // actually remove the style
				{
					const XAP_StringSet * pSS = m_pApp->getStringSet();
					getFrame()->showMessageBox( pSS->getValue (AP_STRING_ID_DLG_Styles_ErrStyleCantDelete),
												XAP_Dialog_MessageBox::b_O,
												XAP_Dialog_MessageBox::a_OK	);
					return 1;
				}
				getFrame()->repopulateCombos();
				_populateWindowData(); // force a refresh
				getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT);
				m_selectedStyle = "";
			}
    	}
		return 1;

	case AP_RID_DIALOG_STYLES_TOP_BUTTON_NEW:
		{
			m_bisNewStyle = true;
			//_win32Dialog.showWindow(SW_HIDE);
			XAP_Frame* pFrame = getFrame();
			//_win32DialogNewModify.runModal(pFrame, AP_DIALOG_ID_STYLES, AP_RID_DIALOG_STYLES_NEWMODIFY, this);
			createModal(pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY));
			if(m_answer == AP_Dialog_Styles::a_OK)
			{
				createNewStyle((gchar *) m_newStyleName);
				_populateCList();
			}
			destroyAbiPreview();
			DELETEP(m_pAbiPreviewWidget);
			//_win32Dialog.showWindow(SW_SHOW);
		}
		return 1;

	case AP_RID_DIALOG_STYLES_TOP_BUTTON_MODIFY:
		{
			// Verify that a style is selected
			if( m_selectedStyle == "" )
			{
				XAP_Frame * pFrame = getFrame();
				const XAP_StringSet * pSS = m_pApp->getStringSet();
				pFrame->showMessageBox( pSS->getValue(AP_STRING_ID_DLG_Styles_ErrNoStyle),
										XAP_Dialog_MessageBox::b_O,
										XAP_Dialog_MessageBox::a_OK);                                        
				m_answer = AP_Dialog_Styles::a_CANCEL;
				return 1;
			}
			else
			{
				PD_Style * pStyle = NULL;
				getDoc()->getStyle(m_selectedStyle.c_str(), &pStyle);

				m_bisNewStyle = false;
				XAP_Frame* pFrame = getFrame();			
				
				XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(getApp());
			
				createModal (pFrame, MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY));				
				/*LPCWSTR lpTemplate = MAKEINTRESOURCEW(AP_RID_DIALOG_STYLES_NEWMODIFY);				
											
				int result = DialogBoxParamW(pWin32App->getInstance(), lpTemplate,
									static_cast<XAP_Win32FrameImpl*>(pFrame->getFrameImpl())->getTopLevelWindow(),
									(DLGPROC)s_dlgProc, (LPARAM)this);*/
				
				if(m_answer == AP_Dialog_Styles::a_OK)
				{
					applyModifiedStyleToDoc();
					getDoc()->updateDocForStyleChange(getCurrentStyle(),true);
					getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT);
				}

				destroyAbiPreview();
				DELETEP(m_pAbiPreviewWidget);
			}
		}
		return 1;

	case AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_REMOVE:
		{
			char szTemp[128];
			_win32DialogNewModify.getControlText( AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_REMOVE,
                                                  szTemp,
	                                              sizeof(szTemp) );			
			removeVecProp(szTemp);
			rebuildDeleteProps();
			updateCurrentStyle();
		}
		return 1;

	case AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_TOGGLEITEMS:
	{
	    RECT 	rect;
	    HMENU 	hMenu;
	    int		x,y;	    	    
	    HWND	hWndButton;
		static int menu_items[]={AP_STRING_ID_DLG_Styles_ModifyParagraph,
								AP_STRING_ID_DLG_Styles_ModifyFont,
								AP_STRING_ID_DLG_Styles_ModifyTabs,
								AP_STRING_ID_DLG_Styles_ModifyNumbering,
								AP_STRING_ID_DLG_Styles_ModifyLanguage
								};
	    
		UT_Win32LocaleString str;

	    hWndButton = GetDlgItem(hWnd, AP_RID_DIALOG_STYLES_NEWMODIFY_BTN_TOGGLEITEMS);
	    XAP_Win32App * app = static_cast<XAP_Win32App *> (m_pApp);		
		const XAP_StringSet * pSS = m_pApp->getStringSet();
	    
		// Get button position
	    GetWindowRect(hWndButton, &rect);
	    x = rect.left;
	    y = rect.bottom;	               		

	    // Menu creation
	    hMenu =  CreatePopupMenu();
		str;
		for (int i=0; i<5; i++) {
			str.fromUTF8(pSS->getValue(menu_items[i]));
			AppendMenuW(hMenu, MF_ENABLED|MF_STRING, i+1, (LPCWSTR)str.c_str());
		}
	
	    // show and track the menu
    	m_selectToggle = TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,
    						x,y,0, hWndButton,  NULL);		    							    	        						 							    
	    
	    switch(m_selectToggle)
		{
		case 0:	// user has cancelled
			break;
		case 1:
			ModifyParagraph();
			break;
		case 2:
			ModifyFont();
			break;
		case 3:
			ModifyTabs();
			break;
		case 4:
			ModifyLists();
			break;
		case 5:
			ModifyLang();
			break;
		default:
			break;			
		}
		
		rebuildDeleteProps();
		updateCurrentStyle();
	    DestroyMenu(hMenu);
		return 1;
	}


	case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_BASEDON:
		if( wNotifyCode == CBN_SELCHANGE )
		{
			eventBasedOn();
			rebuildDeleteProps();
		}	
		return 1;

	case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_FOLLOWPARA:
		if( wNotifyCode == CBN_SELCHANGE )
		{
			eventFollowedBy();
		}	
		return 1;

	case AP_RID_DIALOG_STYLES_NEWMODIFY_CBX_TYPE:
		if( wNotifyCode == CBN_SELCHANGE )
		{
			eventStyleType();
		}
		return 1;

	default:							// we did not handle this notification
		UT_DEBUGMSG(("WM_Command for id %ld\n",wId));
		return 0;						// return zero to let windows take care of it.
	}
	
	return 0;						// return zero to let windows take care of it.
}
Esempio n. 18
0
void ButtonWidget::drawAt ( Drawer &drawer, MenuWidget* parent, int x, int y, Align align )
{
	if ( !show )
	{
		return;
	}

	// Choose correct style
	Style * currentStyle = getCurrentStyle ();

	if ( this->textCache == nullptr )
	{
		this->prepare ( drawer );
		lastStyle = style;
	}
	else
	{
		if ( currentStyle != lastStyle )
		{
			prepare ( drawer, *currentStyle );
			lastStyle = currentStyle;
		}
	}

	// draw
	if ( currentStyle == nullptr )
	{
		SDL_Point alignedPos = this->getAlignedPos( x, y, align );
		lastPos = alignedPos;
		this->textCache->drawAt( alignedPos );
	}
	else
	{
		SDL_Point alignedPos = this->getAlignedPos( x, y, align );
		SDL_Rect size = { alignedPos.x, alignedPos.y, this->getWidth(), this->getHeight() };
		lastPos = alignedPos;

		drawer.setClipRect( size );

		// draw background
		currentStyle->drawBackground( drawer, size );

		// draw text
		DirSize padding = style->getPadding();
		SDL_Point innerPos = { alignedPos.x + padding.left, alignedPos.y + padding.top };
		if ( !hasDynamicWidth() )
		{
			int innerWidth = style->getWidth() - padding.left - padding.right;
			innerPos.x += (innerWidth - textCache->getWidth()) / 2;
		}
		if ( !hasDynamicHeight() )
		{
			int innerHeight = style->getHeight() - padding.top - padding.bottom;
			innerPos.y += (innerHeight - textCache->getHeight()) / 2;
		}
		
		this->textCache->drawAt( innerPos );

		// draw border
		SDL_Rect border = size;

		drawer.setDrawingColor( currentStyle->getBorderColor() );
		for ( int i = 0; i < currentStyle->getBorderThickness(); i++ )
		{
			drawer.drawRect( border );
			border.x++;
			border.y++;
			border.w -= 2;
			border.h -= 2;
		}

		drawer.cancelClipRect();
	}
}
Esempio n. 19
0
bool  AP_UnixDialog_Styles::_populateModify(void)
{
	const XAP_StringSet * pSS = m_pApp->getStringSet();
//
// Don't do any callback while setting up stuff here.
//
	setModifySignalBlocked(true);
	setModifyDescription( m_curStyleDesc.c_str());
//
// Get Style name and put in in the text entry
//
	const char * szCurrentStyle = NULL;
	UT_UTF8String s;
	
	if(!isNew())
	{
		szCurrentStyle= getCurrentStyle();
		if(!szCurrentStyle)
		{
			// TODO: change me to use a real messagebox
			pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ErrNoStyle,s);
			messageBoxOK( s.utf8_str());
			m_answer = AP_Dialog_Styles::a_CANCEL;
			return false;
		}
		gtk_entry_set_text (GTK_ENTRY(m_wStyleNameEntry), getCurrentStyle());
		gtk_editable_set_editable(GTK_EDITABLE(m_wStyleNameEntry),FALSE );
	}
	else
	{
		gtk_editable_set_editable(GTK_EDITABLE(m_wStyleNameEntry),TRUE );
	}
//
// Next interogate the current style and find the based on and followed by
// Styles
//
	const char * szBasedOn = NULL;
	const char * szFollowedBy = NULL;
	PD_Style * pBasedOnStyle = NULL;
	PD_Style * pFollowedByStyle = NULL;
	if(!isNew())
	{
		PD_Style * pStyle = NULL;
		if(szCurrentStyle)
			getDoc()->getStyle(szCurrentStyle,&pStyle);
		if(!pStyle)
		{
			// TODO: do a real error dialog
			pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ErrStyleNot,s);
			messageBoxOK( s.utf8_str());
			m_answer = AP_Dialog_Styles::a_CANCEL;
			return false;
		}
//
// Valid style get the Based On and followed by values
//
	    pBasedOnStyle = pStyle->getBasedOn();
		pFollowedByStyle = pStyle->getFollowedBy();
	}
//
// Next make a glists of all styles and attach them to the BasedOn and FollowedBy
//
	UT_GenericVector<PD_Style*> * pStyles = NULL;
	getDoc()->enumStyles(pStyles);
	UT_sint32 nStyles = pStyles->getItemCount();
	for (UT_sint32 i = 0; i < nStyles; i++)
	{
		const PD_Style * pcStyle = pStyles->getNthItem(i);
		const char * name = pcStyle->getName();
		if(pBasedOnStyle && pcStyle == pBasedOnStyle)
		{
			szBasedOn = name;
		}
		if(pFollowedByStyle && pcStyle == pFollowedByStyle)
			szFollowedBy = name;
		if(szCurrentStyle && strcmp(name,szCurrentStyle) != 0)
			m_gbasedOnStyles.push_back(name);
		else if(szCurrentStyle == NULL)
			m_gbasedOnStyles.push_back(name);

		m_gfollowedByStyles.push_back(name);
	}
	DELETEP(pStyles);

	m_gfollowedByStyles.sort();
	m_gfollowedByStyles.push_back(pSS->getValue(AP_STRING_ID_DLG_Styles_DefCurrent));
	m_gbasedOnStyles.sort();
	m_gbasedOnStyles.push_back(pSS->getValue(AP_STRING_ID_DLG_Styles_DefNone));
	m_gStyleType.push_back(pSS->getValue(AP_STRING_ID_DLG_Styles_ModifyParagraph));
	m_gStyleType.push_back(pSS->getValue(AP_STRING_ID_DLG_Styles_ModifyCharacter));
 
//
// Set the popdown list
//
	setComboContent(GTK_COMBO_BOX_TEXT(m_wBasedOnCombo),m_gbasedOnStyles);
	setComboContent(GTK_COMBO_BOX_TEXT(m_wFollowingCombo),m_gfollowedByStyles);
	if(isNew())
	{
		setComboContent(GTK_COMBO_BOX_TEXT(m_wStyleTypeCombo),m_gStyleType);
	}
//
// OK here we set intial values for the basedOn and followedBy
//
	if(!isNew())
	{
		if(pBasedOnStyle != NULL)
			gtk_entry_set_text (GTK_ENTRY(m_wBasedOnEntry),szBasedOn);
		else
		{
			pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_DefNone,s);
			gtk_entry_set_text (GTK_ENTRY(m_wBasedOnEntry), s.utf8_str());
		}
		
		if(pFollowedByStyle != NULL)
			gtk_entry_set_text (GTK_ENTRY(m_wFollowingEntry),szFollowedBy);
		else
		{
			pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_DefCurrent,s);
			gtk_entry_set_text (GTK_ENTRY(m_wFollowingEntry), s.utf8_str());
		}
		
		const char * pszType = getAttsVal(PT_TYPE_ATTRIBUTE_NAME);
		if(pszType && strstr(pszType,"P") != 0)
		{
			pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ModifyParagraph,s);
			gtk_entry_set_text (GTK_ENTRY(m_wStyleTypeEntry),s.utf8_str());
		}
		else
		{
			pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ModifyCharacter,s);
			gtk_entry_set_text (GTK_ENTRY(m_wStyleTypeEntry),s.utf8_str());
		}
	}
	else
	{
//
// Hardwire defaults for "new"
//
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_DefNone,s);
		gtk_entry_set_text (GTK_ENTRY(m_wBasedOnEntry), s.utf8_str());
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_DefCurrent,s);
		gtk_entry_set_text (GTK_ENTRY(m_wFollowingEntry), s.utf8_str());
		pSS->getValueUTF8(AP_STRING_ID_DLG_Styles_ModifyParagraph,s);
		gtk_entry_set_text (GTK_ENTRY(m_wStyleTypeEntry),s.utf8_str());
	}
	gtk_editable_set_editable(GTK_EDITABLE(m_wFollowingEntry),FALSE );
	gtk_editable_set_editable(GTK_EDITABLE(m_wBasedOnEntry),FALSE );
	gtk_editable_set_editable(GTK_EDITABLE(m_wStyleTypeEntry),FALSE );
//
// Set these in our attributes vector
//
	event_basedOn();
	event_followedBy();
	event_styleType();
	if(isNew())
	{
		fillVecFromCurrentPoint();
	}
	else
	{
		fillVecWithProps(szCurrentStyle,true);
	}
//
// Allow callback's now.
//
	setModifySignalBlocked(false);
//
// Now set the list of properties which can be deleted.
//
	rebuildDeleteProps();
	gtk_entry_set_text(GTK_ENTRY(m_wDeletePropEntry),"");
	return true;
}
Esempio n. 20
0
void AP_UnixDialog_Styles::event_ModifyClicked(void)
{
	PD_Style * pStyle = NULL;
	const char * szCurrentStyle = getCurrentStyle ();
	m_sNewStyleName = szCurrentStyle;

	if(szCurrentStyle)
		getDoc()->getStyle(szCurrentStyle, &pStyle);
	
	if (!pStyle)
	{
		// TODO: error message - nothing selected
		return;
	}
//
// Allow built-ins to be modified
//
#if 0
	if (!pStyle->isUserDefined ())
	{
		// can't change builtin, error message
		const XAP_StringSet * pSS = m_pApp->getStringSet();
		UT_UTF8String s;
		pSS->getValueUTF8 (AP_STRING_ID_DLG_Styles_ErrStyleBuiltin,s);
		const gchar * msg = s.utf8_str();
		
		getFrame()->showMessageBox (static_cast<const char *>(msg),
									XAP_Dialog_MessageBox::b_O,
									XAP_Dialog_MessageBox::a_OK);
		return;
	}	
#endif
	
#if HIDE_MAIN_DIALOG
//
// Hide the old window
//
    gtk_widget_hide(m_windowMain);
#endif
//
// fill the data structures needed for the Modify dialog
//
	setIsNew(false);
	
	modifyRunModal();
	if(m_answer == AP_Dialog_Styles::a_OK)
	{
		applyModifiedStyleToDoc();
		getDoc()->updateDocForStyleChange(getCurrentStyle(),true);
		getDoc()->signalListeners(PD_SIGNAL_UPDATE_LAYOUT);
	}
	else
	{
//
// Do other stuff
//
	}
//  
// Restore the values in the main dialog
//
	
#if HIDE_MAIN_DIALOG
//
// Reveal main window again
//
	gtk_widget_show( m_windowMain);
#endif
}