예제 #1
0
void CMusikSourcesCtrl::FocusNowPlaying()
{
    KillFocus( false );

    m_Libraries.at( 1 )->Select( TRUE );
    SetFocusedItem( m_Libraries.at( 1 ) );
}
예제 #2
0
void CMusikSourcesCtrl::FocusLibrary()
{
    KillFocus( false );

    m_Libraries.at( 0 )->Select( TRUE );
    SetFocusedItem( m_Libraries.at( 0 ) );
}
예제 #3
0
// Destructor
wxWindowMGL::~wxWindowMGL()
{
    SendDestroyEvent();

    if ( gs_mouseCapture == this )
        ReleaseMouse();

    if (gs_activeFrame == this)
    {
        gs_activeFrame = NULL;
        // activate next frame in Z-order:
        if ( m_wnd->prev )
        {
            wxWindowMGL *win = (wxWindowMGL*)m_wnd->prev->userData;
            win->SetFocus();
        }
        else if ( m_wnd->next )
        {
            wxWindowMGL *win = (wxWindowMGL*)m_wnd->next->userData;
            win->SetFocus();
        }
    }

    if ( gs_focusedWindow == this )
        KillFocus();

    if ( gs_windowUnderMouse == this )
        gs_windowUnderMouse = NULL;

    DestroyChildren();

    if ( m_wnd )
        MGL_wmDestroyWindow(m_wnd);
}
예제 #4
0
void CPWL_Wnd::Destroy() {
  KillFocus();

  OnDestroy();

  if (m_bCreated) {
    for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) {
      if (CPWL_Wnd* pChild = m_aChildren[i]) {
        pChild->Destroy();
        delete pChild;
        pChild = nullptr;
      }
    }

    if (m_sPrivateParam.pParentWnd)
      m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
    m_bCreated = FALSE;
  }

  DestroyMsgControl();

  FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
  m_aChildren.RemoveAll();
  m_pVScrollBar = nullptr;
}
예제 #5
0
void CMusikSourcesCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    m_LockHover = true;

    // user pressed f2 to rename an entry
    if ( nChar == VK_F2 )
    {
        CMusikPropTreeItem* pItem = GetFocusedItem();
        if ( pItem )
        {
            CPoint nPos = pItem->GetLocation();

            CRect rcClient;
            GetClientRect( rcClient );

            CRect rect( 20, nPos.y + 1, rcClient.Width(), nPos.y + PROPTREEITEM_DEFHEIGHT - 2 );

            m_EditInPlace.SetString( pItem->GetLabelText() );
            m_EditInPlace.ShowWindow( SW_SHOWDEFAULT );
            m_EditInPlace.MoveWindow( rect );
            m_EditInPlace.SetFocus();
        }
    }

    // user requested playlist deletion
    if ( nChar == VK_DELETE )
    {
        CMusikPropTreeItem* pItem = GetFocusedItem();
        if ( pItem )
        {
            // type was standard playlist...
            if ( pItem->GetPlaylistType() == MUSIK_PLAYLIST_TYPE_STANDARD )
            {
                int nID = pItem->GetPlaylistID();
                int nPos = -1;
                int nNextPos = -1;

                // find the position...
                for ( size_t i = 0; i < m_StdPlaylists.size(); i++ )
                {
                    if ( m_StdPlaylists.at( i ) == pItem )
                    {
                        nPos = i;

                        if ( nPos == m_StdPlaylists.size() - 1 )
                            nNextPos = nPos - 1;
                        else
                            nNextPos = nPos;

                        break;
                    }
                }

                // if the position is valid, then delete it
                // and reload the playlists...
                if ( nPos != -1 )
                {
                    m_Library->DeleteStdPlaylist( nID );
                    LoadStdPlaylists();

                    // now select the next entry in the
                    // list... if -1 select the library...
                    KillFocus( false );
                    if ( nNextPos == -1 )
                    {
                        m_Libraries.at( 0 )->Select( TRUE );
                        SetFocusedItem( m_Libraries.at( 0 ) );
                        int WM_SOURCESLIBRARY = RegisterWindowMessage( "SOURCESLIBRARY" );
                        m_Parent->SendMessage( WM_SOURCESLIBRARY, NULL );
                    }
                    else
                    {
                        m_StdPlaylists.at( nNextPos )->Select( TRUE );
                        SetFocusedItem( m_StdPlaylists.at( nNextPos  ) );
                        int WM_SOURCESSTDPLAYLIST = RegisterWindowMessage( "SOURCESSTDPLAYLIST" );
                        m_Parent->SendMessage( WM_SOURCESSTDPLAYLIST, NULL );
                    }

                    Invalidate();

                }
            }
        }
    }

    m_LockHover = false;
}
예제 #6
0
void CMusikSourcesCtrl::OnDropFiles(HDROP hDropInfo)
{
    // set cursor back to hour glass
    SetCursor( LoadCursor( NULL, IDC_WAIT ) );

    // see if the drag landed on an existing
    // playlist, if it did, we'll append
    CPoint pos;
    ::GetCursorPos( &pos );
    ScreenToClient( &pos );

    CMusikPropTreeItem* pItem = FindItem( pos );

    // make sure the item isn't root
    if ( pItem != NULL && pItem->IsRootLevel() )
        return;

    if ( pItem )
    {
        KillFocus();
        pItem->Select( TRUE );
        SetFocusedItem( pItem );
    }

    // dnd stuff
    size_t nNumFiles;
    TCHAR szNextFile [MAX_PATH];
    SHFILEINFO  rFileInfo;

    nNumFiles = DragQueryFile ( hDropInfo, -1, NULL, 0 );
    CStdStringArray files;

    CStdString sTemp;
    for ( size_t i = 0; i < nNumFiles; i++ )
    {
        if ( DragQueryFile( hDropInfo, i, szNextFile, MAX_PATH ) > 0 )
        {
            // get the filetype. if its a directory
            // that was dropped, we'll want to
            // recurse it and add all the supported
            // media files...
            SHGetFileInfo( szNextFile, 0, &rFileInfo, sizeof( rFileInfo ), SHGFI_ATTRIBUTES );
            if ( rFileInfo.dwAttributes & SFGAO_FOLDER )
            {
                sTemp = szNextFile;
                sTemp += "\\*.*";

                m_Dir.m_Dir = sTemp;
                m_Dir.m_Threaded = false;
                m_Dir.m_Target = &files;

                m_Dir.Run();
            }

            // otherwise it was just a file... add it...
            else
                files.push_back( szNextFile );
        }

    }

    DragFinish( hDropInfo );

    // did we actually hit an item?
    if ( pItem )
    {
        // standard playlist
        if ( pItem->GetPlaylistType() == MUSIK_PLAYLIST_TYPE_STANDARD )
            m_Library->AppendStdPlaylist( pItem->GetPlaylistID(), files );

        // hit now playing?
        else if ( pItem->GetPlaylistType() == MUSIK_SOURCES_TYPE_NOWPLAYING )
        {
            m_Library->BeginTransaction();
            CMusikSong song;
            for ( size_t i = 0; i < files.size(); i++ )
            {
                // add song (if necessary)
                m_Library->AddSong( files.at( i ) );

                m_Library->GetSongFromFilename( files.at( i ), song );
                m_Player->GetPlaylist()->Add( song );
            }
            m_Library->EndTransaction();
        }
    }

    // else make a new playlist
    else
    {
        CStdString playlist_str;
        playlist_str.Format( _T( "New Playlist %d" ), m_StdPlaylists.size() );
        m_Library->CreateStdPlaylist( playlist_str.c_str(), files );
        LoadStdPlaylists();
    }

    // didn't hit an item, a new
    // playlist was created, so it
    // was pushed to the back of the list
    if ( !pItem )
    {
        pItem = m_StdPlaylists.at( m_StdPlaylists.size() - 1 );

        // focus
        KillFocus();
        pItem->Select( TRUE );
        SetFocusedItem( pItem );
    }

    if ( pItem )
        SendNotify( PTN_SELCHANGE, pItem );
}
예제 #7
0
static intptr_t WINAPI MainDialogProc(HANDLE hDlg,intptr_t Msg,intptr_t Param1,void* Param2)
{
  BoardParams* DlgParams=(BoardParams*)Info.SendDlgMessage(hDlg,DM_GETDLGDATA,0,0);
  //if(Msg==DN_KEY&&Param2==KEY_ENTER) return TRUE;
  switch(Msg)
  {
    case DN_INITDIALOG:
      Info.SendDlgMessage(hDlg,DM_RESETBOARD,0,0);
      SetFocus(true);
      break;
    case DN_CONTROLINPUT:
      {
        const INPUT_RECORD* record=(const INPUT_RECORD*)Param2;
        if(record->EventType==KEY_EVENT&&record->Event.KeyEvent.bKeyDown)
        {
          KillFocus();
          if(IsNone(record))
          {
            switch(record->Event.KeyEvent.wVirtualKeyCode)
            {
              case VK_UP:
                DlgParams->curr_col--;
                break;
              case VK_DOWN:
                DlgParams->curr_col++;
                break;
              case VK_LEFT:
                DlgParams->curr_row--;
                break;
              case VK_RIGHT:
                DlgParams->curr_row++;
                break;
              case VK_HOME:
                DlgParams->curr_row=0;
                break;
              case VK_END:
                DlgParams->curr_row=DlgParams->width-1;
                break;
              case VK_PRIOR:
                DlgParams->curr_col=0;
                break;
              case VK_NEXT:
                DlgParams->curr_col=DlgParams->height-1;
                break;
              case L' ':
                {
                  Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
                  if(!DlgParams->finished)
                  {
                    if(!DlgParams->started) Info.SendDlgMessage(hDlg,DM_START_GAME,0,0);
                    OpenPlace(hDlg,DlgParams,DlgParams->curr_row,DlgParams->curr_col,COP_CHECK_ALL);
                  }
                  Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
                }
                break;
              case VK_DELETE:
                {
                  Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
                  if(!DlgParams->finished)
                  {
                    FarDialogItem DialogItem;
                    Info.SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,DlgParams->width*DlgParams->curr_col+DlgParams->curr_row,&DialogItem);
                    switch(GET_DATA_1(DialogItem))
                    {
                      case STATE_CLOSE:
                        SET_DATA_1(DialogItem,STATE_MARKED);
                        DlgParams->curr_mines++;
                        break;
                      case STATE_OPEN:
                        break;
                      case STATE_MARKED:
                        SET_DATA_1(DialogItem,STATE_CLOSE);
                        DlgParams->curr_mines--;
                        break;
                    }
                    Info.SendDlgMessage(hDlg,DM_SETDLGITEMSHORT,DlgParams->width*DlgParams->curr_col+DlgParams->curr_row,&DialogItem);
                    Info.SendDlgMessage(hDlg,DM_SHOWTIME,0,0);
                  }
                  Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
                }
                break;
              case VK_F2:
                DlgParams->started=false;
                DlgParams->finished=FINISH_NO;
                Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,DlgParams->width*DlgParams->height,const_cast<wchar_t*>(GetMsg(mStart)));
                Info.SendDlgMessage(hDlg,DM_RESETBOARD,0,0);
                break;
              case VK_F3:
                {
                  wchar_t ScoreKeyName[1024],PlayerKeyName[1024];
                  FSF.sprintf(ScoreKeyName,L"Score_%d_%d_%d",DlgParams->width,DlgParams->height,DlgParams->mines);
                  FSF.sprintf(PlayerKeyName,L"Player_%d_%d_%d",DlgParams->width,DlgParams->height,DlgParams->mines);
                  CFarSettings settings(MainGuid);
                  __int64 Score; wchar_t Name[512];
                  Score=settings.Get(ScoreKeyName,-1);
                  if(!settings.Get(PlayerKeyName,Name,sizeofa(Name))) Name[0]=0;
                  if(Score>=0&&Name[0])
                  {
                    wchar_t buffer[1024];
                    FSF.sprintf(buffer,GetMsg(mHighscoreFormat),Name,(long)Score);
                    const wchar_t* MsgItems[]={GetMsg(mHighscoreTitle),buffer,GetMsg(mOk)};
                    Info.Message(&MainGuid,&HiscoreGuid,0,NULL,MsgItems,sizeofa(MsgItems),1);
                  }
                }
                break;
            }
          }
          if(DlgParams->curr_row>=DlgParams->width) DlgParams->curr_row=0;
          if(DlgParams->curr_row<0) DlgParams->curr_row=DlgParams->width-1;
          if(DlgParams->curr_col>=DlgParams->height) DlgParams->curr_col=0;
          if(DlgParams->curr_col<0) DlgParams->curr_col=DlgParams->height-1;
          SetFocus(true);
          Info.SendDlgMessage(hDlg,DM_REDRAW,0,0);
        }
        else if(record->EventType==MOUSE_EVENT)
        {
          DWORD Buttons=record->Event.MouseEvent.dwButtonState;
          if(Buttons&FROM_LEFT_1ST_BUTTON_PRESSED) RunKey(L"Keys([[Space]])");
          else if(Buttons&RIGHTMOST_BUTTON_PRESSED) RunKey(L"Keys([[Del]])");
        }
      }
      break;
    case DN_GOTFOCUS:
      SetFocus(false);
      break;
    case DN_KILLFOCUS:
      KillFocus();
      break;
    case DM_RESETBOARD:
      {
        int curr_mines=DlgParams->mines,color;
        FarDialogItem DialogItem;
        Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,FALSE,0);
        for(int i=0;i<DlgParams->height;i++)
          for(int j=0;j<DlgParams->width;j++)
          {
            int k=i*DlgParams->width+j;
            Info.SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,k,&DialogItem);
            SET_DATA_0(DialogItem,0);
            SET_DATA_1(DialogItem,0);
            color=0;
            DialogItem.VBuf[1].Char=GetChar(GET_DATA_0(DialogItem),GET_DATA_1(DialogItem),&color);
            int bgcolor=GetBG(i,j,STATE_CLOSE);
            DialogItem.VBuf[0].Attributes.ForegroundColor=DialogItem.VBuf[1].Attributes.ForegroundColor=DialogItem.VBuf[2].Attributes.ForegroundColor=color;
            DialogItem.VBuf[0].Attributes.BackgroundColor=DialogItem.VBuf[1].Attributes.BackgroundColor=DialogItem.VBuf[2].Attributes.BackgroundColor=bgcolor;
            Info.SendDlgMessage(hDlg,DM_SETDLGITEMSHORT,k,&DialogItem);
          }
        //set mines
        while(curr_mines)
          for(int i=0;i<DlgParams->height;i++)
            for(int j=0;j<DlgParams->width;j++)
            {
              int k=i*DlgParams->width+j;
              Info.SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,k,&DialogItem);
              if(curr_mines&&(!GET_DATA_0(DialogItem)))
              {
                if(rand()<=(RAND_MAX*DlgParams->mines/(DlgParams->width*DlgParams->height)))
                {
                  curr_mines--;
                  SET_DATA_0(DialogItem,9);
                  Info.SendDlgMessage(hDlg,DM_SETDLGITEMSHORT,k,&DialogItem);
                }
              }
            }
        //set places
        for(int i=0;i<DlgParams->height;i++)
          for(int j=0;j<DlgParams->width;j++)
          {
            int k=i*DlgParams->width+j;
            Info.SendDlgMessage(hDlg,DM_GETDLGITEMSHORT,k,&DialogItem);
            if(GET_DATA_0(DialogItem)==0)
            {
              SET_DATA_0(DialogItem,GET_DATA_0(DialogItem)+GetMine(j-1,i-1,hDlg,DlgParams,false));
              SET_DATA_0(DialogItem,GET_DATA_0(DialogItem)+GetMine(j-1,i,hDlg,DlgParams,false));
              SET_DATA_0(DialogItem,GET_DATA_0(DialogItem)+GetMine(j-1,i+1,hDlg,DlgParams,false));
              SET_DATA_0(DialogItem,GET_DATA_0(DialogItem)+GetMine(j,i-1,hDlg,DlgParams,false));
              SET_DATA_0(DialogItem,GET_DATA_0(DialogItem)+GetMine(j,i+1,hDlg,DlgParams,false));
              SET_DATA_0(DialogItem,GET_DATA_0(DialogItem)+GetMine(j+1,i-1,hDlg,DlgParams,false));
              SET_DATA_0(DialogItem,GET_DATA_0(DialogItem)+GetMine(j+1,i,hDlg,DlgParams,false));
              SET_DATA_0(DialogItem,GET_DATA_0(DialogItem)+GetMine(j+1,i+1,hDlg,DlgParams,false));
              Info.SendDlgMessage(hDlg,DM_SETDLGITEMSHORT,k,&DialogItem);
            }
          }
        DlgParams->curr_mines=0;
        Info.SendDlgMessage(hDlg,DM_SHOWTIME,0,0);
        Info.SendDlgMessage(hDlg,DM_ENABLEREDRAW,TRUE,0);
      }
      break;
    case DN_ENTERIDLE:
      Info.SendDlgMessage(hDlg,DM_SHOWTIME,0,0);
      break;
    case DM_SHOWTIME:
      {
        wchar_t buffer[1024]; DWORD diff_time=DlgParams->started?((DlgParams->finished?DlgParams->end_time:GetTickCount())-DlgParams->start_time)/1000:0;
        FSF.sprintf(buffer,GetMsg(mTime),diff_time,DlgParams->curr_mines);
        Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,DlgParams->width*DlgParams->height+1,buffer);
      }
      break;
    case DM_START_GAME:
      Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,DlgParams->width*DlgParams->height,const_cast<wchar_t*>(GetMsg(mGame)));
      DlgParams->started=true;
      DlgParams->start_time=GetTickCount();
      break;
  }
  return Info.DefDlgProc(hDlg,Msg,Param1,Param2);
}