Ejemplo n.º 1
0
PSI_NAMESPACE 

PSI_PROC( void, SimpleMessageBox )( PCOMMON parent, CTEXTSTR title, CTEXTSTR content )
{
	PCOMMON msg;
	CTEXTSTR start, end;
	TEXTCHAR msgtext[256];
	int okay = 0;
	int y = 5;
	uint32_t width, height;
	uint32_t title_width, greatest_width;
#ifdef USE_INTERFACES
	GetMyInterface();
#endif
	GetStringSize( content, &width, &height );
	title_width = GetStringSize( title, NULL, NULL );
	if( title_width > width )
		greatest_width = title_width;
	else
		greatest_width = width;
	msg = CreateFrame( title, 0, 0
						 , greatest_width + 10, height + (COMMON_BUTTON_PAD * 3) + COMMON_BUTTON_HEIGHT
						 , 0, parent );
	end = start = content;
	do
	{
		while( end[0] && end[0] != '\n' )
			end++;
		if( end[0] )
		{
			MemCpy( msgtext, (POINTER)start, end-start );
			msgtext[end-start] = 0;
			//end[0] = 0;
			MakeTextControl( msg, COMMON_BUTTON_PAD, y
							  , greatest_width, height
							  , -1, msgtext, 0 );
			//end[0] = '\n';
			end = start = end+1;
			y += height;
		}
		else
			MakeTextControl( msg, COMMON_BUTTON_PAD, y
							  , greatest_width, height
							  , -1, start, 0 );
	} while( end[0] );
	//AddExitButton( msg, &done );
	AddCommonButtons( msg, NULL, &okay );
	lprintf( WIDE("show message box") );
	DisplayFrame( msg );
	CommonWait( msg );
	DestroyFrame( &msg );
}
Ejemplo n.º 2
0
int SimpleUserQueryEx( TEXTSTR result, int reslen, CTEXTSTR question, PSI_CONTROL pAbove, void (CPROC*query_success_callback)(uintptr_t, LOGICAL), uintptr_t query_user_data )
{
	PSI_CONTROL pf, pc;
	struct user_query_info *query_state = New( struct user_query_info );
	int32_t mouse_x, mouse_y;

	//int Done = FALSE, Okay = FALSE;
	pf = CreateFrame( NULL, 0, 0, 280, 65, 0, pAbove );
	SetCommonUserData( pf, (uintptr_t)query_state );
	query_state->pf = pf;
	query_state->Done = FALSE;
	query_state->Okay = FALSE;
	query_state->result = result;
	query_state->reslen = reslen;
	pc = MakeTextControl( pf, 5, 2, 320, 18, TXT_STATIC, question, TEXT_NORMAL );

	query_state->edit = MakeEditControl( pf, 5, 23, 270, 14, TXT_STATIC, NULL, 0 );
	AddCommonButtons( pf, &query_state->Done, &query_state->Okay );
	SetButtonPushMethod( GetControl( pf, IDOK ), OkayClicked, (uintptr_t)query_state );
	SetButtonPushMethod( GetControl( pf, IDCANCEL ), CancelClicked, (uintptr_t)query_state );
	GetMousePosition( &mouse_x, &mouse_y );
	MoveFrame( pf, mouse_x - 140, mouse_y - 30 );
	//lprintf( WIDE("Show query....") );
	DisplayFrame( pf );
	SetCommonFocus( query_state->edit );

	query_state->query_success = query_success_callback;
	if( !query_success_callback )
	{
		int okay;
		CommonWait( pf );
		if( query_state->Okay )
		{
			GetControlText( query_state->edit, result, reslen );
		}
		DestroyFrame( &pf );
		okay = query_state->Okay;
		Release( query_state );
		return okay;
	}
	else
	{
		query_state->query_success = query_success_callback;
		query_state->query_user_data = query_user_data;
		return 0;
	}

}
Ejemplo n.º 3
0
int main( void )
{
	PSI_CONTROL frame = CreateFrame( WIDE("test scrolling texts"), 0, 0, 1024, 768, 0, NULL );
	if( frame )
	{
		t1 = MakeNamedCaptionedControl( frame, STATIC_TEXT_NAME, 5, 5, 300, 15, -1, WIDE("Scroll This Text...") );
		t2 = MakeNamedCaptionedControl( frame, STATIC_TEXT_NAME, 5, 25, 300, 15, -1, WIDE("Scroll This Text...") );
		t3 = MakeNamedCaptionedControl( frame, STATIC_TEXT_NAME, 5, 45, 300, 15, -1, WIDE("Scroll This Text...") );
		SetControlAlignment( t3, TEXT_CENTER );
		t4 = MakeNamedCaptionedControl( frame, STATIC_TEXT_NAME, 5, 65, 300, 15, -1, WIDE("Scroll This Text...") );
		SetControlAlignment( t4, TEXT_CENTER );
		DisplayFrame( frame );
		AddTimer( 50, DoScroll, 0 );
		CommonWait( frame );
	}
}
Ejemplo n.º 4
0
static void ConfigureMacroButton( PMACRO_BUTTON button, PSI_CONTROL parent )
{
	PSI_CONTROL frame = LoadXMLFrameOver( parent, WIDE( "ConfigureMacroButton.isFrame" ) );
	if( frame )
	{
		int okay = 0;
		int done = 0;
		l.configuration_parent = parent;
		SetCommonButtons( frame, &done, &okay );
		{
			PSI_CONTROL list;
			SetListboxIsTree( list = GetControl( frame, LIST_CONTROL_TYPES ), 1 );
			ResetList( list );
			FillControlsList( list, 1, TASK_PREFIX WIDE( "/control" ), NULL );
			SetCommonButtonControls( frame );
			SetButtonPushMethod( GetControl( frame, BUTTON_ADD_CONTROL ), AddButtonType, (uintptr_t)button );
			//SetButtonPushMethod( GetControl( frame, BUTTON_EDIT_CONTROL ), AddButtonType, (uintptr_t)button );
			{
				PSI_CONTROL list = GetControl( frame, LIST_MACRO_ELEMENTS );
				if( list )
				{
					PMACRO_ELEMENT pme = button->elements;
					while( pme )
					{
						SetItemData( AddListItem( list, (pme->button->text&&pme->button->text[0])?pme->button->text:pme->button->pTypeName ), (uintptr_t)pme );
						pme = NextThing( pme );
					}
				}
			}
			SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_UP ), MoveElementUp, (uintptr_t)button );
			SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_CLONE ), MoveElementClone, (uintptr_t)button );
			SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_CLONE_ELEMENT ), CloneElement, (uintptr_t)button );
			SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_DOWN ), MoveElementDown, (uintptr_t)button );
			SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_CONFIGURE ), ConfigureElement, (uintptr_t)button );
			SetButtonPushMethod( GetControl( frame, BUTTON_ELEMENT_REMOVE ), MoveElementRemove, (uintptr_t)button );
		}
		DisplayFrameOver( frame, parent );
		CommonWait( frame );
		if( okay )
		{
			GetCommonButtonControls( frame );
		}
		DestroyFrame( &frame );
	}
}
Ejemplo n.º 5
0
static uintptr_t OnConfigureControl( CONTROL_NAME )( uintptr_t psv, PSI_CONTROL parent_frame )
{
	PSLIDER_INFO info = (PSLIDER_INFO)psv;
	{
		PSI_CONTROL frame = NULL; 
		int okay = 0;
		int done = 0;
		if( !frame )
		{
			frame = LoadXMLFrame( "seek_slider_properties.frame" );
			if( frame )
			{
				 TEXTCHAR buffer[256];

				SetCommonButtonControls( frame );
				
				SetCheckState( GetControl( frame, CHECKBOX_HORIZONTAL ), info->flags.bHorizontal );
				SetCheckState( GetControl( frame, CHECKBOX_DRAGGING ), info->flags.bDragging );
				SetControlText( GetControl( frame, EDIT_BACKGROUND_IMAGE ), info->image_name );

					 snprintf(buffer, sizeof(buffer), "%d", info->min);
				SetControlText( GetControl( frame, EDIT_MIN ), buffer );

					 snprintf(buffer, sizeof(buffer), "%d", info->max);
				SetControlText( GetControl( frame, EDIT_MAX ), buffer );
				
					 snprintf(buffer, sizeof(buffer), "%d", info->current);
				SetControlText( GetControl( frame, EDIT_CURRENT ), buffer );
				
				SetCommonButtons( frame, &done, &okay );
				DisplayFrameOver( frame, parent_frame );
				CommonWait( frame );

				if( okay )
				{
					GetCommonButtonControls( frame );
					info->font = InterShell_GetCurrentButtonFont();
					if( info->font )
						SetCommonFont( info->control, (*info->font ) );
					info->color = GetColorFromWell( GetControl( frame, CLR_TEXT_COLOR ) );
					info->backcolor = GetColorFromWell( GetControl( frame, CLR_BACKGROUND ) );
					{
						GetControlText( GetControl( frame, EDIT_BACKGROUND_IMAGE ), buffer, sizeof( buffer ) );
						if( info->image_name )
							Release( info->image_name );
						info->image_name = StrDup( buffer );
					}

//					SetSliderColor( info->control, info->color );
//					SetSliderkBackColor( info->control, info->backcolor );

					info->flags.bHorizontal = GetCheckState( GetControl( frame, CHECKBOX_HORIZONTAL ) );
					info->flags.bDragging = GetCheckState( GetControl( frame, CHECKBOX_DRAGGING ) );

					GetControlText( GetControl( frame, EDIT_MIN), buffer, sizeof( buffer ) );
					info->min = atoi(buffer);
					GetControlText( GetControl( frame, EDIT_MAX), buffer, sizeof( buffer ) );
					info->max = atoi(buffer);
					GetControlText( GetControl( frame, EDIT_CURRENT), buffer, sizeof( buffer ) );
					info->current = atoi(buffer);

				}
				DestroyFrame( &frame );
			}
		}
	}
	return psv;
}