Beispiel #1
0
/* Allocate new text window */
TW *
text_new(void)
{
    TW *tw;
    tw = (TW *)malloc(sizeof(TW));
    if (tw == NULL)
        return NULL;
    /* make sure everything is null */
    memset(tw, 0, sizeof(TW));

    /* set some defaults */
    text_font(tw, "Courier New", 10);
    text_size(tw, 80, 24);
    tw->KeyBufSize = 2048;
    tw->CursorFlag = 1;	/* scroll to cursor after \n or \r */
    tw->hwnd = HWND_DESKTOP;

    tw->line_end = 0;
    tw->line_start = 0;
    tw->line_complete = FALSE;
    tw->line_eof = FALSE;

    tw->x = CW_USEDEFAULT;
    tw->y = CW_USEDEFAULT;
    tw->cx = CW_USEDEFAULT;
    tw->cy = CW_USEDEFAULT;
#ifndef WINDOWS_NO_UNICODE
    tw->utf8shift = 0;
#endif
    return tw;
}
Beispiel #2
0
void Fl_Input_Browser::preferred_size(int& w, int& h) const
{
    fl_font(text_font(), float(text_size()));
    h = int(fl_height()+fl_descent()) + box()->dh() + 2;
    if(m_input.maximum_size()>0) {
        int ms = m_input.maximum_size() + 1;
        if (ms > 50) ms = 50;
        w = ms * (int)fl_width((unsigned int)'W') + h;
    }
}
Beispiel #3
0
int PASCAL 
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{

	/* make a test window */
	tw = text_new();

	if (!hPrevInstance) {
	    HICON hicon = LoadIcon(NULL, IDI_APPLICATION);
	    text_register_class(hicon);
	}
	text_font(tw, "Courier New", 10);
	text_size(tw, 80, 80);
	text_drag(tw, "(", ") run\r");

	/* show the text window */
	if (!text_create(tw, "Application Name", nCmdShow)) {
	    /* do the real work here */
	    /* TESTING */
	    int ch;
	    int len;
	    char *line = new char[256];
	    while ( (len = text_read_line(tw, line, 256-1)) != 0 ) {
		text_write_buf(tw, line, len);
	    }
/*
	    while ( text_gets(tw, line, 256-1) ) {
		text_puts(tw, line);
	    }
*/
/*
	    while ( (ch = text_getch(tw, )) != 4 )
		text_putch(tw, ch);
*/
	}
	else {
	    
	}

	/* clean up */
	text_destroy(tw);
	
	/* end program */
	return 0;
}
Beispiel #4
0
void Text_Display::dirty()
{
    Abstract_Text_Widget::dirty();

    _widget->textfont(text_font());
    _widget->textsize(Style::global()->font_size());
    _widget->textcolor(text_color());

    size_hint(
        V2i(
            //Math::max(
            //  Style::global()->size_button(),
            //  base::string_size(_size_string)
            //),
            Font::string_width(_size_string),
            fl_height()
        ) +
        Style::global()->margin_text() * 2 +
        frame_size() * 2);
}
Beispiel #5
0
		void StageSettings::identifyDisplays()
		{
			// loop over all displays
			// (we iterate until size() - 1 because there's also
			// 'disabled' in the combo box)
			for (int i=0; i<std::max(0, controlScreen_comboBox->count() - 1); ++i)
			{
				QPainter p;

				// create a transparent background image
				QImage pm(250, 250, QImage::Format_ARGB32);
				pm.fill(qRgba(0, 0, 0, 0));

				p.begin(&pm);

				QFont text_font("Arial", 200, QFont::Bold);

				QPainterPath text_path;
				text_path.addText(QPointF(10.f, 220.f), text_font, QString::number(i));

				QLinearGradient gradient(0, 0, 0, 100);
				gradient.setColorAt(0.0, qRgba(0, 0, 128, 0));
				gradient.setColorAt(1.0, qRgba(0, 128, 128, 0));

				p.setBrush(gradient);
				p.setPen(QPen(QColor(0, 0, 0), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));

				p.drawPath(text_path);
				p.end();

				pm.createAlphaMask();

				QSplashScreen* splash = new QSplashScreen(QApplication::desktop()->screen(i), QPixmap::fromImage(pm));
				splash->show();

				identification_labels_.push_back(splash);
			}

			QTimer::singleShot(2000, this, SLOT(killIdentificationLabels_()));
		}
Beispiel #6
0
LogViewer::LogViewer( QWidget* parent, const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
	setName( "LogViewer" );
	setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, sizePolicy().hasHeightForWidth() ) );
	
 	QBoxLayout *logLayout = new QVBoxLayout( this, 5, 5); 
	
	textLog = new QTextEdit(this);
	textLog->setMinimumSize( QSize( 200, 80) );
	textLog->setTextFormat(Qt::LogText);
	QFont text_font(  textLog->font() );
	text_font.setFamily( "Courier" );
	text_font.setPointSize( 12 );
	textLog->setFont( text_font ); 
	
	clearButton = new QPushButton( this, "clearButton" );
	saveButton = new QPushButton( this, "saveButton" );
	closeButton = new QPushButton( this, "closeButton" );
	
	logLayout->addWidget( textLog, 2 );
	
	QBoxLayout *hLayout = new QHBoxLayout( logLayout ); 
	hLayout->addWidget(clearButton);
	hLayout->addWidget(saveButton);
	hLayout->addWidget(closeButton);
	
	languageChange();
	resize( QSize(700, 300).expandedTo(minimumSizeHint()) );
	clearWState( WState_Polished );
	
	// signals and slots connections
	connect( clearButton, SIGNAL( clicked() ), this, SLOT( clearLog() ) );
	connect( saveButton, SIGNAL( clicked() ), this, SLOT( saveLog() ) );
	connect( closeButton, SIGNAL( clicked() ), this, SLOT( closeLog() ) );
}
Beispiel #7
0
// Draw tick marks. These lines cross the passed rectangle perpendicular to
// the slider direction. In the direction parallel to the slider direction
// the box should have the same size as the area the slider moves in.
void Fl_Slider::draw_ticks(int x, int y, int w, int h, int min_spacing)
{
    int x1, y1, x2, y2, dx, dy;
    if (horizontal())
    {
        x1 = x2 = x+(slider_size_-1)/2; dx = 1;
        y1 = y; y2 = y + h; dy = 0;
    }
    else
    {
        x1 = x; x2 = x+w; dx = 0;
        y1 = y2 = y+(slider_size_-1)/2; dy = 1;
        w = h;
    }
    if (w <= 0) return;
    double A = minimum();
    double B = maximum();
    if (A > B) {A = B; B = minimum();}

    // Figure out approximate size of min_spacing at zero:
    double derivative;
    if (!log())
    {
        derivative = (B-A)/w;
    }
    else if (A > 0)
    {
        // log slider
        derivative = A/w*20;
    }
    else
    {
        // squared slider, derivative at edge is zero, use value at 1 pixel
        derivative = B/(w*w)*30;
        if (A < 0) derivative *= 4;
    }
                                 // fix for fill sliders
    if (min_spacing < 1) min_spacing = 10;
    derivative *= min_spacing;
    if (derivative < step()) derivative = step();

    // Find closest multiple of 10 larger than spacing:
    int num = 1;
    while (num < derivative) num *= 10;
    int denom = 10;
    while (num >= derivative*denom) denom *= 10;
    denom /= 10;

    for (int n = 0; ; n++)
    {
        // every ten they get further apart for log slider:
        if (log() && n > 10) {n = 2; num *= 10;}
        double v = double(num*n)/denom;
        if (v > fabs(A) && v > fabs(B)) break;
        int small = n%5 ? 2 : 0;
        if (v >= A && v <= B)
        {
            int t = slider_position(v, w);
            fl_line(x1+dx*t+dy*small, y1+dy*t+dx*small, x2+dx*t, y2+dy*t);
            if (n%10 == 0)
            {
                char buffer[20]; sprintf(buffer,"%g",v);
                char* p = buffer;
                while (p[0]=='0' && p[1]) p++;
                fl_font(text_font(), text_size());
                fl_draw(p, x1+dx*t+1, y1+dy*t+fl_size()-fl_descent());
            }
        }
        if (v && -v >= A && -v <= B)
        {
            int t = slider_position(-v, w);
            fl_line(x1+dx*t+dy*small, y1+dy*t+dx*small, x2+dx*t, y2+dy*t);
            if (n%10 == 0)
            {
                char buffer[20]; sprintf(buffer+1,"%g",v);
                char* p = buffer+1;
                while (p[0]=='0' && p[1]) p++;
                p--; p[0] = '-';
                fl_font(text_font(), text_size());
                fl_draw(p, x1+dx*t+1, y1+dy*t+fl_size()-fl_descent());
            }
        }
    }
}
Beispiel #8
0
void Fl_Combo_Box::preferred_size(int& w, int& h) const
{
    fl_font(text_font(), float(text_size()));
    h = int(fl_height()+fl_descent()) + box()->dh() + 2;
}