void WindowManager::show( TopWindow &rWindow ) const { rWindow.show(); if( isOpacityNeeded() ) rWindow.setOpacity( m_alpha ); }
bool GuiPackageResolver(const String& error, const String& path, int line) { prompt: switch(Prompt(Ctrl::GetAppName(), CtrlImg::exclamation(), error + "&while parsing package " + DeQtf(path), "Edit \\& Retry", "Ignore", "Stop")) { case 0: if(!PromptYesNo("Ignoring will damage package. Everything past the " "point of error will be lost.&Do you want to continue ?")) goto prompt; return false; case 1: { TopWindow win; LineEdit edit; edit.Set(LoadFile(path)); edit.SetCursor(edit.GetPos(line)); win.Title(path); win.Add(edit.SizePos()); win.Run(); SaveFile(path, edit.Get()); } return true;; case -1: exit(1); } return false; }
void AddGUILayout() { String name; TopWindow dlg; dlg.Title(t_("New layout")); dlg.SetRect( GetWorkArea().CenterRect(300, 80) ); EditString s; Button ok, cancel; ok.SetLabel(t_("Add")); ok <<= dlg.Acceptor(IDOK); cancel <<= dlg.Rejector(IDCANCEL); cancel.SetLabel(t_("Cancel")); dlg.ToolWindow(); dlg.Add( s.HSizePosZ(8, 8).TopPosZ(8, 18) ); dlg.Add( ok.RightPosZ(80, 65).BottomPosZ(8, 25) ); dlg.Add( cancel.RightPosZ(8, 65).BottomPosZ(8, 25) ); if (dlg.Execute() == IDCANCEL) return; name = (~s).ToString(); if (name.IsEmpty()) name = t_("User Interface"); name = " " + name; SaveLayout(name); DeleteFile(ConfigFile("Layouts.bin")); StoreToFile(*this, ConfigFile("Layouts.bin")); LoadGUILayouts(); _GUILayouts <<= _GUILayouts.GetKey( _GUILayouts.GetCount() - 1 ); UpdateTools(); }
void GenericLayout::refreshRect( int x, int y, int width, int height ) { // Do nothing if the layout is hidden if( !m_visible ) return; // update the transparency global mask m_pImage->clear( x, y, width, height ); // Draw all the controls of the layout std::list<LayeredControl>::const_iterator iter; for( iter = m_controlList.begin(); iter != m_controlList.end(); ++iter ) { CtrlGeneric *pCtrl = (*iter).m_pControl; if( pCtrl->isVisible() ) { pCtrl->draw( *m_pImage, x, y, width, height ); } } // Refresh the associated window TopWindow *pWindow = getWindow(); if( pWindow ) { // first apply new shape to the window pWindow->updateShape(); pWindow->invalidateRect( x, y, width, height ); } }
void Theme::saveConfig() { msg_Dbg( getIntf(), "saving theme configuration"); map<string, TopWindowPtr>::const_iterator itWin; map<string, GenericLayoutPtr>::const_iterator itLay; ostringstream outStream; for( itWin = m_windows.begin(); itWin != m_windows.end(); itWin++ ) { TopWindow *pWin = itWin->second.get(); // Find the layout id for this window string layoutId; const GenericLayout *pLayout = &pWin->getActiveLayout(); for( itLay = m_layouts.begin(); itLay != m_layouts.end(); itLay++ ) { if( itLay->second.get() == pLayout ) { layoutId = itLay->first; } } outStream << '[' << itWin->first << ' ' << layoutId << ' ' << pWin->getLeft() << ' ' << pWin->getTop() << ' ' << pLayout->getWidth() << ' ' << pLayout->getHeight() << ' ' << (pWin->getVisibleVar().get() ? 1 : 0) << ']'; } // Save config to file config_PutPsz( getIntf(), "skins2-config", outStream.str().c_str() ); }
void GenericLayout::resize( int width, int height ) { // Update the window size m_width = width; m_height = height; // Recreate a new image if( m_pImage ) { delete m_pImage; OSFactory *pOsFactory = OSFactory::instance( getIntf() ); m_pImage = pOsFactory->createOSGraphics( width, height ); } // Notify all the controls that the size has changed and redraw them list<LayeredControl>::const_iterator iter; for( iter = m_controlList.begin(); iter != m_controlList.end(); iter++ ) { iter->m_pControl->onResize(); } // Resize and refresh the associated window TopWindow *pWindow = getWindow(); if( pWindow ) { // Resize the window pWindow->resize( width, height ); refreshAll(); // Change the shape of the window and redraw it pWindow->updateShape(); refreshAll(); } }
void Ctrl::SyncTopWindows() { for(int i = 0; i < topctrl.GetCount(); i++) { TopWindow *w = dynamic_cast<TopWindow *>(topctrl[i]); if(w) w->SyncRect(); } }
void Pdb::ToForeground() { TopWindow *w = GetTopWindow(); if(w && !w->IsForeground()) { LLOG("Setting theide as foreground"); w->SetForeground(); } }
Image SizeGrip::CursorImage(Point p, dword) { if(GuiPlatformHasSizeGrip()) { TopWindow *q = dynamic_cast<TopWindow *>(GetTopCtrl()); if(q && !q->IsMaximized() && q->IsSizeable()) return Image::SizeBottomRight(); } return Image::Arrow(); }
void GenericLayout::onControlRelease( const CtrlGeneric &rCtrl ) { // Just forward the request to the window TopWindow *pWindow = getWindow(); if( pWindow ) { pWindow->onControlRelease( rCtrl ); } }
void CtrlGeneric::notifyTooltipChange() const { TopWindow *pWin = getWindow(); if( pWin ) { // Notify the window pWin->onTooltipChange( *this ); } }
void Ctrl::WndSetPos0(const Rect& rect) { GuiLock __; TopWindow *w = dynamic_cast<TopWindow *>(this); if(w) w->SyncFrameRect(rect); invalid.Add(GetRect()); SetWndRect(rect); invalid.Add(rect); }
void sExecutePrompt(PromptDlgWnd__ *dlg, int *result) { dlg->Open(); Vector<Ctrl *> wins = Ctrl::GetTopWindows(); for(int i = 0; i < wins.GetCount(); i++) { TopWindow *w = dynamic_cast<TopWindow *>(wins[i]); if(w && w->IsTopMost()) { dlg->TopMost(); break; } } *result = dlg->RunAppModal(); }
void SizeGrip::Paint(Draw& w) { Size sz = GetSize(); if(!IsTransparent()) w.DrawRect(sz, SColorFace); if(GuiPlatformHasSizeGrip()) { TopWindow *q = dynamic_cast<TopWindow *>(GetTopCtrl()); if(q && !q->IsMaximized() && q->IsSizeable()) { Size isz = CtrlsImg::SizeGrip().GetSize(); w.DrawImage(sz.cx - isz.cx, sz.cy - isz.cy, CtrlsImg::SizeGrip()); } } }
void TopWindow::FixIcons() { TopWindow *q = GetMainWindow(); if(q) { if(IsNull(icon)) { icon = q->GetIcon(); SyncCaption(); } if(IsNull(largeicon)) { largeicon = q->GetIcon(); SyncCaption(); } } }
int main(int argc, char* argv[]) { QApplication app(argc, argv); TopWindow window; QTime midnight(0, 0, 0); qsrand(midnight.secsTo(QTime::currentTime())); window.setAlgorithm(new Johnson()); window.setWindowTitle(QString::fromUtf8("MPD - projekt 1")); window.setMinimumSize(640, 400); window.show(); return app.exec(); }
void WindowsMenu(Bar& bar) { Vector<Ctrl *> w = Ctrl::GetTopWindows(); int p = 1; for(int i = 0; i < w.GetCount() && p < 10; i++) { TopWindow *q = dynamic_cast<TopWindow *>(w[i]); if(q && !q->GetOwner() && p < 10) { bar.Add(Format("&%d ", p++) + FromUnicode(q->GetTitle(), CHARSET_DEFAULT), callback1(PutForeground, Ptr<Ctrl>(q))) .Check(q->IsForeground()) .Help(t_("Activate this window")); } } if(p >= 10) bar.Add(t_("More windows.."), callback(WindowsList)); }
void WindowManager::setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout ) { rWindow.setActiveLayout( &rLayout ); // Rebuild the dependencies stopMove(); }
void WindowManager::move( TopWindow &rWindow, int left, int top ) const { // Compute the real move offset int xOffset = left - rWindow.getLeft(); int yOffset = top - rWindow.getTop(); // Check anchoring; this can change the values of xOffset and yOffset checkAnchors( &rWindow, xOffset, yOffset ); // Move all the windows WinSet_t::const_iterator it; for( it = m_movingWindows.begin(); it != m_movingWindows.end(); ++it ) { (*it)->move( (*it)->getLeft() + xOffset, (*it)->getTop() + yOffset ); } }
void CtrlSliderBg::handleEvent( EvtGeneric &rEvent ) { if( rEvent.getAsString().find( "mouse:left:down" ) != string::npos ) { // Compute the resize factors float factorX, factorY; getResizeFactors( factorX, factorY ); // Get the position of the control const Position *pPos = getPosition(); // Get the value corresponding to the position of the mouse EvtMouse &rEvtMouse = (EvtMouse&)rEvent; int x = rEvtMouse.getXPos(); int y = rEvtMouse.getYPos(); m_rVariable.set( m_rCurve.getNearestPercent( (int)((x - pPos->getLeft()) / factorX), (int)((y - pPos->getTop()) / factorY) ) ); // Forward the clic to the cursor EvtMouse evt( getIntf(), x, y, EvtMouse::kLeft, EvtMouse::kDown ); TopWindow *pWin = getWindow(); if( pWin && m_pCursor ) { EvtEnter evtEnter( getIntf() ); // XXX It was not supposed to be implemented like that !! pWin->forwardEvent( evtEnter, *m_pCursor ); pWin->forwardEvent( evt, *m_pCursor ); } } else if( rEvent.getAsString().find( "scroll" ) != string::npos ) { int direction = ((EvtScroll&)rEvent).getDirection(); float percentage = m_rVariable.get(); if( direction == EvtScroll::kUp ) { percentage += SCROLL_STEP; } else { percentage -= SCROLL_STEP; } m_rVariable.set( percentage ); } }
int main(int argc, char **argv) { XInitThreads(); QApplication app(argc, argv); /*QGLFormat glf = QGLFormat::defaultFormat(); glf.setAlpha( true ); glf.setSampleBuffers( true ); glf.setSamples( 4 ); QGLFormat::setDefaultFormat( glf );*/ TopWindow *tw = new TopWindow(); tw->show(); return app.exec(); }
void VlcProc::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal ) { (void)p_obj; bool b_fullscreen = getFullscreenVar().get(); if( !b_fullscreen ) { if( newVal.b_bool ) { // Create a raise all command CmdRaiseAll *pCmd = new CmdRaiseAll( getIntf(), getIntf()->p_sys->p_theme->getWindowManager() ); // Push the command in the asynchronous command queue AsyncQueue *pQueue = AsyncQueue::instance( getIntf() ); pQueue->push( CmdGenericPtr( pCmd ) ); } } else { Theme* pTheme = getIntf()->p_sys->p_theme; TopWindow *pWin = pTheme->getWindowById( "fullscreenController" ); if( pWin ) { bool b_visible = pWin->getVisibleVar().get(); AsyncQueue *pQueue = AsyncQueue::instance( getIntf() ); if( !b_visible ) { CmdShowWindow* pCmd = new CmdShowWindow( getIntf(), getIntf()->p_sys->p_theme->getWindowManager(), *pWin ); pQueue->push( CmdGenericPtr( pCmd ) ); } else { CmdHideWindow* pCmd = new CmdHideWindow( getIntf(), getIntf()->p_sys->p_theme->getWindowManager(), *pWin ); pQueue->push( CmdGenericPtr( pCmd ) ); } } } }
void Ctrl::DestroyWnd() { for(int i = 0; i < topctrl.GetCount(); i++) if(topctrl[i]->top && topctrl[i]->top->owner_window == this) topctrl[i]->WndDestroy0(); int q = FindTopCtrl(); if(q >= 0) { AddInvalid(GetRect()); topctrl.Remove(q); } if(top) { delete top; top = NULL; } isopen = false; TopWindow *win = dynamic_cast<TopWindow *>(this); if(win) win->DestroyFrame(); }
void Action() { int rowind = GetCurrentRow(); uint64 bit = (int64)Get(2); if(bit == 0) { TopWindow tw; tw.Title("~~~~~"); Image img = Images::hat; ImageCtrl ic; ic.SetImage(img).SetRect(0, 0, img.GetWidth(), img.GetHeight()); tw.Add(ic); tw.SetRect(::GetMousePos().x - 20, GetMousePos().y - 20, img.GetWidth(), img.GetHeight()); tw.RunAppModal(); return; } bool on = ((Option*)GetList().GetCtrl(0))->Get() == 1; uint64 bits = GetWindowLong((HWND)hwnd, (rowind>3+sizeof(stylesbits)/sizeof(stylesbits[0])) ? GWL_EXSTYLE : GWL_STYLE); if(on) SetBit(bits, bit); else ClearBit(bits, bit); SetWindowLong((HWND)hwnd, (rowind > 3 + sizeof(stylesbits)/sizeof(stylesbits[0])) ? GWL_EXSTYLE : GWL_STYLE, (LONG)bits); RedrawWindow(GetDesktopWindow(), 0, 0, RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_FRAME|RDW_ERASE); RedrawWindow((HWND)hwnd, 0, 0, RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_FRAME|RDW_ERASE); }
void WindowsList() { WithSimpleSelectLayout<TopWindow> d; CtrlLayoutOKCancel(d, t_("Activate window")); d.SetRect(0, 0, 400, 300); d.list.AddColumn(); d.list.NoHeader().NoGrid(); Vector<Ctrl *> w = Ctrl::GetTopWindows(); int p = 0; Vector< Ptr<Ctrl> > ww; for(int i = 0; i < w.GetCount() && p < 10; i++) { TopWindow *q = dynamic_cast<TopWindow *>(w[i]); if(q && !q->GetOwner()) { d.list.Add(q->GetTitle()); ww.Add(q); } } d.list.GoBegin(); if(d.Run() == IDOK && d.list.IsCursor()) { Ctrl *q = ww[d.list.GetCursor()]; if(q) q->SetForeground(); } }
void WindowManager::unmaximize( TopWindow &rWindow ) { // Register the window to allow moving it // registerWindow( rWindow ); // Resize the window // FIXME: Ugly const_cast GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout(); startResize( rLayout, kResizeSE ); resize( rLayout, m_maximizeRect.getWidth(), m_maximizeRect.getHeight() ); stopResize(); // Now move it startMove( rWindow ); move( rWindow, m_maximizeRect.getLeft(), m_maximizeRect.getTop() ); stopMove(); rWindow.m_pVarMaximized->set( false ); }
void WindowManager::maximize( TopWindow &rWindow ) { // Save the current position/size of the window, to be able to restore it m_maximizeRect = SkinsRect( rWindow.getLeft(), rWindow.getTop(), rWindow.getLeft() + rWindow.getWidth(), rWindow.getTop() + rWindow.getHeight() ); SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea(); // Move the window startMove( rWindow ); move( rWindow, workArea.getLeft(), workArea.getTop() ); stopMove(); // Now resize it // FIXME: Ugly const_cast GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout(); startResize( rLayout, kResizeSE ); resize( rLayout, workArea.getWidth(), workArea.getHeight() ); stopResize(); rWindow.m_pVarMaximized->set( true ); // Make the window unmovable by unregistering it // unregisterWindow( rWindow ); }
/// Hide the given window void hide( TopWindow &rWindow ) const { rWindow.hide(); }
void WindowManager::addLayout( TopWindow &rWindow, GenericLayout &rLayout ) { rWindow.setActiveLayout( &rLayout ); }
void WindowManager::resize( GenericLayout &rLayout, int width, int height ) const { // TODO: handle anchored windows // Compute the real resizing offset int xOffset = width - rLayout.getWidth(); int yOffset = height - rLayout.getHeight(); // Check anchoring; this can change the values of xOffset and yOffset checkAnchors( rLayout.getWindow(), xOffset, yOffset ); if( m_direction == kResizeS ) xOffset = 0; if( m_direction == kResizeE ) yOffset = 0; int newWidth = rLayout.getWidth() + xOffset; int newHeight = rLayout.getHeight() + yOffset; // Check boundaries if( newWidth < rLayout.getMinWidth() ) { newWidth = rLayout.getMinWidth(); } if( newWidth > rLayout.getMaxWidth() ) { newWidth = rLayout.getMaxWidth(); } if( newHeight < rLayout.getMinHeight() ) { newHeight = rLayout.getMinHeight(); } if( newHeight > rLayout.getMaxHeight() ) { newHeight = rLayout.getMaxHeight(); } if( newWidth == rLayout.getWidth() && newHeight == rLayout.getHeight() ) { return; } // New offset, after the last corrections int xNewOffset = newWidth - rLayout.getWidth(); int yNewOffset = newHeight - rLayout.getHeight(); // Resize the window TopWindow *pWindow = rLayout.getWindow(); pWindow->resize( newWidth, newHeight ); // Do the actual resizing rLayout.resize( newWidth, newHeight ); // refresh content rLayout.refreshAll(); // Move all the anchored windows WinSet_t::const_iterator it; if( m_direction == kResizeE || m_direction == kResizeSE ) { for( it = m_resizeMovingE.begin(); it != m_resizeMovingE.end(); ++it ) { (*it)->move( (*it)->getLeft() + xNewOffset, (*it)->getTop() ); } } if( m_direction == kResizeS || m_direction == kResizeSE ) { for( it = m_resizeMovingS.begin(); it != m_resizeMovingS.end(); ++it ) { (*it)->move( (*it)->getLeft(), (*it)->getTop( )+ yNewOffset ); } } if( m_direction == kResizeE || m_direction == kResizeS || m_direction == kResizeSE ) { for( it = m_resizeMovingSE.begin(); it != m_resizeMovingSE.end(); ++it ) { (*it)->move( (*it)->getLeft() + xNewOffset, (*it)->getTop() + yNewOffset ); } } }