void Fish::Init(){ int x = rand() % ofGetWidth(); int y = rand() % ofGetHeight(); int randNum = rand()%4; switch(randNum){ case 0: x = -100; break; case 1: x = ofGetWidth()+100; break; case 2: y = -100; break; case 3: y = ofGetHeight()+100; break; } mPos = ofPoint(x,y); mAngle = 0.0f; mTime = 0.0f; MoveToCenter(); }
ShowLanguagesDlg::ShowLanguagesDlg(AppWnd *app) { d = new ShowLanguagesDlgPriv; SetParent(d->App = app); GRect r(0, 0, 300, 500); SetPos(r); MoveToCenter(); Name("Show Languages"); r = GetClient(); Children.Insert(d->Lst = new GList(100, 10, 10, r.X() - 20, r.Y() - 50)); Children.Insert(new GButton(IDOK, r.X() - 140, r.Y() - 30, 60, 20, "Ok")); Children.Insert(new GButton(IDCANCEL, r.X() - 70, r.Y() - 30, 60, 20, "Cancel")); if (d->Lst) { d->Lst->AddColumn("Show", 40); d->Lst->AddColumn("Id", 40); d->Lst->AddColumn("Language", 180); for (int i=0; i<d->App->GetLanguages()->Length(); i++) { GLanguage *L = (*d->App->GetLanguages())[i]; if (L) { d->Lst->Insert(new Lang(d->App, L, i)); } } d->Lst->Sort(Cmp, 0); d->Lst->Select(*d->Lst->Start()); } DoModal(); }
bool StepGuider::GuidingCeases(void) { bool bError = false; // We have stopped guiding. Reset bump state and recenter the stepguider m_avgOffset.Invalidate(); m_forceStartBump = false; m_bumpInProgress = false; m_bumpStepWeight = 1.0; m_bumpTimeoutAlertSent = false; // clear bump display in stepguider graph pFrame->pStepGuiderGraph->ShowBump(PHD_Point()); try { if (MoveToCenter()) { throw ERROR_INFO("MoveToCenter() failed"); } } catch (wxString Msg) { POSSIBLY_UNUSED(Msg); bError = true; } return bError; }
IngameWindow::IngameWindow(unsigned int id, const DrawPoint& pos, unsigned short width, unsigned short height, const std::string& title, glArchivItem_Bitmap* background, bool modal, bool closeOnRightClick, Window* parent) : Window(pos, id, parent, width, height), title_(title), background(background), lastMousePos(0, 0), last_down(false), last_down2(false), isModal_(modal), closeme(false), isMinimized_(false), isMoving(false), closeOnRightClick_(closeOnRightClick) { std::fill(button_state.begin(), button_state.end(), BUTTON_UP); contentOffset.x = LOADER.GetImageN("resource", 38)->getWidth(); // left border contentOffset.y = LOADER.GetImageN("resource", 42)->getHeight(); // title bar contentOffsetEnd.x = LOADER.GetImageN("resource", 39)->getWidth(); // right border contentOffsetEnd.y = LOADER.GetImageN("resource", 40)->getHeight(); // bottom bar // For compatibility we treat the given height as the window height, not the content height iwHeight = std::max(0, height - contentOffset.y - contentOffsetEnd.y); // Load last position or center the window if(pos == posLastOrCenter) { if(id < last_pos.size() && last_pos[id].isValid()) Move(last_pos[id]); else MoveToCenter(); } else if(pos == posAtMouse) MoveNextToMouse(); }
/** * Konstruktor von @p IngameWindow. * * @author OLiver */ IngameWindow::IngameWindow(unsigned int id, unsigned short x, unsigned short y, unsigned short width, unsigned short height, const std::string& title, glArchivItem_Bitmap* background, bool modal, bool close_on_right_click) : Window(x, y, id, NULL, width, height), iwHeight(height), title(title), background(background), last_x(0), last_y(0), last_down(false), last_down2(false), modal(modal), closeme(false), minimized(false), move(false), close_on_right_click(close_on_right_click) { memset(button_state, BUTTON_UP, sizeof(ButtonState) * 2); // Load last position or center the window if(x == 0xFFFF) { MoveToCenter(); if(id < MAX_POS_SAVE_ENTRIES) { Point<unsigned short> pos = last_pos[id]; if(pos.x != 0xffff) { Move(pos.x, pos.y); } } } else if(x == 0xFFFE) { MoveNextToMouse(); } }
GAlert::GAlert( GViewI *parent, const char *Title, const char *Text, const char *Btn1, const char *Btn2, const char *Btn3) { GText *t = 0; Children.Insert(t = new GText(-1, 8, 8, -1, -1, (char*)Text)); if (t) { // Setup dialog SetParent(parent); Name((char*)Title); List<GButton> Btns; List<const char> Names; if (Btn1) Names.Insert(Btn1); if (Btn2) Names.Insert(Btn2); if (Btn3) Names.Insert(Btn3); int i = 1, Tx = 0; for (const char *n=Names.First(); n; n=Names.Next()) { GDisplayString ds(SysFont, (char*)n); int x = ds.X(); GButton *v; Btns.Insert(v = new GButton(CMD_BASE + i++, 0, 0, (int) ((30.0f + x) * BTN_SCALE), (int) (20.0f * BTN_SCALE), (char*)n)); Tx += v->X() + ((i>1) ? 10 : 0); } int x = LgiApp->GetMetric(LGI_MET_DECOR_X) + 16; int y = LgiApp->GetMetric(LGI_MET_DECOR_Y) + 20 + 8 + 16; GRect r; if (t) { x += max(Tx, t->X()); y += t->Y(); r.ZOff(x, y); } SetPos(r); MoveToCenter(); // Setup controls int Cx = X() / 2; int Bx = Cx - (Tx / 2); for (GButton *b=Btns.First(); b; b=Btns.Next()) { GRect r; r.ZOff(b->X()-1, b->Y()-1); r.Offset(Bx, t->GetPos().y2 + 8); b->SetPos(r); Children.Insert(b); Bx += b->X() + 10; } } }
GDocApp<OptionsFmt>::GDocApp(const char *appname, const TCHAR *icon, char *optsname) { Options = 0; _LangOptsName = 0; d = new GDocAppPrivate(this, optsname); GRect r(0, 0, 800, 600); SetPos(r); MoveToCenter(); _FileMenu = 0; d->AppName = NewStr(appname?appname:(char*)"Lgi.GDocApp"); char p[MAX_PATH]; if (LgiGetSystemPath(LSP_APP_INSTALL, p, sizeof(p))) { LgiMakePath(p, sizeof(p), p, "_write_test.txt"); GFile f; if (!f.Open(p, O_WRITE)) { d->Mode = InstallDesktop; } else { f.Close(); FileDev->Delete(p, false); } } SetQuitOnClose(true); // Setup class if (icon) { #if defined WIN32 GWin32Class *c = GWin32Class::Create(d->AppName); if (c) { #ifdef UNICODE GPointer p; p.w = (TCHAR*)icon; if (p.i < 0x10000) { c->Class.hIcon = LoadIcon(LgiProcessInst(), MAKEINTRESOURCE(icon)); } else { GAutoWString wIcon(NewStrW(icon)); c->Class.hIcon = LoadIcon(LgiProcessInst(), wIcon); } #else c->Class.hIcon = LoadIcon(LgiProcessInst(), ((NativeInt)icon&0xffff0000)?icon:MAKEINTRESOURCE(icon)); #endif } #else if (icon) SetIcon(icon); #endif } }
GInput::GInput(GViewI *parent, const char *InitStr, const char *Msg, const char *Title, bool Password, GInputCallback callback, void *callbackparam) { Callback = callback; CallbackParam = callbackparam; GText *Txt = new GText(-1, 5, 5, -1, -1, Msg); GDisplayString MsgDs(SysFont, ValidStr(InitStr)?InitStr:"A"); int Dx = LgiApp->GetMetric(LGI_MET_DECOR_X) + 10; int Dy = LgiApp->GetMetric(LGI_MET_DECOR_Y); int ContextX = 400; ContextX = max(ContextX, MsgDs.X() + 40); ContextX = min(ContextX, (int)(GdcD->X() * 0.8)); int EditX = ContextX; int CallbackX = callback ? GBUTTON_MIN_X + 20 : 0; ContextX = max(ContextX, Txt->X() + CallbackX); GRect r(0, 0, ContextX + CallbackX + Dx, 70 + Txt->Y() + Dy); SetParent(parent); Name(Title); SetPos(r); MoveToCenter(); GRect c = GetClient(); Children.Insert(Txt); Children.Insert(Edit = new GEdit(IDC_EDIT, 5, Txt->GetPos().y2 + 5, EditX - 1, MsgDs.Y()+7, InitStr)); if (Edit) { Edit->Password(Password); Edit->Focus(true); if (Callback) { GRect e = Edit->GetPos(); Children.Insert(new GButton(IDC_CALLBACK, c.X() - (CallbackX-5) - 6, e.y1, CallbackX-5, e.Y()-1, "...")); } } GButton *Ok = new GButton(IDOK, 0, 0, -1, -1, LgiLoadString(L_BTN_OK, "Ok")); GButton *Cancel = new GButton(IDCANCEL, 0, 0, -1, -1, LgiLoadString(L_BTN_CANCEL, "Cancel")); int BtnX = max(Ok->X(), Cancel->X()); int BtnY = Edit->GetPos().y2 + 11; GRect p = Cancel->GetPos(); p.x2 = p.x1 + BtnX - 1; p.Offset(c.X() - Cancel->X() - 5, BtnY); Cancel->SetPos(p); p = Ok->GetPos(); p.x2 = p.x1 + BtnX - 1; p.Offset(Cancel->GetPos().x1 - p.X() - 5, BtnY); Ok->SetPos(p); Children.Insert(Ok); Children.Insert(Cancel); Ok->Default(true); }
/****************************************************************************** Function Name : OnCreate Input(s) : lpCreateStruct - Contains the details of window such as width, height, window style. Output : int Functionality : Resizes and Moves the window to the center of its parent Member of : CWaitIndicator Friend of : - Author(s) : Venkatanarayana Makam Date Created : Modifications : ******************************************************************************/ int CWaitIndicator::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) { return -1; } //To resize the window and to move the window to the center of parent MoveToCenter(); return 0; }
App() { Tree = 0; Inc = 0; if (LoadFromResource(IDD_APP)) { MoveToCenter(); GetViewById(IDC_LANG, Inc); } }
void SearchOnGround() { if (CheckPlayerFoundItems()) { if (m_ItemsFound == false) { m_ItemsFound = true; Talk(9); m_timer = 10000; return; } else { //me->DespawnOrUnsummon(0); return; } } switch (m_modus) { case 2: MoveToCenter(); break; case 3: // go to random corner MoveToRandomCorner(); break; case 4: // say searching SearchingOnCorner(); break; case 5: // found break; default: m_modus = 2; break; } }
void WidgetDialog::AutoSize() { const PixelRect parent_rc = GetParentClientRect(); const PixelSize parent_size = parent_rc.GetSize(); PrepareWidget(); // Calculate the minimum size of the dialog PixelSize min_size = widget.Get()->GetMinimumSize(); min_size.cy += GetTitleHeight(); // Calculate the maximum size of the dialog PixelSize max_size = widget.Get()->GetMaximumSize(); max_size.cy += GetTitleHeight(); // Calculate sizes with one button row at the bottom const int min_height_with_buttons = min_size.cy + Layout::GetMaximumControlHeight(); const int max_height_with_buttons = max_size.cy + Layout::GetMaximumControlHeight(); if (/* need full dialog height even for minimum widget height? */ min_height_with_buttons >= parent_size.cy || /* try to avoid putting buttons left on portrait screens; try to comply with maximum widget height only on landscape screens */ (parent_size.cx > parent_size.cy && max_height_with_buttons >= parent_size.cy)) { /* need full height, buttons must be left */ PixelRect rc = parent_rc; if (max_size.cy < parent_size.cy) rc.bottom = rc.top + max_size.cy; PixelRect remaining = buttons.LeftLayout(rc); PixelSize remaining_size = remaining.GetSize(); if (remaining_size.cx > max_size.cx) rc.right -= remaining_size.cx - max_size.cx; Resize(rc.GetSize()); widget.Move(buttons.LeftLayout()); MoveToCenter(); return; } /* see if buttons fit at the bottom */ PixelRect rc = parent_rc; if (max_size.cx < parent_size.cx) rc.right = rc.left + max_size.cx; PixelRect remaining = buttons.BottomLayout(rc); PixelSize remaining_size = remaining.GetSize(); if (remaining_size.cy > max_size.cy) rc.bottom -= remaining_size.cy - max_size.cy; Resize(rc.GetSize()); widget.Move(buttons.BottomLayout()); MoveToCenter(); }
int main(int argc, char *argv[]) { pdr::Controller *controller = pdr::Controller::getInstance(); QApplication app(argc, argv); /* SelectorWindow select_window; select_window.show(); MoveToCenter(select_window) ; app.exec(); */ // below code to make a parser controller->setBGMusic("music/bg_music.mp3"); #if 1 pdr::Frame *frame1 = new pdr::Frame(boost::chrono::milliseconds(5000)) ; // Image demo frame1->addComponent(new pdr::PictureComponent( new QImage("image/walon.jpg"), QPointF(), new pdr::LinearMoveEffect( QPointF(800,0), QPointF(-800,0), boost::chrono::milliseconds(5000)))); // Text demo QFont f ; f.setBold(true); f.setPixelSize(30); frame1->addComponent(new pdr::TextComponent( new pdr::TextItem("Hello",QColor(0,0xff,0,0xff),f), QPointF(), new pdr::LinearMoveEffect( QPointF(800+366,540), QPointF(-800+366,540), boost::chrono::milliseconds(5000)))); //frame1->addComponent(new pdr::TextComponent( // new pdr::TextItem("Hello"))); //frame1->addComponent(new pdr::TextComponent( // new pdr::TextItem("Hello",QColor(0,0xff,0,0xff),f), // QPointF(50,50))); // sound demo //frame1->addComponent(new pdr::SoundComponent("music/oldcarhorn.wav")); frame1->addComponent(new pdr::SoundComponent("music/oldcarhorn.wav", boost::chrono::milliseconds(2000))); pdr::Frame *frame2 = new pdr::Frame(boost::chrono::milliseconds(5000)) ; frame2->addComponent(new pdr::PictureComponent(new QImage("image/walon2.jpg"))); controller->addFrame(frame1); controller->addFrame(frame2); #endif pdr::Frame *frame3 = new pdr::Frame(boost::chrono::milliseconds(15000)) ; frame3->addComponent(new pdr::PictureComponent(new QImage("image/walon3.jpg"), QPointF(), new pdr::RectScrewInOutEffect())); controller->addFrame(frame3); PlayerWindow player_window; pdr::PlayThread p_t ; player_window.show(); MoveToCenter(player_window) ; p_t.start(); app.exec(); //p_t.terminate(); //p_t.quit(); p_t.wait() ; qDebug() <<"WHAT" ; return 0 ; }