Ticket #7991: DriveSetup-SizeTextControl-20110918.diff
File DriveSetup-SizeTextControl-20110918.diff, 3.5 KB (added by , 13 years ago) |
---|
-
Support.cpp
99 99 BSlider(name, label, message, minValue, maxValue, 100 100 B_HORIZONTAL, B_TRIANGLE_THUMB), 101 101 fStartOffset(minValue), 102 fEndOffset(maxValue) 102 fEndOffset(maxValue), 103 fMaxPartitionSize(maxValue) 103 104 { 104 105 SetBarColor((rgb_color){ 0, 80, 255, 255 }); 105 106 char minString[64]; … … 143 144 // headed slider is implemented. 144 145 return fStartOffset; 145 146 } 147 148 int32 149 SizeSlider::MaxPartitionSize() 150 { 151 return fMaxPartitionSize; 152 } -
Support.h
51 51 virtual const char* UpdateText() const; 52 52 int32 Size(); 53 53 int32 Offset(); 54 int32 MaxPartitionSize(); 54 55 55 56 private: 56 57 off_t fStartOffset; 57 58 off_t fEndOffset; 59 off_t fMaxPartitionSize; 58 60 mutable char fStatusLabel[64]; 59 61 }; 60 62 -
CreateParamsPanel.cpp
77 77 enum { 78 78 MSG_OK = 'okok', 79 79 MSG_CANCEL = 'cncl', 80 MSG_PARTITION_TYPE = 'type' 80 MSG_PARTITION_TYPE = 'type', 81 MSG_SIZE_SLIDER = 'ssld', 82 MSG_SIZE_TEXTCONTROL = 'stct' 81 83 }; 82 84 83 85 … … 138 140 fEditor->PartitionTypeChanged(type); 139 141 } 140 142 break; 143 144 case MSG_SIZE_SLIDER: 145 { 146 BString sizeString; 147 sizeString << fSizeSlider->Value(); 148 fSizeTextControl->SetText(sizeString.String()); 149 break; 150 } 151 152 case MSG_SIZE_TEXTCONTROL: 153 { 154 BString sizeString; 155 sizeString = fSizeTextControl->Text(); 156 int32 sizeInt = atoi(sizeString.String()); 157 if (sizeInt >= 0 && sizeInt <= fSizeSlider->MaxPartitionSize()) 158 fSizeSlider->SetValue(sizeInt); 159 else { 160 int32 sizeTextControlLength = fSizeTextControl->TextView()->TextLength(); 161 fSizeTextControl->TextView()->Delete(sizeTextControlLength - 1, sizeTextControlLength); 162 } 163 break; 164 } 141 165 142 166 default: 143 167 BWindow::MessageReceived(message); … … 225 249 fSizeSlider = new SizeSlider("Slider", B_TRANSLATE("Partition size"), NULL, 226 250 offset, offset + size); 227 251 fSizeSlider->SetPosition(1.0); 252 fSizeSlider->SetModificationMessage(new BMessage(MSG_SIZE_SLIDER)); 253 254 BString sizeText; 255 sizeText << fSizeSlider->Value(); 256 fSizeTextControl = new BTextControl("Size Control", 257 "", sizeText.String(), NULL); 258 for(int32 i = 0; i < 256; i++) 259 fSizeTextControl->TextView()->DisallowChar(i); 260 for(int32 i = '0'; i <= '9'; i++) 261 fSizeTextControl->TextView()->AllowChar(i); 262 fSizeTextControl->SetModificationMessage(new BMessage(MSG_SIZE_TEXTCONTROL)); 228 263 229 264 fNameTextControl = new BTextControl("Name Control", 230 265 B_TRANSLATE("Partition name:"), "", NULL); … … 257 292 258 293 AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) 259 294 .Add(fSizeSlider) 295 .Add(fSizeTextControl) 260 296 .Add(BGridLayoutBuilder(0.0, 5.0) 261 297 .Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0) 262 298 .Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0) -
CreateParamsPanel.h
50 50 BMenuField* fTypeMenuField; 51 51 BTextControl* fNameTextControl; 52 52 SizeSlider* fSizeSlider; 53 BTextControl* fSizeTextControl; 53 54 }; 54 55 55 56 #endif // CREATE_PARAMS_PANEL_H