// /// Paint the item entirely. // void TCheckList::PaintItem(DRAWITEMSTRUCT & drawInfo) { TCheckListItem* item = GetItem(drawInfo.itemID); if (item == 0) return; const bool disabled = !item->IsEnabled() || (drawInfo.itemState & ODS_DISABLED); // Prepare DC // TDC dc(drawInfo.hDC); // Erase entire line // TRect rect(drawInfo.rcItem); TBrush bkgnd(TColor::SysWindow); dc.FillRect(rect, bkgnd); // Draw checkbox // TRect checkboxRect(rect.left+1,rect.top+1, rect.left+CheckList_BoxWidth,rect.bottom-1); // Draw checkbox in 3D Windows Style // uint state; if (item->IsIndeterminate()) state = TUIPart::Button3State|TUIPart::Checked;//TUIPart::Pushed; else state = TUIPart::ButtonCheck; if(item->IsChecked()) state |= TUIPart::Checked; if (disabled) state |= TUIPart::Inactive; TUIPart().Paint(dc, checkboxRect, TUIPart::uiButton, (TUIPart::TState)state); // Draw select state with hightlight color // TRect textRect = rect; textRect.left = checkboxRect.right + 2; if (disabled) { dc.SetTextColor(TColor::SysGrayText); dc.SetBkColor(TColor::SysWindow); } else if (drawInfo.itemState & ODS_SELECTED) { TBrush fillBrush(TColor::SysHighlight); dc.FillRect(textRect, fillBrush); dc.SetTextColor(TColor::SysHighlightText); dc.SetBkColor(TColor::SysHighlight); } else { dc.SetTextColor(TColor::SysWindowText); dc.SetBkColor(TColor::SysWindow); } // Draw Text // textRect.left++; PaintText(dc, textRect, item->Text); textRect.left--; // Draw focus and selected states // if (drawInfo.itemState & ODS_FOCUS) dc.DrawFocusRect(textRect); }
LogPrefsView::LogPrefsView(BRect frame) : BView(frame, "DCC prefs", B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BRect checkboxRect(Bounds()); BRect trackingBoundsRect(0.0, 0.0, 0, 0); float maxWidth(0), maxHeight(0); fLogBaseDir = new VTextControl(BRect(0, 0, 0, 0), NULL, S_PREFLOG_LOGPATH, vision_app->GetString("logBaseDir"), new BMessage(M_PREFLOG_LOGPATH_CHANGED)); fLogBaseDir->ResizeToPreferred(); fLogBaseDir->ResizeToPreferred(); fLogBaseDir->SetDivider(fLogBaseDir->StringWidth(S_PREFLOG_LOGPATH) + 5); fLogBaseDir->ResizeTo(Bounds().Width() - 15, fLogBaseDir->Bounds().Height()); fLogBaseDir->MoveTo(be_plain_font->StringWidth("S"), be_plain_font->Size()); AddChild(fLogBaseDir); checkboxRect = fLogBaseDir->Bounds(); fLogStampFormat = new VTextControl(BRect(0, 0, 0, 0), NULL, S_PREFLOG_TS_FORMAT, vision_app->GetString("timestamp_format"), new BMessage(M_PREFLOG_TS_FORMAT_CHANGED)); fLogBaseDir->ResizeToPreferred(); fLogStampFormat->SetDivider(fLogBaseDir->StringWidth(S_PREFLOG_TS_FORMAT) + 5); fLogStampFormat->MoveTo(be_plain_font->StringWidth("S"), fLogBaseDir->Frame().bottom + be_plain_font->Size()); AddChild(fLogStampFormat); checkboxRect.top += fLogStampFormat->Bounds().Height() * 1.2; BMessage msg(M_PREFLOG_CHECKBOX_CHANGED); fClearLogs = new BButton(BRect(0, 0, 0, 0), "Clear Logs", S_PREFLOG_DELETE_LOGS, new BMessage(M_PREFLOG_DELETE_LOGS)); fClearLogs->ResizeToPreferred(); fClearLogs->MoveTo(fLogBaseDir->Bounds().Width() + 200, fLogBaseDir->Frame().bottom + be_plain_font->Size()); if (_CheckIfEmpty()) fClearLogs->SetEnabled(false); AddChild(fClearLogs); checkboxRect.top += be_plain_font->Size(); checkboxRect.bottom = checkboxRect.top; msg.AddString("setting", "timestamp"); fTimeStamp = new BCheckBox(checkboxRect, "timestamp", S_PREFLOG_SHOW_TIMESTAMP, new BMessage(msg)); fTimeStamp->SetValue((vision_app->GetBool("timestamp")) ? B_CONTROL_ON : B_CONTROL_OFF); fTimeStamp->MoveBy(be_plain_font->StringWidth("S"), 0); fTimeStamp->ResizeToPreferred(); trackingBoundsRect = fTimeStamp->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxHeight += trackingBoundsRect.Height() * 1.5; AddChild(fTimeStamp); checkboxRect.top += fTimeStamp->Bounds().Height() * 1.2; msg.ReplaceString("setting", "log_enabled"); fLogEnabled = new BCheckBox(checkboxRect, "fLogEnabled", S_PREFLOG_USE_LOGGING, new BMessage(msg)); fLogEnabled->SetValue((vision_app->GetBool("log_enabled")) ? B_CONTROL_ON : B_CONTROL_OFF); fLogEnabled->MoveBy(be_plain_font->StringWidth("S"), 0); fLogEnabled->ResizeToPreferred(); trackingBoundsRect = fLogEnabled->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxHeight += trackingBoundsRect.Height() * 1.5; AddChild(fLogEnabled); checkboxRect.top += fLogEnabled->Bounds().Height() * 1.2; msg.ReplaceString("setting", "log_filetimestamp"); fLogFileTimestamp = new BCheckBox(checkboxRect, "fLogFileTimestamp", S_PREFLOG_LOG_TIMESTAMP, new BMessage(msg)); fLogFileTimestamp->SetValue(vision_app->GetBool(("log_filetimestamp")) ? B_CONTROL_ON : B_CONTROL_OFF); fLogFileTimestamp->MoveBy(be_plain_font->StringWidth("S"), 0); fLogFileTimestamp->ResizeToPreferred(); trackingBoundsRect = fLogFileTimestamp->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxWidth *= 1.2; maxHeight += trackingBoundsRect.Height() * 1.5; AddChild(fLogFileTimestamp); }
AppWindowPrefsView::AppWindowPrefsView (BRect frame) : BView (frame, "App/Window Prefs", B_FOLLOW_NONE, B_WILL_DRAW) { SetViewColor (ui_color (B_PANEL_BACKGROUND_COLOR)); BMessage msg (M_APPWINDOWPREFS_SETTING_CHANGED); float maxWidth (0), maxHeight (0); BRect trackingBoundsRect (0.0, 0.0, 0, 0); BRect checkboxRect(Bounds()); checkboxRect.bottom = checkboxRect.top; msg.AddString ("setting", "versionParanoid"); fVersionParanoid = new BCheckBox (checkboxRect, "version Paranoid", B_TRANSLATE("Show OS information in version reply"), new BMessage (msg)); fVersionParanoid->SetValue ((!vision_app->GetBool ("versionParanoid")) ? B_CONTROL_ON : B_CONTROL_OFF); fVersionParanoid->MoveBy(be_plain_font->StringWidth("S"), 0); fVersionParanoid->ResizeToPreferred(); trackingBoundsRect = fVersionParanoid->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxHeight += trackingBoundsRect.Height(); AddChild (fVersionParanoid); checkboxRect.OffsetBy(0.0, fVersionParanoid->Bounds().Height() * 1.2); msg.ReplaceString ("setting", "catchAltW"); fCatchAltW = new BCheckBox (checkboxRect, "catch AltW", B_TRANSLATE("Require double Cmd+Q/W to close"), new BMessage (msg)); fCatchAltW->SetValue ((vision_app->GetBool ("catchAltW")) ? B_CONTROL_ON : B_CONTROL_OFF); fCatchAltW->MoveBy(be_plain_font->StringWidth("S"), 0); fCatchAltW->ResizeToPreferred(); trackingBoundsRect = fCatchAltW->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxHeight += trackingBoundsRect.Height() * 1.2; AddChild (fCatchAltW); checkboxRect.OffsetBy(0.0, fCatchAltW->Bounds().Height() * 1.2); msg.ReplaceString ("setting", "stripcolors"); fStripColors = new BCheckBox (checkboxRect, "stripcolors", B_TRANSLATE("Strip mIRC Colors"), new BMessage (msg)); fStripColors->SetValue ((vision_app->GetBool ("stripcolors")) ? B_CONTROL_ON : B_CONTROL_OFF); fStripColors->MoveBy(be_plain_font->StringWidth("S"), 0); fStripColors->ResizeToPreferred(); trackingBoundsRect = fStripColors->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxHeight += trackingBoundsRect.Height() * 1.5; AddChild (fStripColors); checkboxRect.OffsetBy(0.0, fStripColors->Bounds().Height() * 1.2); msg.ReplaceString ("setting", "Newbie Spam Mode"); fSpamMode = new BCheckBox (checkboxRect, "newbiespammode", B_TRANSLATE("Warn when multiline pasting"), new BMessage (msg)); fSpamMode->SetValue ((vision_app->GetBool ("Newbie Spam Mode")) ? B_CONTROL_ON : B_CONTROL_OFF); fSpamMode->MoveBy(be_plain_font->StringWidth("S"), 0); fSpamMode->ResizeToPreferred(); trackingBoundsRect = fSpamMode->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxHeight += trackingBoundsRect.Height() * 1.5; AddChild (fSpamMode); checkboxRect.OffsetBy(0.0, fSpamMode->Bounds().Height() * 1.2); msg.ReplaceString ("setting", "queryOnMsg"); fQueryMsg = new BCheckBox (checkboxRect, "queryOnMsg", B_TRANSLATE("Open new query window on message"), new BMessage (msg)); fQueryMsg->SetValue ((vision_app->GetBool ("queryOnMsg")) ? B_CONTROL_ON : B_CONTROL_OFF); fQueryMsg->MoveBy(be_plain_font->StringWidth("S"), 0); fQueryMsg->ResizeToPreferred(); trackingBoundsRect = fSpamMode->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxHeight += trackingBoundsRect.Height() * 1.5; AddChild (fQueryMsg); checkboxRect.OffsetBy(0.0, fQueryMsg->Bounds().Height() * 1.2); BMenu *encMenu(CreateEncodingMenu()); checkboxRect.left = 0.0; checkboxRect.right = Bounds().Width(); checkboxRect.bottom += fQueryMsg->Bounds().Height() * 1.2; fEncodings = new BMenuField(checkboxRect, "encoding", "Encoding: ", encMenu); AddChild (fEncodings); fEncodings->Menu()->SetLabelFromMarked(true); trackingBoundsRect = fEncodings->Bounds(); maxWidth = (maxWidth < trackingBoundsRect.Width()) ? trackingBoundsRect.Width() : maxWidth; maxHeight += trackingBoundsRect.Height() * 1.5; ResizeTo(maxWidth, maxHeight); }