void StoreSettingL(TInt aIndex) { CALLSTACKITEM_N(_CL("CAutoSettingsImpl"), _CL("StoreSettingL")); TInt i = aIndex; TBuf<256> prev_string; TInt prev_int; if (! DataAt(i)) return; TSettingItem s=TClSettings::GetKClSettings(i); switch (s.iDatatype) { case ::EAP: case ::EInt: case ::EBool: case ::EEnum: { TInt *v=(TInt*)(DataAt(i)); if (!Settings().GetSettingL(i, prev_int) || prev_int!=*v) Settings().WriteSettingL(i, *v); } break; case ::EString: { TBuf<256> *v=(TBuf<256>*)(DataAt(i)); if (!Settings().GetSettingL(i, prev_string) || prev_string.Compare(*v)) Settings().WriteSettingL(i, *v); } break; } }
void LoadSettingL(TInt aIndex) { CALLSTACKITEM_N(_CL("CAutoSettingsImpl"), _CL("LoadSettingL")); TInt i = aIndex; TBuf<256> prev_string; TInt prev_int; if (! DataAt(i)) return; TSettingItem s=TClSettings::GetKClSettings(i); switch (s.iDatatype) { case ::EAP: case ::EInt: case ::EBool: case ::EEnum: { TInt *v=(TInt*)(DataAt(i)); if (Settings().GetSettingL(i, prev_int)) { if (i==SETTING_MEDIA_UPLOAD_ENABLE && iOnlyContextLogPublishing) { if (prev_int>1) { prev_int=1; Settings().WriteSettingL(i, prev_int); } } *v=prev_int; } } break; case ::EString: { TBuf<256> *v=(TBuf<256>*)(DataAt(i)); if (Settings().GetSettingL(i, prev_string)) *v=prev_string; } break; } }
void PixelDrawer::LineToImpl(int to_x, int to_y) { ASSERT( CheckFromLessTo(to_x, to_y) ); Pixel* beg = DataAt( CalcAdds(curX, curY) ); if( curY == to_y ) { int sz = to_x-curX; for( Pixel* end=beg+sz; beg<end; beg++ ) // :TODO: можно сделать, когда со скоростью наложения будет все ясно //AlphaCompositePixel(*beg, fillClr); *(guint32*)beg = intClr; } else { int sz = to_y-curY; for( int i=0; i<sz; i++ ) { // :TODO: --||-- //AlphaCompositePixel(*beg, fillClr); *(guint32*)beg = intClr; beg = (Pixel*)((char*)beg + rowStrd); } } }
void DataView::KeyDown(const char *bytes, int32 numBytes) { int32 modifiers; if (Looper()->CurrentMessage() == NULL || Looper()->CurrentMessage()->FindInt32("modifiers", &modifiers) != B_OK) modifiers = ::modifiers(); // check if the selection is going to be changed switch (bytes[0]) { case B_LEFT_ARROW: case B_RIGHT_ARROW: case B_UP_ARROW: case B_DOWN_ARROW: if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == -1) fKeySelectionStart = fStart; } else fKeySelectionStart = -1; break; } switch (bytes[0]) { case B_LEFT_ARROW: { int32 position = fStart - 1; if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == fEnd) SetSelection(fStart - 1, fEnd); else { SetSelection(fStart, fEnd - 1); position = fEnd; } } else SetSelection(fStart - 1, fStart - 1); MakeVisible(position); break; } case B_RIGHT_ARROW: { int32 position = fEnd + 1; if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == fStart) SetSelection(fStart, fEnd + 1); else SetSelection(fStart + 1, fEnd); } else SetSelection(fEnd + 1, fEnd + 1); MakeVisible(position); break; } case B_UP_ARROW: { int32 start, end; if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == fStart) { start = fEnd - int32(kBlockSize); end = fStart; } else { start = fStart - int32(kBlockSize); end = fEnd; } if (start < 0) start = 0; } else { start = fStart - int32(kBlockSize); if (start < 0) start = fStart; end = start; } SetSelection(start, end); MakeVisible(start); break; } case B_DOWN_ARROW: { int32 start, end; if (modifiers & B_SHIFT_KEY) { if (fKeySelectionStart == fEnd) { start = fEnd; end = fStart + int32(kBlockSize); } else { start = fStart; end = fEnd + int32(kBlockSize); } if (end >= int32(fSizeInView)) end = int32(fSizeInView) - 1; } else { end = fEnd + int32(kBlockSize); if (end >= int32(fSizeInView)) start = fEnd; start = end; } SetSelection(start, end); MakeVisible(end); break; } case B_PAGE_UP: { // scroll one page up, but keep the same cursor column BRect frame = SelectionFrame(fFocus, fStart, fStart); frame.OffsetBy(0, -Bounds().Height()); if (frame.top <= kVerticalSpace) frame.top = kVerticalSpace + 1; ScrollBy(0, -Bounds().Height()); int32 position = PositionAt(fFocus, frame.LeftTop()); SetSelection(position, position); break; } case B_PAGE_DOWN: { // scroll one page down, but keep the same cursor column BRect frame = SelectionFrame(fFocus, fStart, fStart); frame.OffsetBy(0, Bounds().Height()); float lastLine = DataBounds().Height() - 1 - kVerticalSpace; if (frame.top > lastLine) frame.top = lastLine; ScrollBy(0, Bounds().Height()); int32 position = PositionAt(fFocus, frame.LeftTop()); SetSelection(position, position); break; } case B_HOME: SetSelection(0, 0); MakeVisible(fStart); break; case B_END: SetSelection(fDataSize - 1, fDataSize - 1); MakeVisible(fStart); break; case B_TAB: SetFocus(fFocus == kHexFocus ? kAsciiFocus : kHexFocus); MakeVisible(fStart); break; case B_FUNCTION_KEY: // this is ignored break; case B_BACKSPACE: if (fBitPosition == 0) SetSelection(fStart - 1, fStart - 1); if (fFocus == kHexFocus) fBitPosition = (fBitPosition + 4) % 8; // supposed to fall through case B_DELETE: SetSelection(fStart, fStart); // to make sure only the cursor is selected if (fFocus == kHexFocus) { const uint8 *data = DataAt(fStart); if (data == NULL) break; uint8 c = data[0] & (fBitPosition == 0 ? 0x0f : 0xf0); // mask out region to be cleared fEditor.Replace(fOffset + fStart, &c, 1); } else fEditor.Replace(fOffset + fStart, (const uint8 *)"", 1); break; default: if (fFocus == kHexFocus) { // only hexadecimal characters are allowed to be entered const uint8 *data = DataAt(fStart); uint8 c = bytes[0]; if (c >= 'A' && c <= 'F') c += 'A' - 'a'; const char *hexNumbers = "0123456789abcdef"; addr_t number; if (data == NULL || (number = (addr_t)strchr(hexNumbers, c)) == 0) break; SetSelection(fStart, fStart); // to make sure only the cursor is selected number -= (addr_t)hexNumbers; fBitPosition = (fBitPosition + 4) % 8; c = (data[0] & (fBitPosition ? 0x0f : 0xf0)) | (number << fBitPosition); // mask out overwritten region and bit-wise or the number to be inserted if (fEditor.Replace(fOffset + fStart, &c, 1) == B_OK && fBitPosition == 0) SetSelection(fStart + 1, fStart + 1); } else { if (fEditor.Replace(fOffset + fStart, (const uint8 *)bytes, numBytes) == B_OK) SetSelection(fStart + 1, fStart + 1); } break; } }