bool BListView::_Deselect(int32 index) { if (index < 0 || index >= CountItems()) return false; BWindow *window = Window(); BAutolock locker(window); if (window && !locker.IsLocked()) return false; BListItem *item = ItemAt(index); if (item && item->IsSelected()) { BRect frame(ItemFrame(index)); BRect bounds(Bounds()); item->Deselect(); if (fFirstSelected == index && fLastSelected == index) { fFirstSelected = -1; fLastSelected = -1; } else { if (fFirstSelected == index) fFirstSelected = _CalcFirstSelected(index); if (fLastSelected == index) fLastSelected = _CalcLastSelected(index); } if (window && bounds.Intersects(frame)) DrawItem(ItemAt(index), frame, true); } return true; }
void THeaderView::ReSize(void) { long height; float width; if (fIncoming) height = MIN_HEADER_HEIGHT; else height = HEADER_HEIGHT; if (fWidth != (width = Window()->Frame().Width())) { if (fWidth < width) { SetHighColor(VIEW_COLOR, VIEW_COLOR, VIEW_COLOR); StrokeLine(BPoint(fWidth, 1), BPoint(fWidth, height - 2)); } else { SetHighColor(120, 120, 120); StrokeLine(BPoint(width, 1), BPoint(width, height - 2)); } fWidth = width; } }
//: Called if the target is moved. // The current implemenation is empty. void CMDITitleView::TargetMoved(BPoint point) { // The following code is useless. CMDIClientView::MoveViewTo // automatically moves TitleView AND target view. #if 0 // If someone calls Hide() on the target, the target gets a frame moved // event. It calls TargetMoved() of this view. But the passed coordinates // are meaningless. They are VERY BIG random numbers. Therefore I ignore // that message. This seems like YET ANOTHER BEOS BUG! if(!target->IsHidden()) { // There is a documentation bug in the BeBook. // The point passed in FrameMoved is in window, not in parent, coordinates! point -= Parent()->Bounds().LeftTop(); Window()->ConvertToScreen(&point); Parent()->ConvertFromScreen(&point); CMDIClientView *client = dynamic_cast<CMDIClientView *>(Parent()); client->MoveViewTo(this, point.x, point.y-Bounds().Height()); } #endif // 0 }
void URLView::MouseDown( BPoint point ) { // If the link isn't enabled, don't do anything. if( !IsEnabled() ) return; // See which mouse buttons were clicked. int32 buttons = Window()->CurrentMessage()->FindInt32( "buttons" ); // We want to highlight the text if the user clicks on // the URL. We want to be sure to only register a click // if the user clicks on the link text itself and not just // anywhere in the view. if( GetTextRect().Contains( point ) ) { SetHighColor( clickColor ); Redraw(); // Set the link as selected and track the mouse. selected = true; SetMouseEventMask( B_POINTER_EVENTS ); // Remember where the user clicked so we can correctly // offset the transparent URL if the user drags. BRect frame = Frame(); frame.OffsetTo( B_ORIGIN ); dragOffset = point; if( Alignment() == B_ALIGN_RIGHT ) { dragOffset.x -= frame.Width() - StringWidth( Text() ); } else if( Alignment() == B_ALIGN_CENTER ) { dragOffset.x -= (frame.Width() / 2) - (StringWidth( Text() ) / 2); } // Pop up the context menu? if( buttons == B_SECONDARY_MOUSE_BUTTON ) inPopup = true; } }
bool ColumnListView::SetDisplayOrder(const int32* ColumnOrder) //Sets the display order using a BList of CLVColumn's { BWindow* ParentWindow = Window(); if(ParentWindow) ParentWindow->Lock(); //Add the items to the display list in order fColumnDisplayList.MakeEmpty(); int32 ColumnsToSet = fColumnList.CountItems(); for(int32 Counter = 0; Counter < ColumnsToSet; Counter++) { if(ColumnOrder[Counter] >= ColumnsToSet) { if(ParentWindow) ParentWindow->Unlock(); return false; } for(int32 Counter2 = 0; Counter2 < Counter; Counter2++) if(ColumnOrder[Counter] == ColumnOrder[Counter2]) { if(ParentWindow) ParentWindow->Unlock(); return false; } fColumnDisplayList.AddItem(fColumnList.ItemAt(ColumnOrder[Counter])); } //Update everything about the columns ColumnsChanged(); //Let the program know that the display order changed. if(ParentWindow) ParentWindow->Unlock(); DisplayOrderChanged(ColumnOrder); return true; }
void ScrolledListView::MouseDown(BPoint point) { int32 clicks; Window()->CurrentMessage()->FindInt32("clicks", &clicks); Activate(); if (!IsFocus()) MakeFocus(); int32 newSelection = (int) (point.y / ItemHeight()); if (newSelection < 0 || newSelection >= NumItems()) newSelection = -1; // double-click opens if (selection == newSelection && selection >= 0 && clicks > 1) OpenSelectedItem(selection); // first click selects, maybe moves else { Select(newSelection); if (CanRearrange()) TrackRearrangement(point); } }
void HTGListView::MouseDown(BPoint point) { BListView::MouseDown(point); int index = CurrentSelection(); if(index < 0) return; HTGTweetItem* clickedItem = (HTGTweetItem*)ItemAt(index); if(clickedItem == NULL) return; int32 buttons; Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0) { clickedItem->LeftClicked(point, this, ItemFrame(index)); } else if((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { clickedItem->RightClicked(point, this, ItemFrame(index)); } }
/* * drawButton() draws a button. */ void drawButton(void *obj, void *w) { int highlight = 0; int boxcolor; int objcolor; WINDOW* win = Window(w); int x = WX(w), y = WY(w); if (obj == 0 || objType(obj) != O_BUTTON) return; x += OBJ(obj)->dtx; y += OBJ(obj)->dty; boxcolor = IS_CURRENT(obj) ? ACTIVE_COLOR : WINDOW_COLOR; objcolor = BUTTON_COLOR | (OBJ_READONLY(obj) ? READONLY_COLOR : 0); wmove(win, y, x-1); setcolor(win, boxcolor); waddch(win, '['); highlight = (OBJ(obj)->content && *((int*)(OBJ(obj)->content)) != 0); getyx(win,y,x); if (OBJ(obj)->flags & OBJ_CLICKED) { setcolor(win, PRESSED_COLOR); waddstr(win, OBJ(obj)->title); } else { setcolor(win, IS_CURRENT(obj) ? (objcolor|CURRENT_COLOR) : objcolor); waddstr(win,OBJ(obj)->title); } setcolor(win, boxcolor); waddch(win, ']'); wmove(win,y,x); } /* drawButton */
void ArpTwoStateButton::Draw(BRect clip) { inherited::Draw(clip); drawing_mode mode = DrawingMode(); SetDrawingMode(B_OP_ALPHA); SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); bool state = (mDrawFromSwitched) ? mSwitched : mPressed; if( state && mBmPressed ) { BRect r( clip ); BRect b( mBmPressed->Bounds() ); if( r.right > b.right ) r.right = b.right; if( r.bottom > b.bottom ) r.bottom = b.bottom; DrawBitmapAsync( mBmPressed, r, r ); } else if( !state && mBmNormal ) { BRect r( clip ); BRect b( mBmNormal->Bounds() ); if( r.right > b.right ) r.right = b.right; if( r.bottom > b.bottom ) r.bottom = b.bottom; DrawBitmapAsync( mBmNormal, r, r ); } if (Window()) Sync(); SetDrawingMode(mode); }
// ----------------------------------------------------------------------------- // CAafAppCameraView::SizeChanged() // Called by framework when the view size is changed. // ----------------------------------------------------------------------------- // void CAafAppCameraView::SizeChanged() { __LOGSTR_TOFILE("CAafAppCameraView::SizeChanged() begins"); #if USE_SKIN_SUPPORT if(iBgContext) { iBgContext->SetRect(Rect()); if ( &Window() ) { iBgContext->SetParentPos( PositionRelativeToScreen() ); } } #endif if ( iContainer ) { CAafAppUi* appUi = (CAafAppUi*)iCoeEnv->AppUi(); iContainer->SetRect( appUi->ClientRect() ); } __LOGSTR_TOFILE("CAafAppCameraView::SizeChanged() ends"); }
void AmTrackDataView::MouseMoved( BPoint where, uint32 code, const BMessage *a_message) { /* Sometimes, this view might not receive a mouse up for * whatever reason, which can cause the scroll runner to * lock into permanent autoscroll. This simply makes sure * the scroll runner has been deleted if it's not valid. */ int32 button; if (Window()->CurrentMessage()->FindInt32("buttons", &button) != B_OK) button = 0; if (button == 0) MouseCleanup(where); if (!mTarget) return; /* There is a bug that seems to be caused by the ArpBitmapCache * stuff, which causes the view to continually receive MouseMoved() * events, even when the mouse is not moving (note that this does not * always occur, it seems more frequent on some systems then others). * This doesn't seem to be a problem in R6, although I'm not entirely * certain about that. */ if (mLastPt == where) return; mLastPt = where; if (button != 0) { // WRITE TOOL BLOCK AmTool* tool = mActiveTool.WriteLock(); if (tool) { tool->MouseMoved(mSongRef, mTarget, where, code); if (mToolGraphic && tool->Id() == mToolGraphic->OwnerId() ) mToolGraphic->MouseMoved(where, code); } mActiveTool.WriteUnlock(tool); // END WRITE TOOL BLOCK } if (mToolControls) mToolControls->MouseMoved(this, where); }
void SeqMeasureControl::ShowTimeSignatureMenu(BPoint pt) const { AmSignature sig; if (SignatureForPt(pt, sig) != B_OK) return; BPopUpMenu* menu = new BPopUpMenu("menu"); if (!menu) return; menu->SetFontSize(10); menu->SetAsyncAutoDestruct(true); BMessage signatureChoices; if (seq_get_message_preference(SIGNATURE_CHOICES_PREF, &signatureChoices) == B_OK) { int32 beats; for(int32 k = 0; signatureChoices.FindInt32("beats", k, &beats) == B_OK; k++) { int32 beatvalue; if (signatureChoices.FindInt32("beat value", k, &beatvalue) == B_OK) { BString label; label << beats << " / " << beatvalue; BMessage* msg = new BMessage(CHANGE_SIGNATURE_MSG); BMenuItem* item; if (msg && (item = new BMenuItem(label.String(), msg)) ) { msg->AddInt32("measure", sig.Measure() ); msg->AddInt32("beats", beats); msg->AddInt32("beat value", beatvalue); menu->AddItem(item); item->SetTarget(this); } } } } BMessage* msg = new BMessage(CHANGE_SIGNATURE_MSG); BMenuItem* item; if ( msg && (item = new BMenuItem("Other...", msg)) ) { msg->AddInt32("measure", sig.Measure() ); msg->AddInt32("beats", sig.Beats() ); msg->AddInt32("beat value", sig.BeatValue() ); menu->AddItem(item); item->SetTarget( Window() ); } /* If I'm a track measure control, add in my motion list. */ BMenu* motionMenu = NULL; if (mTrackWinProps && (motionMenu = new BMenu("Motion")) ) { BMessage* msg = new BMessage(CHANGE_MOTION_MSG); BMenuItem* item; if (msg && (item = new BMenuItem(NONE_STR, msg)) ) { msg->AddInt32("code", MOTION_NONE); msg->AddInt32("measure", sig.Measure() ); motionMenu->AddItem(item); item->SetTarget(this); } msg = new BMessage(CHANGE_MOTION_MSG); if (msg && (item = new BMenuItem(CLEAR_STR, msg)) ) { msg->AddInt32("code", MOTION_CLEAR); msg->AddInt32("measure", sig.Measure() ); motionMenu->AddItem(item); item->SetTarget(this); } BString label, key; for (uint32 k = 0; AmGlobals().GetMotionInfo(k, label, key) == B_OK; k++) { msg = new BMessage(CHANGE_MOTION_MSG); if (msg && (item = new BMenuItem(label.String(), msg)) ) { if (k == 0) motionMenu->AddSeparatorItem(); msg->AddString(MOTION_KEY_STR, key); msg->AddInt32("measure", sig.Measure() ); motionMenu->AddItem(item); item->SetTarget(this); } } if (motionMenu) { menu->AddSeparatorItem(); BMenuItem* i = new BMenuItem(motionMenu); if (i) menu->AddItem(i); } } BRect frame(pt, pt); menu->Go( ConvertToScreen(pt), true, false, ConvertToScreen(frame), true); }
void ActivityView::MouseDown(BPoint where) { int32 buttons = B_SECONDARY_MOUSE_BUTTON; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); if (buttons == B_PRIMARY_MOUSE_BUTTON) { fZoomPoint = where; fOriginalResolution = fDrawResolution; fZooming = true; SetMouseEventMask(B_POINTER_EVENTS); return; } BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); BMenu* additionalMenu = new BMenu(B_TRANSLATE("Additional items")); additionalMenu->SetFont(be_plain_font); SystemInfo info; BMenuItem* item; for (int32 i = 0; i < DataSource::CountSources(); i++) { const DataSource* source = DataSource::SourceAt(i); if (source->MultiCPUOnly() && info.CPUCount() == 1) continue; BMessage* message = new BMessage(kMsgToggleDataSource); message->AddInt32("index", i); item = new BMenuItem(source->Name(), message); if (FindDataSource(source)) item->SetMarked(true); if (source->Primary()) menu->AddItem(item); else additionalMenu->AddItem(item); } menu->AddItem(new BMenuItem(additionalMenu)); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show legend"), new BMessage(kMsgToggleLegend))); item->SetMarked(fShowLegend); menu->SetTargetForItems(this); additionalMenu->SetTargetForItems(this); ActivityWindow* window = dynamic_cast<ActivityWindow*>(Window()); if (window != NULL && window->ActivityViewCount() > 1) { menu->AddSeparatorItem(); BMessage* message = new BMessage(kMsgRemoveView); message->AddPointer("view", this); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove graph"), message)); item->SetTarget(window); } ConvertToScreen(&where); menu->Go(where, true, false, true); }
void BatteryInfoView::AttachedToWindow() { Window()->CenterOnScreen(); }
// ------------------------------------------------------------------- // * Protected Methods // ------------------------------------------------------------------- void GDView::MessageReceived(BMessage* theMessage) { WGAxisEditWind* editWind; BRect frame; BMessenger* theMessenger; BMessage axisMesg; int32 colorVal; int16 markVal; const char* labelStr; switch ( theMessage->what ){ case WGAxisEditWind::class_ID : if(theMessage->FindMessage(x_axis_name,&axisMesg) == B_OK) { labelStr = axisMesg.FindString(axis_label); if(labelStr != NULL) { mGraph->SetXLabel(labelStr); } mGraph->mXAxis->SetValues(&axisMesg); } axisMesg.MakeEmpty(); if(theMessage->FindMessage(y_axis_name,&axisMesg) == B_OK) { labelStr = axisMesg.FindString(axis_label); if(labelStr != NULL) { mGraph->SetYLabel(labelStr); } mGraph->mYAxis->SetValues(&axisMesg); } if(theMessage->FindInt32(plot_color_name,&colorVal) == B_OK) { mGraph->SetPlotColor(::ValueToColor(colorVal)); } if(theMessage->FindInt16(plot_mark_name,&markVal) == B_OK) { mGraph->SetPlotMark((EPlotMark)markVal); } mGraph->ForceReDraw(); break; case G_erase_data: mData.ClearData(); Reset(); break; case G_reset_axes : SetGraphAxis(mGraph->mXAxis,scale_linear); SetGraphAxis(mGraph->mYAxis,scale_linear); mGraph->ForceReDraw(); break; case G_invalidate : Reset(); break; case G_set_params: int16 theParam; if((theMessage->FindInt16(pName,&theParam) == B_OK) && (theParam != mData.GetFitParams())) { mData.SetFitParams(theParam); Reset(); } break; case G_change_axis: frame = Window()->Frame(); frame.top = frame.bottom; frame.left = frame.right; editWind = new WGAxisEditWind(frame); editWind->SetXDefaults(mGraph->mXAxis); editWind->SetYDefaults(mGraph->mYAxis); editWind->SetXLabel(mGraph->GetXLabel()); editWind->SetYLabel(mGraph->GetYLabel()); editWind->SetPlotMarkDefault(mGraph->PlotMark()); editWind->SetPlotColorDefault(mGraph->PlotColor()); // Set messenger here theMessenger = new BMessenger(this); editWind->SetTarget(theMessenger); break; default : this->BView::MessageReceived(theMessage); } }
void BochsView::KeyDown(const char *bytes, int32 numBytes) { BMessage *msg; //int32 key; int32 modifiers; uint8 byte; msg = Window()->CurrentMessage(); if (!msg) { BX_DEBUG(("keydown() msg NULL")); return; } modifiers = msg->FindInt32("modifiers"); #if 0 B_SHIFT_KEY = 0x00000001, B_COMMAND_KEY = 0x00000002, B_CONTROL_KEY = 0x00000004, B_CAPS_LOCK = 0x00000008, B_SCROLL_LOCK = 0x00000010, B_NUM_LOCK = 0x00000020, B_OPTION_KEY = 0x00000040, B_MENU_KEY = 0x00000080, B_LEFT_SHIFT_KEY = 0x00000100, B_RIGHT_SHIFT_KEY = 0x00000200, B_LEFT_COMMAND_KEY = 0x00000400, B_RIGHT_COMMAND_KEY = 0x00000800, B_LEFT_CONTROL_KEY = 0x00001000, B_RIGHT_CONTROL_KEY = 0x00002000, B_LEFT_OPTION_KEY = 0x00004000, B_RIGHT_OPTION_KEY = 0x00008000 #endif //if (modifiers) { // fprintf(stderr, "# modifiers = %08x\n", (unsigned) modifiers); //} if (numBytes == 1) { //fprintf(stderr, "# down: char %02xh\n", (unsigned) bytes[0]); byte = bytes[0]; if (byte == 0x00) { // Ctrl-Space enq_key_event(BX_KEY_CTRL_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_SPACE, BX_KEY_PRESSED); enq_key_event(BX_KEY_SPACE, BX_KEY_RELEASED); enq_key_event(BX_KEY_CTRL_L, BX_KEY_RELEASED); return; } if (byte == 0x1b) { // Esc if (modifiers & B_CONTROL_KEY) enq_key_event(BX_KEY_CTRL_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_ESC, BX_KEY_PRESSED); enq_key_event(BX_KEY_ESC, BX_KEY_RELEASED); if (modifiers & B_CONTROL_KEY) enq_key_event(BX_KEY_CTRL_L, BX_KEY_RELEASED); return; } if ((byte >= 0x30) && (byte <= 0x39)) { // 0 .. 9 byte -= 0x30; enq_key_event(BX_KEY_0 + byte, BX_KEY_PRESSED); enq_key_event(BX_KEY_0 + byte, BX_KEY_RELEASED); return; } if ((byte >= 0x41) && (byte <= 0x5A)) { // A .. Z byte -= 0x41; enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_A + byte, BX_KEY_PRESSED); enq_key_event(BX_KEY_A + byte, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); return; } if ((byte >= 0x61) && (byte <= 0x7A)) { // a .. z byte -= 0x61; enq_key_event(BX_KEY_A + byte, BX_KEY_PRESSED); enq_key_event(BX_KEY_A + byte, BX_KEY_RELEASED); return; } switch (byte) { case 0x20: // Space enq_key_event(BX_KEY_SPACE, BX_KEY_PRESSED); enq_key_event(BX_KEY_SPACE, BX_KEY_RELEASED); break; case 0x21: // Exclamation Point enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_1, BX_KEY_PRESSED); enq_key_event(BX_KEY_1, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x22: // Double Quotes enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_SINGLE_QUOTE, BX_KEY_PRESSED); enq_key_event(BX_KEY_SINGLE_QUOTE, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x23: // Pound Sign enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_3, BX_KEY_PRESSED); enq_key_event(BX_KEY_3, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x24: // Dollar Sign enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_4, BX_KEY_PRESSED); enq_key_event(BX_KEY_4, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x25: // Percent enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_5, BX_KEY_PRESSED); enq_key_event(BX_KEY_5, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x26: // Ampersand enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_7, BX_KEY_PRESSED); enq_key_event(BX_KEY_7, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x27: // Single Quote enq_key_event(BX_KEY_SINGLE_QUOTE, BX_KEY_PRESSED); enq_key_event(BX_KEY_SINGLE_QUOTE, BX_KEY_RELEASED); break; case 0x28: // Left Paren enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_9, BX_KEY_PRESSED); enq_key_event(BX_KEY_9, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x29: // Right Paren enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_0, BX_KEY_PRESSED); enq_key_event(BX_KEY_0, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x2a: // Multiply enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_8, BX_KEY_PRESSED); enq_key_event(BX_KEY_8, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x2b: // Add enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_EQUALS, BX_KEY_PRESSED); enq_key_event(BX_KEY_EQUALS, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x2c: // Comma enq_key_event(BX_KEY_COMMA, BX_KEY_PRESSED); enq_key_event(BX_KEY_COMMA, BX_KEY_RELEASED); break; case 0x2d: // Minus enq_key_event(BX_KEY_MINUS, BX_KEY_PRESSED); enq_key_event(BX_KEY_MINUS, BX_KEY_RELEASED); break; case 0x2e: // Period enq_key_event(BX_KEY_PERIOD, BX_KEY_PRESSED); enq_key_event(BX_KEY_PERIOD, BX_KEY_RELEASED); break; case 0x2f: // Slash enq_key_event(BX_KEY_SLASH, BX_KEY_PRESSED); enq_key_event(BX_KEY_SLASH, BX_KEY_RELEASED); break; case 0x3a: // Colon enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_SEMICOLON, BX_KEY_PRESSED); enq_key_event(BX_KEY_SEMICOLON, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x3b: // Semi-Colon enq_key_event(BX_KEY_SEMICOLON, BX_KEY_PRESSED); enq_key_event(BX_KEY_SEMICOLON, BX_KEY_RELEASED); break; case 0x3c: // Less Than enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_COMMA, BX_KEY_PRESSED); enq_key_event(BX_KEY_COMMA, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x3d: // Equals enq_key_event(BX_KEY_EQUALS, BX_KEY_PRESSED); enq_key_event(BX_KEY_EQUALS, BX_KEY_RELEASED); break; case 0x3e: // Greater Than enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_PERIOD, BX_KEY_PRESSED); enq_key_event(BX_KEY_PERIOD, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x3f: // Question Mark enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_SLASH, BX_KEY_PRESSED); enq_key_event(BX_KEY_SLASH, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x40: // At Sign enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_2, BX_KEY_PRESSED); enq_key_event(BX_KEY_2, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x5b: // Left Bracket enq_key_event(BX_KEY_LEFT_BRACKET, BX_KEY_PRESSED); enq_key_event(BX_KEY_LEFT_BRACKET, BX_KEY_RELEASED); break; case 0x5c: // Back Slash enq_key_event(BX_KEY_BACKSLASH, BX_KEY_PRESSED); enq_key_event(BX_KEY_BACKSLASH, BX_KEY_RELEASED); break; case 0x5d: // Right Bracket enq_key_event(BX_KEY_RIGHT_BRACKET, BX_KEY_PRESSED); enq_key_event(BX_KEY_RIGHT_BRACKET, BX_KEY_RELEASED); break; case 0x5e: // Caret enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_6, BX_KEY_PRESSED); enq_key_event(BX_KEY_6, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x5f: // Underscore enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_MINUS, BX_KEY_PRESSED); enq_key_event(BX_KEY_MINUS, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x60: // Grave Accent enq_key_event(BX_KEY_GRAVE, BX_KEY_PRESSED); enq_key_event(BX_KEY_GRAVE, BX_KEY_RELEASED); break; case 0x7b: // Left Brace enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_LEFT_BRACKET, BX_KEY_PRESSED); enq_key_event(BX_KEY_LEFT_BRACKET, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x7c: // Verticle Bar enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_BACKSLASH, BX_KEY_PRESSED); enq_key_event(BX_KEY_BACKSLASH, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x7d: // Right Brace enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_RIGHT_BRACKET, BX_KEY_PRESSED); enq_key_event(BX_KEY_RIGHT_BRACKET, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case 0x7e: // Tilde enq_key_event(BX_KEY_SHIFT_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_GRAVE, BX_KEY_PRESSED); enq_key_event(BX_KEY_GRAVE, BX_KEY_RELEASED); enq_key_event(BX_KEY_SHIFT_L, BX_KEY_RELEASED); break; case B_BACKSPACE: enq_key_event(BX_KEY_BACKSPACE, BX_KEY_PRESSED); enq_key_event(BX_KEY_BACKSPACE, BX_KEY_RELEASED); break; case B_ENTER: //case B_RETURN: enq_key_event(BX_KEY_ENTER, BX_KEY_PRESSED); enq_key_event(BX_KEY_ENTER, BX_KEY_RELEASED); break; case B_TAB: enq_key_event(BX_KEY_TAB, BX_KEY_PRESSED); enq_key_event(BX_KEY_TAB, BX_KEY_RELEASED); break; case B_LEFT_ARROW: enq_key_event(BX_KEY_LEFT, BX_KEY_PRESSED); enq_key_event(BX_KEY_LEFT, BX_KEY_RELEASED); break; case B_RIGHT_ARROW: enq_key_event(BX_KEY_RIGHT, BX_KEY_PRESSED); enq_key_event(BX_KEY_RIGHT, BX_KEY_RELEASED); break; case B_UP_ARROW: enq_key_event(BX_KEY_UP, BX_KEY_PRESSED); enq_key_event(BX_KEY_UP, BX_KEY_RELEASED); break; case B_DOWN_ARROW: enq_key_event(BX_KEY_DOWN, BX_KEY_PRESSED); enq_key_event(BX_KEY_DOWN, BX_KEY_RELEASED); break; #if 0 case B_FUNCTION_KEY: break; msg->FindInt32("key", &key); switch (key) { case B_F1_KEY: break; case B_F2_KEY: break; case B_F3_KEY: break; case B_F4_KEY: break; case B_F5_KEY: break; case B_F6_KEY: break; case B_F7_KEY: break; case B_F8_KEY: break; case B_F9_KEY: break; case B_F10_KEY: break; case B_F11_KEY: break; case B_F12_KEY: break; case B_PRINT_KEY: break; case B_SCROLL_KEY: break; case B_PAUSE_KEY: break; default: fprintf(stderr, "# keydown() unknown function key %08xh\n", (unsigned) key); } #endif case B_INSERT: break; enq_key_event(BX_KEY_INSERT, BX_KEY_PRESSED); enq_key_event(BX_KEY_INSERT, BX_KEY_RELEASED); break; case B_DELETE: break; enq_key_event(BX_KEY_DELETE, BX_KEY_PRESSED); enq_key_event(BX_KEY_DELETE, BX_KEY_RELEASED); break; case B_HOME: break; enq_key_event(BX_KEY_HOME, BX_KEY_PRESSED); enq_key_event(BX_KEY_HOME, BX_KEY_RELEASED); break; case B_END: break; enq_key_event(BX_KEY_END, BX_KEY_PRESSED); enq_key_event(BX_KEY_END, BX_KEY_RELEASED); break; case B_PAGE_UP: break; enq_key_event(BX_KEY_PAGE_UP, BX_KEY_PRESSED); enq_key_event(BX_KEY_PAGE_UP, BX_KEY_RELEASED); break; case B_PAGE_DOWN: break; enq_key_event(BX_KEY_PAGE_DOWN, BX_KEY_PRESSED); enq_key_event(BX_KEY_PAGE_DOWN, BX_KEY_RELEASED); break; default: if ((byte >= 0x01) && (byte <= 0x1a)) { // If the above keys dont catch this case, synthesize a // Ctrl-A .. Ctrl-Z event byte -= 1; enq_key_event(BX_KEY_CTRL_L, BX_KEY_PRESSED); enq_key_event(BX_KEY_A + byte, BX_KEY_PRESSED); enq_key_event(BX_KEY_A + byte, BX_KEY_RELEASED); enq_key_event(BX_KEY_CTRL_L, BX_KEY_RELEASED); return; } fprintf(stderr, "# keydown: char %02xh unhandled\n", (unsigned) bytes[0]); return; } return; } else { // ignore for now fprintf(stderr, "# keydown() ignoring multibyte key\n"); } }
OutputView::OutputView(Controller *controller) : BView("Capture Options", B_WILL_DRAW), fController(controller) { SetLayout(new BGroupLayout(B_VERTICAL)); BBox *selectBox = new BBox("selection"); selectBox->SetLabel("Selection"); selectBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP)); AddChild(selectBox); BBox *outputBox = new BBox("output"); outputBox->SetLabel("Output"); outputBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP)); AddChild(outputBox); Settings settings; const char *kTCLabel = "File name:"; const char *fileName = NULL; settings.GetOutputFileName(&fileName); fFileName = new BTextControl("file name", kTCLabel, fileName, new BMessage(kFileNameChanged)); const char *kOutputMenuLabel = "Output Format:"; fOutputFileType = new BOptionPopUp("OutFormat", kOutputMenuLabel, new BMessage(kFileTypeChanged)); const char *kCodecMenuLabel = "Codec:"; BPopUpMenu *popUpMenu = new BPopUpMenu("Codecs"); fCodecMenu = new BMenuField("OutCodec", kCodecMenuLabel, popUpMenu); fWholeScreen = new BRadioButton("screen frame", "Whole screen", new BMessage(kCheckBoxAreaSelectionChanged)); fCustomArea = new BRadioButton("custom area", "Custom Area", new BMessage(kCheckBoxAreaSelectionChanged)); fSelectArea = new BButton("select area", "Select", new BMessage(kSelectArea)); fSelectArea->SetEnabled(false); fMinimizeOnStart = new BCheckBox("Minimize on start", "Minimize on recording", new BMessage(kMinimizeOnRecording)); fRectView = new PreviewView(); BView *layoutView = BLayoutBuilder::Group<>() .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING) .Add(fFileName) .Add(fOutputFileType) .Add(fCodecMenu) .Add(fMinimizeOnStart) .End() .View(); outputBox->AddChild(layoutView); layoutView = BLayoutBuilder::Group<>() .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .AddGroup(B_VERTICAL) .AddGroup(B_HORIZONTAL) .AddGroup(B_VERTICAL, 0) .Add(fWholeScreen) .Add(fCustomArea) .End() .AddGroup(B_VERTICAL) .AddGlue() .Add(fSelectArea) .End() .End() .Add(fRectView) .End() .View(); selectBox->AddChild(layoutView); fMinimizeOnStart->SetValue(settings.MinimizeOnRecording() ? B_CONTROL_ON : B_CONTROL_OFF); // fill in the list of available file formats media_file_format mff; int32 cookie = 0; bool firstFound = true; while (get_next_file_format(&cookie, &mff) == B_OK) { if (mff.capabilities & media_file_format::B_KNOWS_ENCODED_VIDEO) { fOutputFileType->AddOption(mff.pretty_name, mff.family); if (firstFound) { fOutputFileType->MenuField()->Menu()->ItemAt(0)->SetMarked(true); firstFound = false; } } } fWholeScreen->SetValue(B_CONTROL_ON); UpdateSettings(); fController->SetCaptureArea(BScreen(Window()).Frame()); fController->SetMediaFormatFamily(FormatFamily()); fController->SetOutputFileName(fFileName->Text()); }
virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *MessagePntr) { Window()->CurrentMessage()->PrintToStream(); };
void WorkspacesView::MouseDown(BPoint where) { // With enabled auto-raise feature, we'll get mouse messages we don't // want to handle here. if (!Bounds().Contains(where)) return; int32 buttons = 0; if (Window() != NULL && Window()->CurrentMessage() != NULL) Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0) return; // open context menu BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); // TODO: alternatively change the count here directly? BMenuItem* changeItem = new BMenuItem("Change workspace count" B_UTF8_ELLIPSIS, new BMessage(kMsgChangeCount)); menu->AddItem(changeItem); WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window()); if (window != NULL) { BMenuItem* item; menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem("Show window title", new BMessage(kMsgToggleTitle))); if (window->Look() == B_TITLED_WINDOW_LOOK) item->SetMarked(true); menu->AddItem(item = new BMenuItem("Show window border", new BMessage(kMsgToggleBorder))); if (window->Look() == B_TITLED_WINDOW_LOOK || window->Look() == B_MODAL_WINDOW_LOOK) item->SetMarked(true); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem("Always on top", new BMessage(kMsgToggleAlwaysOnTop))); if (window->Feel() == B_FLOATING_ALL_WINDOW_FEEL) item->SetMarked(true); menu->AddItem(item = new BMenuItem("Auto-raise", new BMessage(kMsgToggleAutoRaise))); if (window->IsAutoRaising()) item->SetMarked(true); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("About Workspaces" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(window); } changeItem->SetTarget(this); ConvertToScreen(&where); menu->Go(where, true, true, true); }
Window XCreateWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top, int width, int height, int dummy1, int depth, int inputOutput, int visual, int mask, XSetWindowAttributes * xSetWindowAttributes) { return Window(); };
Window DefaultRootWindow(Display* nativeDisplayType) { return Window(); };
void CGuideContainer::SetSpeedCamPicture(TInt on) { iSpeedCamPicture->SetShow(on == 1); Window().Invalidate(iSpeedCamPicture->Rect()); }
virtual void MouseUp (BPoint where) { Window()->CurrentMessage()->PrintToStream(); };
void InterfacesListView::MouseDown(BPoint where) { int32 buttons = 0; Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((B_SECONDARY_MOUSE_BUTTON & buttons) == 0) { // If not secondary mouse button do the default BListView::MouseDown(where); return; } InterfaceListItem* item = FindItem(where); if (item == NULL) return; // Remove all items from the menu for (int32 i = fContextMenu->CountItems(); i >= 0; --i) { BMenuItem* menuItem = fContextMenu->RemoveItem(i); delete menuItem; } // Now add the ones we want if (item->GetSettings()->IsDisabled()) { fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Enable"), new BMessage(kMsgInterfaceToggle))); } else { fContextMenu->AddItem(new BMenuItem( B_TRANSLATE("Configure" B_UTF8_ELLIPSIS), new BMessage(kMsgInterfaceConfigure))); if (item->GetSettings()->AutoConfigure(AF_INET) || item->GetSettings()->AutoConfigure(AF_INET6)) { fContextMenu->AddItem(new BMenuItem( B_TRANSLATE("Renegotiate Address"), new BMessage(kMsgInterfaceRenegotiate))); } fContextMenu->AddItem(new BSeparatorItem()); fContextMenu->AddItem(new BMenuItem(B_TRANSLATE("Disable"), new BMessage(kMsgInterfaceToggle))); } fContextMenu->ResizeToPreferred(); BMenuItem* selected = fContextMenu->Go(ConvertToScreen(where)); if (selected == NULL) return; switch (selected->Message()->what) { case kMsgInterfaceConfigure: { InterfaceWindow* win = new InterfaceWindow(item->GetSettings()); win->MoveTo(ConvertToScreen(where)); win->Show(); break; } case kMsgInterfaceToggle: item->SetDisabled(!item->IsDisabled()); Invalidate(); break; case kMsgInterfaceRenegotiate: item->GetSettings()->RenegotiateAddresses(); break; } }
void NetPrefsServerView::MessageReceived (BMessage * msg) { switch (msg->what) { case M_SERVER_ITEM_SELECTED: { BRow *row (fServerList->CurrentSelection ()); if (row) { fEditButton->SetEnabled (true); fRemoveButton->SetEnabled (true); } else { fEditButton->SetEnabled (false); fRemoveButton->SetEnabled (false); } } break; case M_SERVER_ADD_ITEM: { BMessenger msgr (fEntryWin); if (msgr.IsValid ()) fEntryWin->Activate (); else { fEntryWin = new ServerEntryWindow (this, new BMessage (M_SERVER_RECV_DATA), NULL, 0); fEntryWin->Show (); } } break; case M_SERVER_EDIT_ITEM: { BMessenger msgr (fEntryWin); if (msgr.IsValid ()) fEntryWin->Activate (); else { BRow *row (fServerList->CurrentSelection ()); if (!row) break; int32 count (0); ssize_t size (0); type_code type; fActiveNetwork->GetInfo ("server", &type, &count); const ServerData *compData; for (int32 i = 0; i < count; i++) { fActiveNetwork->FindData ("server", B_RAW_TYPE, i, reinterpret_cast < const void **>(&compData), &size); if (!strcmp (compData->serverName, ((BStringField *) row->GetField (1))->String ())) break; } BMessage *invoke (new BMessage (M_SERVER_RECV_DATA)); invoke->AddBool ("edit", true); fEntryWin = new ServerEntryWindow (this, invoke, compData, size); fEntryWin->Show (); } } break; case M_SERVER_REMOVE_ITEM: { RemoveServer (); fNetWin.SendMessage (M_SERVER_DATA_CHANGED); } break; case M_SERVER_RECV_DATA: { const ServerData *data; ssize_t size; Window ()->DisableUpdates (); msg->FindData ("server", B_RAW_TYPE, reinterpret_cast < const void **>(&data), &size); if (msg->HasBool ("edit")) RemoveServer (); UpdateNetworkData (data); AddServer (data); Window ()->EnableUpdates (); fNetWin.SendMessage (M_SERVER_DATA_CHANGED); } break; default: BView::MessageReceived (msg); break; } }
void WorkspacesView::MouseDown(BPoint where) { // With enabled auto-raise feature, we'll get mouse messages we don't // want to handle here. if (!Bounds().Contains(where)) return; int32 buttons = 0; if (Window() != NULL && Window()->CurrentMessage() != NULL) Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0) return; // open context menu BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); menu->SetFont(be_plain_font); // TODO: alternatively change the count here directly? BMenuItem* changeItem = new BMenuItem(B_TRANSLATE("Change workspace count" B_UTF8_ELLIPSIS), new BMessage(kMsgChangeCount)); menu->AddItem(changeItem); WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window()); if (window != NULL) { // inside Workspaces app BMenuItem* item; menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show window tab"), new BMessage(kMsgToggleTitle))); if (window->Look() == B_TITLED_WINDOW_LOOK) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show window border"), new BMessage(kMsgToggleBorder))); if (window->Look() == B_TITLED_WINDOW_LOOK || window->Look() == B_MODAL_WINDOW_LOOK) item->SetMarked(true); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Always on top"), new BMessage(kMsgToggleAlwaysOnTop))); if (window->Feel() == B_FLOATING_ALL_WINDOW_FEEL) item->SetMarked(true); menu->AddItem(item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(kMsgToggleAutoRaise))); if (window->IsAutoRaising()) item->SetMarked(true); if (be_roster->IsRunning(kDeskbarSignature)) { menu->AddItem(item = new BMenuItem(B_TRANSLATE("Live in the Deskbar"), new BMessage(kMsgToggleLiveInDeskbar))); BDeskbar deskbar; item->SetMarked(deskbar.HasItem(kDeskbarItemName)); } menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("About Workspaces" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED))); menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(window); } else { // we're replicated in some way... BMenuItem* item; menu->AddSeparatorItem(); // check which way BDragger *dragger = dynamic_cast<BDragger*>(ChildAt(0)); if (dragger) { // replicant menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove replicant"), new BMessage(B_TRASH_TARGET))); item->SetTarget(dragger); } else { // Deskbar item menu->AddItem(item = new BMenuItem(B_TRANSLATE("Remove replicant"), new BMessage(kMsgToggleLiveInDeskbar))); item->SetTarget(this); } } changeItem->SetTarget(this); ConvertToScreen(&where); menu->Go(where, true, true, true); }
void MiniMenuField::Draw(BRect) { BRect bounds(Bounds()); bounds.InsetBy(2, 2); BRect rect(bounds); rect.right--; rect.bottom--; rgb_color darkest = tint_color(kBlack, 0.6f); rgb_color dark = tint_color(kBlack, 0.4f); rgb_color medium = dark; rgb_color light = tint_color(kBlack, 0.03f); SetHighColor(medium); // draw frame and shadow BeginLineArray(10); AddLine(rect.RightTop(), rect.RightBottom(), darkest); AddLine(rect.RightBottom(), rect.LeftBottom(), darkest); AddLine(rect.LeftBottom(), rect.LeftTop(), medium); AddLine(rect.LeftTop(), rect.RightTop(), medium); AddLine(bounds.LeftBottom() + BPoint(2, 0), bounds.RightBottom(), dark); AddLine(bounds.RightTop() + BPoint(0, 1), bounds.RightBottom(), dark); rect.InsetBy(1, 1); AddLine(rect.RightTop(), rect.RightBottom(), medium); AddLine(rect.RightBottom(), rect.LeftBottom(), medium); AddLine(rect.LeftBottom(), rect.LeftTop(), light); AddLine(rect.LeftTop(), rect.RightTop(), light); EndLineArray(); // draw triangle rect = BRect(5, 5, 15, 15); const rgb_color outlineColor = kBlack; const rgb_color middleColor = {150, 150, 150, 255}; BeginLineArray(5); AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 3, rect.top + 7), outlineColor); AddLine(BPoint(rect.left + 3, rect.top + 1), BPoint(rect.left + 6, rect.top + 4), outlineColor); AddLine(BPoint(rect.left + 6, rect.top + 4), BPoint(rect.left + 3, rect.top + 7), outlineColor); AddLine(BPoint(rect.left + 4, rect.top + 3), BPoint(rect.left + 4, rect.top + 5), middleColor); AddLine(BPoint(rect.left + 5, rect.top + 4), BPoint(rect.left + 5, rect.top + 4), middleColor); EndLineArray(); // draw focus if focused, else erase focus bounds = Bounds(); bool focused = IsFocus() && Window()->IsActive(); rgb_color markColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); rgb_color viewColor = ViewColor(); BeginLineArray(4); AddLine(BPoint(bounds.left, bounds.top), BPoint(bounds.right, bounds.top), focused ? markColor : viewColor); AddLine(BPoint(bounds.right, bounds.top), BPoint(bounds.right, bounds.bottom), focused ? markColor : viewColor); AddLine(BPoint(bounds.right, bounds.bottom), BPoint(bounds.left, bounds.bottom), focused ? markColor : viewColor); AddLine(BPoint(bounds.left, bounds.bottom), BPoint(bounds.left, bounds.top), focused ? markColor : viewColor); EndLineArray(); }
void PackageView::MessageReceived(BMessage* message) { switch (message->what) { case P_MSG_INSTALL: { fBeginButton->SetEnabled(false); fInstallTypes->SetEnabled(false); fDestination->SetEnabled(false); fStatusWindow->Show(); fInstallProcess.Start(); break; } case P_MSG_PATH_CHANGED: { BString path; if (message->FindString("path", &path) == B_OK) fCurrentPath.SetTo(path.String()); break; } case P_MSG_OPEN_PANEL: fExpectingOpenPanelResult = true; fOpenPanel->Show(); break; case P_MSG_INSTALL_TYPE_CHANGED: { int32 index; if (message->FindInt32("index", &index) == B_OK) _InstallTypeChanged(index); break; } case P_MSG_I_FINISHED: { BAlert* notify = new BAlert("installation_success", B_TRANSLATE("The package you requested has been successfully " "installed on your system."), B_TRANSLATE("OK")); notify->SetFlags(notify->Flags() | B_CLOSE_ON_ESCAPE); notify->Go(); fStatusWindow->Hide(); fBeginButton->SetEnabled(true); fInstallTypes->SetEnabled(true); fDestination->SetEnabled(true); fInstallProcess.Stop(); BWindow *parent = Window(); if (parent && parent->Lock()) parent->Quit(); break; } case P_MSG_I_ABORT: { BAlert* notify = new BAlert("installation_aborted", B_TRANSLATE( "The installation of the package has been aborted."), B_TRANSLATE("OK")); notify->SetFlags(notify->Flags() | B_CLOSE_ON_ESCAPE); notify->Go(); fStatusWindow->Hide(); fBeginButton->SetEnabled(true); fInstallTypes->SetEnabled(true); fDestination->SetEnabled(true); fInstallProcess.Stop(); break; } case P_MSG_I_ERROR: { // TODO: Review this BAlert* notify = new BAlert("installation_failed", B_TRANSLATE("The requested package failed to install on your " "system. This might be a problem with the target package " "file. Please consult this issue with the package " "distributor."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); fprintf(stderr, B_TRANSLATE("Error while installing the package\n")); notify->SetFlags(notify->Flags() | B_CLOSE_ON_ESCAPE); notify->Go(); fStatusWindow->Hide(); fBeginButton->SetEnabled(true); fInstallTypes->SetEnabled(true); fDestination->SetEnabled(true); fInstallProcess.Stop(); break; } case P_MSG_STOP: { // This message is sent to us by the PackageStatus window, informing // user interruptions. // We actually use this message only when a post installation script // is running and we want to kill it while it's still running fStatusWindow->Hide(); fBeginButton->SetEnabled(true); fInstallTypes->SetEnabled(true); fDestination->SetEnabled(true); fInstallProcess.Stop(); break; } case B_REFS_RECEIVED: { if (!_ValidateFilePanelMessage(message)) break; entry_ref ref; if (message->FindRef("refs", &ref) == B_OK) { BPath path(&ref); if (path.InitCheck() != B_OK) break; dev_t device = dev_for_path(path.Path()); BVolume volume(device); if (volume.InitCheck() != B_OK) break; BMenuItem* item = fDestField->MenuItem(); BString name = _NamePlusSizeString(path.Path(), volume.FreeBytes(), B_TRANSLATE("%name% (%size% free)")); item->SetLabel(name.String()); fCurrentPath.SetTo(path.Path()); } break; } case B_CANCEL: { if (!_ValidateFilePanelMessage(message)) break; // file panel aborted, select first suitable item for (int32 i = 0; i < fDestination->CountItems(); i++) { BMenuItem* item = fDestination->ItemAt(i); BMessage* message = item->Message(); if (message == NULL) continue; BString path; if (message->FindString("path", &path) == B_OK) { fCurrentPath.SetTo(path.String()); item->SetMarked(true); break; } } break; } case B_SIMPLE_DATA: if (message->WasDropped()) { uint32 type; int32 count; status_t ret = message->GetInfo("refs", &type, &count); // check whether the message means someone dropped a file // to our view if (ret == B_OK && type == B_REF_TYPE) { // if it is, send it along with the refs to the application message->what = B_REFS_RECEIVED; be_app->PostMessage(message); } } // fall-through default: BView::MessageReceived(message); break; } }
// ----------------------------------------------------------------------------- // COsmo4AppView::ConstructL() // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void COsmo4AppView::ConstructL( const TRect& aRect ) { const char *opt; Bool first_launch = 0; #if defined(__SERIES60_3X__) selector = CRemConInterfaceSelector::NewL(); target = CRemConCoreApiTarget::NewL(*selector, *this); selector->OpenTargetL(); #endif // Create a window for this application view CreateWindowL(); // Set the windows size SetRect( aRect ); //draw ActivateL(); #ifndef GPAC_GUI_ONLY m_window = Window(); m_session = CEikonEnv::Static()->WsSession(); m_mx = gf_mx_new("Osmo4"); //load config file m_user.config = gf_cfg_init(NULL, &first_launch); if (!m_user.config) { MessageBox("Cannot create GPAC Config file", "Fatal Error"); User::Leave(KErrGeneral); } if (first_launch) { MessageBox("Osmo4", "Thank you for Installing"); } /*load modules*/ opt = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory"); m_user.modules = gf_modules_new(opt, m_user.config); if (!m_user.modules || !gf_modules_get_count(m_user.modules)) { MessageBox(m_user.modules ? "No modules available" : "Cannot create module manager", "Fatal Error"); if (m_user.modules) gf_modules_del(m_user.modules); gf_cfg_del(m_user.config); User::Leave(KErrGeneral); } if (first_launch) { /*first launch, register all files ext*/ for (u32 i=0; i<gf_modules_get_count(m_user.modules); i++) { GF_InputService *ifce = (GF_InputService *) gf_modules_load_interface(m_user.modules, i, GF_NET_CLIENT_INTERFACE); if (!ifce) continue; if (ifce) { ifce->CanHandleURL(ifce, "test.test"); gf_modules_close_interface((GF_BaseInterface *)ifce); } } } /*we don't thread the terminal, ie appart from the audio renderer, media decoding and visual rendering is handled by the app process*/ m_user.init_flags = GF_TERM_NO_VISUAL_THREAD | GF_TERM_NO_REGULATION; m_user.EventProc = GPAC_EventProc; m_user.opaque = this; m_user.os_window_handler = (void *) &m_window; m_user.os_display = (void *) &m_session; m_term = gf_term_new(&m_user); if (!m_term) { MessageBox("Cannot load GPAC terminal", "Fatal Error"); gf_modules_del(m_user.modules); gf_cfg_del(m_user.config); User::Leave(KErrGeneral); } //MessageBox("GPAC terminal loaded", "Success !"); /*ok set output size*/ TSize s = m_window.Size(); gf_term_set_size(m_term, s.iWidth, s.iHeight); /*start our callback (every ms)*/ const TInt KTickInterval = 33000; m_pTimer = CPeriodic::NewL(CActive::EPriorityStandard); m_pTimer->Start(KTickInterval, KTickInterval, TCallBack(myTick, this)); opt = gf_cfg_get_key(m_user.config, "General", "StartupFile"); if (opt) gf_term_connect(m_term, opt); #endif }
void PackageView::AttachedToWindow() { status_t ret = fInfo.InitCheck(); if (ret != B_OK && ret != B_NO_INIT) { BAlert* warning = new BAlert("parsing_failed", B_TRANSLATE("The package file is not readable.\nOne of the " "possible reasons for this might be that the requested file " "is not a valid BeOS .pkg package."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); warning->SetFlags(warning->Flags() | B_CLOSE_ON_ESCAPE); warning->Go(); Window()->PostMessage(B_QUIT_REQUESTED); return; } // Set the window title BWindow* parent = Window(); BString title; BString name = fInfo.GetName(); if (name.CountChars() == 0) { title = B_TRANSLATE("Package installer"); } else { title = B_TRANSLATE("Install %name%"); title.ReplaceAll("%name%", name); } parent->SetTitle(title.String()); fBeginButton->SetTarget(this); fOpenPanel->SetTarget(BMessenger(this)); fInstallTypes->SetTargetForItems(this); if (ret != B_OK) return; // If the package is valid, we can set up the default group and all // other things. If not, then the application will close just after // attaching the view to the window _InstallTypeChanged(0); fStatusWindow = new PackageStatus(B_TRANSLATE("Installation progress"), NULL, NULL, this); // Show the splash screen, if present BMallocIO* image = fInfo.GetSplashScreen(); if (image != NULL) { PackageImageViewer* imageViewer = new PackageImageViewer(image); imageViewer->Go(); } // Show the disclaimer/info text popup, if present BString disclaimer = fInfo.GetDisclaimer(); if (disclaimer.Length() != 0) { PackageTextViewer* text = new PackageTextViewer( disclaimer.String()); int32 selection = text->Go(); // The user didn't accept our disclaimer, this means we cannot // continue. if (selection == 0) parent->Quit(); } }