void ColumnListView::AddSortKey(int32 ColumnIndex) { CLVColumn* Column; if(ColumnIndex >= 0) { Column = (CLVColumn*)fColumnList.ItemAt(ColumnIndex); if(!(Column->Flags()&CLV_SORT_KEYABLE)) return; } else Column = NULL; if(Column && !fSortKeyList.HasItem(Column)) { BWindow* ParentWindow = Window(); if(ParentWindow) ParentWindow->Lock(); BRect LabelBounds = fColumnLabelView->Bounds(); fSortKeyList.AddItem(Column); if(Column->fSortMode == NoSort) SetSortMode(ColumnIndex,Ascending); SortItems(); //Need to draw new underline fColumnLabelView->Invalidate(BRect(Column->fColumnBegin,LabelBounds.top,Column->fColumnEnd, LabelBounds.bottom)); if(ParentWindow) ParentWindow->Unlock(); } }
void QHaikuCursor::changeCursor(QCursor *windowCursor, QWindow *window) { if (!window) return; BWindow *haikuWindow = reinterpret_cast<BWindow*>(window->winId()); // We expect that every BWindow has exactly one BView as child, // so we can use CurrentFocus to retrieve it and call SetViewCursor // to change the cursor for the whole window. if (!windowCursor) { BView *view = haikuWindow->CurrentFocus(); if (view) { view->SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); } } else { const Qt::CursorShape shape = windowCursor->shape(); if (!m_cursors.contains(shape)) m_cursors.insert(shape, new BCursor(m_cursorIds.value(shape))); BView *view = haikuWindow->CurrentFocus(); if (view) { view->LockLooper(); view->SetViewCursor(m_cursors.value(shape)); view->UnlockLooper(); } } }
void TTracker::CloseAllWindows() { // this is a response to the DeskBar sending us a B_QUIT, when it really // means to say close all your windows. It might be better to have it // send a kCloseAllWindows message and have windowless apps stay running, // which is what we will do for the Tracker AutoLock<WindowList> lock(&fWindowList); int32 count = CountWindows(); for (int32 index = 0; index < count; index++) { BWindow *window = WindowAt(index); // avoid the desktop if (!dynamic_cast<BDeskWindow *>(window) && !dynamic_cast<BStatusWindow *>(window)) window->PostMessage(B_CLOSE_REQUESTED); } // count from end to beginning so we can remove items safely for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) { BWindow *window = fWindowList.ItemAt(index); if (!dynamic_cast<BDeskWindow *>(window) && !dynamic_cast<BStatusWindow *>(window)) // ToDo: // get rid of the Remove here, BContainerWindow::Quit does it fWindowList.RemoveItemAt(index); } }
void BToolTipManager::ShowTip(BToolTip* tip, BPoint where, void* owner) { BToolTip* current = NULL; void* currentOwner = NULL; BMessage reply; if (fWindow.SendMessage(kMsgCurrentToolTip, &reply) == B_OK) { reply.FindPointer("current", (void**)¤t); reply.FindPointer("owner", ¤tOwner); } // Release reference from the message if (current != NULL) current->ReleaseReference(); if (current == tip || currentOwner == owner) { fWindow.SendMessage(kMsgShowToolTip); return; } fWindow.SendMessage(kMsgHideToolTip); if (tip != NULL) { BWindow* window = new BPrivate::ToolTipWindow(tip, where, owner); window->Show(); fWindow = BMessenger(window); } }
/*static*/ int32 BMenuBar::_TrackTask(void* arg) { menubar_data data; thread_id id; receive_data(&id, &data, sizeof(data)); BMenuBar* menuBar = data.menuBar; if (data.useRect) menuBar->fExtraRect = &data.rect; menuBar->_SetStickyMode(data.sticky); int32 action; menuBar->_Track(&action, data.menuIndex, data.showMenu); menuBar->fTracking = false; menuBar->fExtraRect = NULL; // We aren't the BWindow thread, so don't call MenusEnded() directly BWindow* window = menuBar->Window(); window->PostMessage(_MENUS_DONE_); _set_menu_sem_(window, B_BAD_SEM_ID); delete_sem(menuBar->fMenuSem); menuBar->fMenuSem = B_BAD_SEM_ID; return 0; }
// --------------------------------------------------------------------- //! Minimizes UI // --------------------------------------------------------------------- void BeSkinView::Minimize() { BWindow* window = Window(); BAutolock locker(window); window->Minimize(true); }
// --------------------------------------------------------------------- //! Restores minimized UI // --------------------------------------------------------------------- void BeSkinView::Restore() { BWindow* window = Window(); BAutolock locker(window); window->Minimize(false); }
int main(int argc, char** argv) { BApplication app("application/x-vnd.Antares-DrawAfterChildren"); BRect frame(100, 100, 700, 400); BWindow* window = new BWindow(frame, "Window", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE); frame.OffsetTo(B_ORIGIN); TestView* view = new TestView(frame); window->AddChild(view); frame.InsetBy(20, 20); frame.right = frame.left + frame.Width() / 2 - 10; BView* child = new ChildView(frame, "child 1", (rgb_color){ 200, 200, 200, 255 }); view->AddChild(child); frame.OffsetBy(frame.Width() + 20, 0); child = new ChildView(frame, "child 2", B_TRANSPARENT_COLOR); view->AddChild(child); window->Show(); app.Run(); return 0; }
// show_window void show_window(BRect frame, const char* name) { BWindow* window = new BWindow(frame, name, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE); BView* view = new TestView(window->Bounds(), "test", B_FOLLOW_ALL, B_WILL_DRAW/* | B_FULL_UPDATE_ON_RESIZE*/); window->AddChild(view); BRect b(0.0, 0.0, 50.0, 15.0); b.OffsetTo(5.0, view->Bounds().bottom - (b.Height() + 15.0)); BButton* control = new BButton(b, "button", "Copy", new BMessage(MSG_COPY_BITS)); view->AddChild(control); control->SetTarget(view); // test CopyBits() on top of children b = BRect(80, 130, 130, 160); BView* child = new BView(b, "some child", B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, 0); child->SetViewColor(255, 0, 0); view->AddChild(child); b = BRect(136, 127, 158, 140); child = new BView(b, "some other child", B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, 0); child->SetViewColor(255, 255, 0); view->AddChild(child); window->Show(); }
void SButton::KeyDown(const char *bytes, int32 numBytes) { if(numBytes == 1) { if(bytes[0] == B_ENTER || bytes[0] == B_RETURN || bytes[0] == B_SPACE) { BWindow *window = Window(); BMessage *msg = window->CurrentMessage(); if(msg) { if(msg->what == B_KEY_DOWN) { int32 key_repeat = 0; if(msg->FindInt32("be:key_repeat", &key_repeat) == B_OK) { if(key_repeat > 0) return; } } } waitting = true; waitting_is_keyboard = true; Draw(Bounds()); window->UpdateIfNeeded(); return; } } BView::KeyDown(bytes, numBytes); }
void SButton::KeyUp(const char *bytes, int32 numBytes) { if(numBytes == 1) { if(bytes[0] == B_ENTER || bytes[0] == B_RETURN || bytes[0] == B_SPACE) { BWindow *window = Window(); BMessage *msg = window->CurrentMessage(); if(msg) { if(msg->what == B_KEY_UP) { int32 key_repeat = 0; if(msg->FindInt32("be:key_repeat", &key_repeat) == B_OK) { if(key_repeat > 0) return; } } } waitting = false; waitting_is_keyboard = false; Invoke(); return; } } BView::KeyUp(bytes, numBytes); }
void SButton::MouseDown(BPoint where) { if(!IsEnabled()) return; BWindow *window = Window(); if(!(window->Flags() & B_AVOID_FOCUS)) window->Activate(); if(tooltips) { BMessage msg(S_TOOLTIPS_CHANGED); msg.AddBool("state", false); BMessenger msgr(NULL, window); msgr.SendMessage(&msg); } if(!waitting_is_keyboard) { waitting = true; DrawDefault(Bounds(), true, window->IsActive()); SetMouseEventMask(B_POINTER_EVENTS, B_SUSPEND_VIEW_FOCUS | B_LOCK_WINDOW_FOCUS); window->UpdateIfNeeded(); } }
void ColumnListView::SetSorting(int32 NumberOfKeys, int32* SortKeys, CLVSortMode* SortModes) { BWindow* ParentWindow = Window(); if(ParentWindow) ParentWindow->Lock(); //Need to remove old sort keys and erase all the old underlines BRect LabelBounds = fColumnLabelView->Bounds(); int32 SortKeyCount = fSortKeyList.CountItems(); for(int32 Counter = 0; Counter < SortKeyCount; Counter++) { CLVColumn* UnderlineColumn = (CLVColumn*)fSortKeyList.ItemAt(Counter); if(UnderlineColumn->fSortMode != NoSort) fColumnLabelView->Invalidate(BRect(UnderlineColumn->fColumnBegin,LabelBounds.top, UnderlineColumn->fColumnEnd,LabelBounds.bottom)); } fSortKeyList.MakeEmpty(); for(int32 Counter = 0; Counter < NumberOfKeys; Counter++) { if(Counter == 0) SetSortKey(SortKeys[0]); else AddSortKey(SortKeys[Counter]); SetSortMode(SortKeys[Counter],SortModes[Counter]); } if(ParentWindow) ParentWindow->Unlock(); }
void ColumnListView::SetSortMode(int32 ColumnIndex,CLVSortMode Mode) { CLVColumn* Column; if(ColumnIndex >= 0) { Column = (CLVColumn*)fColumnList.ItemAt(ColumnIndex); if(!(Column->Flags()&CLV_SORT_KEYABLE)) return; } else return; if(Column->fSortMode != Mode) { BWindow* ParentWindow = Window(); if(ParentWindow) ParentWindow->Lock(); BRect LabelBounds = fColumnLabelView->Bounds(); Column->fSortMode = Mode; if(Mode == NoSort && fSortKeyList.HasItem(Column)) fSortKeyList.RemoveItem(Column); SortItems(); //Need to draw or erase underline fColumnLabelView->Invalidate(BRect(Column->fColumnBegin,LabelBounds.top,Column->fColumnEnd, LabelBounds.bottom)); if(ParentWindow) ParentWindow->Unlock(); } }
// --------------------------------------------------------------------- bool BeSkinView::IsUIActive() const { BWindow* window = Window(); BAutolock locker(window); return window->IsActive(); }
int main(int argc, char ** argv) { BApplication app("application/x-vnd.misza-SystemInfoReplicant"); BRect temp,r; BPath path; find_directory(B_USER_SETTINGS_DIRECTORY,&path); path.Append("SystemInfoReplicant",true); BFile file(path.Path(),B_READ_ONLY); if(file.InitCheck() == B_OK) { BMessage msg; msg.Unflatten(&file); if(msg.FindRect("frame",&temp) == B_OK) r = temp; } else r = BRect(250,250,424,385); BWindow* window = new SIReplicant(r); window->Show(); app.Run(); return 0; }
// --------------------------------------------------------------------- //! Hides UI // --------------------------------------------------------------------- void BeSkinView::Hide() { BWindow* window = Window(); BAutolock locker(window); return window->Hide(); }
int targatobpic( const unsigned char* targa, int targasize, BPicture* picture) { BRect frame(0,0,100,100); // arbitraire BBitmap *bitmap; BView *view; BWindow *window; bitmap=targatobbitmap(targa,targasize); if(!bitmap) return -1; window=new BWindow(frame,NULL,B_MODAL_WINDOW,0); view=new BView(frame,NULL,B_FOLLOW_NONE,0); window->AddChild(view); view->BeginPicture(picture); view->DrawBitmap(bitmap); view->EndPicture(); delete bitmap; delete window; return 0; }
// --------------------------------------------------------------------- bool BeSkinView::IsUIMinimized() const { BWindow* window = Window(); BAutolock locker(window); return window->IsMinimized(); }
bool ProjectWindow::QuitRequested() { if (fShowingLibs) { BString title("Libraries: "); title << fProject->GetName(); for (int32 i = 0; i < be_app->CountWindows(); i++) { BWindow *win = be_app->WindowAt(i); if (title.Compare(win->Title()) == 0) { win->PostMessage(B_QUIT_REQUESTED); break; } } } fProject->Save(); if (fErrorWindow) { fErrorWindow->Quit(); fErrorWindow = NULL; } DeregisterWindow(); return true; }
void AmControlChangeReport::ReadSong(const AmSong* song) { _AmControlEntryCollection entries; const AmTrack* track; for (uint32 k = 0; (track = song->Track(k)); k++) { _AmControlEntry entry(track); control_report(&(track->Phrases()), entry); if (entry.controls.size() > 0) entries.AddEntry(entry); } BRect f(100, 100, 400, 400); BWindow* window = new BWindow( f, "Control Change Report", B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS); if (window) { BOutlineListView* lv = new BOutlineListView( BRect(0, 0, f.Width() - 15, f.Height() - 15), "outline", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL); if (lv) { entries.AddTo(lv); BScrollView* scroll = new BScrollView("scroll", lv, B_FOLLOW_ALL, 0, true, true); if (scroll) window->AddChild(scroll); else window->AddChild(lv); } window->Show(); } }
/** * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). */ static _EGLSurface * haiku_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, void *native_window, const EGLint *attrib_list) { CALLED(); struct haiku_egl_surface* surface; surface = (struct haiku_egl_surface*) calloc(1, sizeof (*surface)); if (!surface) { _eglError(EGL_BAD_ALLOC, "haiku_create_window_surface"); return NULL; } if (!_eglInitSurface(&surface->surf, disp, EGL_WINDOW_BIT, conf, attrib_list)) { free(surface); return NULL; } (&surface->surf)->SwapInterval = 1; TRACE("Creating window\n"); BWindow* win = (BWindow*)native_window; TRACE("Creating GL view\n"); surface->gl = new BGLView(win->Bounds(), "OpenGL", B_FOLLOW_ALL_SIDES, 0, BGL_RGB | BGL_DOUBLE | BGL_ALPHA); TRACE("Adding GL\n"); win->AddChild(surface->gl); TRACE("Showing window\n"); win->Show(); return &surface->surf; }
void BepdfApplication::MessageReceived (BMessage * msg) { if (msg == NULL) { fprintf (stderr, "xpdf: message NULL received\n"); return; } switch (msg->what) { case NOTIFY_QUIT_MSG: if (mWindow) { BWindow* w = mWindow; w->Lock(); w->PostMessage(B_QUIT_REQUESTED); w->Unlock(); } break; case NOTIFY_CLOSE_MSG: if (mWindow) { mWindow->Lock(); mWindow->UpdateWindowsMenu(); mWindow->Unlock(); } break; case B_CANCEL: if (!mWindow && mReadyToQuit) { PostMessage(B_QUIT_REQUESTED); } break; default: BApplication::MessageReceived(msg); } }
// SetExportMode void SavePanel::SetExportMode(bool exportMode) { BWindow* window = Window(); if (!window || !window->Lock()) return; // adjust window title and enable format menu BString helper("Icon-O-Matic: "); if (exportMode) { fFormatMF->SetEnabled(true); SetExportMode(fExportMode); _EnableSettings(); helper << B_TRANSLATE_CONTEXT("Export Icon", "Dialog title"); } else { fExportMode = ExportMode(); // does not overwrite fExportMode in case we already were // in native save mode fNativeMI->SetMarked(true); fFormatMF->SetEnabled(false); fSettingsB->SetEnabled(false); helper << B_TRANSLATE_CONTEXT("Save Icon", "Dialog title"); } window->Unlock(); }
void ImageView::MouseUp(BPoint point) { BWindow *parent = Window(); if (parent) parent->PostMessage(P_MSG_CLOSE); }
void CDoc::PostToAll(unsigned long msg, bool async) { doclist::iterator di; doclist lst = sfDocList; BLooper *me = BLooper::LooperForThread(find_thread(NULL)); for (di = lst.begin(); di != lst.end(); di++) { BWindow *w = dynamic_cast<BWindow*>(*di); if (w) { BMessage reply; if (async || w == dynamic_cast<BWindow*>(me)) w->PostMessage(msg); else { BMessenger msgr(w); FailOSErr(msgr.SendMessage(msg, &reply)); } } } }
BView *BubbleHelper::FindView(BPoint where) { BView *winview=NULL; BWindow *win; long windex=0; while((winview==NULL)&&((win=be_app->WindowAt(windex++))!=NULL)) { if(win!=textwin) { // lock with timeout, in case somebody has a non-running window around // in their app. if(win->LockWithTimeout(1E6)==B_OK) { BRect frame=win->Frame(); if(frame.Contains(where)) { BPoint winpoint; winpoint=where-frame.LeftTop(); winview=win->FindView(winpoint); if(winview) { BRegion region; BPoint newpoint=where; winview->ConvertFromScreen(&newpoint); winview->GetClippingRegion(®ion); if(!region.Contains(newpoint)) winview=0; } } win->Unlock(); } } } return winview; }
// --------------------------------------------------------------------- //! Closes UI window. // --------------------------------------------------------------------- void BeSkinView::CloseUI() { BWindow* window = Window(); BAutolock locker(window); window->PostMessage(B_QUIT_REQUESTED); }
int32 ViewPulserCode (void *PassedInData) { int i; bigtime_t CurrentTime; bigtime_t WakeupTime = 0; BWindow *WindowOfView; CounterView *ViewPntr; ViewPntr = (CounterView *) PassedInData; WindowOfView = ViewPntr->Window (); for (i = 0; i < 20000 && !TimeToDie; i++) { WakeupTime += 10000; WindowOfView->Lock (); ViewPntr->Animate (); WindowOfView->Unlock (); // Go to sleep until the next update time, accounting for // time wasted locking the window. CurrentTime = system_time (); if (WakeupTime < CurrentTime) WakeupTime = CurrentTime; else snooze_until (WakeupTime, B_SYSTEM_TIMEBASE); } return B_OK; // Return code of thread. }
bool ColumnListView::RemoveColumn(CLVColumn* Column) //Removes a CLVColumn from the ColumnListView. Returns true if successful. { if(!fColumnList.HasItem(Column)) return false; int32 ColumnIndex = fSortKeyList.IndexOf(Column); if(ColumnIndex >= 0) fSortKeyList.RemoveItem(ColumnIndex); if(Column->fFlags & CLV_EXPANDER) fExpanderColumn = -1; BWindow* ParentWindow = Window(); if(ParentWindow) ParentWindow->Lock(); //Remove Column from the column and display lists fColumnDisplayList.RemoveItem(Column); fColumnList.RemoveItem(Column); //Tell the column it has been removed Column->fParent = NULL; //Set the scroll bars and tell views to update ColumnsChanged(); if(ParentWindow) ParentWindow->Unlock(); return true; }