Ejemplo n.º 1
0
/**
  *     @brief 建立主視窗跟相關的一些元件
  *
  *     MainWindow的建構子,作為初始化整個視窗的開頭,他先呼叫 ui->setupUi()
  *     把 Qt Designer畫出來的 From給建立起來,再來是呼叫 Boshiamy的建構子
  *     這邊設定Boshiamy的字根對照表是『建議碼』,然後建立計時器跟定時器,把定時
  *     器的 signal跟 MainWindow的函式 void showTime()連接起來。
  *     設定 MainWindow的 Status bar把 status這個 Label給連過去。
  *     設定一些基本常數,清空鍵盤暫存,如果外掛的打字範本不存在就呼叫原始的打字範本
  *     呼叫 drawLayout()完成所有畫圖的工作。
  */
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	check = new Boshiamy();
        check->setStatus(B_Standard);
	timer = new QTimer(this);
	time = new QTime();
	connect( timer,SIGNAL( timeout() ),this,SLOT( showTime() ) );
	status = new QLabel();
	statusBar()->addPermanentWidget(status);
        Col = 9;                                                        ///< 預設每行是 10個;
	Buff = "";
/// 這底下是後來加上去的。
	QString filename = QDir::currentPath() + QDir::separator() + "text.txt";
	QFile file(filename);
	if( file.open(QIODevice::ReadOnly) )
	{
		QTextStream in(&file);
		QString SampleText = in.readAll();
		setText(SampleText);
	}
	else{
		setText(Sample_Text);
	}
	At = 0;
	correct = 0,incorrect = 0,recorrect=0;
	drawLayout();
}
Ejemplo n.º 2
0
void drawWindowLayout(struct window_t* window)
{
    glfwMakeContextCurrent(window->handle);

    setGLClearColor();
    glClear(GL_COLOR_BUFFER_BIT);

    drawLayout(&window->layout, false);

    glfwSwapBuffers(window->handle);
}
Ejemplo n.º 3
0
void SettingsClockfaceMenu::draw(Adafruit_GFX* display) const {
  drawLayout(display, F("Clockfaces"));

  // Menu Items
  for (uint8_t i = 0; i < FACE_MAX+1; ++i) {
    display->setCursor(5, 13 + (i * 10));
    if (selection == i) {
      display->setTextColor(BLACK, WHITE);
      display->fillRect(
        0    , 12 + (i * 10),
        WIDTH, 9,
        WHITE);
    } else {
      display->setTextColor(WHITE);
    }
    if (i == FACE_MAX) {
      display->print(F("Back"));
    } else {
      if (state.enabled_faces & _BV(i)) {
        display->print('*');
      } else {
        display->print(' ');
      }
      switch (i) {
      case FACE_PONG:
        display->print(F(" Pong"));
        break;
      case FACE_DIGITAL:
        display->print(F(" Digital"));
        break;
      case FACE_PACMAN:
        display->print(F(" Pacman"));
        break;
      case FACE_TETRIS:
        display->print(F(" Tetris"));
        break;
      }
    }
  }
}
Ejemplo n.º 4
0
void SettingsDateMenu::draw(Adafruit_GFX* display) const {
  drawLayout(display, F("Set Date"));

  // Date text
  display->setTextSize(2);
  display->setTextColor(WHITE);
  display->setCursor(20, 23);
  display->print(state.now.day());
  display->setCursor(50, 23);
  display->print(state.getMonthStr(state.now.month()));
  display->setCursor(90, 30);
  display->setTextSize(1);
  display->print(state.now.year());

  // Triangle selectors
  if (selection < 3) {
    display->fillTriangle(
      30 + (selection * 35), 15,
      35 + (selection * 35), 20,
      25 + (selection * 35), 20,
      WHITE);
  } else if (selection < 6) {
    display->fillTriangle(
      30 + ((selection - 3) * 35), 45,
      35 + ((selection - 3) * 35), 40,
      25 + ((selection - 3) * 35), 40,
      WHITE);
  }

  // Back item
  if (selection == 6) {
    display->fillRect(0, 53, WIDTH, 10, WHITE);
    display->setTextColor(BLACK, WHITE);
  } else {
    display->setTextColor(WHITE);
  }
  display->setTextSize(1);
  display->setCursor(5, 54);
  display->print(F("Back"));
}
Ejemplo n.º 5
0
/*!
 @brief イメージの取得

 @param [in]    pSelectItem     選択データ
 @param [out]   bitmap          イメージ
 */
BOOL CImageFontDlg::GetBitmapImage(LPVOID pSelectItem, CImage &bitmap)
{
	CRect rect;
	GetClientRect(&rect);

	bitmap.Create(rect.Width(), rect.Height(), 32);

	HDC hDC = bitmap.GetDC();
	Gdiplus::Graphics graphics(hDC);
	graphics.Clear((Gdiplus::ARGB)Gdiplus::Color::White);

	CString strMessage;
	strMessage = _T("1234567890\n");
	strMessage += _T("abcdefghijklmnopqrstuvwxyz\n");
	strMessage += _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n");
	strMessage += _T("あいおえおかきくけこさしすせそたちつてとなにぬねの\n");
	strMessage += _T("はひふへほまみむめもやゆよらりるれろわをん\n");

	LOGFONT *pLogfont = (LOGFONT *) pSelectItem;
	Gdiplus::Font font(hDC, pLogfont);

	Gdiplus::RectF drawLayout(0, 0, (Gdiplus::REAL)rect.Width(), (Gdiplus::REAL)rect.Height());

	Gdiplus::StringFormat stringFormat;
	stringFormat.SetAlignment(Gdiplus::StringAlignmentCenter);
	stringFormat.SetLineAlignment(Gdiplus::StringAlignmentCenter);
	stringFormat.SetTrimming(Gdiplus::StringTrimmingNone);

	Gdiplus::SolidBrush brush((Gdiplus::ARGB)Gdiplus::Color::Black);

	graphics.SetTextRenderingHint((Gdiplus::TextRenderingHint) (GetSpaceKeyDownCount() % (int)Gdiplus::TextRenderingHintClearTypeGridFit));
	graphics.DrawString(strMessage, -1, &font, drawLayout, &stringFormat,&brush);


	bitmap.ReleaseDC();

	return TRUE;
}
layoutEditPreviewDialog::layoutEditPreviewDialog(NineMLLayout * inSrcNineMLLayout, glConnectionWidget * glConn, QWidget *parent) :
    QDialog(parent)
{

    srcNineMLLayout = inSrcNineMLLayout;
    glView = glConn;
    QObject::connect(this, SIGNAL(drawLayout(vector<loc>)), glView, SLOT(drawLocations(vector<loc>)));

    this->setModal(true);
    this->setMinimumSize(200, 400);
    this->setWindowTitle("Preview layout");
    //this->setWindowIcon();

    // add the main layout
    this->setLayout(new QVBoxLayout);
    this->layout()->setContentsMargins(0,0,0,0);

    // make the dialog scrollable
    this->layout()->addWidget(new QScrollArea);
    QWidget * content = new QWidget;
    ((QScrollArea *) this->layout()->itemAt(0)->widget())->setWidget(content);
    ((QScrollArea *) this->layout()->itemAt(0)->widget())->setWidgetResizable(true);
    content->setLayout(new QFormLayout);
    QFormLayout * contentLayout = (QFormLayout *) content->layout();

    QSpinBox * numNeurons = new QSpinBox;
    numNeurons->setRange(1, 20000000);
    numNeurons->setProperty("name", "numNeurons");
    numNeurons->setValue(99.0);
    QObject::connect(numNeurons, SIGNAL(valueChanged(QString)), this, SLOT(reDraw(QString)));


    contentLayout->addRow("Number of neurons:", numNeurons);


    // start adding the items
    if (srcNineMLLayout->ParameterList.size() > 1) {
        contentLayout->addRow("<b>Parameters</b>", new QLabel(""));
    }

    // add the parameters
    for (uint i = 0; i < srcNineMLLayout->ParameterList.size(); ++i) {

        if (srcNineMLLayout->ParameterList[i]->name != "numNeurons") {
            // add to main layout
            QDoubleSpinBox * value = new QDoubleSpinBox;
            value->setRange(-200000, 200000);
            value->setSingleStep(0.1);
            value->setDecimals(3);
            value->setValue(1.0);
            value->setProperty("name", srcNineMLLayout->ParameterList[i]->name);
            QObject::connect(value, SIGNAL(valueChanged(QString)), this, SLOT(reDraw(QString)));
            contentLayout->addRow(srcNineMLLayout->ParameterList[i]->name + ":", value);
        }

    }

    if (srcNineMLLayout->StateVariableList.size() > 3) {
        contentLayout->addRow("<b>State variables</b>", new QLabel(""));
    }

    // add the state vars
    for (uint i = 0; i < srcNineMLLayout->StateVariableList.size(); ++i) {

        if (srcNineMLLayout->StateVariableList[i]->name != "x" && srcNineMLLayout->StateVariableList[i]->name != "y" && srcNineMLLayout->StateVariableList[i]->name != "z") {
            // add to main layout
            QDoubleSpinBox * value = new QDoubleSpinBox;
            value->setRange(-200000, 200000);
            value->setSingleStep(0.1);
            value->setDecimals(3);
            value->setValue(1.0);
            value->setProperty("name", srcNineMLLayout->StateVariableList[i]->name);
            QObject::connect(value, SIGNAL(valueChanged(QString)), this, SLOT(reDraw(QString)));
            contentLayout->addRow(srcNineMLLayout->StateVariableList[i]->name + ":", value);
        }

    }

    contentLayoutRef = contentLayout;

    // force a redraw!
    numNeurons->setValue(100.0);
}
void layoutEditPreviewDialog::reDraw(QString) {

    // create a new layoutData from the layout:

    NineMLLayoutData * data = new NineMLLayoutData(srcNineMLLayout);

    // populate from the spinboxes:
    for (uint i = 0; i < data->ParameterList.size(); ++i) {
        for (uint j = 0; j < (uint) contentLayoutRef->count(); ++j) {
            if (contentLayoutRef->itemAt(j)->widget()) {
                QString clsName = "QDoubleSpinBox";
                if (clsName.contains(contentLayoutRef->itemAt(j)->widget()->metaObject()->className())) {
                    if (contentLayoutRef->itemAt(j)->widget()->property("name").toString() == data->ParameterList[i]->name) {
                        data->ParameterList[i]->value[0] = ((QDoubleSpinBox *) contentLayoutRef->itemAt(j)->widget())->value();
                    }
                }
            }
        }
    }

    for (uint i = 0; i < data->StateVariableList.size(); ++i) {
        for (uint j = 0; j < (uint) contentLayoutRef->count(); ++j) {
            if (contentLayoutRef->itemAt(j)->widget()) {
                QString clsName = "QDoubleSpinBox";
                if (clsName.contains(contentLayoutRef->itemAt(j)->widget()->metaObject()->className())) {
                    if (contentLayoutRef->itemAt(j)->widget()->property("name").toString() == data->StateVariableList[i]->name) {
                        data->StateVariableList[i]->value[0] = ((QDoubleSpinBox *) contentLayoutRef->itemAt(j)->widget())->value();
                    }
                }
            }
        }
    }

    int numNeurons;
    for (uint j = 0; j < (uint) contentLayoutRef->count(); ++j) {
        if (contentLayoutRef->itemAt(j)->widget()) {
            QString clsName = "QSpinBox";
            if (clsName.contains(contentLayoutRef->itemAt(j)->widget()->metaObject()->className())) {
                numNeurons = ((QSpinBox *) contentLayoutRef->itemAt(j)->widget())->value();
             }
        }
    }


    // ok, data is filled in, now to get the locations
    vector <loc> locations;

    QString err;
    data->generateLayout(numNeurons, &locations, err);

    if (err.size() == 0) {
        emit drawLayout(locations);
    } else
    {
        emit drawLayout(locations);
        QMessageBox msgBox;
        msgBox.setText(err);
        msgBox.exec();
    }

}
Ejemplo n.º 8
0
void Layout::drawself()
{
    drawLayout();
}
Ejemplo n.º 9
0
void drawMenu(WPADData *wd) {
	int x,z=0,l,y,zz=0;
	GRRLIB_DrawImg(0, 0, 640, 480, tex_menuback, 0, 1, 1, 255);

	switch(curmenunum) {
		case MAIN_MENU :
			GRRLIB_DrawImg(0, 52, 608, 400, tex_menufore, 0, 1, 1, 255);

			// Overlay the Japanese name for Mahjongg Solitaire - Shanghi
			if(opt_lang==JAPANESE)
				GRRLIB_DrawImg(354, 142, 72, 40, tex_shanghi, 0, 1, 1, 255);

			for(x=0;x<5;x++) {
				GRRLIB_GPrintf(320,mainhs[x][1],0xFFFFFFFF,x==0?1.15:1,1, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_MMENU_PLAY + x]);
			}

			GRRLIB_GPrintf( 10, 420, 0xFFFFFFFF, 0.5, 0.5, ALIGN_LEFT, CUR_FONT(true), VERSION_STRING);
			break;
		case PLAY_MENU :
			GRRLIB_DrawImg(34,30,576,264, tex_menufore, 0, 1, 1, 255);
			f32 zoom;
			int strlen;

			for(x=0;x<3;x++) {
				strlen = GRRLIB_GetStringWidth(CUR_FONT(false), curtext[LNG_PMENU_1PLAYER+x*2]);
				if(strlen>playhs[x][2]) {
					zoom=(float)playhs[x][2]/(float)strlen;
					GRRLIB_GPrintf(playhs[x][0],playhs[x][1],0xFFFFFFFF,zoom,1, ALIGN_LEFT,CUR_FONT(msel==x),curtext[LNG_PMENU_1PLAYER+x*2]);
				}
				else {
					GRRLIB_GPrintf(playhs[x][0]+playhs[x][2]/2,playhs[x][1],0xFFFFFFFF,1,1, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_PMENU_1PLAYER+x*2]);
				}
				strlen = GRRLIB_GetStringWidth(CUR_FONT(false), curtext[LNG_PMENU_1PLAYER+x*2+1]);
				if(strlen>playhs[x][2]) {
					zoom=(float)playhs[x][2]/(float)strlen;
					GRRLIB_GPrintf(playhs[x][0],playhs[x][1]+36,0xFFFFFFFF,zoom,1, ALIGN_LEFT,CUR_FONT(msel==x),curtext[LNG_PMENU_1PLAYER+x*2+1]);
				}
				else {
					GRRLIB_GPrintf(playhs[x][0]+playhs[x][2]/2,playhs[x][1]+36,0xFFFFFFFF,1,1, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_PMENU_1PLAYER+x*2+1]);
				}
			}

			GRRLIB_GPrintf(600, playhs[3][1],0xFFFFFFFF,1,1, ALIGN_RIGHT,CUR_FONT(msel==x),curtext[LNG_GAME_BACK]);

			for(x=0;x<3;x++) {
				if(!(x==msel))
					GRRLIB_DrawImg(playhs[x][0], 90, 168, 196,tex_shade, 0, 1, 1, 255);
			}
			break;
		case OPTIONS_MENU :
			GRRLIB_DrawImg(-9, 30, 640, 420, tex_menufore, 0, 1, 1, 255);

			for(x=0;x<6;x++) {
				// check if on/off entry
				if(x==4 || x==2 || x==5) {
					char buffer[60];

					strcpy(buffer,curtext[LNG_OMENU_CTILESET+x]);

					if((x==4 && opt_rumble) || (x==2 && opt_hoverhint) || (x==5 && opt_widescreen)) {
						char *s2 = strchr(buffer,'/');
						if(s2!=NULL)
							buffer[s2-buffer]='\0';
					}
					else {
						char *s2=strchr(buffer,'/') + 1;
						char *s1=strrchr(buffer,' ') + 1;
						if(s1!=NULL && s2!=NULL)
							memmove(s1,s2,60-(s2-buffer)+1);
					}

					GRRLIB_GPrintf(320,opths[x][1],0xFFFFFFFF,1,1, ALIGN_CENTRE,CUR_FONT(msel==x),buffer);

				}
				else
					GRRLIB_GPrintf(320,opths[x][1],0xFFFFFFFF,1,1, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_OMENU_CTILESET+x]);
			}
			GRRLIB_GPrintf(600, opths[6][1],0xFFFFFFFF,1,1, ALIGN_RIGHT,CUR_FONT(msel==x),curtext[LNG_GAME_BACK]);

			break;
		case SOUND_MENU :
			GRRLIB_DrawImg(86,30,524,436, tex_menufore, 0, 1, 1, 255);

			for(x=0;x<2;x++) {
				GRRLIB_GPrintf(320,soundhs[x+3][1],0xFFFFFFFF,1,1, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_SMENU_MUSIC+x]);
			}
			GRRLIB_GPrintf(600, soundhs[2][1],0xFFFFFFFF,1,1, ALIGN_RIGHT,CUR_FONT(msel==x),curtext[LNG_GAME_BACK]);

			// draw the offs
			GRRLIB_GPrintf(186,115,0xFFFFFFFF,1,1, ALIGN_RIGHT,CUR_FONT(false),curtext[LNG_SMENU_MUSIC+2]);
			GRRLIB_GPrintf(186,224,0xFFFFFFFF,1,1, ALIGN_RIGHT,CUR_FONT(false),curtext[LNG_SMENU_MUSIC+2]);

			// draw the fulls
			GRRLIB_GPrintf(454,115,0xFFFFFFFF,1,1, ALIGN_LEFT,CUR_FONT(false),curtext[LNG_SMENU_MUSIC+3]);
			GRRLIB_GPrintf(454,224,0xFFFFFFFF,1,1, ALIGN_LEFT,CUR_FONT(false),curtext[LNG_SMENU_MUSIC+3]);

			if(msel==0) {
				if(wd->btns_h & WPAD_BUTTON_A)
					GRRLIB_DrawImg(xmusic-4, soundhs[0][1]-2, 60, 60, tex_sball, 0, 1, 1, 255);
				else
					GRRLIB_DrawImg(xmusic, soundhs[0][1]+2, 44, 44, tex_uball, 0, 1, 1, 255);
			}
			else
				GRRLIB_DrawImg(xmusic, soundhs[0][1]+2, 44, 44, tex_uball, 0, 1, 1, 255);

			if(msel==1) {
				if(wd->btns_h & WPAD_BUTTON_A)
					GRRLIB_DrawImg(xsound-4, soundhs[1][1]-2, 60, 60, tex_sball, 0, 1, 1, 255);
				else
					GRRLIB_DrawImg(xsound, soundhs[1][1]+2, 44, 44, tex_uball, 0, 1, 1, 255);
			}
			else
				GRRLIB_DrawImg(xsound, soundhs[1][1]+2, 44, 44, tex_uball, 0, 1, 1, 255);

			break;
		case LANG_MENU :
			for(x=0;x<9;x++) {
				// set
				int tx = x + (curpage==0?0:9);
				// only show if overall less then number of languages supported
				if(tx<=13) {
					if(x==msel) {
						zz=512-oldz;
						for(y=0;y<108;y+=4) {
							z=oldz;
							for(l=0;l<148;l+=4) {
								GRRLIB_DrawGTile(langhs[x][0]-5+l+SinTab[zz%SinSize]/4,langhs[x][1]+y+SinTab[z%SinSize]/4,4,4,tex_flags,148,108,0,1.1,1.1,0xFFFFFFFF,(tx%4)*37+(tx/4)*27*37*4 +l/4+(y/4)*37*4);
								z++;
							}
							zz--;
						}
					}
					else
						GRRLIB_DrawGTile(langhs[x][0],langhs[x][1],148,108,tex_flags,4,4,0,1,1,0xFFEEEEEE,tx);

					GRRLIB_DrawGTile(langhs[x][0]-8,langhs[x][1]+80,160,40,tex_languages,4,4,0,1,1,0xFFFFFFFF,tx);
				}
			}

			oldz+=1;
			if(oldz>=256) oldz=0;

			if(curpage==0) {
				if(btnover)
					GRRLIB_DrawImg(580,220,40,40, tex_plus, 0, 1, 1, 255);
				else
					GRRLIB_DrawImg(580,220,40,40, tex_plus, 0, 0.8, 0.8, 127);
			}
			else {
				if(btnover)
					GRRLIB_DrawImg(10,220,40,40, tex_minus, 0, 1, 1, 255);
				else
					GRRLIB_DrawImg(10,220,40,40, tex_minus, 0, 0.8, 0.8, 128);
			}

			break;
		case LAYOUT_MENU :
			GRRLIB_GPrintf(320,27,0xFFFFFFFF,1,1, ALIGN_CENTRE,CUR_FONT(true),curtext[LNG_OMENU_CLAYOUT]);

			for(x=0;x<6;x++) {
				GRRLIB_DrawImg(layouths[x][0],layouths[x][1]-10,180,208, tex_layout, 0, 1, 0.8, 255);
				int tx = x + (curpage==0?0:6);
				drawLayout(tx);
			}

			for(x=0;x<6;x++) {
				int tx = x + (curpage==0?0:6);
				if(!(x==msel))
					GRRLIB_DrawImg(layouths[x][0]+4, layouths[x][1]-8, 168, 196,tex_shade, 0, 1, 0.8, 255);
					if(opt_lang==JAPANESE)
						GRRLIB_GPrintf(layouths[x][0]+92,layouths[x][1]+152,0xFFFFFFFF,1,0.8, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_LAYOUT_DEFAULT+tx]);
					else
						GRRLIB_GPrintf(layouths[x][0]+77,layouths[x][1]+152,0xFFFFFFFF,0.55,0.8, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_LAYOUT_DEFAULT+tx]);
			}

			if(curpage==0) {
				if(btnover)
					GRRLIB_DrawImg(600,240,40,40, tex_plus, 0, 1, 1, 255);
				else
					GRRLIB_DrawImg(600,240,40,40, tex_plus, 0, 0.8, 0.8, 127);
			}
			else {
				if(btnover)
					GRRLIB_DrawImg(0,240,40,40, tex_minus, 0, 1, 1, 255);
				else
					GRRLIB_DrawImg(0,240,40,40, tex_minus, 0, 0.8, 0.8, 128);
			}
			break;
		case TILESET_MENU :
		{
			GRRLIB_GPrintf(320,27,0xFFFFFFFF,1,1, ALIGN_CENTRE,CUR_FONT(true),curtext[LNG_OMENU_CTILESET]);

			for(x=0;x<6;x++) {
				GRRLIB_DrawImg(layouths[x][0],layouths[x][1]-10,180,208, tex_layout, 0, 1, 0.8, 255);

				GRRLIB_DrawImg(layouths[x][0]+4-236,layouths[x][1]-148,640,480,tex_bk[x],0,0.24,0.3,255);

				GRRLIB_DrawImg(layouths[x][0]+4,layouths[x][1]-10+3,168, 200, tex_border, 0, 1, 0.8, 255);

				for(y=0;y<4;y++) {
					GRRLIB_DrawGTile(layouths[x][0]+21+y*30,layouths[x][1]+29+y*22,44,60,tex_tiles[x],21,2,0,1,1,0xFFFFFFFF,y*11);
				}
			}

			for(x=0;x<6;x++) {
				if(!(x==msel))
					GRRLIB_DrawImg(layouths[x][0]+4, layouths[x][1]-8, 168, 196,tex_shade, 0, 1, 0.8, 255);
					if(opt_lang==JAPANESE)
						GRRLIB_GPrintf(layouths[x][0]+92,layouths[x][1]+152,0xFFFFFFFF,1,0.8, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_TILESET_DEFAULT+x]);
					else
						GRRLIB_GPrintf(layouths[x][0]+77,layouths[x][1]+152,0xFFFFFFFF,0.55,0.8, ALIGN_CENTRE,CUR_FONT(msel==x),curtext[LNG_TILESET_DEFAULT+x]);
			}
		}
		break;
		case HIGHSCORE_MENU:
		{
		    drawHighscoreMenu();
		}
		break;
	}
}