static XP_Bool ddStartBoard( BoardCtxt* board, XP_U16 xx, XP_U16 yy ) { DragState* ds = &board->dragState; XP_Bool trayVisible; XP_U16 col, row; #ifdef DEBUG XP_Bool found = #endif coordToCell( board, xx, yy, &col, &row ); XP_ASSERT( found ); #ifdef XWFEATURE_CROSSHAIRS if ( !board->hideCrosshairs ) { (void)crosshairs_set( board, col, row ); } #endif trayVisible = board->trayVisState == TRAY_REVEALED; if ( trayVisible && holdsPendingTile( board, col, row ) ) { XP_U16 modelc, modelr; ds->dtype = DT_TILE; flipIf( board, col, row, &modelc, &modelr ); #ifdef DEBUG found = #endif model_getTile( board->model, modelc, modelr, XP_TRUE, board->selPlayer, &ds->tile, &ds->isBlank, NULL, NULL ); XP_ASSERT( found ); } else { /* If we're not dragging a tile, we can either drag the board (scroll) or work on hint regions. Sometimes scrolling isn't possible. Sometimes hint dragging is disabled. But if both are possible, then the alt key determines it. I figure scrolling will be more common than hint dragging when both are possible, but you can turn hint dragging off, so if it's on that's probably what you want. */ ScrollData* vsd = &board->sd[SCROLL_V]; XP_Bool canScroll = vsd->lastVisible < model_numRows(board->model); if ( 0 ) { #ifdef XWFEATURE_SEARCHLIMIT } else if ( !board->gi->hintsNotAllowed && board->gi->allowHintRect && trayVisible ) { if ( !util_altKeyDown(board->util) ) { ds->dtype = DT_HINTRGN; } else if ( canScroll ) { ds->dtype = DT_BOARD; } #endif } else if ( canScroll ) { ds->dtype = DT_BOARD; } } ds->start.u.board.col = col; ds->start.u.board.row = row; return ds->dtype != DT_NONE; } /* ddStartBoard */
void XFE_FrameListMenu::item_activate(Widget item) { XP_ASSERT( XfeIsAlive(m_submenu) ); int i = XfeChildGetIndex(item) - m_firstslot; XP_ASSERT( i > 0 ); if (i <= 0) { return; } XP_List * frame_list = getShownFrames(); XFE_Frame * frame = (XFE_Frame *) XP_ListGetObjectNum(frame_list,i); XP_ASSERT( frame != NULL ); if (frame) { frame->show(); } XmUpdateDisplay(frame->getBaseWidget()); if (frame_list) { XP_ListDestroy(frame_list); } }
////////////////////////////////////////////////////////////////////////// // // XFE_TaskBar Private Methods // ////////////////////////////////////////////////////////////////////////// void XFE_TaskBar::setIconGroupForCommand(CommandType cmd, IconGroup *icons) { Widget * children; Cardinal num_children; Cardinal i; XfeChildrenGet(m_widget,&children,&num_children); for (i = 0; i < num_children; i ++) { if (XfeIsButton(children[i])) { if (Command::intern(XtName(children[i])) == cmd) { XFE_Button * button = (XFE_Button *) XfeInstancePointer(children[i]); XP_ASSERT(button); if (!button) return; button->setPixmap(icons); return; } } } XP_ASSERT(0); // command not found in the taskbar... }
void XFE_SubscribeView::tab_activate(int pos) { XP_ASSERT(pos >=0 && pos <=2); m_activeView = (XFE_SubTabView*)m_subviews[pos]; // associate the active view with the pane, so we have a way // to get to the right outliner. m_activeView->setPane(m_pane); m_activeView->defaultFocus(); m_activeView->syncServerCombo(); switch(pos) { case 0: // All tab MSG_SubscribeSetMode(m_pane, MSG_SubscribeAll); break; case 1: // Search tab MSG_SubscribeSetMode(m_pane, MSG_SubscribeSearch); break; case 2: // New tab MSG_SubscribeSetMode(m_pane, MSG_SubscribeNew); m_activeView->doCommand(xfeCmdGetNewGroups); break; default: XP_ASSERT(0); break; } m_activeView->updateButtons(); }
PRIVATE int crawl_PageScanConvPut(NET_StreamClass *stream, char *s, int32 l) { crawl_page_scan_stream *obj=stream->data_object; int status; XP_ASSERT(obj->parse_obj != NULL); XP_ASSERT(obj->page != NULL); if (!obj->page->dontFollow) /* no directive to cache without parsing */ status = CRAWL_ParserPut(obj->parse_obj, s, l, crawl_processToken, obj->page); else status = CRAWL_PARSE_NO_ERROR; switch (status) { case CRAWL_PARSE_NO_ERROR: return(0); case CRAWL_PARSE_ERROR: obj->page->dontFollow = PR_TRUE; return(0); case CRAWL_PARSE_TERMINATE: obj->page->dontFollow = PR_TRUE; return(0); case CRAWL_PARSE_OUT_OF_MEMORY: return(MK_UNABLE_TO_CONVERT); default: XP_ASSERT(0); break; } return(status); }
Widget XFE_Toolbox::tabOfItem(Widget item,XP_Bool opened) { XP_ASSERT( XfeIsAlive(m_widget) ); XP_ASSERT( XfeIsAlive(item) ); return XfeToolBoxItemGetTab(m_widget,item,(Boolean) opened); }
XP_Bool XFE_Toolbox::stateOfItem(Widget item) { XP_ASSERT( XfeIsAlive(m_widget) ); XP_ASSERT( XfeIsAlive(item) ); return (XP_Bool) XfeToolBoxItemGetOpen(m_widget,item); }
void XFE_Toolbox::setItemPosition(Widget item,int position) { XP_ASSERT( XfeIsAlive(m_widget) ); XP_ASSERT( XfeIsAlive(item) ); XfeToolBoxItemSetPosition(m_widget,item,position); }
void XFE_Toolbox::setItemOpen(Widget item,XP_Bool open) { XP_ASSERT( XfeIsAlive(m_widget) ); XP_ASSERT( XfeIsAlive(item) ); XfeToolBoxItemSetOpen(m_widget,item,open); }
/* * Make all the directories specified in the path */ int XP_MakeDirectoryR(const char* name, XP_FileType type) { char separator; int result = 0; char * finalName; #if defined(XP_WIN) || defined(XP_OS2) separator = '\\'; #elif defined XP_UNIX separator = '/'; #endif finalName = WH_FileName(name, type); if ( finalName ) { char * dirPath; char * currentEnd; int err = 0; XP_StatStruct s; dirPath = XP_STRDUP( finalName ); if (dirPath == NULL) return -1; currentEnd = XP_STRCHR(dirPath, separator); /* Loop through every part of the directory path */ while (currentEnd != 0) { char savedChar; savedChar = currentEnd[1]; currentEnd[1] = 0; if ( XP_Stat(dirPath, &s, xpURL ) != 0) err = XP_MakeDirectory(dirPath, xpURL); if ( err != 0) { XP_ASSERT( FALSE ); /* Could not create the directory? */ break; } currentEnd[1] = savedChar; currentEnd = XP_STRCHR( ¤tEnd[1], separator); } if ( err == 0 ) /* If the path is not terminated with / */ { if ( dirPath[XP_STRLEN( dirPath) - 1] != separator ) if ( XP_Stat(dirPath, &s, xpURL ) != 0) err = XP_MakeDirectory(dirPath, xpURL); } if ( 0 != err ) result = err; if ( dirPath ) XP_FREE( dirPath ); } else result = -1; if ( finalName ) XP_FREE( finalName ); XP_ASSERT( result == 0 ); /* For debugging only */ return result; }
int XFE_Toolbox::positionOfItem(Widget item) { XP_ASSERT( XfeIsAlive(m_widget) ); XP_ASSERT( XfeIsAlive(item) ); // return XfeToolBoxItemGetPosition(m_widget,item); return XfeToolBoxItemGetIndex(m_widget,item); }
void dragDropTileInfo( const BoardCtxt* board, Tile* tile, XP_Bool* isBlank ) { const DragState* ds = &board->dragState; XP_ASSERT( dragDropInProgress( board ) ); XP_ASSERT( ds->dtype == DT_TILE ); XP_ASSERT ( OBJ_BOARD == ds->start.obj || OBJ_TRAY == ds->start.obj ); *tile = ds->tile; *isBlank = ds->isBlank; }
static void centerIn( XP_Rect* rInner, const XP_Rect* rOuter, XP_U16 width, XP_U16 height ) { rInner->width = width; rInner->height = height; XP_ASSERT( width <= rOuter->width ); rInner->left = rOuter->left + ( (rOuter->width - width) / 2 ); XP_ASSERT( height <= rOuter->height ); rInner->top = rOuter->top + ( (rOuter->height - height) / 2 ); }
XP_Bool get_16bit_row_bmp (CONVERT_IMGCONTEXT *p_params,CONVERT_IMG_INFO *p_info,CONVERT_IMG_ROW p_outputbuffer) /* This version is for reading 8-bit colormap indexes */ { CONVERT_IMG_ROW outptr = p_outputbuffer; BYTE t_byte; int16 col; uint32 t_redmask=0x00007C00; uint32 t_greenmask=0x000003E0; uint32 t_bluemask=0x0000001F; char t_redshift=10; char t_greenshift=5; char t_blueshift=0; uint16 t_redpad=0; uint16 t_greenpad=0; uint16 t_bluepad=0; if (!p_outputbuffer||!p_params||!p_info) { XP_ASSERT(FALSE); return FALSE; } if (p_info->m_numcolorentries==3) { if (!p_info->m_colormap) { XP_ASSERT(FALSE); return FALSE; } t_redmask=(p_info->m_colormap[0]<<16)+(p_info->m_colormap[1]<<8)+p_info->m_colormap[2]; t_greenmask=(p_info->m_colormap[3]<<16)+(p_info->m_colormap[4]<<8)+p_info->m_colormap[5]; t_bluemask=(p_info->m_colormap[6]<<16)+(p_info->m_colormap[7]<<8)+p_info->m_colormap[8]; process_color_mask(&t_redmask,&t_redshift,&t_redpad); process_color_mask(&t_greenmask,&t_greenshift,&t_greenpad); process_color_mask(&t_bluemask,&t_blueshift,&t_bluepad); } for (col = p_info->m_image_width; col > 0; col--) { uint16 t_pixel;/*16bits*/ uint16 t_temppixel; if (-1==read_param(&p_params->m_stream,&t_pixel,sizeof(t_pixel))) return FALSE; p_info->m_image_size+=sizeof(t_pixel); t_temppixel=(uint16)(t_redmask&t_pixel); if (t_redshift>0) t_temppixel=t_temppixel>>t_redshift; else t_temppixel=t_temppixel<<(-1 *t_redshift); t_temppixel=t_temppixel+t_redpad; outptr[0]=(BYTE)t_temppixel; t_temppixel=(uint16)(t_greenmask&t_pixel); if (t_greenshift>0) t_temppixel=t_temppixel>>t_greenshift; else
void XFE_TaskBar::updateFloatingAppearance() { XP_ASSERT( XfeIsAlive(m_widget) ); XP_ASSERT( m_isFloating == True ); unsigned char button_layout; button_layout = XFE_Toolbar::styleToLayout(fe_globalPrefs.toolbar_style); XtVaSetValues(m_widget,XmNbuttonLayout,button_layout,NULL); }
void fill_png_row(CONVERT_IMG_ROW inputrgb, png_bytep outputindex, int16 width,colorhash_table cht) { int i; XP_ASSERT(inputrgb); XP_ASSERT(outputindex); XP_ASSERT(cht); for (i=0; i<width; i++) { outputindex[i]=(BYTE)ppm_lookupcolor( cht, &((pixel*)inputrgb)[i] ); } }
void XFE_TaskBar::setFloatingTitle(const char * title) { XP_ASSERT( XfeIsAlive(m_widget) ); XP_ASSERT( m_isFloating == True ); XP_ASSERT( m_isFloating == True ); Widget shell_widget = XfeAncestorFindByClass(m_widget, shellWidgetClass, XfeFIND_ANY); XtVaSetValues(shell_widget,XmNtitle,title,NULL); }
XFE_ToolboxItem * XFE_Toolbox::getItemAtIndex(Cardinal index) { XP_ASSERT( XfeIsAlive(m_widget) ); XP_ASSERT( index < getNumItems() ); XP_ASSERT( XfeIsAlive(m_widget) ); Widget item = XfeToolBoxItemGetByIndex(m_widget,index); XP_ASSERT( XfeIsAlive(item) ); return (XFE_ToolboxItem *) XfeUserData(item); }
void dict_makeIndex( const DictIter* iter, XP_U16 depth, IndexData* data ) { ASSERT_INITED( iter ); const DictionaryCtxt* dict = iter->dict; XP_ASSERT( depth < MAX_COLS_DICT ); XP_U16 ii, needCount; const XP_U16 nFaces = dict_numTileFaces( dict ); XP_U16 nNonBlankFaces = nFaces; XP_Bool hasBlank = dict_hasBlankTile( dict ); if ( hasBlank ) { --nNonBlankFaces; } for ( ii = 1, needCount = nNonBlankFaces; ii < depth; ++ii ) { needCount *= nNonBlankFaces; } XP_ASSERT( needCount <= data->count ); Tile allTiles[nNonBlankFaces]; XP_U16 nTiles = 0; for ( ii = 0; ii < nFaces; ++ii ) { if ( hasBlank && ii == dict_getBlankTile( dict ) ) { continue; } allTiles[nTiles++] = (Tile)ii; } /* For each tile string implied by depth (A if depth == 1, AAA if == 3 ), * find the first word starting with that IF EXISTS. If it does, find its * index. As an optimization, find index starting with the previous word. */ data->count = 0; DictIter prevIter; dict_initIterFrom( &prevIter, iter ); if ( firstWord( &prevIter ) ) { DictPosition prevIndex = 0; Tile prefix[depth]; doOneDepth( allTiles, nNonBlankFaces, prefix, 0, depth, data, &prevIter, &prevIndex ); } #ifdef DEBUG DictPosition pos; for ( pos = 1; pos < data->count; ++pos ) { XP_ASSERT( data->indices[pos-1] < data->indices[pos] ); } #endif } /* dict_makeIndex */
static DictPosition placeWordClose( DictIter* iter, const DictPosition position, XP_U16 depth, const IndexData* data ) { XP_S16 low = 0; XP_S16 high = data->count - 1; XP_S16 index = -1; for ( ; ; ) { if ( low > high ) { break; } index = low + ( (high - low) / 2); if ( position < data->indices[index] ) { high = index - 1; } else if ( data->indices[index+1] <= position) { low = index + 1; } else { break; } } /* Now we have the index immediately below the position we want. But we may be better off starting with the next if it's closer. The last index is a special case since we use lastWord rather than a prefix to init */ if ( ( index + 1 < data->count ) && (data->indices[index + 1] - position) < (position - data->indices[index]) ) { ++index; } if ( !findWordStartsWith( iter, &data->prefixes[depth*index], depth ) ) { XP_ASSERT(0); } return data->indices[index]; } /* placeWordClose */
LO_AnchorData* XPLO_GetAnchorData(LO_Element *element) { XP_ASSERT(element->type == LO_TEXT || element->type == LO_IMAGE || element->type == LO_SUBDOC || element->type == LO_LINEFEED || element->type == LO_TABLE); switch (element->type) { case LO_TEXT: return ((LO_TextStruct*)element)->anchor_href; case LO_IMAGE: return ((LO_ImageStruct*)element)->anchor_href; case LO_SUBDOC: return ((LO_SubDocStruct*)element)->anchor_href; case LO_LINEFEED: return ((LO_LinefeedStruct*)element)->anchor_href; case LO_TABLE: return ((LO_TableStruct*)element)->anchor_href; default: return NULL; } }
void XFE_ABDirListView::GetDragTargets(int row, int column, Atom **targets, int *num_targets) { D(("XFE_ABDirListView::GetDragTargets(row=%d, col=%d)\n", row, column)); XP_ASSERT(row > -1); if (row == -1) { *targets = NULL; *num_targets = 0; }/* if */ else { if (!m_outliner->isSelected(row)) m_outliner->selectItemExclusive(row); *num_targets = 2; *targets = new Atom[ *num_targets ]; (*targets)[0] = XFE_OutlinerDrop::_XA_NETSCAPE_DIRSERV; (*targets)[1] = XFE_OutlinerDrop::_XA_NETSCAPE_PAB; }/* else */ }
CProgressMac::CProgressMac(PW_WindowType type) { ResIDT windowID; fCancelcb = NULL; fCancelClosure = NULL; switch (type) { case pwApplicationModal: windowID = kProgressModalWindowID; break; case pwStandard: windowID = kProgressStandardWindowID; break; default: XP_ASSERT(false); // invalid window type } fWindow = LWindow::CreateWindow( windowID, (type == pwApplicationModal) ? NULL : LCommander::GetTopCommander()); ThrowIfNil_(fWindow); fLine1 = (LCaption*)fWindow->FindPaneByID('LIN1'); fLine2 = (LCaption*)fWindow->FindPaneByID('LIN2'); fLine3 = (LCaption*)fWindow->FindPaneByID('LIN3'); fProgress = (CPatternProgressBar *)fWindow->FindPaneByID('PtPb'); ThrowIfNil_(fLine1); ThrowIfNil_(fLine2); ThrowIfNil_(fLine3); ThrowIfNil_(fProgress); }
XFE_CALLBACK_DEFN(XFE_TaskBar,doCommandNotice) (XFE_NotificationCenter * /*obj*/, void * /*clientData*/, void * callData) { XP_ASSERT( m_parentFrame != NULL ); // This code is identical to that in XFE_Toolbar::doCommand_cb() XFE_DoCommandArgs * cmdArgs = (XFE_DoCommandArgs *)callData; if (m_parentFrame->handlesCommand(cmdArgs->cmd, cmdArgs->callData, cmdArgs->info) && m_parentFrame->isCommandEnabled(cmdArgs->cmd, cmdArgs->callData, cmdArgs->info)) { // Busy XFE_MozillaApp::theApp()->notifyInterested(XFE_MozillaApp::appBusyCallback); xfe_ExecuteCommand(m_parentFrame, cmdArgs->cmd, cmdArgs->callData, cmdArgs->info ); // Not busy XFE_MozillaApp::theApp()->notifyInterested(XFE_MozillaApp::appNotBusyCallback); m_parentFrame->notifyInterested(Command::commandDispatchedCallback, callData); } }
void XFE_TaskBar::createButtons(TaskBarSpec * spec) { XP_ASSERT( XfeIsAlive(m_widget) ); if (!spec) { return; } TaskBarSpec *cur_spec = spec; while (cur_spec->taskBarButtonName) { // Create the button only if it is not disabled through resources. if (XfeChildIsEnabled(m_widget, (String) cur_spec->taskBarButtonName, "TaskBarButton", True)) { createTaskBarButton(cur_spec); } cur_spec++; } }
void XFE_TaskBar::createFloatingWidgets(Widget parent) { XP_ASSERT( XfeIsAlive(parent) ); unsigned char orientation = fe_globalPrefs.task_bar_horizontal ? XmHORIZONTAL : XmVERTICAL; // Create the floating task bar m_widget = XtVaCreateWidget(FLOATING_TASK_BAR_NAME, xfeTaskBarWidgetClass, parent, XmNorientation, orientation, XmNusePreferredWidth, True, XmNusePreferredHeight, True, NULL); // Create floating buttons createButtons(m_floatingSpec); // Show both label and pixmap for floating tools XtVaSetValues(m_widget,XmNbuttonLayout,XmBUTTON_LABEL_ON_BOTTOM,NULL); // Update the floating appearance for the first time updateFloatingAppearance(); // Update the icons layout when needed XFE_MozillaApp::theApp()->registerInterest( XFE_MozillaApp::updateToolbarAppearance, this, (XFE_FunctionNotification)updateIconAppearance_cb); }
char* XFE_ABDirListView::getColumnText(int column) { char *tmp = 0; switch (column) { case OUTLINER_COLUMN_NAME: #if defined(USE_ABCOM) if (m_containerLine) { AB_ContainerAttribValue *value = NULL; int error = AB_GetContainerAttribute(m_containerLine, attribName, &value); XP_ASSERT(value && value->attrib == attribName); if (value->u.string) tmp = XP_STRDUP(value->u.string); //todo need to free it AB_FreeContainerAttribValue(value); }/* if */ #else if (m_dirLine && m_dirLine->description) { tmp = XP_STRDUP(m_dirLine->description); }/* if */ #endif /* USE_ABCOM */ break; }/* switch () */ return tmp; }
static const XP_UCHAR* and_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode ) { XP_UCHAR* result = ""; UTIL_CBK_HEADER("getUserString", "(I)Ljava/lang/String;" ); int index = stringCode - 1; /* see LocalizedStrIncludes.h */ XP_ASSERT( index < VSIZE( util->userStrings ) ); if ( ! util->userStrings[index] ) { jstring jresult = (*env)->CallObjectMethod( env, util->jutil, mid, stringCode ); jsize len = (*env)->GetStringUTFLength( env, jresult ); XP_UCHAR* buf = XP_MALLOC( util->util.mpool, len + 1 ); const char* jchars = (*env)->GetStringUTFChars( env, jresult, NULL ); XP_MEMCPY( buf, jchars, len ); buf[len] = '\0'; (*env)->ReleaseStringUTFChars( env, jresult, jchars ); deleteLocalRef( env, jresult ); util->userStrings[index] = buf; } result = util->userStrings[index]; UTIL_CBK_TAIL(); return result; }
DB * CallDBOpenUsingFileURL(char *fileURL, int flags,int mode, DBTYPE type, const void *openinfo) { DB *result; char *path; char *escapedPath; if (fileURL == NULL) return NULL; escapedPath = unescapeURL(fileURL); #ifdef XP_MAC path = WH_FilePlatformName(convertFileURLToNSPRCopaceticPath(fileURL)); XP_ASSERT(path != NULL); #else path = convertFileURLToNSPRCopaceticPath(escapedPath); #endif result = dbopen(path, flags, mode, type, openinfo); #ifdef XP_MAC XP_FREE(path); #endif if (escapedPath != NULL) freeMem(escapedPath); return result; }
static XWBonusType and_util_getSquareBonus( XW_UtilCtxt* XP_UNUSED(uc), XP_U16 boardSize, XP_U16 col, XP_U16 row ) { #define BONUS_DIM 8 static const int s_buttsBoard[BONUS_DIM][BONUS_DIM] = { { BONUS_TRIPLE_WORD, BONUS_NONE, BONUS_NONE,BONUS_DOUBLE_LETTER,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_TRIPLE_WORD }, { BONUS_NONE, BONUS_DOUBLE_WORD, BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_TRIPLE_LETTER,BONUS_NONE,BONUS_NONE }, { BONUS_NONE, BONUS_NONE, BONUS_DOUBLE_WORD,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_LETTER,BONUS_NONE }, { BONUS_DOUBLE_LETTER,BONUS_NONE, BONUS_NONE,BONUS_DOUBLE_WORD,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_LETTER }, { BONUS_NONE, BONUS_NONE, BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_WORD,BONUS_NONE,BONUS_NONE,BONUS_NONE }, { BONUS_NONE, BONUS_TRIPLE_LETTER,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_TRIPLE_LETTER,BONUS_NONE,BONUS_NONE }, { BONUS_NONE, BONUS_NONE, BONUS_DOUBLE_LETTER,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_LETTER,BONUS_NONE }, { BONUS_TRIPLE_WORD, BONUS_NONE, BONUS_NONE,BONUS_DOUBLE_LETTER,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_WORD }, }; /* buttsBoard */ int half = boardSize / 2; if ( col > half ) { col = (half*2) - col; } if ( row > half ) { row = (half*2) - row; } XP_ASSERT( col < BONUS_DIM && row < BONUS_DIM ); return s_buttsBoard[row][col]; #undef BONUS_DIM }